/** * Creates a new Velocity context that extends the VelocityContext of the * test suite with information about this test case. To keep test cases * isolated, the context does not wrap the test suite context, but clones * and extends it. To reduce overhead, the test suite context is cached so * it is only produced the first time. * * @return VelocityContext with information about the test suite and test * case. * @throws DataSourceException * */ public Context createVelocityContext() throws DataSourceException { if (fTestSuiteVelocityContext == null) { fTestSuiteVelocityContext = getSuite().createVelocityContext(); } Context ctx = CLONER.deepClone(fTestSuiteVelocityContext); ctx.put("testCaseName", getRawName()); if (fDataSource != null) { DataSourceUtil.initializeContext(ctx, fDataSource, fRowIndex); } if (fSetUpVelocityScript != null) { StringWriter sW = new StringWriter(); Velocity.evaluate(ctx, sW, "setUpTestCase", fSetUpVelocityScript); } return ctx; }