Updating the unit tests so that they can be run successfully directly inside Eclipse: this means fixing the location of the basedir by extending from PlexusTestCase and using the getBasedir() method.

git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1778361 13f79535-47bb-0310-9956-ffa450edef68
master
Guillaume Boué 2017-01-12 00:06:50 +00:00
parent 117eaf66a5
commit f50e9ebb58
2 changed files with 5 additions and 5 deletions

View File

@ -50,7 +50,7 @@ public class TestAnnotationsReader
MojoAnnotationsScanner mojoAnnotationsScanner = (MojoAnnotationsScanner) lookup( MojoAnnotationsScanner.ROLE ); MojoAnnotationsScanner mojoAnnotationsScanner = (MojoAnnotationsScanner) lookup( MojoAnnotationsScanner.ROLE );
MojoAnnotationsScannerRequest request = new MojoAnnotationsScannerRequest(); MojoAnnotationsScannerRequest request = new MojoAnnotationsScannerRequest();
request.setClassesDirectories( Collections.singletonList( new File( "target/test-classes" ) ) ); request.setClassesDirectories( Collections.singletonList( new File( getBasedir(), "target/test-classes" ) ) );
request.setIncludePatterns( Arrays.asList( "**/FooMojo.class" ) ); request.setIncludePatterns( Arrays.asList( "**/FooMojo.class" ) );
request.setProject( new MavenProject() ); request.setProject( new MavenProject() );

View File

@ -23,17 +23,17 @@ import static org.easymock.EasyMock.*;
import java.io.File; import java.io.File;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.Logger;
import junit.framework.TestCase;
public class DefaultMojoAnnotationsScannerTest public class DefaultMojoAnnotationsScannerTest
extends TestCase extends PlexusTestCase
{ {
private DefaultMojoAnnotationsScanner scanner = new DefaultMojoAnnotationsScanner(); private DefaultMojoAnnotationsScanner scanner = new DefaultMojoAnnotationsScanner();
public void testSkipModuleInfoClassInArchive() throws Exception public void testSkipModuleInfoClassInArchive() throws Exception
{ {
scanner.scanArchive( new File( "src/test/resources/java9-module.jar"), null, false ); scanner.scanArchive( new File( getBasedir(), "target/test-classes/java9-module.jar"), null, false );
} }
public void testJava8Annotations() throws Exception public void testJava8Annotations() throws Exception
@ -42,7 +42,7 @@ public class DefaultMojoAnnotationsScannerTest
expect( logger.isDebugEnabled() ).andReturn( false ); expect( logger.isDebugEnabled() ).andReturn( false );
replay( logger ); replay( logger );
scanner.enableLogging( logger ); scanner.enableLogging( logger );
scanner.scanArchive( new File( "src/test/resources/java8-annotations.jar"), null, false ); scanner.scanArchive( new File( getBasedir(), "target/test-classes/java8-annotations.jar"), null, false );
} }
} }