Container { public String createClasspath(String basedir, String aplVersion) { try { Stream<Path> paths = Files.walk(Paths.get(basedir)); String jarsPath = paths .filter(path -> path.toFile().isDirectory() && path.toFile().getName().contains(aplVersion)) .flatMap(path -> { try { return Files.walk(Paths.get(path.toFile().getAbsolutePath())); } catch (IOException e) { throw new UncheckedIOException(e); } }) .filter(path -> path.toFile().isFile() && path.toFile().getName().endsWith(".jar")) .map(path -> path.toFile().getAbsolutePath()) .collect(joining(":")); if (jarsPath.isEmpty()) { return basedir; } else { return basedir + ":" + jarsPath; } } catch (IOException e) { throw new UncheckedIOException(e); } } Container(int poolSize); void start(final String mainClass, String classpath); void start(final String mainClass, String basedir, String aplVersion); void start(final String mainClass); String createClasspath(String basedir, String aplVersion); JvmPool getPool(); void setLogDir(File logDir); void setMonitorSuppliers(Set<MonitorSupplier> monitorSuppliers); void setLifetime(long survivalTime); void setJavaOpts(String javaOpts); void setAutoTuning(boolean autoTuning); void setEvaluator(Evaluator evaluator); void setBasedir(String basedir); String getBasedir();  }
@Test public void createClasspathWithBaseDirAndAplVersion() { Container sut = new Container(1); String basePath = new File(ContainerTest.class.getClassLoader().getResource("containerTestResources").getPath()) .getAbsolutePath(); String versionFolder = basePath + File.separator + "0.1.0" + File.separator; assertThat(sut.createClasspath(basePath, "0.1.0")).startsWith(basePath + ":"); assertThat(sut.createClasspath(basePath, "0.1.0")).contains(versionFolder + "applicationA.jar"); assertThat(sut.createClasspath(basePath, "0.1.0")) .contains(versionFolder + "subDir" + File.separator + "applicationB.jar"); assertThat(sut.createClasspath(basePath, "0.1.1")).isEqualTo(basePath); }
@Test public void returnBaseDirWhenFileNotFound() { Container sut = new Container(1); String basePath = new File(ContainerTest.class.getClassLoader().getResource("containerTestResources").getPath()) .getAbsolutePath(); assertThat(sut.createClasspath(basePath, "0.2.0")).isEqualTo(basePath); }