[Commented] (SUREFIRE-1004) Enhance pattern/wildcard capabilities for dependenciesToScan to GAVT

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Commented] (SUREFIRE-1004) Enhance pattern/wildcard capabilities for dependenciesToScan to GAVT

JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/SUREFIRE-1004?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16324614#comment-16324614 ]

ASF GitHub Bot commented on SUREFIRE-1004:
------------------------------------------

Github user Tibor17 commented on a diff in the pull request:

    https://github.com/apache/maven-surefire/pull/173#discussion_r161336480
 
    --- Diff: maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/util/DependenciesScannerTest.java ---
    @@ -69,19 +78,141 @@ public void testLocateTestClasses()
             assertEquals( 1, props.size() );
         }
     
    -    private File writeTestFile()
    +    /**
    +     * Test for artifact with classifier
    +     */
    +    @Test
    +    public void testLocateTestClassesFromArtifactWithClassifier()
    +        throws Exception
    +    {
    +        File testJarFile = writeTestFile( "DependenciesScannerTest2-1.0-tests-jdk15.jar", "org/test/TestA.class",
    +                                          "org/test/other/TestAA.class", "org/test/TestB.class" );
    +        Artifact testArtifact =
    +            new DefaultArtifact( "org.surefire.dependency", "dependent-artifact2",
    +                                 VersionRange.createFromVersion( "1.0" ), "test", "jar", "tests-jdk15", null );
    +        testArtifact.setFile( testJarFile );
    +
    +        List<String> scanDependencies = new ArrayList<String>();
    +        scanDependencies.add( "org.surefire.dependency:dependent-artifact2:::tests-jdk15" );
    +
    +        List<String> include = new ArrayList<String>();
    +        include.add( "**/*A.java" );
    +        List<String> exclude = new ArrayList<String>();
    +
    +        DependencyScanner scanner =
    +            new DependencyScanner( DependencyScanner.filter( Collections.singletonList( testArtifact ),
    +                                                             scanDependencies ),
    +                                   new TestListResolver( include, exclude ) );
    +
    +        ScanResult classNames = scanner.scan();
    +        assertNotNull( classNames );
    +        assertEquals( 2, classNames.size() );
    +
    +        Map<String, String> props = new HashMap<String, String>();
    +        classNames.writeTo( props );
    +        assertEquals( 2, props.size() );
    +    }
    +
    +    /**
    +     * Test with type when two artifacts are present, should only find the class in jar with correct type
    +     */
    +    @Test
    +    public void testLocateTestClassesFromMultipleArtifactsWithType()
    +        throws Exception
    +    {
    +        File jarFile =
    +            writeTestFile( "DependenciesScannerTest3-1.0.jar", "org/test/ClassA.class", "org/test/ClassB.class" );
    +        Artifact mainArtifact = new DefaultArtifact( "org.surefire.dependency", "dependent-artifact3",
    +                                                     VersionRange.createFromVersion( "1.0" ), "test", "jar", null,
    +                                                     new DefaultArtifactHandler() );
    +        mainArtifact.setFile( jarFile );
    +
    +        File testJarFile =
    +            writeTestFile( "DependenciesScannerTest3-1.0-tests.jar", "org/test/TestA.class", "org/test/TestB.class" );
    +        Artifact testArtifact = new DefaultArtifact( "org.surefire.dependency", "dependent-artifact3",
    +                                                     VersionRange.createFromVersion( "1.0" ), "test", "test-jar", null,
    +                                                     new DefaultArtifactHandler() );
    +        testArtifact.setFile( testJarFile );
    +
    +        List<String> scanDependencies = new ArrayList<String>();
    +        scanDependencies.add( "org.surefire.dependency:dependent-artifact3::test-jar" );
    +
    +        List<String> include = new ArrayList<String>();
    +        include.add( "**/*A.java" );
    +        List<String> exclude = new ArrayList<String>();
    +
    +        DependencyScanner scanner =
    +            new DependencyScanner( DependencyScanner.filter( Arrays.asList( mainArtifact, testArtifact ),
    --- End diff --
   
    Try to make the constructor call more compact using e.g. static imports or extracting to another local variables.


> Enhance pattern/wildcard capabilities for dependenciesToScan to GAVT
> --------------------------------------------------------------------
>
>                 Key: SUREFIRE-1004
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1004
>             Project: Maven Surefire
>          Issue Type: Improvement
>          Components: Maven Failsafe Plugin, Maven Surefire Plugin
>    Affects Versions: 2.15
>            Reporter: Andreas Gudian
>
> * Enhance what has been built with SUREFIRE-569 to support patterns as in maven-shade-plugin. Use maven-common-artifact-filters for that.
> * Add/Adapt documentation and examples.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)