private String getTestRunner(String testFramework) { if (TestFramework.TEST_JUNIT.equals(testFramework)) { return "org.codehaus.tycho.surefire.junit.JUnitDirectoryTestSuite"; } else if (TestFramework.TEST_JUNIT4.equals(testFramework)) { return "org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite"; } throw new IllegalArgumentException(); // can't happen }
private Set<File> getSurefirePlugins(String testFramework) throws MojoExecutionException { Set<File> result = new LinkedHashSet<File>(); String fragment; if (TestFramework.TEST_JUNIT.equals(testFramework)) { fragment = "org.sonatype.tycho.surefire.junit"; } else if (TestFramework.TEST_JUNIT4.equals(testFramework)) { fragment = "org.sonatype.tycho.surefire.junit4"; } else { throw new IllegalArgumentException("Unsupported test framework " + testFramework); } for (Artifact artifact : pluginArtifacts) { if ("org.sonatype.tycho".equals(artifact.getGroupId())) { if ("org.sonatype.tycho.surefire.osgibooter".equals(artifact.getArtifactId()) || fragment.equals(artifact.getArtifactId())) { result.add(artifact.getFile()); } } } if (result.size() != 2) { StringBuilder sb = new StringBuilder( "Unable to locate org.sonatype.tycho:org.sonatype.tycho.surefire.osgibooter and/or its fragments\n"); sb.append("Test framework: " + testFramework); sb.append("All plugin artifacts: "); for (Artifact artifact : pluginArtifacts) { sb.append("\n\t").append(artifact.toString()); } sb.append("\nMatched OSGi test booter artifacts: "); for (File file : result) { sb.append("\n\t").append(file.getAbsolutePath()); } throw new MojoExecutionException(sb.toString()); } return result; }