private void checkFractionAutodetection(String log) { if (testingProject.doesAutodetectionHappen()) { assertThat(log).contains("Scanning for needed WildFly Swarm fractions"); } else { assertThat(log).doesNotContain("Scanning for needed WildFly Swarm fractions"); } }
private void checkFractionsPresent(Archive uberjar) throws IOException { assertThat(uberjar.contains("META-INF/wildfly-swarm-manifest.yaml")).isTrue(); String manifestContent = readFileFromArchive(uberjar, "META-INF/wildfly-swarm-manifest.yaml"); for (String fraction : testingProject.fractionsThatShouldBePresent()) { assertThat(manifestContent).contains("org.wildfly.swarm." + fraction); assertThat(manifestContent).contains("org.wildfly.swarm:" + fraction); assertThat(uberjar.contains("m2repo/org/wildfly/swarm/" + fraction)).isTrue(); } for (String fraction : testingProject.fractionsThatShouldBeMissing()) { assertThat(manifestContent).doesNotContain("org.wildfly.swarm." + fraction); assertThat(manifestContent).doesNotContain("org.wildfly.swarm:" + fraction); assertThat(uberjar.contains("m2repo/org/wildfly/swarm/" + fraction)).isFalse(); } }
@Before public void setUpProject() throws IOException, VerificationException { assumeTrue("Set the M2_HOME environment variable", System.getenv("M2_HOME") != null); assumeTrue( "Run from Maven or set the project.version system property", System.getProperty("project.version") != null); File projectDir = ResourceExtractor.extractResourcePath(getClass(), "/testing-project", tmp.getRoot(), true); testingProject.prepare(projectDir.toPath()); verifier = new Verifier(projectDir.getAbsolutePath(), true); verifier.setForkJvm(true); logPath = Paths.get(verifier.getBasedir()).resolve(verifier.getLogFileName()); }
@Test public void buildUberjarAndRunTests() throws IOException, VerificationException, InterruptedException { String goal = "package"; if (testingProject.canRunTests()) { goal = "verify"; // a lot of these fail because of SWARM-873 if (testingProject.additionalDependency == AdditionalDependency.USING_JAVA_EE) { goal = "package"; } } try { verifier.executeGoal(goal); } catch (VerificationException e) { if (testingProject.dependencies == Dependencies.JAVA_EE_APIS && testingProject.autodetection == Autodetection.NEVER) { // the only situation when build failure is expected String log = new String(Files.readAllBytes(logPath), StandardCharsets.UTF_8); assertThat(log).contains("No WildFly Swarm Bootstrap fraction found"); return; } throw e; } verifier.assertFilePresent( "target/testing-project." + testingProject.packaging.fileExtension()); verifier.assertFilePresent("target/testing-project-swarm.jar"); String log = new String(Files.readAllBytes(logPath), StandardCharsets.UTF_8); assertThat(log).doesNotContain("[ERROR]"); assertThat(log).doesNotContain("[WARNING]"); assertThat(log).contains("BUILD SUCCESS"); checkFractionAutodetection(log); File uberjarFile = new File(verifier.getBasedir(), "target/testing-project-swarm.jar"); Archive uberjar = ShrinkWrap.createFromZipFile(GenericArchive.class, uberjarFile); checkFractionsPresent(uberjar); checkMainClass(uberjar); }