/** * Creates a new instance. * @param callerClass the caller class (for detecting testing resources) * @param context the current testing context * @param tools the testing tools */ protected BatchTestTool(Class<?> callerClass, TestContext context, TestToolRepository tools) { this.classLoader = context.getClassLoader(); this.batchArguments = new LinkedHashMap<>(context.getArguments()); this.environmentVariables = new LinkedHashMap<>(context.getEnvironmentVariables()); this.callerClass = callerClass; this.tools = new TestToolRepository(classLoader); }
LOG.debug("Creating test helper for Direct I/O (basePath={})", rootPath); //$NON-NLS-1$ this.variables = new VariableTable(RedefineStrategy.ERROR); variables.defineVariables(context.getArguments()); String resolvedRootPath = resolve(rootPath); LOG.debug("Resolved base path: {} -> {}", rootPath, resolvedRootPath); //$NON-NLS-1$
return null; ClassLoader classLoader = context.getClassLoader(); String rest = source.getSchemeSpecificPart(); LOG.debug("Attempts to load {} as a class", rest); //$NON-NLS-1$ definition.getModelClass(), description); ParameterList parameterList = new ParameterList(context.getArguments()); ResourceManipulator manipulator = WindGateTestHelper.createResourceManipulator(context, description, parameterList); definition.getModelClass(), description); ParameterList parameterList = new ParameterList(context.getArguments()); ResourceManipulator manipulator = WindGateTestHelper.createResourceManipulator(context, description, parameterList);
/** * Creates a new instance. * @param callerClass the caller class (for detecting testing resources) * @param context the current testing context */ public BatchTestTool(Class<?> callerClass, TestContext context) { this(callerClass, context, new TestToolRepository(context.getClassLoader())); }
private static File getHomePath(TestContext context) { String home = context.getEnvironmentVariables().get(ENV_FRAMEWORK_HOME); if (home == null || home.trim().isEmpty()) { return null; } File file = new File(home); return file; }
@Override public void truncate( WindGateExporterDescription description, TestContext context) throws IOException { ProcessScript<?> process = WindGateTestHelper.createProcessScript( description.getModelType(), description); ParameterList parameterList = new ParameterList(context.getArguments()); ResourceManipulator manipulator = WindGateTestHelper.createResourceManipulator(context, description, parameterList); manipulator.cleanupDrain(process); }
static void setCached(VerifyContext context, ExcelSheetRuleExtensionRepository repository) { Reference<ExcelSheetRuleExtensionRepository> ref; if (repository.getClass().getClassLoader() == ClassLoader.getSystemClassLoader()) { ref = new SoftReference<>(repository); } else { ref = new WeakReference<>(repository); } CACHE.put(context.getTestContext().getClassLoader(), ref); }
private static File findFileOnHomePath(TestContext testContext, String path) { assert testContext != null; assert path != null; String home = testContext.getEnvironmentVariables().get(ENV_FRAMEWORK_HOME); if (home != null) { File file = new File(home, path); if (file.exists()) { return file; } } else { LOG.warn(MessageFormat.format( Messages.getString("WindGateTestHelper.warnUndefinedEnvironmentVariable"), //$NON-NLS-1$ ENV_FRAMEWORK_HOME)); } return null; }
@Override public void truncate( WindGateImporterDescription description, TestContext context) throws IOException { ProcessScript<?> process = WindGateTestHelper.createProcessScript( description.getModelType(), description); ParameterList parameterList = new ParameterList(context.getArguments()); ResourceManipulator manipulator = WindGateTestHelper.createResourceManipulator(context, description, parameterList); manipulator.cleanupSource(process); }
private static ExcelSheetRuleExtensionRepository newInstance(VerifyContext context) { ClassLoader classLoader = context.getTestContext().getClassLoader(); List<ExcelSheetRuleExtension> extensions = new ArrayList<>(); for (ExcelSheetRuleExtension extension : ServiceLoader.load(ExcelSheetRuleExtension.class, classLoader)) { extensions.add(extension); } return new ExcelSheetRuleExtensionRepository(extensions); }
/** * Creates a WindGate {@link ProfileContext} for the test context. * @param testContext the current test context * @return the created {@link ProfileContext} * @since 0.7.2 */ public static ProfileContext createProfileContext(TestContext testContext) { if (testContext == null) { throw new IllegalArgumentException("testContext must not be null"); //$NON-NLS-1$ } Holder.clean(); ClassLoader loader = findClassLoader(testContext); return new ProfileContext(loader, new ParameterList(testContext.getEnvironmentVariables())); }
@Override public <V> ModelOutput<V> createOutput( DataModelDefinition<V> definition, WindGateExporterDescription description, TestContext context) throws IOException { ProcessScript<V> process = WindGateTestHelper.createProcessScript( definition.getModelClass(), description); ParameterList parameterList = new ParameterList(context.getArguments()); ResourceManipulator manipulator = WindGateTestHelper.createResourceManipulator(context, description, parameterList); DrainDriver<V> driver = manipulator.createDrainForDrain(process); return new WindGateOutput<>(WindGateTestHelper.prepare(driver)); }
/** * Returns a {@link ExcelSheetRuleExtensionRepository} for the target context. * @param context the target context * @return a repository object * @throws IllegalArgumentException if some parameters were {@code null} */ public static ExcelSheetRuleExtensionRepository get(VerifyContext context) { if (context == null) { throw new IllegalArgumentException("context must not be null"); //$NON-NLS-1$ } Reference<ExcelSheetRuleExtensionRepository> ref = CACHE.get(context.getTestContext().getClassLoader()); ExcelSheetRuleExtensionRepository cached = ref == null ? null : ref.get(); if (cached != null) { return cached; } ExcelSheetRuleExtensionRepository created = newInstance(context); setCached(context, created); return created; }
@Override public <V> DataModelSource createSource( DataModelDefinition<V> definition, WindGateExporterDescription description, TestContext context) throws IOException { ProcessScript<V> process = WindGateTestHelper.createProcessScript( definition.getModelClass(), description); ParameterList parameterList = new ParameterList(context.getArguments()); ResourceManipulator manipulator = WindGateTestHelper.createResourceManipulator(context, description, parameterList); SourceDriver<V> driver = manipulator.createSourceForDrain(process); return new WindGateSource<>(WindGateTestHelper.prepare(driver), definition); } }
private static ClassLoader findClassLoader(TestContext testContext) { assert testContext != null; ClassLoader current = testContext.getClassLoader(); File pluginDirectory = findFileOnHomePath(testContext, PRODUCTION_PLUGIN_DIRECTORY); if (pluginDirectory == null || pluginDirectory.isDirectory() == false) {
@Override public <V> ModelOutput<V> createOutput( DataModelDefinition<V> definition, WindGateImporterDescription description, TestContext context) throws IOException { ProcessScript<V> process = WindGateTestHelper.createProcessScript( definition.getModelClass(), description); ParameterList parameterList = new ParameterList(context.getArguments()); ResourceManipulator manipulator = WindGateTestHelper.createResourceManipulator(context, description, parameterList); DrainDriver<V> driver = manipulator.createDrainForSource(process); return new WindGateOutput<>(WindGateTestHelper.prepare(driver)); } }