public static ClassLoader toClassLoader(Collection<String> classPaths) throws MalformedURLException { return toClassLoader(classPaths, ClassUtils.class.getClassLoader()); }
classPaths.add(externalDependencyJarPath); ClassLoader customClassLoader = ClassUtils.toClassLoader(classPaths);
@Test public void shouldBuildRunnerWithExternalSystemUnderDevelopmentAndCustomClassLoader() throws Exception { URI specsFolderUri = getClass().getResource("/specs-executor/external").toURI(); File specsFolder = new File(specsFolderUri); String externalDependencyJarPath = new File(specsFolder, "external-calculator.jar").getAbsolutePath(); Set<String> classPaths = new HashSet<String>(); classPaths.add(externalDependencyJarPath); ClassLoader customClassLoader = ClassUtils.toClassLoader(classPaths); new SpecificationRunnerBuilder(DUMMY_REPO).classLoader(customClassLoader).systemUnderDevelopment( "info.novatec.testit.livingdoc.external.fixture.MyCustomSystemUnderDevelopment").build(DocumentRunner.class); }
@Test public void shouldBuildRunnerWithExternalInterpreterSelectorAndCustomClassLoader() throws Exception { URI specsFolderUri = getClass().getResource("/specs-executor/external").toURI(); File specsFolder = new File(specsFolderUri); String externalDependencyJarPath = new File(specsFolder, "external-calculator.jar").getAbsolutePath(); Set<String> classPaths = new HashSet<String>(); classPaths.add(externalDependencyJarPath); ClassLoader customClassLoader = ClassUtils.toClassLoader(classPaths); new SpecificationRunnerBuilder(DUMMY_REPO).classLoader(customClassLoader).interpreterSelector( "info.novatec.testit.livingdoc.external.fixture.MyCustomInterpreterSelector").build(DocumentRunner.class); }
ClassLoader currentClassLoader = getClass().getClassLoader(); Collection<String> dependencies = resolveDependentClassPaths(systemUnderTest); ClassLoader dependencyCassLoader = ClassUtils.toClassLoader(dependencies, currentClassLoader);
@Test public void shouldExecuteDocumentSpecificationWithExternalFixtureSource() throws Exception { URI specsFolderUri = getClass().getResource("/specs-executor/external").toURI(); File outputDirectory = TestFileUtils.createTempReportsDirectory(); File specsFolder = new File(specsFolderUri); String repository = FileSystemRepository.class.getName() + ";" + specsFolder; // This jar contains a compiled calculator class. If you want to adjust // this calculator, you've to create a new jar by yourself. String externalDependencyJarPath = new File(specsFolder, "external-calculator.jar").getAbsolutePath(); Set<String> classPaths = new HashSet<String>(); classPaths.add(externalDependencyJarPath); ClassLoader customClassLoader = ClassUtils.toClassLoader(classPaths); RecorderMonitor recorderMonitor = new RecorderMonitor(); LoggingMonitor loggingMonitor = new LoggingMonitor(); SpecificationRunner runner = new SpecificationRunnerBuilder(repository).classLoader(customClassLoader) .systemUnderDevelopment(DefaultSystemUnderDevelopment.class.getName()).outputDirectory(outputDirectory).monitors( recorderMonitor, loggingMonitor).build(DocumentRunner.class); new SpecificationRunnerExecutor(runner).execute("AExternalCalculatorSample.html"); Statistics statistics = recorderMonitor.getStatistics(); Assert.assertEquals(6, statistics.totalCount()); Assert.assertEquals(4, statistics.rightCount()); Assert.assertEquals(1, statistics.wrongCount()); Assert.assertEquals(0, statistics.ignoredCount()); Assert.assertEquals(1, statistics.exceptionCount()); }
@Test public void shouldExecuteDocumentSpecificationWithExternalSystemUnderDevelopment() throws Exception { URI specsFolderUri = getClass().getResource("/specs-executor/external").toURI(); File outputDirectory = TestFileUtils.createTempReportsDirectory(); File specsFolder = new File(specsFolderUri); String repository = FileSystemRepository.class.getName() + ";" + specsFolder; // This jar contains a compiled calculator class. If you want to adjust // this calculator, you've to create a new jar by yourself. String externalDependencyJarPath = new File(specsFolder, "external-calculator.jar").getAbsolutePath(); Set<String> classPaths = new HashSet<String>(); classPaths.add(externalDependencyJarPath); ClassLoader customClassLoader = ClassUtils.toClassLoader(classPaths); RecorderMonitor recorderMonitor = new RecorderMonitor(); LoggingMonitor loggingMonitor = new LoggingMonitor(); SpecificationRunner runner = new SpecificationRunnerBuilder(repository).classLoader(customClassLoader) .systemUnderDevelopment("info.novatec.testit.livingdoc.external.fixture.MyCustomSystemUnderDevelopment") .outputDirectory(outputDirectory).monitors(recorderMonitor, loggingMonitor).build(DocumentRunner.class); new SpecificationRunnerExecutor(runner).execute("AExternalCalculatorSample.html"); Statistics statistics = recorderMonitor.getStatistics(); Assert.assertEquals(6, statistics.totalCount()); Assert.assertEquals(4, statistics.rightCount()); Assert.assertEquals(1, statistics.wrongCount()); Assert.assertEquals(0, statistics.ignoredCount()); Assert.assertEquals(1, statistics.exceptionCount()); }
classPaths.add(externalDependencyJarPath); ClassLoader customClassLoader = ClassUtils.toClassLoader(classPaths);