1   package org.apache.maven.jar;
2   
3   /* ====================================================================
4    *   Licensed to the Apache Software Foundation (ASF) under one or more
5    *   contributor license agreements.  See the NOTICE file distributed with
6    *   this work for additional information regarding copyright ownership.
7    *   The ASF licenses this file to You under the Apache License, Version 2.0
8    *   (the "License"); you may not use this file except in compliance with
9    *   the License.  You may obtain a copy of the License at
10   *
11   *       http://www.apache.org/licenses/LICENSE-2.0
12   *
13   *   Unless required by applicable law or agreed to in writing, software
14   *   distributed under the License is distributed on an "AS IS" BASIS,
15   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   *   See the License for the specific language governing permissions and
17   *   limitations under the License.
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  }