KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > apisupport > project > ManifestManagerTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.apisupport.project;
21
22 import java.io.File JavaDoc;
23 import java.util.Collections JavaDoc;
24
25 /**
26  * Test functionality of ManifestManager.
27  *
28  * @author Martin Krauskopf
29  */

30 public class ManifestManagerTest extends TestBase {
31
32     // XXX test also implementation version
33

34     public ManifestManagerTest(String JavaDoc name) {
35         super(name);
36     }
37
38     private File JavaDoc suite1, suite2;
39
40     protected void setUp() throws Exception JavaDoc {
41         super.setUp();
42         suite1 = resolveEEPFile("suite1");
43         suite2 = resolveEEPFile("suite2");
44     }
45
46     public void testDirectManifestFile() throws Exception JavaDoc {
47         File JavaDoc basedir = new File JavaDoc(suite2, "misc-project");
48         ManifestManager mm = ManifestManager.getInstance(new File JavaDoc(basedir, "manifest.mf"), false);
49         assertEquals("right codeNameBase", "org.netbeans.examples.modules.misc", mm.getCodeNameBase());
50         assertEquals("right release version", "1", mm.getReleaseVersion());
51         assertEquals("right specification version", "1.0", mm.getSpecificationVersion());
52         assertEquals("right localizing bundle", "org/netbeans/examples/modules/misc/Bundle.properties",
53                 mm.getLocalizingBundle());
54         
55         basedir = new File JavaDoc(suite1, "action-project");
56         mm = ManifestManager.getInstance(new File JavaDoc(basedir, "manifest.mf"), false);
57         assertEquals("right codeNameBase", "org.netbeans.examples.modules.action", mm.getCodeNameBase());
58         assertNull("no release version", mm.getReleaseVersion());
59     }
60     
61     public void testFriends() throws Exception JavaDoc {
62         File JavaDoc manifest = new File JavaDoc(getWorkDir(), "testManifest.mf");
63         String JavaDoc mfContent = "Manifest-Version: 1.0\n" +
64                 "Ant-Version: Apache Ant 1.6.5\n" +
65                 "Created-By: 1.4.2_10-b03 (Sun Microsystems Inc.)\n" +
66                 "OpenIDE-Module-Public-Packages: org.netbeans.modules.editor.hints.spi.*\n" +
67                 "OpenIDE-Module-Friends: org.netbeans.modules.java.hints, org.netbeans.\n" +
68                 " modules.j2ee.ejbcore, org.netbeans.modules.kjava.editor\n" +
69                 "OpenIDE-Module-Module-Dependencies: org.openide.filesystems > 6.2, org\n" +
70                 " .openide.util > 6.2, org.openide.modules > 6.2, org.openide.nodes > 6\n" +
71                 " .2, org.openide.awt > 6.2, org.openide.text > 6.2, org.openide.loader\n" +
72                 " s, org.netbeans.modules.editor.lib/1, org.netbeans.modules.editor.mim\n" +
73                 " elookup/1\n" +
74                 "OpenIDE-Module-Build-Version: 060123\n" +
75                 "OpenIDE-Module-Specification-Version: 1.10.0.1\n" +
76                 "OpenIDE-Module: org.netbeans.modules.editor.hints/1\n" +
77                 "OpenIDE-Module-Implementation-Version: 1\n" +
78                 "OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/editor/hints/re\n" +
79                 " sources/Bundle.properties\n" +
80                 "OpenIDE-Module-Install: org/netbeans/modules/editor/hints/HintsModule.\n" +
81                 " class\n" +
82                 "OpenIDE-Module-Requires: org.openide.modules.ModuleFormat1\n";
83         dump(manifest, mfContent);
84         ManifestManager mm = ManifestManager.getInstance(manifest, true);
85         assertEquals("one public package", 1, mm.getPublicPackages().length);
86     }
87     
88     public void testJarWithNoManifest() throws Exception JavaDoc {
89         // See #87064.
90
File JavaDoc jar = new File JavaDoc(getWorkDir(), "test.jar");
91         TestBase.createJar(jar, Collections.singletonMap("foo", "bar"), null);
92         ManifestManager.getInstanceFromJAR(jar);
93     }
94     
95 }
96
Popular Tags