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