You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kr...@apache.org on 2012/01/24 08:03:42 UTC
svn commit: r1235142 -
/maven/shared/trunk/maven-archiver/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
Author: krosenvold
Date: Tue Jan 24 07:03:42 2012
New Revision: 1235142
URL: http://svn.apache.org/viewvc?rev=1235142&view=rev
Log:
o Changed test to use java.util.jar.Manfiest methods
Modified:
maven/shared/trunk/maven-archiver/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
Modified: maven/shared/trunk/maven-archiver/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-archiver/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java?rev=1235142&r1=1235141&r2=1235142&view=diff
==============================================================================
--- maven/shared/trunk/maven-archiver/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java (original)
+++ maven/shared/trunk/maven-archiver/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java Tue Jan 24 07:03:42 2012
@@ -34,7 +34,6 @@ import org.apache.maven.project.MavenPro
import org.apache.maven.settings.Settings;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.archiver.jar.JarArchiver;
-import org.codehaus.plexus.archiver.jar.Manifest;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;
@@ -54,6 +53,7 @@ import java.util.Set;
import java.util.TreeSet;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
+import java.util.jar.Manifest;
public class MavenArchiverTest
extends TestCase
@@ -100,16 +100,14 @@ public class MavenArchiverTest
manifest = archiver.getManifest( session, project, config );
- assertNotNull( manifest.getMainSection() );
+ assertNotNull( manifest.getMainAttributes() );
+
+ for (Map.Entry<String, Attributes> entry : manifest.getEntries().entrySet()) {
+ System.out.println( entry.getKey() + " " + entry.getValue().getValue("Extension-List") );
- java.util.Enumeration enume = manifest.getSectionNames();
- while ( enume.hasMoreElements() )
- {
- Manifest.Section section = manifest.getSection( enume.nextElement().toString() );
- System.out.println( section + " " + section.getAttributeValue( "Extension-List" ) );
}
- assertEquals( null, manifest.getMainSection().getAttributeValue( "Extension-List" ) );
+ assertEquals( null, manifest.getMainAttributes().getValue( "Extension-List" ) );
MockArtifact artifact1 = new MockArtifact();
artifact1.setGroupId( "org.apache.dummy" );
@@ -122,7 +120,7 @@ public class MavenArchiverTest
manifest = archiver.getManifest( session, project, config );
- assertEquals( null, manifest.getMainSection().getAttributeValue( "Extension-List" ) );
+ assertEquals( null, manifest.getMainAttributes().getValue( "Extension-List" ) );
MockArtifact artifact2 = new MockArtifact();
artifact2.setGroupId( "org.apache.dummy" );
@@ -135,7 +133,7 @@ public class MavenArchiverTest
manifest = archiver.getManifest( session, project, config );
- assertEquals( "dummy2", manifest.getMainSection().getAttributeValue( "Extension-List" ) );
+ assertEquals( "dummy2", manifest.getMainAttributes().getValue( "Extension-List" ) );
MockArtifact artifact3 = new MockArtifact();
artifact3.setGroupId( "org.apache.dummy" );
@@ -148,7 +146,7 @@ public class MavenArchiverTest
manifest = archiver.getManifest( session, project, config );
- assertEquals( "dummy2", manifest.getMainSection().getAttributeValue( "Extension-List" ) );
+ assertEquals( "dummy2", manifest.getMainAttributes().getValue( "Extension-List" ) );
MockArtifact artifact4 = new MockArtifact();
artifact4.setGroupId( "org.apache.dummy" );
@@ -161,7 +159,7 @@ public class MavenArchiverTest
manifest = archiver.getManifest( session, project, config );
- assertEquals( "dummy2 dummy4", manifest.getMainSection().getAttributeValue( "Extension-List" ) );
+ assertEquals( "dummy2 dummy4", manifest.getMainAttributes().getValue( "Extension-List" ) );
}
public void testMultiClassPath()
@@ -200,7 +198,7 @@ public class MavenArchiverTest
archiveConfiguration.addManifestEntry( "Class-Path", "help/" );
Manifest manifest = archiver.getManifest( session, project, archiveConfiguration );
- String classPath = manifest.getMainSection().getAttribute( "Class-Path" ).getValue();
+ String classPath = manifest.getMainAttributes().getValue( "Class-Path" );
assertTrue( "User specified Class-Path entry was not added to manifest",
classPath.indexOf( "help/" ) != -1 );
assertTrue( "Class-Path generated by addClasspath was not added to manifest",
@@ -577,12 +575,12 @@ public class MavenArchiverTest
Manifest manifest = archiver.getManifest( session, project, config );
- Manifest.Section section = manifest.getSection( "SectionOne" );
+ Attributes section = manifest.getAttributes("SectionOne");
assertNotNull( "The section is not present in the manifest as it should be.", section );
- Manifest.Attribute attribute = section.getAttribute( "key" );
+ String attribute = section.getValue("key");
assertNotNull( "The attribute we are looking for is not present in the section.", attribute );
- assertEquals( "The value of the attribute is wrong.", "value", attribute.getValue() );
+ assertEquals( "The value of the attribute is wrong.", "value", attribute );
}
public void testDefaultClassPathValue()
@@ -706,7 +704,7 @@ public class MavenArchiverTest
Manifest manifest = archiver.getManifest( session, project, config );
String[] classPathEntries =
- StringUtils.split( new String( manifest.getMainSection().getAttributeValue( "Class-Path" ).getBytes() ),
+ StringUtils.split( new String( manifest.getMainAttributes().getValue( "Class-Path" ).getBytes() ),
" " );
assertEquals( "org/apache/dummy/dummy1/1.0/dummy1-1.0.jar", classPathEntries[0] );
assertEquals( "org/apache/dummy/foo/dummy2/1.5/dummy2-1.5.jar", classPathEntries[1] );
@@ -760,7 +758,7 @@ public class MavenArchiverTest
Manifest manifest = archiver.getManifest( session, project, config );
String[] classPathEntries =
- StringUtils.split( new String( manifest.getMainSection().getAttributeValue( "Class-Path" ).getBytes() ),
+ StringUtils.split( new String( manifest.getMainAttributes().getValue( "Class-Path" ).getBytes() ),
" " );
assertEquals( "org/apache/dummy/dummy1/1.1-SNAPSHOT/dummy1-1.1-20081022.112233-1.jar",
classPathEntries[0] );
@@ -818,7 +816,7 @@ public class MavenArchiverTest
Manifest manifest = archiver.getManifest( session, project, config );
String[] classPathEntries =
- StringUtils.split( new String( manifest.getMainSection().getAttributeValue( "Class-Path" ).getBytes() ),
+ StringUtils.split( new String( manifest.getMainAttributes().getValue( "Class-Path" ).getBytes() ),
" " );
assertEquals( "org/apache/dummy/dummy1/1.0/TEST-dummy1-1.0.jar", classPathEntries[0] );
assertEquals( "org/apache/dummy/foo/dummy2/1.5/TEST-dummy2-1.5.jar", classPathEntries[1] );
@@ -874,7 +872,7 @@ public class MavenArchiverTest
Manifest manifest = archiver.getManifest( session, project, config );
String[] classPathEntries =
- StringUtils.split( new String( manifest.getMainSection().getAttributeValue( "Class-Path" ).getBytes() ),
+ StringUtils.split( new String( manifest.getMainAttributes().getValue( "Class-Path" ).getBytes() ),
" " );
assertEquals( "org/apache/dummy/dummy1/1.1-SNAPSHOT/TEST-dummy1-1.1-20081022.112233-1.jar",
classPathEntries[0] );
@@ -932,7 +930,7 @@ public class MavenArchiverTest
Manifest manifest = archiver.getManifest( session, project, config );
String[] classPathEntries =
- StringUtils.split( new String( manifest.getMainSection().getAttributeValue( "Class-Path" ).getBytes() ),
+ StringUtils.split( new String( manifest.getMainAttributes().getValue( "Class-Path" ).getBytes() ),
" " );
assertEquals( "org/apache/dummy/dummy1/1.1-SNAPSHOT/TEST-dummy1-1.1-SNAPSHOT.jar", classPathEntries[0] );
assertEquals( "org/apache/dummy/foo/dummy2/1.5/TEST-dummy2-1.5.jar", classPathEntries[1] );