1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/rt/aot/src/test/java/org/apidesign/bck2brwsr/aot/ExportPublicPackagesTest.java Thu Nov 20 05:56:47 2014 +0100
1.3 @@ -0,0 +1,73 @@
1.4 +/**
1.5 + * Back 2 Browser Bytecode Translator
1.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
1.7 + *
1.8 + * This program is free software: you can redistribute it and/or modify
1.9 + * it under the terms of the GNU General Public License as published by
1.10 + * the Free Software Foundation, version 2 of the License.
1.11 + *
1.12 + * This program is distributed in the hope that it will be useful,
1.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.15 + * GNU General Public License for more details.
1.16 + *
1.17 + * You should have received a copy of the GNU General Public License
1.18 + * along with this program. Look for COPYING file in the top folder.
1.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
1.20 + */
1.21 +package org.apidesign.bck2brwsr.aot;
1.22 +
1.23 +import java.io.File;
1.24 +import java.io.InputStream;
1.25 +import java.util.HashSet;
1.26 +import java.util.Set;
1.27 +import java.util.TreeSet;
1.28 +import java.util.jar.Attributes;
1.29 +import org.apidesign.vm4brwsr.Bck2Brwsr;
1.30 +import static org.testng.Assert.*;
1.31 +import org.testng.annotations.AfterClass;
1.32 +import org.testng.annotations.AfterMethod;
1.33 +import org.testng.annotations.BeforeClass;
1.34 +import org.testng.annotations.BeforeMethod;
1.35 +import org.testng.annotations.Test;
1.36 +
1.37 +/**
1.38 + *
1.39 + * @author Jaroslav Tulach
1.40 + */
1.41 +public class ExportPublicPackagesTest {
1.42 +
1.43 + public ExportPublicPackagesTest() {
1.44 + }
1.45 +
1.46 + @Test public void classicOSGIHeaders() throws Exception {
1.47 + Attributes attr = new Attributes();
1.48 + attr.putValue("Export-Package",
1.49 + "net.java.html.json;uses:=\"net.java.html\";version=\"1.0.0\","
1.50 + + "org.netbeans.html.json.spi;uses:=\"net.java.html\";version=\"1.0.0\""
1.51 + );
1.52 + Set<String> keep = new HashSet<>();
1.53 + Bck2BrwsrJars.exportPublicPackages(attr, keep);
1.54 +
1.55 + assertEquals(keep.size(), 2, "Two: " + keep);
1.56 + assertTrue(keep.contains("net/java/html/json/"), "json pkg: " + keep);
1.57 + assertTrue(keep.contains("org/netbeans/html/json/spi/"), "SPI pkg: " + keep);
1.58 + }
1.59 +
1.60 + @Test public void mylynOSGIHeaders() throws Exception {
1.61 + Attributes attr = new Attributes();
1.62 + attr.putValue("Export-Package",
1.63 +"org.eclipse.mylyn.commons.core,org.eclipse.mylyn.commo" +
1.64 +"ns.core.io,org.eclipse.mylyn.commons.core.net,org.eclipse.mylyn.commo" +
1.65 +"ns.core.operations,org.eclipse.mylyn.commons.core.storage;x-internal:" +
1.66 +"=true,org.eclipse.mylyn.internal.commons.core;x-internal:=true,org.ec" +
1.67 +"lipse.mylyn.internal.commons.core.operations;x-internal:=true"
1.68 + );
1.69 + Set<String> keep = new TreeSet<>();
1.70 + Bck2BrwsrJars.exportPublicPackages(attr, keep);
1.71 +
1.72 + assertEquals(keep.size(), 7, "Two: " + keep);
1.73 + 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/]");
1.74 + }
1.75 +
1.76 +}