2 * Back 2 Browser Bytecode Translator
3 * Copyright (C) 2012-2015 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. Look for COPYING file in the top folder.
16 * If not, see http://opensource.org/licenses/GPL-2.0.
18 package org.apidesign.bck2brwsr.aot;
21 import java.io.InputStream;
22 import java.util.HashSet;
24 import java.util.TreeSet;
25 import java.util.jar.Attributes;
26 import org.apidesign.vm4brwsr.Bck2Brwsr;
27 import static org.testng.Assert.*;
28 import org.testng.annotations.AfterClass;
29 import org.testng.annotations.AfterMethod;
30 import org.testng.annotations.BeforeClass;
31 import org.testng.annotations.BeforeMethod;
32 import org.testng.annotations.Test;
36 * @author Jaroslav Tulach
38 public class ExportPublicPackagesTest {
40 public ExportPublicPackagesTest() {
43 @Test public void classicOSGIHeaders() throws Exception {
44 Attributes attr = new Attributes();
45 attr.putValue("Export-Package",
46 "net.java.html.json;uses:=\"net.java.html\";version=\"1.0.0\","
47 + "org.netbeans.html.json.spi;uses:=\"net.java.html\";version=\"1.0.0\""
49 Set<String> keep = new HashSet<>();
50 Bck2BrwsrJars.exportPublicPackages(attr, keep);
52 assertEquals(keep.size(), 2, "Two: " + keep);
53 assertTrue(keep.contains("net/java/html/json/"), "json pkg: " + keep);
54 assertTrue(keep.contains("org/netbeans/html/json/spi/"), "SPI pkg: " + keep);
57 @Test public void mylynOSGIHeaders() throws Exception {
58 Attributes attr = new Attributes();
59 attr.putValue("Export-Package",
60 "org.eclipse.mylyn.commons.core,org.eclipse.mylyn.commo" +
61 "ns.core.io,org.eclipse.mylyn.commons.core.net,org.eclipse.mylyn.commo" +
62 "ns.core.operations,org.eclipse.mylyn.commons.core.storage;x-internal:" +
63 "=true,org.eclipse.mylyn.internal.commons.core;x-internal:=true,org.ec" +
64 "lipse.mylyn.internal.commons.core.operations;x-internal:=true"
66 Set<String> keep = new TreeSet<>();
67 Bck2BrwsrJars.exportPublicPackages(attr, keep);
69 assertEquals(keep.size(), 7, "Seven: " + keep);
70 assertEquals(keep.toString(), "[org/eclipse/mylyn/commons/core/, org/eclipse/mylyn/commons/core/io/, org/eclipse/mylyn/commons/core/net/, org/eclipse/mylyn/commons/core/operations/, org/eclipse/mylyn/commons/core/storage/, org/eclipse/mylyn/internal/commons/core/, org/eclipse/mylyn/internal/commons/core/operations/]");
73 @Test public void lookupHeaders() throws Exception {
74 Attributes attr = new Attributes();
75 attr.putValue("OpenIDE-Module-Public-Packages",
76 "org.openide.util.*, org.openide.util.lookup.*, org.openide.util.lookup.implspi.*"
78 Set<String> keep = new TreeSet<>();
79 Bck2BrwsrJars.exportPublicPackages(attr, keep);
81 assertEquals(keep.size(), 3, "Three: " + keep);
82 assertTrue(keep.contains("org/openide/util/"), "main pkg: " + keep);
83 assertTrue(keep.contains("org/openide/util/lookup/"), "util pkg: " + keep);
84 assertTrue(keep.contains("org/openide/util/lookup/implspi/"), "spiimpl pkg: " + keep);