Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java?rev=1807877&r1=1807876&r2=1807877&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java Sat Sep 9 10:35:59 2017 @@ -54,7 +54,7 @@ public class TestCollectMojo assertNotNull( mojo.getProject() ); MavenProject project = mojo.getProject(); - mojo.setSilent(true); + mojo.setSilent( true ); Set<Artifact> artifacts = this.stubFactory.getScopedArtifacts(); Set<Artifact> directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); artifacts.addAll( directArtifacts ); @@ -64,8 +64,8 @@ public class TestCollectMojo mojo.execute(); DependencyStatusSets results = mojo.getResults(); - assertNotNull(results); - assertEquals(artifacts.size(), results.getResolvedDependencies().size()); + assertNotNull( results ); + assertEquals( artifacts.size(), results.getResolvedDependencies().size() ); } /** @@ -83,13 +83,13 @@ public class TestCollectMojo assertNotNull( mojo.getProject() ); MavenProject project = mojo.getProject(); - mojo.setSilent(true); + mojo.setSilent( true ); Set<Artifact> artifacts = this.stubFactory.getScopedArtifacts(); Set<Artifact> directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); artifacts.addAll( directArtifacts ); - project.setArtifacts(artifacts); - project.setDependencyArtifacts(directArtifacts); + project.setArtifacts( artifacts ); + project.setDependencyArtifacts( directArtifacts ); setVariableValueToObject( mojo, "excludeTransitive", Boolean.TRUE ); @@ -104,7 +104,7 @@ public class TestCollectMojo { File testPom = new File( getBasedir(), "target/test-classes/unit/collect-test/plugin-config.xml" ); CollectDependenciesMojo mojo = (CollectDependenciesMojo) lookupMojo( "collect", testPom ); - mojo.setSilent(false); + mojo.setSilent( false ); assertFalse( mojo.getLog() instanceof SilentLog ); } // TODO: Test skipping artifacts.
Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java?rev=1807877&r1=1807876&r2=1807877&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java Sat Sep 9 10:35:59 2017 @@ -44,29 +44,30 @@ public class TestGetMojo File testPom = new File( getBasedir(), "target/test-classes/unit/get-test/plugin-config.xml" ); assert testPom.exists(); mojo = (GetMojo) lookupMojo( "get", testPom ); - + assertNotNull( mojo ); - + LegacySupport legacySupport = lookup( LegacySupport.class ); legacySupport.setSession( newMavenSession( new MavenProjectStub() ) ); DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) legacySupport.getRepositorySession(); repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( testDir.getAbsolutePath() ) ); - + setVariableValueToObject( mojo, "session", legacySupport.getSession() ); } /** * Test transitive parameter * - * @throws Exception + * @throws Exception in case of errors */ public void testTransitive() throws Exception { // Set properties, transitive = default value = true setVariableValueToObject( mojo, "transitive", Boolean.FALSE ); - setVariableValueToObject( mojo, "remoteRepositories", "central::default::http://repo1.maven.apache.org/maven2" ); + setVariableValueToObject( mojo, "remoteRepositories", + "central::default::http://repo1.maven.apache.org/maven2" ); mojo.setGroupId( "org.apache.maven" ); mojo.setArtifactId( "maven-model" ); mojo.setVersion( "2.0.9" ); @@ -77,11 +78,11 @@ public class TestGetMojo setVariableValueToObject( mojo, "transitive", Boolean.FALSE ); mojo.execute(); } - + /** * Test remote repositories parameter * - * @throws Exception + * @throws Exception in case of errors */ public void testRemoteRepositories() throws Exception @@ -98,7 +99,7 @@ public class TestGetMojo /** * Test parsing of the remote repositories parameter * - * @throws Exception + * @throws Exception in case of errors */ public void testParseRepository() throws Exception Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java?rev=1807877&r1=1807876&r2=1807877&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java Sat Sep 9 10:35:59 2017 @@ -38,7 +38,7 @@ public class TestPropertiesMojo /** * tests the proper discovery and configuration of the mojo * - * @throws Exception + * @throws Exception in case of errors */ public void testSetProperties() throws Exception Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java?rev=1807877&r1=1807876&r2=1807877&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java Sat Sep 9 10:35:59 2017 @@ -158,15 +158,14 @@ public class TestSkip private void doConfigTest( String mojoName, String configFile ) throws Exception { - File testPom = - new File( getBasedir(), "target/test-classes/unit/skip-test/" + configFile ); + File testPom = new File( getBasedir(), "target/test-classes/unit/skip-test/" + configFile ); Mojo mojo = lookupMojo( mojoName, testPom ); assertNotNull( mojo ); CapturingLog log = new CapturingLog(); mojo.setLog( log ); mojo.execute(); - assertTrue(log.getContent().contains("Skipping plugin execution")); + assertTrue( log.getContent().contains( "Skipping plugin execution" ) ); } class CapturingLog @@ -293,7 +292,7 @@ public class TestSkip private void print( String prefix, CharSequence content ) { - sb.append("[").append(prefix).append("] ").append(content.toString()).append( "\n" ); + sb.append( "[" ).append( prefix ).append( "] " ).append( content.toString() ).append( "\n" ); } private void print( String prefix, Throwable error ) @@ -303,7 +302,7 @@ public class TestSkip error.printStackTrace( pWriter ); - sb.append("[").append(prefix).append("] ").append(sWriter.toString()).append( "\n" ); + sb.append( "[" ).append( prefix ).append( "] " ).append( sWriter.toString() ).append( "\n" ); } private void print( String prefix, CharSequence content, Throwable error ) @@ -313,8 +312,7 @@ public class TestSkip error.printStackTrace( pWriter ); - sb.append("[").append(prefix).append("] ").append(content.toString()).append( "\n\n" ) - .append( sWriter.toString() ).append( "\n" ); + sb.append( "[" ).append( prefix ).append( "] " ).append( content.toString() ).append( "\n\n" ).append( sWriter.toString() ).append( "\n" ); } protected String getContent() Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java?rev=1807877&r1=1807876&r2=1807877&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java Sat Sep 9 10:35:59 2017 @@ -53,7 +53,9 @@ public class TestAnalyzeDepMgt Artifact exclusionArtifact; DependencyManagement depMgt; + DependencyManagement depMgtNoExclusions; + protected void setUp() throws Exception { @@ -66,7 +68,6 @@ public class TestAnalyzeDepMgt Set<Artifact> allArtifacts = stubFactory.getMixedArtifacts(); Set<Artifact> directArtifacts = stubFactory.getClassifiedArtifacts(); - exclusionArtifact = stubFactory.getReleaseArtifact(); directArtifacts.add( exclusionArtifact ); ex = new Exclusion(); @@ -87,7 +88,6 @@ public class TestAnalyzeDepMgt depMgt = new DependencyManagement(); depMgt.setDependencies( list ); - project.setArtifacts( allArtifacts ); project.setDependencyArtifacts( directArtifacts ); @@ -107,8 +107,8 @@ public class TestAnalyzeDepMgt // version isn't used in the key, it can be different dep.setVersion( "1.1" ); - Artifact artifact = stubFactory.createArtifact( "group", "artifact", "1.0", Artifact.SCOPE_COMPILE, "type", - "class" ); + Artifact artifact = + stubFactory.createArtifact( "group", "artifact", "1.0", Artifact.SCOPE_COMPILE, "type", "class" ); // basic case ok assertEquals( dep.getManagementKey(), mojo.getArtifactManagementKey( artifact ) ); @@ -156,7 +156,7 @@ public class TestAnalyzeDepMgt list.add( ex ); Map<String, Exclusion> map = mojo.addExclusions( list ); - assertEquals( 1,map.size() ); + assertEquals( 1, map.size() ); assertTrue( map.containsKey( mojo.getExclusionKey( ex ) ) ); assertSame( ex, map.get( mojo.getExclusionKey( ex ) ) ); } @@ -173,7 +173,7 @@ public class TestAnalyzeDepMgt assertEquals( 1, l.size() ); - assertEquals( mojo.getExclusionKey( ex ), mojo.getExclusionKey(l.get( 0 )) ); + assertEquals( mojo.getExclusionKey( ex ), mojo.getExclusionKey( l.get( 0 ) ) ); } public void testGetMismatch() @@ -191,7 +191,8 @@ public class TestAnalyzeDepMgt assertSame( exclusion, results.get( stubFactory.getReleaseArtifact() ) ); } - public void testMojo() throws IOException + public void testMojo() + throws IOException { mojo.setIgnoreDirect( false ); try Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java?rev=1807877&r1=1807876&r2=1807877&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java Sat Sep 9 10:35:59 2017 @@ -37,8 +37,7 @@ public class TestAnalyzeDuplicateMojo public void testDuplicate() throws Exception { - File testPom = - new File( getBasedir(), "target/test-classes/unit/duplicate-dependencies/plugin-config.xml" ); + File testPom = new File( getBasedir(), "target/test-classes/unit/duplicate-dependencies/plugin-config.xml" ); AnalyzeDuplicateMojo mojo = (AnalyzeDuplicateMojo) lookupMojo( "analyze-duplicate", testPom ); assertNotNull( mojo ); DuplicateLog log = new DuplicateLog(); @@ -53,8 +52,7 @@ public class TestAnalyzeDuplicateMojo public void testDuplicate2() throws Exception { - File testPom = - new File( getBasedir(), "target/test-classes/unit/duplicate-dependencies/plugin-config2.xml" ); + File testPom = new File( getBasedir(), "target/test-classes/unit/duplicate-dependencies/plugin-config2.xml" ); AnalyzeDuplicateMojo mojo = (AnalyzeDuplicateMojo) lookupMojo( "analyze-duplicate", testPom ); assertNotNull( mojo ); DuplicateLog log = new DuplicateLog(); Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java?rev=1807877&r1=1807876&r2=1807877&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java Sat Sep 9 10:35:59 2017 @@ -60,12 +60,12 @@ public class TestCopyMojo assertNotNull( mojo.getProject() ); // MavenProject project = mojo.getProject(); // init classifier things - + MavenSession session = newMavenSession( mojo.getProject() ); setVariableValueToObject( mojo, "session", session ); - + DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) session.getRepositorySession(); - + repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( stubFactory.getWorkingDir() ) ); } @@ -172,7 +172,7 @@ public class TestCopyMojo assertFilesExist( list, true ); } - + public void testCopyFileWithBaseVersion() throws Exception { @@ -182,16 +182,16 @@ public class TestCopyMojo item.setArtifactId( "artifact" ); item.setGroupId( "groupId" ); item.setVersion( "1.0-20130210.213424-191" ); - list.add(item); + list.add( item ); mojo.setArtifactItems( createArtifactItemArtifacts( list ) ); - mojo.setUseBaseVersion(true); + mojo.setUseBaseVersion( true ); mojo.execute(); assertFilesExist( list, true ); } - + public void testSkip() throws Exception { @@ -203,7 +203,7 @@ public class TestCopyMojo mojo.execute(); for ( ArtifactItem item : list ) { - //these will be null because no processing has occured only when everything is skipped + // these will be null because no processing has occured only when everything is skipped assertEquals( null, item.getOutputDirectory() ); assertEquals( null, item.getDestFileName() ); } @@ -245,7 +245,7 @@ public class TestCopyMojo throws Exception { List<ArtifactItem> list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() ); - + ArtifactItem item = list.get( 0 ); item.setOutputDirectory( new File( mojo.getOutputDirectory(), "testOverride" ) ); mojo.setStripVersion( true ); @@ -382,11 +382,11 @@ public class TestCopyMojo MavenProject project = mojo.getProject(); project.setDependencies( createDependencyArtifacts( getDependencyList( item ) ) ); - + // ensure dependency exists item.setClassifier( "sources" ); item.setType( "jar" ); - + // pre-create item item.setVersion( "2.1" ); createArtifact( item ); @@ -751,31 +751,31 @@ public class TestCopyMojo assertTrue( time < copiedFile.lastModified() ); } - + public void testCopyFileWithOverideLocalRepo() throws Exception { final File localRepo = stubFactory.getWorkingDir(); - + List<ArtifactItem> list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() ); mojo.setArtifactItems( list ); - - File execLocalRepo = new File( this.testDir.getAbsolutePath(), "executionLocalRepo" ); + + File execLocalRepo = new File( this.testDir.getAbsolutePath(), "executionLocalRepo" ); assertFalse( execLocalRepo.exists() ); - + stubFactory.setWorkingDir( execLocalRepo ); createArtifactItemArtifacts( list ); - + assertFalse( "default local repo should not exist", localRepo.exists() ); - + mojo.setLocalRepositoryDirectory( execLocalRepo ); - + mojo.execute(); assertFilesExist( list, true ); - - } + + } private List<Dependency> createDependencyArtifacts( List<Dependency> items ) throws IOException @@ -785,12 +785,12 @@ public class TestCopyMojo { String classifier = "".equals( item.getClassifier() ) ? null : item.getClassifier(); stubFactory.createArtifact( item.getGroupId(), item.getArtifactId(), - VersionRange.createFromVersion( item.getVersion() ), null, - item.getType(), classifier, item.isOptional() ); + VersionRange.createFromVersion( item.getVersion() ), null, item.getType(), + classifier, item.isOptional() ); } return items; } - + private List<ArtifactItem> createArtifactItemArtifacts( List<ArtifactItem> items ) throws IOException { @@ -805,12 +805,11 @@ public class TestCopyMojo throws IOException { stubFactory.setCreateFiles( true ); - - String classifier = "".equals( item.getClassifier() ) ? null : item.getClassifier(); + + String classifier = "".equals( item.getClassifier() ) ? null : item.getClassifier(); String version = item.getVersion() != null ? item.getVersion() : item.getBaseVersion(); - stubFactory.createArtifact( item.getGroupId(), item.getArtifactId(), - version, null, - item.getType(), classifier ); + stubFactory.createArtifact( item.getGroupId(), item.getArtifactId(), version, null, item.getType(), + classifier ); return item; } } Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java?rev=1807877&r1=1807876&r2=1807877&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java Sat Sep 9 10:35:59 2017 @@ -58,7 +58,7 @@ public class TestIncludeExcludeUnpackMoj // mojo.silent = true; // it needs to get the archivermanager - //stubFactory.setUnpackableFile( mojo.getArchiverManager() ); + // stubFactory.setUnpackableFile( mojo.getArchiverManager() ); // i'm using one file repeatedly to archive so I can test the name // programmatically. stubFactory.setSrcFile( new File( getBasedir() + File.separatorChar + PACKED_FILE_PATH ) ); @@ -73,12 +73,12 @@ public class TestIncludeExcludeUnpackMoj mojo.setMarkersDirectory( new File( this.testDir, "markers" ) ); mojo.setArtifactItems( list ); - + MavenSession session = newMavenSession( mojo.getProject() ); setVariableValueToObject( mojo, "session", session ); - + DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) session.getRepositorySession(); - + repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( stubFactory.getWorkingDir() ) ); } @@ -120,7 +120,7 @@ public class TestIncludeExcludeUnpackMoj /** * This test will validate that only the 1 and 11 files get unpacked * - * @throws Exception + * @throws Exception in case of errors. */ public void testUnpackIncludesManyFiles() throws Exception @@ -136,7 +136,7 @@ public class TestIncludeExcludeUnpackMoj /** * This test will verify only the 2 file gets unpacked * - * @throws Exception + * @throws Exception in case of errors. */ public void testUnpackIncludesSingleFile() throws Exception @@ -152,7 +152,7 @@ public class TestIncludeExcludeUnpackMoj /** * This test will verify all files get unpacked * - * @throws Exception + * @throws Exception in case of errors. */ public void testUnpackIncludesAllFiles() throws Exception @@ -168,7 +168,7 @@ public class TestIncludeExcludeUnpackMoj /** * This test will validate that only the 2 and 3 files get unpacked * - * @throws Exception + * @throws Exception in case of errors. */ public void testUnpackExcludesManyFiles() throws Exception @@ -182,9 +182,9 @@ public class TestIncludeExcludeUnpackMoj } /** - * This test will verify only the 1, 11 & 3 files get unpacked + * This test will verify only the 1, 11 & 3 files get unpacked * - * @throws Exception + * @throws Exception in case of errors. */ public void testUnpackExcludesSingleFile() throws Exception @@ -200,7 +200,7 @@ public class TestIncludeExcludeUnpackMoj /** * This test will verify no files get unpacked * - * @throws Exception + * @throws Exception in case of errors. */ public void testUnpackExcludesAllFiles() throws Exception Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java?rev=1807877&r1=1807876&r2=1807877&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java Sat Sep 9 10:35:59 2017 @@ -73,10 +73,10 @@ public class TestUnpackMojo + "target/test-classes/unit/unpack-dependencies-test/test.txt" ) ); mojo.setUseJvmChmod( true ); - + MavenSession session = newMavenSession( mojo.getProject() ); setVariableValueToObject( mojo, "session", session ); - + DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) session.getRepositorySession(); repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( stubFactory.getWorkingDir() ) ); @@ -145,7 +145,7 @@ public class TestUnpackMojo assertMarkerFiles( list, true ); } - + public void testSkip() throws Exception { @@ -186,17 +186,18 @@ public class TestUnpackMojo // pretend that the output directory cannot be found event after mkdirs has been called by the mojo // ifor instance in the case when the outputDirectory cannot be created because of permissions on the // parent of the output directory - mojo.setOutputDirectory( new File( currentFile.getAbsolutePath() ) { + mojo.setOutputDirectory( new File( currentFile.getAbsolutePath() ) + { private static final long serialVersionUID = -8559876942040177020L; @Override public boolean exists() { - //this file will always report that it does not exist + // this file will always report that it does not exist return false; } - }); + } ); try { mojo.execute(); @@ -364,7 +365,7 @@ public class TestUnpackMojo item.setClassifier( "classifier" ); item.setGroupId( "groupId" ); item.setType( "jar" ); - + MavenProject project = mojo.getProject(); project.setDependencies( createArtifacts( getDependencyList( item ) ) ); @@ -375,8 +376,10 @@ public class TestUnpackMojo item.setGroupId( "groupId" ); item.setType( "jar" ); - stubFactory.createArtifact( "groupId", "artifactId-2", VersionRange.createFromVersion( "3.0-SNAPSHOT" ), null, "jar", "classifier", false ); - stubFactory.createArtifact( "groupId", "artifactId-2", VersionRange.createFromVersion( "3.1" ), null, "jar", "classifier", false ); + stubFactory.createArtifact( "groupId", "artifactId-2", VersionRange.createFromVersion( "3.0-SNAPSHOT" ), null, + "jar", "classifier", false ); + stubFactory.createArtifact( "groupId", "artifactId-2", VersionRange.createFromVersion( "3.1" ), null, "jar", + "classifier", false ); List<ArtifactItem> list = new ArrayList<ArtifactItem>(); list.add( item ); @@ -470,7 +473,7 @@ public class TestUnpackMojo Artifact artifact = stubFactory.getSnapshotArtifact(); assertTrue( artifact.getFile().setLastModified( System.currentTimeMillis() - 2000 ) ); - ArtifactItem item = new ArtifactItem( createArtifact( artifact ) ); + ArtifactItem item = new ArtifactItem( createArtifact( artifact ) ); List<ArtifactItem> list = new ArrayList<ArtifactItem>( 1 ); list.add( item ); @@ -528,7 +531,7 @@ public class TestUnpackMojo throws Exception { final long now = System.currentTimeMillis(); - + mojo.setSilent( false ); stubFactory.setCreateFiles( true ); Artifact artifact = stubFactory.getSnapshotArtifact(); @@ -566,8 +569,8 @@ public class TestUnpackMojo displayFile( "marker ", marker ); System.out.println( "marker.lastModified() = " + marker.lastModified() ); System.out.println( "unpackedFile.lastModified() = " + unpackedFile.lastModified() ); - assertTrue( "unpackedFile '" + unpackedFile + "' lastModified() == " + marker.lastModified() + ": should be different", - marker.lastModified() != unpackedFile.lastModified() ); + assertTrue( "unpackedFile '" + unpackedFile + "' lastModified() == " + marker.lastModified() + + ": should be different", marker.lastModified() != unpackedFile.lastModified() ); } private void displayFile( String description, File file ) @@ -575,7 +578,7 @@ public class TestUnpackMojo System.out.println( description + ' ' + DateFormatUtils.ISO_DATETIME_FORMAT.format( file.lastModified() ) + ' ' + file.getPath().substring( getBasedir().length() ) ); } - + public void assertUnpacked( ArtifactItem item, boolean overWrite ) throws Exception { @@ -603,42 +606,44 @@ public class TestUnpackMojo public File getUnpackedFile( ArtifactItem item ) { - File unpackedFile = - new File( item.getOutputDirectory(), - DependencyArtifactStubFactory.getUnpackableFileName( item.getArtifact() ) ); + File unpackedFile = new File( item.getOutputDirectory(), + DependencyArtifactStubFactory.getUnpackableFileName( item.getArtifact() ) ); assertTrue( unpackedFile.exists() ); return unpackedFile; } - + // respects the createUnpackableFile flag of the ArtifactStubFactory - private List<Dependency> createArtifacts( List<Dependency> items ) throws IOException { + private List<Dependency> createArtifacts( List<Dependency> items ) + throws IOException + { for ( Dependency item : items ) { - String classifier = "".equals( item.getClassifier() ) ? null : item.getClassifier(); + String classifier = "".equals( item.getClassifier() ) ? null : item.getClassifier(); stubFactory.createArtifact( item.getGroupId(), item.getArtifactId(), - VersionRange.createFromVersion( item.getVersion() ), null, - item.getType(), classifier, item.isOptional() ); + VersionRange.createFromVersion( item.getVersion() ), null, item.getType(), + classifier, item.isOptional() ); } return items; } - - private Artifact createArtifact( Artifact art ) throws IOException + + private Artifact createArtifact( Artifact art ) + throws IOException { - String classifier = "".equals( art.getClassifier() ) ? null : art.getClassifier(); + String classifier = "".equals( art.getClassifier() ) ? null : art.getClassifier(); stubFactory.createArtifact( art.getGroupId(), art.getArtifactId(), - VersionRange.createFromVersion( art.getVersion() ), null, - art.getType(), classifier, art.isOptional() ); + VersionRange.createFromVersion( art.getVersion() ), null, art.getType(), classifier, + art.isOptional() ); return art; } - - private ArtifactItem createArtifact( ArtifactItem item ) throws IOException + + private ArtifactItem createArtifact( ArtifactItem item ) + throws IOException { - String classifier = "".equals( item.getClassifier() ) ? null : item.getClassifier(); - stubFactory.createArtifact( item.getGroupId(), item.getArtifactId(), - item.getVersion(), null, - item.getType(), classifier ); + String classifier = "".equals( item.getClassifier() ) ? null : item.getClassifier(); + stubFactory.createArtifact( item.getGroupId(), item.getArtifactId(), item.getVersion(), null, item.getType(), + classifier ); return item; } } Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java?rev=1807877&r1=1807876&r2=1807877&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java Sat Sep 9 10:35:59 2017 @@ -44,7 +44,7 @@ public class TestBuildClasspathMojo /** * tests the proper discovery and configuration of the mojo * - * @throws Exception + * @throws Exception in case of an error. */ public void testEnvironment() throws Exception @@ -84,8 +84,8 @@ public class TestBuildClasspathMojo assertNotNull( file ); assertTrue( file.length() > 0 ); - assertTrue(file.contains(File.pathSeparator)); - assertTrue(file.contains(File.separator)); + assertTrue( file.contains( File.pathSeparator ) ); + assertTrue( file.contains( File.separator ) ); String fileSep = "#####"; String pathSep = "%%%%%"; @@ -98,10 +98,10 @@ public class TestBuildClasspathMojo assertNotNull( file ); assertTrue( file.length() > 0 ); - assertFalse(file.contains(File.pathSeparator)); - assertFalse(file.contains(File.separator)); - assertTrue(file.contains(fileSep)); - assertTrue(file.contains(pathSep)); + assertFalse( file.contains( File.pathSeparator ) ); + assertFalse( file.contains( File.separator ) ); + assertTrue( file.contains( fileSep ) ); + assertTrue( file.contains( pathSep ) ); String propertyValue = project.getProperties().getProperty( "outputProperty" ); assertNull( propertyValue ); @@ -112,7 +112,8 @@ public class TestBuildClasspathMojo } - public void testPath() throws Exception + public void testPath() + throws Exception { File testPom = new File( getBasedir(), "target/test-classes/unit/build-classpath-test/plugin-config.xml" ); BuildClasspathMojo mojo = (BuildClasspathMojo) lookupMojo( "build-classpath", testPom ); @@ -148,29 +149,31 @@ public class TestBuildClasspathMojo sb.setLength( 0 ); mojo.setPrependGroupId( true ); mojo.appendArtifactPath( artifact, sb ); - assertEquals("If prefix is null, prependGroupId has no impact ", "%M2_REPO%"+File.separator - + DependencyUtil.getFormattedFileName( artifact, false, false ), sb.toString()); - + assertEquals( "If prefix is null, prependGroupId has no impact ", + "%M2_REPO%" + File.separator + DependencyUtil.getFormattedFileName( artifact, false, false ), + sb.toString() ); + mojo.setLocalRepoProperty( "" ); mojo.setPrefix( "prefix" ); sb.setLength( 0 ); mojo.setPrependGroupId( true ); mojo.appendArtifactPath( artifact, sb ); - assertEquals("prefix"+File.separator+DependencyUtil.getFormattedFileName( artifact, false, true ), - sb.toString()); + assertEquals( "prefix" + File.separator + DependencyUtil.getFormattedFileName( artifact, false, true ), + sb.toString() ); mojo.setPrependGroupId( false ); - + mojo.setLocalRepoProperty( "" ); mojo.setPrefix( "prefix" ); sb.setLength( 0 ); mojo.appendArtifactPath( artifact, sb ); - assertEquals("prefix"+File.separator+artifact.getFile().getName(),sb.toString()); - + assertEquals( "prefix" + File.separator + artifact.getFile().getName(), sb.toString() ); + mojo.setPrefix( "prefix" ); mojo.setStripVersion( true ); sb.setLength( 0 ); mojo.appendArtifactPath( artifact, sb ); - assertEquals( "prefix" + File.separator + DependencyUtil.getFormattedFileName( artifact, true ), sb.toString() ); - + assertEquals( "prefix" + File.separator + DependencyUtil.getFormattedFileName( artifact, true ), + sb.toString() ); + } } Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java?rev=1807877&r1=1807876&r2=1807877&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java Sat Sep 9 10:35:59 2017 @@ -63,9 +63,9 @@ public class TestCopyDependenciesMojo setVariableValueToObject( mojo, "session", session ); DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) session.getRepositorySession(); - + repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( stubFactory.getWorkingDir() ) ); - + Set<Artifact> artifacts = this.stubFactory.getScopedArtifacts(); Set<Artifact> directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); artifacts.addAll( directArtifacts ); @@ -108,7 +108,7 @@ public class TestCopyDependenciesMojo /** * tests the proper discovery and configuration of the mojo * - * @throws Exception + * @throws Exception in case of an error. */ public void testMojo() throws Exception @@ -140,22 +140,21 @@ public class TestCopyDependenciesMojo assertTrue( file.exists() ); } } - + public void testStripClassifier() - throws Exception - { - mojo.stripClassifier = true; - mojo.execute(); + throws Exception + { + mojo.stripClassifier = true; + mojo.execute(); - Set<Artifact> artifacts = mojo.getProject().getArtifacts(); - for ( Artifact artifact : artifacts ) - { - String fileName = DependencyUtil.getFormattedFileName( artifact, false, false, false, true ); - File file = new File( mojo.outputDirectory, fileName ); - assertTrue( file.exists() ); - } + Set<Artifact> artifacts = mojo.getProject().getArtifacts(); + for ( Artifact artifact : artifacts ) + { + String fileName = DependencyUtil.getFormattedFileName( artifact, false, false, false, true ); + File file = new File( mojo.outputDirectory, fileName ); + assertTrue( file.exists() ); } - + } public void testUseBaseVersion() throws Exception @@ -212,7 +211,7 @@ public class TestCopyDependenciesMojo mojo.includeTypes = "jar"; mojo.excludeTypes = "jar"; - //shouldn't get anything. + // shouldn't get anything. mojo.execute(); @@ -236,7 +235,6 @@ public class TestCopyDependenciesMojo } } - public void testExcludeArtifactId() throws Exception { @@ -262,7 +260,7 @@ public class TestCopyDependenciesMojo mojo.includeArtifactIds = "one"; mojo.excludeArtifactIds = "one"; - //shouldn't get anything + // shouldn't get anything mojo.execute(); @@ -293,7 +291,7 @@ public class TestCopyDependenciesMojo mojo.getProject().setDependencyArtifacts( new HashSet<Artifact>() ); mojo.includeGroupIds = "one"; mojo.excludeGroupIds = "one"; - //shouldn't get anything + // shouldn't get anything mojo.execute(); @@ -335,6 +333,7 @@ public class TestCopyDependenciesMojo assertEquals( artifact.getGroupId().equals( "one" ), !file.exists() ); } } + public void testExcludeMultipleGroupIds() throws Exception { @@ -349,7 +348,8 @@ public class TestCopyDependenciesMojo String fileName = DependencyUtil.getFormattedFileName( artifact, false ); File file = new File( mojo.outputDirectory, fileName ); - assertEquals( artifact.getGroupId().equals( "one" ) || artifact.getGroupId().equals( "two" ), !file.exists() ); + assertEquals( artifact.getGroupId().equals( "one" ) || artifact.getGroupId().equals( "two" ), + !file.exists() ); } } @@ -378,7 +378,7 @@ public class TestCopyDependenciesMojo mojo.includeClassifiers = "one"; mojo.excludeClassifiers = "one"; - //shouldn't get anything + // shouldn't get anything mojo.execute(); @@ -415,8 +415,8 @@ public class TestCopyDependenciesMojo for ( Artifact artifact : artifacts ) { String fileName = DependencyUtil.getFormattedFileName( artifact, false ); - File folder = DependencyUtil.getFormattedOutputDirectory( false, true, false, false, false, mojo.outputDirectory, - artifact ); + File folder = DependencyUtil.getFormattedOutputDirectory( false, true, false, false, false, + mojo.outputDirectory, artifact ); File file = new File( folder, fileName ); assertTrue( file.exists() ); } @@ -445,13 +445,14 @@ public class TestCopyDependenciesMojo { mojo.classifier = testClassifier; mojo.type = testType; - - for( Artifact artifact : mojo.getProject().getArtifacts() ) + + for ( Artifact artifact : mojo.getProject().getArtifacts() ) { String type = testType != null ? testType : artifact.getType(); - - stubFactory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getScope(), type, testClassifier ); - + + stubFactory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), + artifact.getScope(), type, testClassifier ); + } mojo.execute(); @@ -514,11 +515,9 @@ public class TestCopyDependenciesMojo } /* - * public void testOverwrite() { stubFactory.setCreateFiles( false ); - * Artifact artifact = stubFactory.createArtifact( "test", "artifact", "1.0" ); - * - * File testFile = new File( getBasedir() + File.separatorChar + - * "target/test-classes/unit/copy-dependencies-test/test.zip" ); } + * public void testOverwrite() { stubFactory.setCreateFiles( false ); Artifact artifact = + * stubFactory.createArtifact( "test", "artifact", "1.0" ); File testFile = new File( getBasedir() + + * File.separatorChar + "target/test-classes/unit/copy-dependencies-test/test.zip" ); } */ public void testDontOverWriteRelease() @@ -658,8 +657,8 @@ public class TestCopyDependenciesMojo public void testGetDependencies() throws MojoExecutionException { - assertEquals( mojo.getResolvedDependencies( true ).toString(), mojo.getDependencySets( true ) - .getResolvedDependencies().toString() ); + assertEquals( mojo.getResolvedDependencies( true ).toString(), + mojo.getDependencySets( true ).getResolvedDependencies().toString() ); } public void testExcludeProvidedScope() @@ -770,7 +769,8 @@ public class TestCopyDependenciesMojo Set<Artifact> set = new HashSet<Artifact>(); set.add( stubFactory.createArtifact( "org.apache.maven", "maven-artifact", "2.0.7", Artifact.SCOPE_COMPILE ) ); - stubFactory.createArtifact( "org.apache.maven", "maven-artifact", "2.0.7", Artifact.SCOPE_COMPILE, "pom", null ); + stubFactory.createArtifact( "org.apache.maven", "maven-artifact", "2.0.7", Artifact.SCOPE_COMPILE, "pom", + null ); mojo.getProject().setArtifacts( set ); mojo.execute(); @@ -782,13 +782,13 @@ public class TestCopyDependenciesMojo assertTrue( file + " doesn't exist", file.exists() ); } } - - public void testPrependGroupId() + + public void testPrependGroupId() throws Exception { mojo.prependGroupId = true; mojo.execute(); - + Set<Artifact> artifacts = mojo.getProject().getArtifacts(); for ( Artifact artifact : artifacts ) { Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java?rev=1807877&r1=1807876&r2=1807877&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java Sat Sep 9 10:35:59 2017 @@ -80,7 +80,7 @@ public class TestCopyDependenciesMojo2 LegacySupport legacySupport = lookup( LegacySupport.class ); MavenSession session = newMavenSession( project ); setVariableValueToObject( mojo, "session", session ); - + legacySupport.setSession( session ); DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) legacySupport.getRepositorySession(); @@ -213,8 +213,8 @@ public class TestCopyDependenciesMojo2 for ( Artifact artifact : artifacts ) { String fileName = DependencyUtil.getFormattedFileName( artifact, false ); - File folder = DependencyUtil.getFormattedOutputDirectory( false, false, true, false, false, mojo.outputDirectory, - artifact ); + File folder = DependencyUtil.getFormattedOutputDirectory( false, false, true, false, false, + mojo.outputDirectory, artifact ); File file = new File( folder, fileName ); assertTrue( file.exists() ); } @@ -234,8 +234,8 @@ public class TestCopyDependenciesMojo2 for ( Artifact artifact : artifacts ) { String fileName = DependencyUtil.getFormattedFileName( artifact, false ); - File folder = DependencyUtil.getFormattedOutputDirectory( false, true, true, false, false, mojo.outputDirectory, - artifact ); + File folder = DependencyUtil.getFormattedOutputDirectory( false, true, true, false, false, + mojo.outputDirectory, artifact ); File file = new File( folder, fileName ); assertTrue( file.exists() ); } @@ -255,8 +255,8 @@ public class TestCopyDependenciesMojo2 for ( Artifact artifact : artifacts ) { String fileName = DependencyUtil.getFormattedFileName( artifact, false ); - File folder = DependencyUtil.getFormattedOutputDirectory( true, false, true, false, false, mojo.outputDirectory, - artifact ); + File folder = DependencyUtil.getFormattedOutputDirectory( true, false, true, false, false, + mojo.outputDirectory, artifact ); File file = new File( folder, fileName ); assertTrue( file.exists() ); } @@ -265,92 +265,81 @@ public class TestCopyDependenciesMojo2 public void testRepositoryLayout() throws Exception { - String baseVersion = "2.0-SNAPSHOT"; - String groupId = "testGroupId"; - String artifactId = "expanded-snapshot"; - - Artifact expandedSnapshot = createExpandedVersionArtifact( baseVersion, - groupId, - artifactId, - "compile", - "jar", - null); + String baseVersion = "2.0-SNAPSHOT"; + String groupId = "testGroupId"; + String artifactId = "expanded-snapshot"; + + Artifact expandedSnapshot = + createExpandedVersionArtifact( baseVersion, groupId, artifactId, "compile", "jar", null ); mojo.getProject().getArtifacts().add( expandedSnapshot ); mojo.getProject().getDependencyArtifacts().add( expandedSnapshot ); - Artifact pomExpandedSnapshot = createExpandedVersionArtifact( baseVersion, - groupId, - artifactId, - "compile", - "pom", - null); + Artifact pomExpandedSnapshot = + createExpandedVersionArtifact( baseVersion, groupId, artifactId, "compile", "pom", null ); mojo.getProject().getArtifacts().add( pomExpandedSnapshot ); mojo.getProject().getDependencyArtifacts().add( pomExpandedSnapshot ); mojo.useRepositoryLayout = true; mojo.execute(); - + ArtifactFactory artifactFactory = lookup( ArtifactFactory.class ); - + File outputDirectory = mojo.outputDirectory; - ArtifactRepository targetRepository = new MavenArtifactRepository( - "local", - outputDirectory.toURL().toExternalForm(), - new DefaultRepositoryLayout(), - new ArtifactRepositoryPolicy(), - new ArtifactRepositoryPolicy() ); + ArtifactRepository targetRepository = + new MavenArtifactRepository( "local", outputDirectory.toURL().toExternalForm(), + new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), + new ArtifactRepositoryPolicy() ); Set<Artifact> artifacts = mojo.getProject().getArtifacts(); for ( Artifact artifact : artifacts ) { - assertArtifactExists( artifact, targetRepository ); - - if ( ! artifact.getBaseVersion().equals( artifact.getVersion() ) ) + assertArtifactExists( artifact, targetRepository ); + + if ( !artifact.getBaseVersion().equals( artifact.getVersion() ) ) { - Artifact baseArtifact = - artifactFactory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), - artifact.getBaseVersion(), artifact.getScope(), - artifact.getType() ); - assertArtifactExists( baseArtifact, targetRepository ); + Artifact baseArtifact = artifactFactory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), + artifact.getBaseVersion(), artifact.getScope(), + artifact.getType() ); + assertArtifactExists( baseArtifact, targetRepository ); } } } - private Artifact createExpandedVersionArtifact( String baseVersion, - String groupId, - String artifactId, - String scope, - String type, - String classifier ) - throws IOException - { - Artifact expandedSnapshot = this.stubFactory.createArtifact( groupId, artifactId, VersionRange.createFromVersion( baseVersion ), scope, type, classifier, false ); + private Artifact createExpandedVersionArtifact( String baseVersion, String groupId, String artifactId, String scope, + String type, String classifier ) + throws IOException + { + Artifact expandedSnapshot = + this.stubFactory.createArtifact( groupId, artifactId, VersionRange.createFromVersion( baseVersion ), scope, + type, classifier, false ); Snapshot snapshot = new Snapshot(); snapshot.setTimestamp( "20130710.122148" ); snapshot.setBuildNumber( 1 ); RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( expandedSnapshot, snapshot ); String newVersion = snapshot.getTimestamp() + "-" + snapshot.getBuildNumber(); - expandedSnapshot.setResolvedVersion( StringUtils.replace( baseVersion, Artifact.SNAPSHOT_VERSION, newVersion ) ); + expandedSnapshot.setResolvedVersion( StringUtils.replace( baseVersion, Artifact.SNAPSHOT_VERSION, + newVersion ) ); expandedSnapshot.addMetadata( metadata ); - return expandedSnapshot; - } + return expandedSnapshot; + } + + private void assertArtifactExists( Artifact artifact, ArtifactRepository targetRepository ) + { + File file = new File( targetRepository.getBasedir(), targetRepository.getLayout().pathOf( artifact ) ); + assertTrue( "File doesn't exist: " + file.getAbsolutePath(), file.exists() ); - private void assertArtifactExists( Artifact artifact, ArtifactRepository targetRepository ) { - File file = new File( targetRepository.getBasedir(), - targetRepository.getLayout().pathOf( artifact ) ); - assertTrue( "File doesn't exist: " + file.getAbsolutePath(), file.exists() ); - - Collection<ArtifactMetadata> metas = artifact.getMetadataList(); - for ( ArtifactMetadata meta : metas ) - { - File metaFile = new File( targetRepository.getBasedir(), - targetRepository.getLayout().pathOfLocalRepositoryMetadata( meta, targetRepository) ); - assertTrue( metaFile.exists() ); + Collection<ArtifactMetadata> metas = artifact.getMetadataList(); + for ( ArtifactMetadata meta : metas ) + { + File metaFile = + new File( targetRepository.getBasedir(), + targetRepository.getLayout().pathOfLocalRepositoryMetadata( meta, targetRepository ) ); + assertTrue( metaFile.exists() ); } - } + } public void testSubPerArtifactRemoveVersion() throws Exception @@ -364,8 +353,8 @@ public class TestCopyDependenciesMojo2 for ( Artifact artifact : artifacts ) { String fileName = DependencyUtil.getFormattedFileName( artifact, true ); - File folder = DependencyUtil.getFormattedOutputDirectory( false, false, true, false, true, mojo.outputDirectory, - artifact ); + File folder = DependencyUtil.getFormattedOutputDirectory( false, false, true, false, true, + mojo.outputDirectory, artifact ); File file = new File( folder, fileName ); assertTrue( file.exists() ); } @@ -386,8 +375,8 @@ public class TestCopyDependenciesMojo2 for ( Artifact artifact : artifacts ) { String fileName = DependencyUtil.getFormattedFileName( artifact, true ); - File folder = DependencyUtil.getFormattedOutputDirectory( false, true, true, false, true, mojo.outputDirectory, - artifact ); + File folder = DependencyUtil.getFormattedOutputDirectory( false, true, true, false, true, + mojo.outputDirectory, artifact ); File file = new File( folder, fileName ); assertTrue( file.exists() ); } Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java?rev=1807877&r1=1807876&r2=1807877&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java Sat Sep 9 10:35:59 2017 @@ -28,21 +28,22 @@ import org.apache.maven.plugins.dependen import org.apache.maven.project.MavenProject; public class TestIncludeExcludeUnpackDependenciesMojo - extends AbstractDependencyMojoTestCase + extends AbstractDependencyMojoTestCase { - private final String PACKED_FILE = "test.zip"; + private final String PACKED_FILE = "test.zip"; - private final String UNPACKED_FILE_PREFIX = "test"; - private final String UNPACKED_FILE_SUFFIX = ".txt"; + private final String UNPACKED_FILE_PREFIX = "test"; - private final String PACKED_FILE_PATH = "target/test-classes/unit/unpack-dependencies-test/" + PACKED_FILE; + private final String UNPACKED_FILE_SUFFIX = ".txt"; - UnpackDependenciesMojo mojo; + private final String PACKED_FILE_PATH = "target/test-classes/unit/unpack-dependencies-test/" + PACKED_FILE; + + UnpackDependenciesMojo mojo; protected void setUp() throws Exception { - // required for mojo lookups to work + // required for mojo lookups to work super.setUp( "unpack-dependencies", true ); File testPom = new File( getBasedir(), "target/test-classes/unit/unpack-dependencies-test/plugin-config.xml" ); @@ -51,7 +52,7 @@ public class TestIncludeExcludeUnpackDep // mojo.silent = true; // it needs to get the archivermanager - //stubFactory.setUnpackableFile( mojo.getArchiverManager() ); + // stubFactory.setUnpackableFile( mojo.getArchiverManager() ); // i'm using one file repeatedly to archive so I can test the name // programmatically. stubFactory.setSrcFile( new File( getBasedir() + File.separatorChar + PACKED_FILE_PATH ) ); @@ -86,101 +87,107 @@ public class TestIncludeExcludeUnpackDep /** * This test will validate that only the 1 and 11 files get unpacked - * @throws Exception + * + * @throws Exception in case of errors */ public void testUnpackIncludesManyFiles() - throws Exception - { + throws Exception + { mojo.setIncludes( "**/*1" + UNPACKED_FILE_SUFFIX ); mojo.execute(); assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); assertUnpacked( false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); assertUnpacked( false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); - } + } /** * This test will verify only the 2 file gets unpacked - * @throws Exception + * + * @throws Exception in case of errors */ public void testUnpackIncludesSingleFile() - throws Exception - { + throws Exception + { mojo.setIncludes( "**/test2" + UNPACKED_FILE_SUFFIX ); mojo.execute(); assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); assertUnpacked( false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); - } + } /** * This test will verify all files get unpacked - * @throws Exception + * + * @throws Exception in case of errors */ public void testUnpackIncludesAllFiles() - throws Exception - { + throws Exception + { mojo.setIncludes( "**/*" ); mojo.execute(); assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); - } + } /** * This test will validate that only the 2 and 3 files get unpacked - * @throws Exception + * + * @throws Exception in case of errors */ public void testUnpackExcludesManyFiles() - throws Exception - { + throws Exception + { mojo.setExcludes( "**/*1" + UNPACKED_FILE_SUFFIX ); mojo.execute(); assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); - } + } /** - * This test will verify only the 1, 11 & 3 files get unpacked - * @throws Exception + * This test will verify only the 1, 11 & 3 files get unpacked + * + * @throws Exception in case of errors */ public void testUnpackExcludesSingleFile() - throws Exception - { + throws Exception + { mojo.setExcludes( "**/test2" + UNPACKED_FILE_SUFFIX ); mojo.execute(); assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); assertUnpacked( false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); - } + } /** * This test will verify no files get unpacked - * @throws Exception + * + * @throws Exception in case of errors */ public void testUnpackExcludesAllFiles() - throws Exception - { + throws Exception + { mojo.setExcludes( "**/*" ); mojo.execute(); assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); assertUnpacked( false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); assertUnpacked( false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); - } + } public void testNoIncludeExcludes() - throws Exception - { + throws Exception + { mojo.execute(); assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX ); assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX ); assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX ); assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX ); - } + } } Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java?rev=1807877&r1=1807876&r2=1807877&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java Sat Sep 9 10:35:59 2017 @@ -72,10 +72,10 @@ public class TestUnpackDependenciesMojo assertNotNull( mojo ); assertNotNull( mojo.getProject() ); MavenProject project = mojo.getProject(); - + MavenSession session = newMavenSession( project ); setVariableValueToObject( mojo, "session", session ); - + DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) session.getRepositorySession(); repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( stubFactory.getWorkingDir() ) ); @@ -134,8 +134,9 @@ public class TestUnpackDependenciesMojo throws Exception { mojo.execute(); - for (Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts()) { - assertUnpacked(artifact); + for ( Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts() ) + { + assertUnpacked( artifact ); } } @@ -144,8 +145,9 @@ public class TestUnpackDependenciesMojo { mojo.excludeTransitive = true; mojo.execute(); - for (Artifact artifact : (Iterable<Artifact>) mojo.getProject().getDependencyArtifacts()) { - assertUnpacked(artifact); + for ( Artifact artifact : (Iterable<Artifact>) mojo.getProject().getDependencyArtifacts() ) + { + assertUnpacked( artifact ); } } @@ -157,8 +159,9 @@ public class TestUnpackDependenciesMojo mojo.excludeTypes = "jar"; mojo.execute(); - for (Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts()) { - assertUnpacked(!artifact.getType().equalsIgnoreCase("jar"), artifact); + for ( Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts() ) + { + assertUnpacked( !artifact.getType().equalsIgnoreCase( "jar" ), artifact ); } } @@ -172,8 +175,9 @@ public class TestUnpackDependenciesMojo mojo.execute(); - for (Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts()) { - assertUnpacked(!artifact.getScope().equals("provided"), artifact); + for ( Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts() ) + { + assertUnpacked( !artifact.getScope().equals( "provided" ), artifact ); } } @@ -188,8 +192,9 @@ public class TestUnpackDependenciesMojo mojo.execute(); - for (Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts()) { - assertUnpacked(!artifact.getScope().equals("system"), artifact); + for ( Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts() ) + { + assertUnpacked( !artifact.getScope().equals( "system" ), artifact ); } } @@ -203,8 +208,9 @@ public class TestUnpackDependenciesMojo mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.excludeScope ); - for (Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts()) { - assertUnpacked(!saf.include(artifact), artifact); + for ( Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts() ) + { + assertUnpacked( !saf.include( artifact ), artifact ); } } @@ -236,8 +242,9 @@ public class TestUnpackDependenciesMojo mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.excludeScope ); - for (Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts()) { - assertUnpacked(!saf.include(artifact), artifact); + for ( Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts() ) + { + assertUnpacked( !saf.include( artifact ), artifact ); } } @@ -249,7 +256,7 @@ public class TestUnpackDependenciesMojo mojo.includeTypes = "jar"; mojo.excludeTypes = "jar"; - //shouldn't get anything + // shouldn't get anything mojo.execute(); @@ -281,8 +288,9 @@ public class TestUnpackDependenciesMojo mojo.useSubDirectoryPerType = true; mojo.execute(); - for (Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts()) { - assertUnpacked(artifact); + for ( Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts() ) + { + assertUnpacked( artifact ); } } @@ -292,8 +300,9 @@ public class TestUnpackDependenciesMojo mojo.useSubDirectoryPerArtifact = true; mojo.execute(); - for (Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts()) { - assertUnpacked(artifact); + for ( Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts() ) + { + assertUnpacked( artifact ); } } @@ -306,8 +315,9 @@ public class TestUnpackDependenciesMojo mojo.useSubDirectoryPerType = true; mojo.execute(); - for (Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts()) { - assertUnpacked(artifact); + for ( Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts() ) + { + assertUnpacked( artifact ); } } @@ -318,8 +328,9 @@ public class TestUnpackDependenciesMojo mojo.stripVersion = true; mojo.execute(); - for (Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts()) { - assertUnpacked(artifact); + for ( Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts() ) + { + assertUnpacked( artifact ); } } @@ -333,8 +344,9 @@ public class TestUnpackDependenciesMojo mojo.stripVersion = true; mojo.execute(); - for (Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts()) { - assertUnpacked(artifact); + for ( Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts() ) + { + assertUnpacked( artifact ); } } @@ -347,8 +359,9 @@ public class TestUnpackDependenciesMojo mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.includeScope ); - for (Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts()) { - assertUnpacked(saf.include(artifact), artifact); + for ( Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts() ) + { + assertUnpacked( saf.include( artifact ), artifact ); } } @@ -362,8 +375,9 @@ public class TestUnpackDependenciesMojo mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.includeScope ); - for (Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts()) { - assertUnpacked(saf.include(artifact), artifact); + for ( Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts() ) + { + assertUnpacked( saf.include( artifact ), artifact ); } } @@ -376,8 +390,9 @@ public class TestUnpackDependenciesMojo mojo.execute(); ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.includeScope ); - for (Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts()) { - assertUnpacked(saf.include(artifact), artifact); + for ( Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts() ) + { + assertUnpacked( saf.include( artifact ), artifact ); } } @@ -389,8 +404,9 @@ public class TestUnpackDependenciesMojo mojo.includeScope = "provided"; mojo.execute(); - for (Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts()) { - assertUnpacked(Artifact.SCOPE_PROVIDED.equals(artifact.getScope()), artifact); + for ( Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts() ) + { + assertUnpacked( Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ), artifact ); } } @@ -403,8 +419,9 @@ public class TestUnpackDependenciesMojo mojo.execute(); - for (Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts()) { - assertUnpacked(Artifact.SCOPE_SYSTEM.equals(artifact.getScope()), artifact); + for ( Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts() ) + { + assertUnpacked( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ), artifact ); } } @@ -416,7 +433,7 @@ public class TestUnpackDependenciesMojo mojo.includeArtifactIds = "one"; mojo.excludeArtifactIds = "one"; - //shouldn't get anything + // shouldn't get anything mojo.execute(); Iterator<Artifact> iter = mojo.getProject().getArtifacts().iterator(); @@ -448,8 +465,9 @@ public class TestUnpackDependenciesMojo // test - get all direct dependencies and verify that they exist if they // do not have a classifier of "one" // then delete the file and at the end, verify the folder is empty. - for (Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts()) { - assertUnpacked(!artifact.getArtifactId().equals("one"), artifact); + for ( Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts() ) + { + assertUnpacked( !artifact.getArtifactId().equals( "one" ), artifact ); } } @@ -461,8 +479,9 @@ public class TestUnpackDependenciesMojo mojo.excludeGroupIds = "one"; mojo.execute(); - for (Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts()) { - assertUnpacked(!artifact.getGroupId().equals("one"), artifact); + for ( Artifact artifact : (Iterable<Artifact>) mojo.getProject().getArtifacts() ) + { + assertUnpacked( !artifact.getGroupId().equals( "one" ), artifact ); } } @@ -473,7 +492,7 @@ public class TestUnpackDependenciesMojo mojo.getProject().setDependencyArtifacts( new HashSet<Artifact>() ); mojo.includeGroupIds = "one"; mojo.excludeGroupIds = "one"; - //shouldn't get anything + // shouldn't get anything mojo.execute(); @@ -522,31 +541,34 @@ public class TestUnpackDependenciesMojo mojo.classifier = testClassifier; mojo.type = testType; - for (Artifact artifact : mojo.getProject().getArtifacts()) + for ( Artifact artifact : mojo.getProject().getArtifacts() ) { - String type = testType != null ? testType: artifact.getType(); + String type = testType != null ? testType : artifact.getType(); this.stubFactory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), VersionRange.createFromVersion( artifact.getBaseVersion() ), artifact.getScope(), type, testClassifier, false ); } - + mojo.execute(); - for (Artifact artifact : mojo.getProject().getArtifacts()) { + for ( Artifact artifact : mojo.getProject().getArtifacts() ) + { String useClassifier = artifact.getClassifier(); String useType = artifact.getType(); - if (StringUtils.isNotEmpty(testClassifier)) { + if ( StringUtils.isNotEmpty( testClassifier ) ) + { useClassifier = testClassifier; // type is only used if classifier is used. - if (StringUtils.isNotEmpty(testType)) { + if ( StringUtils.isNotEmpty( testType ) ) + { useType = testType; } } Artifact unpacked = - stubFactory.createArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), - Artifact.SCOPE_COMPILE, useType, useClassifier); - assertUnpacked(unpacked); + stubFactory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), + Artifact.SCOPE_COMPILE, useType, useClassifier ); + assertUnpacked( unpacked ); } } @@ -580,11 +602,11 @@ public class TestUnpackDependenciesMojo public File getUnpackedFile( Artifact artifact ) { - File destDir = DependencyUtil.getFormattedOutputDirectory( mojo.isUseSubDirectoryPerScope(), - mojo.isUseSubDirectoryPerType(), - mojo.isUseSubDirectoryPerArtifact(), - mojo.useRepositoryLayout, mojo.stripVersion, - mojo.getOutputDirectory(), artifact ); + File destDir = + DependencyUtil.getFormattedOutputDirectory( mojo.isUseSubDirectoryPerScope(), + mojo.isUseSubDirectoryPerType(), + mojo.isUseSubDirectoryPerArtifact(), mojo.useRepositoryLayout, + mojo.stripVersion, mojo.getOutputDirectory(), artifact ); File unpacked = new File( destDir, DependencyArtifactStubFactory.getUnpackableFileName( artifact ) ); assertTrue( unpacked.exists() ); return unpacked; @@ -595,7 +617,6 @@ public class TestUnpackDependenciesMojo return new DefaultFileMarkerHandler( artifact, mojo.getMarkersDirectory() ); } - public void assertUnpacked( Artifact artifact, boolean overWrite ) throws InterruptedException, MojoExecutionException, MojoFailureException { Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java?rev=1807877&r1=1807876&r2=1807877&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java Sat Sep 9 10:35:59 2017 @@ -86,11 +86,11 @@ public class TestUnpackDependenciesMojo2 public File getUnpackedFile( Artifact artifact ) { - File destDir = DependencyUtil.getFormattedOutputDirectory( mojo.isUseSubDirectoryPerScope(), - mojo.isUseSubDirectoryPerType(), - mojo.isUseSubDirectoryPerArtifact(), - mojo.useRepositoryLayout, mojo.stripVersion, - mojo.getOutputDirectory(), artifact ); + File destDir = + DependencyUtil.getFormattedOutputDirectory( mojo.isUseSubDirectoryPerScope(), + mojo.isUseSubDirectoryPerType(), + mojo.isUseSubDirectoryPerArtifact(), mojo.useRepositoryLayout, + mojo.stripVersion, mojo.getOutputDirectory(), artifact ); File unpacked = new File( destDir, DependencyArtifactStubFactory.getUnpackableFileName( artifact ) ); assertTrue( unpacked.exists() ); return unpacked; Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java?rev=1807877&r1=1807876&r2=1807877&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojoTest.java Sat Sep 9 10:35:59 2017 @@ -27,15 +27,16 @@ import org.apache.maven.artifact.Artifac import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.plugins.dependency.utils.DependencyStatusSets; -public class ResolveDependenciesMojoTest extends AbstractDependencyMojoTestCase +public class ResolveDependenciesMojoTest + extends AbstractDependencyMojoTestCase { protected void setUp() - throws Exception + throws Exception { // required for mojo lookups to work super.setUp( "dss", true ); } - + public void testDependencyStatusLog() throws IOException { @@ -96,7 +97,8 @@ public class ResolveDependenciesMojoTest mojo.getOutput( true, false, false ); } - private ResolveDependenciesMojo newMojo( final DependencyStatusSets dss ) { + private ResolveDependenciesMojo newMojo( final DependencyStatusSets dss ) + { ResolveDependenciesMojo mojo = new ResolveDependenciesMojo(); mojo.results = dss; return mojo; Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java?rev=1807877&r1=1807876&r2=1807877&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java Sat Sep 9 10:35:59 2017 @@ -43,7 +43,7 @@ public class TestResolveMojo /** * tests the proper discovery and configuration of the mojo * - * @throws Exception + * @throws Exception in case of errors. */ public void testresolveTestEnvironment() throws Exception Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/testUtils/DependencyArtifactStubFactory.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/testUtils/DependencyArtifactStubFactory.java?rev=1807877&r1=1807876&r2=1807877&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/testUtils/DependencyArtifactStubFactory.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/testUtils/DependencyArtifactStubFactory.java Sat Sep 9 10:35:59 2017 @@ -42,10 +42,9 @@ public class DependencyArtifactStubFacto this.flattenedPath = flattenedPath; } - /** - * @param theWorkingDir - * @param theCreateFiles + * @param theWorkingDir {@link File} + * @param theCreateFiles true/false. */ public DependencyArtifactStubFactory( File theWorkingDir, boolean theCreateFiles ) { @@ -67,14 +66,14 @@ public class DependencyArtifactStubFacto } return list; } - + @Override public Artifact createArtifact( String groupId, String artifactId, VersionRange versionRange, String scope, String type, String classifier, boolean optional ) throws IOException { File workingDir = getWorkingDir(); - + if ( !flattenedPath ) { StringBuilder path = new StringBuilder( 128 ); @@ -88,11 +87,12 @@ public class DependencyArtifactStubFacto // don't use flatten directories, won't happen at runtime setWorkingDir( new File( workingDir, path.toString() ) ); } - - Artifact artifact = super.createArtifact( groupId, artifactId, versionRange, scope, type, classifier, optional ); - + + Artifact artifact = + super.createArtifact( groupId, artifactId, versionRange, scope, type, classifier, optional ); + setWorkingDir( workingDir ); - + return artifact; } - } +} Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/testUtils/DependencyTestUtils.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/testUtils/DependencyTestUtils.java?rev=1807877&r1=1807876&r2=1807877&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/testUtils/DependencyTestUtils.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/testUtils/DependencyTestUtils.java Sat Sep 9 10:35:59 2017 @@ -42,12 +42,8 @@ public class DependencyTestUtils /** * Deletes a directory and its contents. * - * @param dir - * The base directory of the included and excluded files. - * - * @throws IOException - * @throws MojoExecutionException - * When a directory failed to get deleted. + * @param dir {@link File} The base directory of the included and excluded files. + * @throws IOException in case of an error. When a directory failed to get deleted. */ public static void removeDirectory( File dir ) throws IOException @@ -79,14 +75,12 @@ public class DependencyTestUtils } /** - * convience method to set values to variables in objects that don't have - * setters - * - * @param object - * @param variable - * @param value + * convenience method to set values to variables in objects that don't have setters * - * @throws IllegalAccessException + * @param object {@link Object} + * @param variable the field name. + * @param value The value to be set. + * @throws IllegalAccessException in case of an error. */ public static void setVariableValueToObject( Object object, String variable, Object value ) throws IllegalAccessException @@ -106,7 +100,7 @@ public class DependencyTestUtils long time = System.currentTimeMillis(); time = time - ( time % 1000 ); assertTrue( "Updating last modification time of marker file " + file.getAbsolutePath() - + " failed unexpectedly.", file.setLastModified( time ) ); + + " failed unexpectedly.", file.setLastModified( time ) ); // wait at least a second for filesystems that only record to the // nearest second.