http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java deleted file mode 100644 index ed0d40c..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java +++ /dev/null @@ -1,174 +0,0 @@ -package org.apache.maven.surefire.its.fixture; -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.plugin.surefire.log.api.ConsoleLogger; -import org.apache.maven.plugin.surefire.log.api.PrintStreamLogger; -import org.apache.maven.plugins.surefire.report.ReportTestSuite; -import org.apache.maven.plugins.surefire.report.SurefireReportParser; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; -import static org.junit.Assume.assumeTrue; - -@SuppressWarnings( { "JavaDoc" } ) -public class HelperAssertions -{ - /** - * assert that the reports in the specified testDir have the right summary statistics - */ - public static void assertTestSuiteResults( int total, int errors, int failures, int skipped, File testDir ) - { - IntegrationTestSuiteResults suite = parseTestResults( testDir ); - assertTestSuiteResults( total, errors, failures, skipped, suite ); - } - - public static void assertTestSuiteResults( int total, int errors, int failures, int skipped, int flakes, File testDir ) - { - IntegrationTestSuiteResults suite = parseTestResults( testDir ); - assertTestSuiteResults( total, errors, failures, skipped, flakes, suite ); - } - - public static void assertTestSuiteResults( int total, File testDir ) - { - IntegrationTestSuiteResults suite = parseTestResults( testDir ); - assertTestSuiteResults( total, suite ); - } - - /** - * assert that the reports in the specified testDir have the right summary statistics - */ - public static void assertIntegrationTestSuiteResults( int total, int errors, int failures, int skipped, - File testDir ) - { - IntegrationTestSuiteResults suite = parseIntegrationTestResults( testDir ); - assertTestSuiteResults( total, errors, failures, skipped, suite ); - } - - public static void assertIntegrationTestSuiteResults( int total, File testDir ) - { - IntegrationTestSuiteResults suite = parseIntegrationTestResults( testDir ); - assertTestSuiteResults( total, suite ); - } - - public static void assertTestSuiteResults( int total, int errors, int failures, int skipped, - IntegrationTestSuiteResults actualSuite ) - { - assertEquals( "wrong number of tests", total, actualSuite.getTotal() ); - assertEquals( "wrong number of errors", errors, actualSuite.getErrors() ); - assertEquals( "wrong number of failures", failures, actualSuite.getFailures() ); - assertEquals( "wrong number of skipped", skipped, actualSuite.getSkipped() ); - } - - public static void assertTestSuiteResults( int total, IntegrationTestSuiteResults actualSuite ) - { - assertEquals( "wrong number of tests", total, actualSuite.getTotal() ); - } - - public static void assertTestSuiteResults( int total, int errors, int failures, int skipped, int flakes, - IntegrationTestSuiteResults actualSuite ) - { - assertTestSuiteResults(total, errors, failures, skipped, actualSuite); - assertEquals( "wrong number of flaky tests", flakes, actualSuite.getFlakes() ); - } - - public static IntegrationTestSuiteResults parseTestResults( File... testDirs ) - { - List<ReportTestSuite> reports = extractReports( testDirs ); - return parseReportList( reports ); - } - - public static IntegrationTestSuiteResults parseIntegrationTestResults( File... testDirs ) - { - List<ReportTestSuite> reports = extractITReports( testDirs ); - return parseReportList( reports ); - } - - /** - * Converts a list of ReportTestSuites into an IntegrationTestSuiteResults object, suitable for summary assertions - */ - public static IntegrationTestSuiteResults parseReportList( List<ReportTestSuite> reports ) - { - assertTrue( "No reports!", !reports.isEmpty() ); - int total = 0, errors = 0, failures = 0, skipped = 0, flakes = 0; - for ( ReportTestSuite report : reports ) - { - total += report.getNumberOfTests(); - errors += report.getNumberOfErrors(); - failures += report.getNumberOfFailures(); - skipped += report.getNumberOfSkipped(); - flakes += report.getNumberOfFlakes(); - } - return new IntegrationTestSuiteResults( total, errors, failures, skipped, flakes ); - } - - public static List<ReportTestSuite> extractReports( File... testDirs ) - { - List<File> reportsDirs = new ArrayList<File>(); - for ( File testDir : testDirs ) - { - File reportsDir = new File( testDir, "target/surefire-reports" ); - assertTrue( "Reports directory is missing: " + reportsDir.getAbsolutePath(), reportsDir.exists() ); - reportsDirs.add( reportsDir ); - } - ConsoleLogger logger = new PrintStreamLogger( System.out ); - SurefireReportParser parser = new SurefireReportParser( reportsDirs, Locale.getDefault(), logger ); - try - { - return parser.parseXMLReportFiles(); - } - catch ( Exception e ) - { - throw new RuntimeException( "Couldn't parse XML reports", e ); - } - } - - public static List<ReportTestSuite> extractITReports( File... testDirs ) - { - List<File> reportsDirs = new ArrayList<File>(); - for ( File testDir : testDirs ) - { - File reportsDir = new File( testDir, "target/failsafe-reports" ); - assertTrue( "Reports directory is missing: " + reportsDir.getAbsolutePath(), reportsDir.exists() ); - reportsDirs.add( reportsDir ); - } - ConsoleLogger logger = new PrintStreamLogger( System.out ); - SurefireReportParser parser = new SurefireReportParser( reportsDirs, Locale.getDefault(), logger ); - try - { - return parser.parseXMLReportFiles(); - } - catch ( Exception e ) - { - throw new RuntimeException( "Couldn't parse XML reports", e ); - } - } - - public static void assumeJavaVersion( double expectedVersion ) - { - String thisVersion = System.getProperty( "java.specification.version" ); - assumeTrue( "java.specification.version: " + thisVersion, - Double.valueOf( thisVersion ) >= expectedVersion ); - } -}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/IntegrationTestSuiteResults.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/IntegrationTestSuiteResults.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/IntegrationTestSuiteResults.java deleted file mode 100644 index f147281..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/IntegrationTestSuiteResults.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.apache.maven.surefire.its.fixture; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -public class IntegrationTestSuiteResults -{ - private int total, errors, failures, skipped, flakes; - - public IntegrationTestSuiteResults( int total, int errors, int failures, int skipped ) - { - this.total = total; - this.errors = errors; - this.failures = failures; - this.skipped = skipped; - } - - public IntegrationTestSuiteResults( int total, int errors, int failures, int skipped, int flakes ) - { - this(total, errors, failures, skipped); - this.flakes = flakes; - } - - public int getTotal() - { - return total; - } - - public void setTotal( int total ) - { - this.total = total; - } - - public int getErrors() - { - return errors; - } - - public void setErrors( int errors ) - { - this.errors = errors; - } - - public int getFailures() - { - return failures; - } - - public void setFailures( int failures ) - { - this.failures = failures; - } - - public int getSkipped() - { - return skipped; - } - - public void setSkipped( int skipped ) - { - this.skipped = skipped; - } - - public int getFlakes() - { - return flakes; - } - - public void setFlakes( int flakes ) - { - this.flakes = flakes; - } - -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java deleted file mode 100755 index bd12dda..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java +++ /dev/null @@ -1,504 +0,0 @@ -package org.apache.maven.surefire.its.fixture; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.commons.lang.text.StrSubstitutor; -import org.apache.maven.it.VerificationException; -import org.apache.maven.it.Verifier; -import org.apache.maven.it.util.ResourceExtractor; -import org.apache.maven.shared.utils.io.FileUtils; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; - -import static java.util.Collections.unmodifiableList; - -/** - * Encapsulate all needed features to start a maven run - * <br> - * - * @author Kristian Rosenvold - */ -public class MavenLauncher -{ - private final List<String> cliOptions = new ArrayList<String>(); - - private final List<String> goals = new ArrayList<String>(); - - private final Map<String, String> envvars = new HashMap<String, String>(); - - private File unpackedAt; - - private Verifier verifier; - - private OutputValidator validator; - - private final Class testCaseBeingRun; - - private final String resourceName; - - private final String suffix; - - private final String[] cli; - - private boolean expectFailure; - - public MavenLauncher( Class testClass, String resourceName, String suffix, String[] cli ) - { - this.testCaseBeingRun = testClass; - this.resourceName = resourceName; - this.suffix = suffix != null ? suffix : ""; - this.cli = cli == null ? null : cli.clone(); - resetGoals(); - resetCliOptions(); - } - - public MavenLauncher( Class testClass, String resourceName, String suffix ) - { - this( testClass, resourceName, suffix, null ); - } - - public File getUnpackedAt() - { - return ensureUnpacked(); - } - - private File ensureUnpacked() - { - if ( unpackedAt == null ) - { - unpackedAt = simpleExtractResources( testCaseBeingRun, resourceName ); - } - return unpackedAt; - } - - public void moveUnpackTo( File dest ) - throws IOException - { - FileUtils.deleteDirectory( dest ); - //noinspection ResultOfMethodCallIgnored - getUnpackedAt().renameTo( dest ); - unpackedAt = dest; - } - - public void resetGoals() - { - goals.clear(); - } - - void addCliOption( String cliOption ) - { - cliOptions.add( cliOption ); - } - - - - private StackTraceElement findTopElemenent( StackTraceElement[] stackTrace, Class testClassToLookFor ) - { - StackTraceElement bestmatch = null; - for ( StackTraceElement stackTraceElement : stackTrace ) - { - if ( stackTraceElement.getClassName().equals( testClassToLookFor.getName() ) ) - { - bestmatch = stackTraceElement; - } - } - return bestmatch; - } - - StackTraceElement[] getStackTraceElements() - { - try - { - throw new RuntimeException(); - } - catch ( RuntimeException e ) - { - return e.getStackTrace(); - } - } - - public void reset() - { - resetGoals(); - resetCliOptions(); - } - - private void resetCliOptions() - { - cliOptions.clear(); - } - - public MavenLauncher getSubProjectLauncher( String subProject ) - throws VerificationException - { - MavenLauncher mavenLauncher = - new MavenLauncher( testCaseBeingRun, resourceName + File.separator + subProject, suffix, cli ); - mavenLauncher.unpackedAt = new File( ensureUnpacked(), subProject ); - return mavenLauncher; - } - - public OutputValidator getSubProjectValidator( String subProject ) - throws VerificationException - { - final File subFile = getValidator().getSubFile( subProject ); - return new OutputValidator( new Verifier( subFile.getAbsolutePath() ) ); - } - - - public MavenLauncher addEnvVar( String key, String value ) - { - envvars.put( key, value ); - return this; - } - - public MavenLauncher assertNotPresent( String subFile ) - { - getVerifier().assertFileNotPresent( getValidator().getSubFile( subFile ).getAbsolutePath() ); - return this; - } - - public MavenLauncher showErrorStackTraces() - { - addCliOption( "-e" ); - return this; - } - - public MavenLauncher debugLogging() - { - addCliOption( "-X" ); - return this; - } - - public MavenLauncher failNever() - { - addCliOption( "-fn" ); - return this; - } - - public MavenLauncher offline() - { - addCliOption( "-o" ); - return this; - } - - public MavenLauncher skipClean() - { - writeGoal( "-Dclean.skip=true" ); - return this; - } - - public MavenLauncher addGoal( String goal ) - { - writeGoal( goal ); - return this; - } - - public FailsafeOutputValidator executeVerify() - { - return new FailsafeOutputValidator( conditionalExec( "verify" ) ); - } - - public OutputValidator executeTest() - { - return conditionalExec( "test" ); - } - - List<String> getGoals() - { - return unmodifiableList( goals ); - } - - private void writeGoal( String newGoal ) - { - if ( newGoal != null && newGoal.startsWith( "-D" ) ) - { - final String sysPropKey = - newGoal.contains( "=" ) ? newGoal.substring( 0, newGoal.indexOf( '=' ) ) : newGoal; - - final String sysPropStarter = sysPropKey + "="; - - for ( ListIterator<String> it = goals.listIterator(); it.hasNext(); ) - { - String goal = it.next(); - if ( goal.equals( sysPropKey ) || goal.startsWith( sysPropStarter ) ) - { - System.out.printf( "[WARNING] System property already exists '%s'. Overriding to '%s'.\n", - goal, newGoal ); - it.set( newGoal ); - return; - } - } - } - goals.add( newGoal ); - } - - private OutputValidator conditionalExec(String goal) - { - OutputValidator verify; - try - { - verify = execute( goal ); - } - catch ( SurefireVerifierException exc ) - { - if ( expectFailure ) - { - return getValidator(); - } - else - { - throw exc; - } - } - if ( expectFailure ) - { - throw new RuntimeException( "Expecting build failure, got none!" ); - } - return verify; - - } - - public MavenLauncher withFailure() - { - this.expectFailure = true; - return this; - } - - - public OutputValidator execute( String goal ) - { - addGoal( goal ); - return executeCurrentGoals(); - } - - public OutputValidator executeCurrentGoals() - { - - String userLocalRepo = System.getProperty( "user.localRepository" ); - String testBuildDirectory = System.getProperty( "testBuildDirectory" ); - boolean useInterpolatedSettings = Boolean.getBoolean( "useInterpolatedSettings" ); - - try - { - if ( useInterpolatedSettings ) - { - File interpolatedSettings = new File( testBuildDirectory, "interpolated-settings" ); - - if ( !interpolatedSettings.exists() ) - { - // hack "a la" invoker plugin to download dependencies from local repo - // and not download from central - - Map<String, String> values = new HashMap<String, String>( 1 ); - values.put( "localRepositoryUrl", toUrl( userLocalRepo ) ); - StrSubstitutor strSubstitutor = new StrSubstitutor( values ); - - String fileContent = FileUtils.fileRead( new File( testBuildDirectory, "settings.xml" ) ); - - String filtered = strSubstitutor.replace( fileContent ); - - FileUtils.fileWrite( interpolatedSettings.getAbsolutePath(), filtered ); - - } - - addCliOption( "-s " + interpolatedSettings.getCanonicalPath() ); - } - getVerifier().setCliOptions( cliOptions ); - - getVerifier().executeGoals( goals, envvars ); - return getValidator(); - } - catch ( IOException e ) - { - throw new SurefireVerifierException( e.getMessage(), e ); - } - catch ( VerificationException e ) - { - throw new SurefireVerifierException( e.getMessage(), e ); - } - finally - { - getVerifier().resetStreams(); - } - } - - private static String toUrl( String filename ) - { - /* - * NOTE: Maven fails to properly handle percent-encoded "file:" URLs (WAGON-111) so don't use File.toURI() here - * as-is but use the decoded path component in the URL. - */ - String url = "file://" + new File( filename ).toURI().getPath(); - if ( url.endsWith( "/" ) ) - { - url = url.substring( 0, url.length() - 1 ); - } - return url; - } - - public MavenLauncher activateProfile( String profile ) - { - return addGoal( "-P" + profile ); - } - - public MavenLauncher sysProp( String variable, String value ) - { - return addGoal( "-D" + variable + "=" + value ); - } - - public MavenLauncher sysProp( Map<String, String> properties ) - { - for ( Map.Entry<String, String> property : properties.entrySet() ) - { - sysProp( property.getKey(), property.getValue() ); - } - return this; - } - - public MavenLauncher sysProp( String variable, boolean value ) - { - return addGoal( "-D" + variable + "=" + value ); - } - - public MavenLauncher sysProp( String variable, int value ) - { - return addGoal( "-D" + variable + "=" + value ); - } - - public MavenLauncher sysProp( String variable, double value ) - { - return addGoal( "-D" + variable + "=" + value ); - } - - public MavenLauncher showExceptionMessages() - { - addCliOption( "-e" ); - return this; - } - - public MavenLauncher deleteSiteDir() - { - try - { - FileUtils.deleteDirectory( getValidator().getSubFile( "site" ) ); - } - catch ( IOException e ) - { - throw new SurefireVerifierException( e ); - } - return this; - } - - public OutputValidator getValidator() - { - if ( validator == null ) - { - this.validator = new OutputValidator( getVerifier() ); - } - return validator; - } - - public void setForkJvm( boolean forkJvm ) { - getVerifier().setForkJvm( forkJvm ); - } - - private Verifier getVerifier() - { - if ( verifier == null ) - { - try - { - verifier = - cli == null - ? new Verifier( ensureUnpacked().getAbsolutePath(), null, false ) - : new Verifier( ensureUnpacked().getAbsolutePath(), null, false, cli ); - } - catch ( VerificationException e ) - { - throw new RuntimeException( e ); - } - } - return verifier; - } - - private File simpleExtractResources( Class<?> cl, String resourcePath ) - { - if ( !resourcePath.startsWith( "/" ) ) - { - resourcePath = "/" + resourcePath; - } - File tempDir = getUnpackDir(); - File testDir = new File( tempDir, resourcePath ); - try - { - File parentPom = new File( tempDir.getParentFile(), "pom.xml" ); - if (!parentPom.exists()){ - URL resource = cl.getResource( "/pom.xml" ); - FileUtils.copyURLToFile( resource, parentPom ); - } - - FileUtils.deleteDirectory( testDir ); - File file = ResourceExtractor.extractResourceToDestination( cl, resourcePath, tempDir, true ); - return file.getCanonicalFile(); - } - catch ( IOException e ) - { - throw new RuntimeException( e ); - } - - } - - File getUnpackDir() - { - String tempDirPath = System.getProperty( "maven.test.tmpdir", System.getProperty( "java.io.tmpdir" ) ); - return new File( tempDirPath, - testCaseBeingRun.getSimpleName() + "_" + getTestMethodName() + suffix ); - } - - public File getArtifactPath( String gid, String aid, String version, String ext ) - { - return new File( verifier.getArtifactPath( gid, aid, version, ext ) ); - } - - String getTestMethodName() - { - // dirty. Im sure we can use junit4 rules to attach testname to thread instead - StackTraceElement[] stackTrace = getStackTraceElements(); - StackTraceElement topInTestClass; - topInTestClass = findTopElemenent( stackTrace, testCaseBeingRun ); - if ( topInTestClass == null ) - { - // Look in superclass... - topInTestClass = findTopElemenent( stackTrace, testCaseBeingRun.getSuperclass() ); - } - if ( topInTestClass != null ) - { - return topInTestClass.getMethodName(); - } - throw new IllegalStateException( "Cannot find " + testCaseBeingRun.getName() + "in stacktrace" ); - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncherTest.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncherTest.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncherTest.java deleted file mode 100644 index 42657c0..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncherTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.apache.maven.surefire.its.fixture; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.junit.Test; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.hamcrest.CoreMatchers.hasItems; - -/** - * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> - * @since 2.20 - */ -public class MavenLauncherTest -{ - @Test - public void shouldNotDuplicateSystemProperties() - { - MavenLauncher launcher = new MavenLauncher( getClass(), "", "" ) - .addGoal( "-DskipTests" ) - .addGoal( "-Dx=a" ) - .addGoal( "-DskipTests" ) - .addGoal( "-Dx=b" ); - - assertThat( launcher.getGoals(), hasItems( "-Dx=b", "-DskipTests" ) ); - - assertThat( launcher.getGoals().size(), is( 2 ) ); - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java deleted file mode 100644 index a76f86f..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java +++ /dev/null @@ -1,230 +0,0 @@ -package org.apache.maven.surefire.its.fixture; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.Collection; -import java.util.List; - -import org.apache.commons.io.FileUtils; -import org.apache.maven.it.VerificationException; -import org.apache.maven.it.Verifier; -import org.hamcrest.Matcher; - -import static org.hamcrest.MatcherAssert.assertThat; - -/** - * A specialized verifier that enforces a standard use case for surefire IT's - * - * @author Kristian Rosenvold - */ -public class OutputValidator -{ - protected final Verifier verifier; - - protected final File baseDir; - - public OutputValidator( Verifier verifier ) - { - this.verifier = verifier; - this.baseDir = new File( verifier.getBasedir() ); - } - - public OutputValidator verifyTextInLog( String text ) - { - try - { - verifier.verifyTextInLog( text ); - } - catch ( VerificationException e ) - { - throw new SurefireVerifierException( e ); - } - return this; - } - - - public OutputValidator verifyErrorFreeLog() - { - try - { - verifier.verifyErrorFreeLog(); - } - catch ( VerificationException e ) - { - throw new SurefireVerifierException( e ); - } - return this; - } - - public OutputValidator verifyErrorFree( int total ) - { - try - { - verifier.verifyErrorFreeLog(); - this.assertTestSuiteResults( total, 0, 0, 0 ); - return this; - } - catch ( VerificationException e ) - { - throw new SurefireVerifierException( e ); - } - } - - public OutputValidator assertThatLogLine( Matcher<String> line, Matcher<Integer> nTimes ) - throws VerificationException - { - int counter = 0; - for ( String log : loadLogLines() ) - { - if ( line.matches( log ) ) - { - counter++; - } - } - assertThat( "log pattern does not match nTimes", counter, nTimes ); - return this; - } - - public Collection<String> loadLogLines() - throws VerificationException - { - return verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false ); - } - - public List<String> loadFile( File file, Charset charset ) - { - //noinspection unchecked - try - { - return FileUtils.readLines( file, charset.name() ); - } - catch ( IOException e ) - { - throw new SurefireVerifierException( e ); - } - } - - public String getBasedir() - { - return verifier.getBasedir(); - } - - /** - * Returns a file, referenced from the extracted root (where pom.xml is located) - * - * @param path The subdirectory under basedir - * @return A file - */ - public File getSubFile( String path ) - { - return new File( getBasedir(), path ); - } - - public OutputValidator assertTestSuiteResults( int total, int errors, int failures, int skipped ) - { - HelperAssertions.assertTestSuiteResults( total, errors, failures, skipped, baseDir ); - return this; - } - - public OutputValidator assertTestSuiteResults( int total, int errors, int failures, int skipped, int flakes ) - { - HelperAssertions.assertTestSuiteResults( total, errors, failures, skipped, flakes, baseDir ); - return this; - } - - public OutputValidator assertTestSuiteResults( int total ) - { - HelperAssertions.assertTestSuiteResults( total, baseDir ); - return this; - } - - public OutputValidator assertIntegrationTestSuiteResults( int total, int errors, int failures, int skipped ) - { - HelperAssertions.assertIntegrationTestSuiteResults( total, errors, failures, skipped, baseDir ); - return this; - } - - public OutputValidator assertIntegrationTestSuiteResults( int total ) - { - HelperAssertions.assertIntegrationTestSuiteResults( total, baseDir ); - return this; - } - - public TestFile getTargetFile( String modulePath, String fileName ) - { - File targetDir = getSubFile( modulePath + "/target" ); - return new TestFile( new File( targetDir, fileName ), this ); - } - - public TestFile getTargetFile( String fileName ) - { - File targetDir = getSubFile( "target" ); - return new TestFile( new File( targetDir, fileName ), this ); - } - - public TestFile getSurefireReportsFile( String fileName ) - { - File targetDir = getSurefireReportsDirectory(); - return new TestFile( new File( targetDir, fileName ), this ); - } - - public TestFile getSurefireReportsXmlFile( String fileName ) - { - File targetDir = getSurefireReportsDirectory(); - return new TestFile( new File( targetDir, fileName ), Charset.forName( "UTF-8" ), this ); - } - - public File getSurefireReportsDirectory() - { - return getSubFile( "target/surefire-reports" ); - } - - public TestFile getSiteFile( String fileName ) - { - File targetDir = getSubFile( "target/site" ); - return new TestFile( new File( targetDir, fileName ), this ); - } - - public File getBaseDir() - { - return baseDir; - } - - public boolean stringsAppearInSpecificOrderInLog( String[] strings ) - throws VerificationException - { - int i = 0; - for ( String line : loadLogLines() ) - { - if ( line.startsWith( strings[i] ) ) - { - if ( i == strings.length - 1 ) - { - return true; - } - ++i; - } - } - return false; - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/Settings.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/Settings.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/Settings.java deleted file mode 100644 index 28013fb..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/Settings.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.apache.maven.surefire.its.fixture; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> - * @since 2.19 - */ -public enum Settings -{ - JUNIT4_TEST( TestFramework.JUNIT4, Configuration.TEST ), - JUNIT47_TEST( TestFramework.JUNIT47, Configuration.TEST ), - JUNIT4_INCLUDES( TestFramework.JUNIT4, Configuration.INCLUDES ), - JUNIT47_INCLUDES( TestFramework.JUNIT47, Configuration.INCLUDES ), - JUNIT4_INCLUDES_EXCLUDES( TestFramework.JUNIT4, Configuration.INCLUDES_EXCLUDES ), - JUNIT47_INCLUDES_EXCLUDES( TestFramework.JUNIT47, Configuration.INCLUDES_EXCLUDES ), - JUNIT4_INCLUDES_FILE( TestFramework.JUNIT4, Configuration.INCLUDES_FILE ), - JUNIT47_INCLUDES_FILE( TestFramework.JUNIT47, Configuration.INCLUDES_FILE ), - JUNIT4_INCLUDES_EXCLUDES_FILE( TestFramework.JUNIT4, Configuration.INCLUDES_EXCLUDES_FILE ), - JUNIT47_INCLUDES_EXCLUDES_FILE( TestFramework.JUNIT47, Configuration.INCLUDES_EXCLUDES_FILE ), - TestNG_TEST( TestFramework.TestNG, Configuration.TEST ), - TestNG_INCLUDES( TestFramework.TestNG, Configuration.INCLUDES ), - TestNG_INCLUDES_EXCLUDES( TestFramework.TestNG, Configuration.INCLUDES_EXCLUDES ), - TestNG_INCLUDES_FILE( TestFramework.TestNG, Configuration.INCLUDES_FILE ), - TestNG_INCLUDES_EXCLUDES_FILE( TestFramework.TestNG, Configuration.INCLUDES_EXCLUDES_FILE ); - - private final TestFramework framework; - private final Configuration configuration; - - Settings( TestFramework framework, Configuration configuration ) - { - this.framework = framework; - this.configuration = configuration; - } - - public String path() - { - return name().replace( '_', '-' ).toLowerCase(); - } - - public String profile() - { - return path(); - } - - public TestFramework getFramework() - { - return framework; - } - - public Configuration getConfiguration() - { - return configuration; - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java deleted file mode 100644 index ee04dbc..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.apache.maven.surefire.its.fixture; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * Contains commonly used features for most tests, encapsulating - * common use cases. - * <br> - * Also includes thread-safe access to the extracted resource - * files, which AbstractSurefireIntegrationTestClass does not. - * Thread safe only for running in "classes" mode. - * - * @author Kristian Rosenvold - */ -public abstract class SurefireJUnit4IntegrationTestCase -{ - public OutputValidator executeErrorFreeTest( String sourceName, int total ) - { - return unpack( sourceName ).executeTest().verifyErrorFree( total ); - } - - public SurefireLauncher unpack( String sourceName ) - { - return unpack( getClass(), sourceName, "" ); - } - - public SurefireLauncher unpack( String sourceName, String suffix ) - { - return unpack( getClass(), sourceName, suffix ); - } - - public static SurefireLauncher unpack( Class testClass, String sourceName, String suffix, String[] cli ) - { - MavenLauncher mavenLauncher = new MavenLauncher( testClass, sourceName, suffix, cli ); - return new SurefireLauncher( mavenLauncher ); - } - - public static SurefireLauncher unpack( Class testClass, String sourceName, String suffix ) - { - return unpack( testClass, sourceName, suffix, null ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java deleted file mode 100755 index 76d96e0..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java +++ /dev/null @@ -1,492 +0,0 @@ -package org.apache.maven.surefire.its.fixture; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.it.VerificationException; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import static org.apache.commons.lang3.StringUtils.isBlank; - -/** - * Encapsulate all needed features to start a surefire run - * <br> - * Also includes thread-safe access to the extracted resource - * files - * - * @author Kristian Rosenvold - - */ -public final class SurefireLauncher -{ - public static final String EXT_JDK_HOME_KEY = "jdk.home"; - - public static final String EXT_JDK_HOME = System.getProperty( EXT_JDK_HOME_KEY ); - - private static final File JAVA_HOME = javaHome(); - - private final MavenLauncher mavenLauncher; - - private final String surefireVersion = System.getProperty( "surefire.version" ); - - public SurefireLauncher( MavenLauncher mavenLauncher ) - { - this.mavenLauncher = mavenLauncher; - reset(); - } - - public MavenLauncher maven() - { - return mavenLauncher; - } - - String getTestMethodName() - { - return mavenLauncher.getTestMethodName(); - } - - public void reset() - { - mavenLauncher.reset(); - for ( String s : getInitialGoals() ) - { - mavenLauncher.addGoal( s ); - } - setInProcessJavaHome(); - } - - private static File javaHome() - { - String javaHome = isBlank( EXT_JDK_HOME ) ? System.getenv( "JAVA_HOME" ) : EXT_JDK_HOME; - if ( isBlank( javaHome ) ) - { - javaHome = System.getProperty( "java.home" ); - File jre = new File( javaHome ); - if ( "jre".equals( jre.getName() ) ) - { - javaHome = jre.getParent(); - } - } - - try - { - File javaHomeAsDir = new File( javaHome ).getCanonicalFile(); - if ( !javaHomeAsDir.isDirectory() ) - { - throw new RuntimeException( javaHomeAsDir.getAbsolutePath() + " is not a JAVA_HOME directory." ); - } - System.out.println( "Using JAVA_HOME=" + javaHomeAsDir.getAbsolutePath() + " in forked launcher." ); - return javaHomeAsDir; - } - catch ( IOException e ) - { - throw new RuntimeException( e ); - } - } - - private void setInProcessJavaHome() - { - setLauncherJavaHome( JAVA_HOME.getPath() ); - } - - public SurefireLauncher setLauncherJavaHome( String javaHome ) - { - mavenLauncher.addEnvVar( "JAVA_HOME", javaHome ); - return this; - } - - public SurefireLauncher getSubProjectLauncher( String subProject ) - throws VerificationException - { - return new SurefireLauncher( mavenLauncher.getSubProjectLauncher( subProject ) ); - } - - public OutputValidator getSubProjectValidator( String subProject ) - throws VerificationException - { - return mavenLauncher.getSubProjectValidator( subProject ); - } - - public SurefireLauncher addEnvVar( String key, String value ) - { - mavenLauncher.addEnvVar( key, value ); - return this; - } - - public SurefireLauncher setMavenOpts(String opts){ - addEnvVar( "MAVEN_OPTS", opts ); - return this; - } - - private List<String> getInitialGoals() - { - List<String> goals = new ArrayList<>(); - - goals.add( "-Dsurefire.version=" + surefireVersion ); - - String jacocoAgent = System.getProperty( "jacoco.agent", "" ); - goals.add( "-Djacoco.agent=" + jacocoAgent ); - - return goals; - } - - public SurefireLauncher showErrorStackTraces() - { - mavenLauncher.showErrorStackTraces(); - return this; - } - - public SurefireLauncher debugLogging() - { - mavenLauncher.debugLogging(); - return this; - } - - @SuppressWarnings( "UnusedDeclaration" ) - public SurefireLauncher debugSurefireFork() - { - mavenLauncher.sysProp( "maven.surefire.debug", "true" ); - return this; - } - - public SurefireLauncher failNever() - { - mavenLauncher.failNever(); - return this; - } - - public SurefireLauncher groups( String groups ) - { - mavenLauncher.sysProp( "groups", groups ); - return this; - } - - public SurefireLauncher addGoal( String goal ) - { - mavenLauncher.addGoal( goal ); - return this; - } - - public OutputValidator executeTest() - { - return mavenLauncher.execute( "test" ); - } - - public OutputValidator executeInstall() - throws VerificationException - { - return mavenLauncher.execute( "install" ); - } - - - public FailsafeOutputValidator executeVerify() - { - OutputValidator verify = execute( "verify" ); - return new FailsafeOutputValidator( verify ); - } - - public OutputValidator execute( String goal ) - { - return mavenLauncher.execute( goal ); - } - - public OutputValidator executeSurefireReport() - { - return mavenLauncher.execute( "surefire-report:report" ); - } - - - public OutputValidator executeCurrentGoals() - { - return mavenLauncher.executeCurrentGoals(); - } - - - public SurefireLauncher printSummary( boolean printsummary ) - { - mavenLauncher.sysProp( "printSummary", printsummary ); - return this; - } - - public SurefireLauncher redirectToFile( boolean redirect ) - { - mavenLauncher.sysProp( "maven.test.redirectTestOutputToFile", redirect ); - return this; - } - - public SurefireLauncher forkOnce() - { - return forkMode( "once" ); - } - - public SurefireLauncher forkNever() - { - return forkMode( "never" ); - } - - public SurefireLauncher forkAlways() - { - return forkMode( "always" ); - } - - public SurefireLauncher forkPerTest() - { - return forkMode( "pertest" ); - } - - public SurefireLauncher forkPerThread() - { - return forkMode( "perthread" ); - } - - public SurefireLauncher threadCount( int threadCount ) - { - mavenLauncher.sysProp( "threadCount", threadCount ); - return this; - } - - public SurefireLauncher forkCount( int forkCount ) - { - mavenLauncher.sysProp( "forkCount", forkCount ); - return this; - } - - public SurefireLauncher reuseForks( boolean reuseForks ) - { - mavenLauncher.sysProp( "reuseForks", reuseForks ); - return this; - } - - public SurefireLauncher forkMode( String forkMode ) - { - mavenLauncher.sysProp( "forkMode", forkMode ); - return this; - } - - public SurefireLauncher runOrder( String runOrder ) - { - mavenLauncher.sysProp( "surefire.runOrder", runOrder ); - return this; - } - - public SurefireLauncher failIfNoTests( boolean fail ) - { - mavenLauncher.sysProp( "failIfNoTests", fail ); - return this; - } - - - public SurefireLauncher mavenTestFailureIgnore( boolean fail ) - { - mavenLauncher.sysProp( "maven.test.failure.ignore", fail ); - return this; - } - - public SurefireLauncher failIfNoSpecifiedTests( boolean fail ) - { - mavenLauncher.sysProp( "surefire.failIfNoSpecifiedTests", fail ); - return this; - } - - public SurefireLauncher useSystemClassLoader( boolean useSystemClassLoader ) - { - mavenLauncher.sysProp( "useSystemClassLoader", useSystemClassLoader ); - return this; - } - - public SurefireLauncher activateProfile( String profile ) - { - mavenLauncher.activateProfile( profile ); - return this; - } - - - protected String getSurefireVersion() - { - return surefireVersion; - } - - public SurefireLauncher disablePerCoreThreadCount() - { - mavenLauncher.sysProp( "perCoreThreadCount", false ); - return this; - } - - public SurefireLauncher disableParallelOptimization() - { - mavenLauncher.sysProp( "parallelOptimized", "false" ); - return this; - } - - public SurefireLauncher parallel( String parallel ) - { - mavenLauncher.sysProp( "parallel", parallel ); - return this; - } - - public SurefireLauncher parallelSuites() - { - return parallel( "suites" ); - } - - public SurefireLauncher parallelClasses() - { - return parallel( "classes" ); - } - - public SurefireLauncher parallelMethods() - { - return parallel( "methods" ); - } - - public SurefireLauncher parallelBoth() - { - return parallel( "both" ); - } - - public SurefireLauncher parallelSuitesAndClasses() - { - return parallel( "suitesAndClasses" ); - } - - public SurefireLauncher parallelSuitesAndMethods() - { - return parallel( "suitesAndMethods" ); - } - - public SurefireLauncher parallelClassesAndMethods() - { - return parallel( "classesAndMethods" ); - } - - public SurefireLauncher parallelAll() - { - return parallel( "all" ); - } - - public SurefireLauncher useUnlimitedThreads() - { - mavenLauncher.sysProp( "useUnlimitedThreads", true ); - return this; - } - - public SurefireLauncher threadCountSuites( int count ) - { - mavenLauncher.sysProp( "threadCountSuites", count ); - return this; - } - - public SurefireLauncher threadCountClasses( int count ) - { - mavenLauncher.sysProp( "threadCountClasses", count ); - return this; - } - - public SurefireLauncher threadCountMethods( int count ) - { - mavenLauncher.sysProp( "threadCountMethods", count ); - return this; - } - - public SurefireLauncher parallelTestsTimeoutInSeconds( double timeout ) - { - mavenLauncher.sysProp( "surefire.parallel.timeout", timeout ); - return this; - } - - public SurefireLauncher parallelTestsTimeoutForcedInSeconds( double timeout ) - { - mavenLauncher.sysProp( "surefire.parallel.forcedTimeout", timeout ); - return this; - } - - public SurefireLauncher argLine( String value ) - { - mavenLauncher.sysProp( "argLine", value ); - return this; - } - - public SurefireLauncher sysProp( String variable, String value ) - { - mavenLauncher.sysProp( variable, value ); - return this; - } - - public SurefireLauncher setJUnitVersion( String version ) - { - mavenLauncher.sysProp( "junit.version", version ); - return this; - } - - public SurefireLauncher setGroups( String groups ) - { - mavenLauncher.sysProp( "groups", groups ); - return this; - } - - public SurefireLauncher setExcludedGroups( String excludedGroups ) - { - mavenLauncher.sysProp( "excludedGroups", excludedGroups ); - return this; - } - - - public File getUnpackedAt() - { - return mavenLauncher.getUnpackedAt(); - } - - public SurefireLauncher addFailsafeReportOnlyGoal() - { - mavenLauncher.addGoal( getReportPluginGoal( ":failsafe-report-only" ) ); - return this; - } - - public SurefireLauncher addSurefireReportGoal() - { - mavenLauncher.addGoal( getReportPluginGoal( "report" ) ); - return this; - } - - public SurefireLauncher addSurefireReportOnlyGoal() - { - mavenLauncher.addGoal( getReportPluginGoal( "report-only" ) ); - return this; - } - - private String getReportPluginGoal( String goal ) - { - return "org.apache.maven.plugins:maven-surefire-report-plugin:" + getSurefireVersion() + ":" + goal; - } - - public SurefireLauncher setTestToRun( String basicTest ) - { - mavenLauncher.sysProp( "test", basicTest ); - return this; - } - - public SurefireLauncher setForkJvm() - { - mavenLauncher.setForkJvm( true ); - return this; - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java deleted file mode 100644 index b5df941..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncherTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.apache.maven.surefire.its.fixture; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.IOException; -import org.apache.maven.it.VerificationException; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * @author Kristian Rosenvold - */ -public class SurefireLauncherTest -{ - @Test - public void launcherGetsProperMethodName() - throws IOException, VerificationException - { - MavenLauncher mavenLauncher = new MavenLauncher( SurefireLauncherTest.class, "foo", "" ); - String method = new SurefireLauncher( mavenLauncher ).getTestMethodName(); - assertEquals( "launcherGetsProperMethodName", method ); - - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireVerifierException.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireVerifierException.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireVerifierException.java deleted file mode 100644 index 5201503..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireVerifierException.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.apache.maven.surefire.its.fixture; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * @author Kristian Rosenvold - */ -public class SurefireVerifierException - extends RuntimeException -{ - public SurefireVerifierException( String message, Throwable cause ) - { - super( message, cause ); - } - - public SurefireVerifierException( Throwable cause ) - { - super( cause ); - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java deleted file mode 100644 index cf6ad84..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFile.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.apache.maven.surefire.its.fixture; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.net.URI; -import java.nio.charset.Charset; -import java.util.List; -import org.apache.commons.io.FileUtils; - -import junit.framework.Assert; - -import static junit.framework.Assert.assertTrue; - -/** - * @author Kristian Rosenvold - */ -public class TestFile -{ - private final File file; - - private final Charset encoding; - - private final OutputValidator surefireVerifier; - - public TestFile( File file, OutputValidator surefireVerifier ) - { - this( file, Charset.defaultCharset(), surefireVerifier); - } - - public TestFile( File file, Charset charset, OutputValidator surefireVerifier ) - { - this.file = file; - this.encoding = charset; - this.surefireVerifier = surefireVerifier; - } - - public OutputValidator assertFileExists() - { - assertTrue( "File doesn't exist: " + file.getAbsolutePath(), file.exists() ); - return surefireVerifier; - } - - public OutputValidator assertFileNotExists() - { - assertTrue( "File doesn't exist: " + file.getAbsolutePath(), !file.exists() ); - return surefireVerifier; - } - - public void delete() - { - //noinspection ResultOfMethodCallIgnored - file.delete(); - } - - public String getAbsolutePath() - { - return file.getAbsolutePath(); - } - - public boolean exists() - { - return file.exists(); - } - - public FileInputStream getFileInputStream() - throws FileNotFoundException - { - return new FileInputStream( file ); - } - - public String slurpFile() - { - try - { - StringBuilder sb = new StringBuilder(); - BufferedReader reader; - reader = new BufferedReader( new FileReader( file ) ); - for ( String line = reader.readLine(); line != null; line = reader.readLine() ) - { - sb.append( line ); - } - reader.close(); - return sb.toString(); - } - catch ( IOException e ) - { - throw new SurefireVerifierException( e ); - } - - } - - public String readFileToString() - { - try - { - return FileUtils.readFileToString( file ); - } - catch ( IOException e ) - { - throw new SurefireVerifierException( e ); - } - } - - public boolean isFile() - { - return file.isFile(); - } - - public TestFile assertContainsText( String text ) - { - final List<String> list = surefireVerifier.loadFile( file, encoding ); - for ( String line : list ) - { - if ( line.contains( text ) ) - { - return this; - } - } - Assert.fail( "Did not find expected message in log" ); - return null; - } - - public URI toURI() - { - return file.toURI(); - } - - public File getFile() - { - return file; - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFramework.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFramework.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFramework.java deleted file mode 100644 index c544347..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/TestFramework.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.apache.maven.surefire.its.fixture; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> - * @since 2.19 - */ -public enum TestFramework -{ - JUNIT4, JUNIT47, TestNG -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1024VerifyFailsafeIfTestedIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1024VerifyFailsafeIfTestedIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1024VerifyFailsafeIfTestedIT.java deleted file mode 100644 index 886cd07..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1024VerifyFailsafeIfTestedIT.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.apache.maven.surefire.its.jiras; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.apache.maven.surefire.its.fixture.SurefireLauncher; -import org.junit.Test; - -/** - * "verify" goal ignores "dependenciesToScan" parameter when checking tests existence - * <p> - * Found in Surefire 2.16. - * - * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> - * @see <a href="https://issues.apache.org/jira/browse/SUREFIRE-1024">SUREFIRE-1024</a> - * @since 2.19 - */ -public class Surefire1024VerifyFailsafeIfTestedIT - extends SurefireJUnit4IntegrationTestCase -{ - - @Test - public void shouldScanAndRunTestsInDependencyJars() throws Exception { - SurefireLauncher launcher = unpack( "surefire-1024" ); - launcher.executeVerify() - .verifyTextInLog( "class jiras.surefire1024.A1IT#test() dependency to scan" ); - - launcher.getSubProjectValidator( "jiras-surefire-1024-it" ) - .assertIntegrationTestSuiteResults( 1, 0, 0, 0 ); - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1028UnableToRunSingleIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1028UnableToRunSingleIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1028UnableToRunSingleIT.java deleted file mode 100644 index ec63a8a..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1028UnableToRunSingleIT.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.apache.maven.surefire.its.jiras; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.apache.maven.surefire.its.fixture.SurefireLauncher; -import org.junit.Test; - -/** - * Plugin Configuration: parallel=classes - * <br> - * With Surefire 2.15 - * {@code $ mvn test -Dtest=MyTest#testFoo} - * Results: - * Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 - * <br> - * With Surefire 2.16 - * {@code $ mvn test -Dtest=MyTest#testFoo} - * <br> - * Results: - * Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 - * - * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> - * @see <a href="https://issues.apache.org/jira/browse/SUREFIRE-1028">SUREFIRE-1028</a> - * @since 2.18 - */ -public class Surefire1028UnableToRunSingleIT - extends SurefireJUnit4IntegrationTestCase -{ - - @Test - public void methodFilteringParallelExecution() - { - unpack().setTestToRun( "SomeTest#test" ).parallelClasses().useUnlimitedThreads() - .executeTest().verifyErrorFree( 1 ).verifyTextInLog( "OK!" ); - } - - private SurefireLauncher unpack() - { - return unpack( "surefire-1028-unable-to-run-single-test" ); - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1036NonFilterableJUnitRunnerWithCategoriesIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1036NonFilterableJUnitRunnerWithCategoriesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1036NonFilterableJUnitRunnerWithCategoriesIT.java deleted file mode 100644 index 0d6d8b6..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1036NonFilterableJUnitRunnerWithCategoriesIT.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.apache.maven.surefire.its.jiras; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.it.VerificationException; -import org.apache.maven.shared.utils.xml.Xpp3Dom; -import org.apache.maven.shared.utils.xml.Xpp3DomBuilder; -import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.apache.maven.surefire.its.fixture.SurefireLauncher; -import org.apache.maven.surefire.its.fixture.TestFile; -import org.junit.Test; - -import java.io.FileNotFoundException; - -import static org.junit.Assert.*; - -/** - * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> - * @see <a href="https://issues.apache.org/jira/browse/SUREFIRE-1036">SUREFIRE-1036</a> - * @since 2.18 - */ -public class Surefire1036NonFilterableJUnitRunnerWithCategoriesIT - extends SurefireJUnit4IntegrationTestCase -{ - - @Test - public void test() - throws VerificationException, FileNotFoundException - { - OutputValidator validator = unpack().maven().executeTest(); - validator.assertTestSuiteResults( 1, 0, 0, 0 ); - assertFalse( validator.getSurefireReportsXmlFile( - "TEST-jiras.surefire1036.TestSomethingWithMockitoRunner.xml" ).exists() ); - assertFalse( validator.getSurefireReportsXmlFile( "TEST-jiras.surefire1036.TestSomeUnit.xml" ).exists() ); - TestFile reportFile = - validator.getSurefireReportsXmlFile( "TEST-jiras.surefire1036.TestSomeIntegration.xml" ); - assertTestCount( reportFile, 1 ); - } - - private SurefireLauncher unpack() - { - return unpack( "surefire-1036-NonFilterableJUnitRunnerWithCategories" ); - } - - private void assertTestCount( TestFile reportFile, int tests ) - throws FileNotFoundException - { - assertTrue( reportFile.exists() ); - Xpp3Dom testResult = Xpp3DomBuilder.build( reportFile.getFileInputStream(), "UTF-8" ); - Xpp3Dom[] children = testResult.getChildren( "testcase" ); - assertEquals( tests, children.length ); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1041FailingJUnitRunnerIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1041FailingJUnitRunnerIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1041FailingJUnitRunnerIT.java deleted file mode 100644 index bb65682..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1041FailingJUnitRunnerIT.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.apache.maven.surefire.its.jiras; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.junit.Test; - -/** - * SUREFIRE-1041: An error in a JUnit runner should not lead to an error in Surefire - * - * @author Andreas Gudian - */ -public class Surefire1041FailingJUnitRunnerIT - extends SurefireJUnit4IntegrationTestCase -{ - @Test - public void reportErrorInJUnitRunnerAsTestError() - { - unpack( "surefire-1041-exception-in-junit-runner" ).mavenTestFailureIgnore( true ).executeTest().assertTestSuiteResults( 1, 1, 0, 0 ); - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1053SystemPropertiesIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1053SystemPropertiesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1053SystemPropertiesIT.java deleted file mode 100644 index b3ed744..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1053SystemPropertiesIT.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.apache.maven.surefire.its.jiras; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.apache.maven.surefire.its.fixture.SurefireLauncher; -import org.junit.Test; - -import static org.junit.Assert.assertFalse; - -/** - * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> - * @see <a href="https://issues.apache.org/jira/browse/SUREFIRE-1053">SUREFIRE-1053</a> - * @since 2.18 - */ -public class Surefire1053SystemPropertiesIT - extends SurefireJUnit4IntegrationTestCase -{ - @Test - public void checkWarningsFileEncoding() - { - unpack().sysProp( "file.encoding", "ISO-8859-1" ) - .executeTest() - .verifyErrorFree( 1 ) - .verifyTextInLog( "file.encoding cannot be set as system property, use <argLine>-D" - + "file.encoding=...</argLine> instead" ); - } - @Test - public void checkWarningsSysPropTwice() throws Exception - { - OutputValidator validator = unpack() - .argLine( "-DmyArg=myVal2 -Dfile.encoding=ISO-8859-1" ) - .sysProp( "file.encoding", "ISO-8859-1" ) - .executeTest() - .verifyErrorFree( 1 ) - .verifyTextInLog( "The system property myArg is configured twice! " - + "The property appears in <argLine/> and any of <systemPropertyVariables/>, " - + "<systemProperties/> or user property." ); - - for ( String line : validator.loadLogLines() ) - { - assertFalse( "no warning for file.encoding not in argLine", - line.contains( "file.encoding cannot be set as system property, use <argLine>" ) ); - assertFalse( "no warning for double definition of file.encoding", - line.contains( "The system property file.encoding is configured twice!" ) ); - } - - } - - private SurefireLauncher unpack() - { - return unpack( "surefire-1053-system-properties" ); - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1055CorrectConcurrentTestCountIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1055CorrectConcurrentTestCountIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1055CorrectConcurrentTestCountIT.java deleted file mode 100644 index 0293a75..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1055CorrectConcurrentTestCountIT.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.apache.maven.surefire.its.jiras; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.surefire.its.fixture.OutputValidator; -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.junit.Test; - -/** - * SUREFIRE-1055 Correct test count in parallel run mode. - * - * @author Kristian Rosenvold - */ -public class Surefire1055CorrectConcurrentTestCountIT - extends SurefireJUnit4IntegrationTestCase -{ - @Test - public void testTestNgAndJUnitTogether() - { - OutputValidator outputValidator = unpack( "surefire-1055-parallelTestCount" ).executeTest(); - outputValidator.assertTestSuiteResults( 21, 0, 0, 0 ); - - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4d00932a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1080ParallelForkDoubleTestIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1080ParallelForkDoubleTestIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1080ParallelForkDoubleTestIT.java deleted file mode 100644 index d6a38fa..0000000 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1080ParallelForkDoubleTestIT.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.apache.maven.surefire.its.jiras; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; -import org.apache.maven.surefire.its.fixture.SurefireLauncher; -import org.junit.Test; - -/** - * Description of SUREFIRE-1080: <br> - * <br> - * There are 9 tests in total in the attached project, and mvn test will show 9 tests run. - * When I use the command " mvn test -Dparallel=classes -DforkCount=2 -DuseUnlimitedThreads=true", it shows 13 tests - * run (and sometimes 16), and some tests are run more than once. - * If I remove forkCount, or parallel, everything will be fine. But it is problematic when combining together. - * Apache Maven 3.2.2-SNAPSHOT - * Surefire 2.18-SNAPSHOT - * JUnit 4.11 - * - * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> - * @see <a href="https://issues.apache.org/jira/browse/SUREFIRE-1080">SUREFIRE-1080</a> - * @since 2.18 - */ -public class Surefire1080ParallelForkDoubleTestIT - extends SurefireJUnit4IntegrationTestCase -{ - @Test - public void test() - { - unpack().executeTest().assertTestSuiteResults( 9 ); - } - - private SurefireLauncher unpack() - { - return unpack( "surefire-1080-parallel-fork-double-test" ); - } -}