1 package org.apache.maven.jar;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import java.io.File;
22 import java.io.IOException;
23
24 import junit.framework.TestCase;
25
26 /**
27 * JarUtils Test class.
28 *
29 * @author <a href="mailto:ltheussl@apache.org">Lukas Theussl</a>
30 * @version $Id: JarUtilsTest.java 531612 2007-04-23 21:28:38Z ltheussl $
31 */
32 public class JarUtilsTest extends TestCase
33 {
34
35 /** Tests the manifest entries. */
36 public void testManifestEntries()
37 {
38 JarUtils jarUtils = new JarUtils();
39 File manifestFile =
40 new File( System.getProperty( "basedir"), "src/test/resources/MANIFEST.MF" );
41
42 try
43 {
44 jarUtils.extractManifestFromFile( manifestFile );
45 }
46 catch (IOException e)
47 {
48 e.printStackTrace();
49 fail( "Could not open manifest file!" );
50 }
51
52 assertEquals( jarUtils.getMainAttribute( "Manifest-Version" ), "1.0" );
53 assertEquals( jarUtils.getMainAttribute( "Ant-Version" ), "Apache Ant 1.6.5" );
54 assertEquals( jarUtils.getMainAttribute( "Created-By" ), "1.4.2_10-b03 (Sun Microsystems Inc.)" );
55 assertEquals( jarUtils.getMainAttribute( "Built-By" ), "me" );
56 assertEquals( jarUtils.getMainAttribute( "Maven-Version" ), "1.1-beta-3-SNAPSHOT" );
57
58 assertEquals( jarUtils.getSectionAttribute( "Extension-name" ), "org.apache.maven" );
59 assertEquals( jarUtils.getSectionAttribute( "Specification-Title" ), "Create jar files" );
60 assertEquals( jarUtils.getSectionAttribute( "Specification-Vendor" ), "Apache Software Foundation" );
61 assertEquals( jarUtils.getSectionAttribute( "Specification-Version" ), "1.8" );
62 assertEquals( jarUtils.getSectionAttribute( "Implementation-Title" ), "org.apache.maven" );
63 assertEquals( jarUtils.getSectionAttribute( "Implementation-Vendor" ), "Apache Software Foundation" );
64 assertEquals( jarUtils.getSectionAttribute( "Implementation-Version" ), "1.8-SNAPSHOT" );
65
66 assertTrue( jarUtils.containsSection( "org/apache/maven" ) );
67 assertTrue( jarUtils.containsMainAttribute( "Maven-Version" ) );
68 assertTrue( jarUtils.containsSectionAttribute( "Specification-Version" ) );
69
70 }
71
72 }