jaroslav@1724: /** jaroslav@1724: * Back 2 Browser Bytecode Translator jaroslav@1724: * Copyright (C) 2012 Jaroslav Tulach jaroslav@1724: * jaroslav@1724: * This program is free software: you can redistribute it and/or modify jaroslav@1724: * it under the terms of the GNU General Public License as published by jaroslav@1724: * the Free Software Foundation, version 2 of the License. jaroslav@1724: * jaroslav@1724: * This program is distributed in the hope that it will be useful, jaroslav@1724: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@1724: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@1724: * GNU General Public License for more details. jaroslav@1724: * jaroslav@1724: * You should have received a copy of the GNU General Public License jaroslav@1724: * along with this program. Look for COPYING file in the top folder. jaroslav@1724: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@1724: */ jaroslav@1724: package org.apidesign.bck2brwsr.aot; jaroslav@1724: jaroslav@1724: import java.io.File; jaroslav@1724: import java.io.InputStream; jaroslav@1724: import java.util.HashSet; jaroslav@1724: import java.util.Set; jaroslav@1724: import java.util.TreeSet; jaroslav@1724: import java.util.jar.Attributes; jaroslav@1724: import org.apidesign.vm4brwsr.Bck2Brwsr; jaroslav@1724: import static org.testng.Assert.*; jaroslav@1724: import org.testng.annotations.AfterClass; jaroslav@1724: import org.testng.annotations.AfterMethod; jaroslav@1724: import org.testng.annotations.BeforeClass; jaroslav@1724: import org.testng.annotations.BeforeMethod; jaroslav@1724: import org.testng.annotations.Test; jaroslav@1724: jaroslav@1724: /** jaroslav@1724: * jaroslav@1724: * @author Jaroslav Tulach jaroslav@1724: */ jaroslav@1724: public class ExportPublicPackagesTest { jaroslav@1724: jaroslav@1724: public ExportPublicPackagesTest() { jaroslav@1724: } jaroslav@1724: jaroslav@1724: @Test public void classicOSGIHeaders() throws Exception { jaroslav@1724: Attributes attr = new Attributes(); jaroslav@1724: attr.putValue("Export-Package", jaroslav@1724: "net.java.html.json;uses:=\"net.java.html\";version=\"1.0.0\"," jaroslav@1724: + "org.netbeans.html.json.spi;uses:=\"net.java.html\";version=\"1.0.0\"" jaroslav@1724: ); jaroslav@1724: Set keep = new HashSet<>(); jaroslav@1724: Bck2BrwsrJars.exportPublicPackages(attr, keep); jaroslav@1724: jaroslav@1724: assertEquals(keep.size(), 2, "Two: " + keep); jaroslav@1724: assertTrue(keep.contains("net/java/html/json/"), "json pkg: " + keep); jaroslav@1724: assertTrue(keep.contains("org/netbeans/html/json/spi/"), "SPI pkg: " + keep); jaroslav@1724: } jaroslav@1724: jaroslav@1724: @Test public void mylynOSGIHeaders() throws Exception { jaroslav@1724: Attributes attr = new Attributes(); jaroslav@1724: attr.putValue("Export-Package", jaroslav@1724: "org.eclipse.mylyn.commons.core,org.eclipse.mylyn.commo" + jaroslav@1724: "ns.core.io,org.eclipse.mylyn.commons.core.net,org.eclipse.mylyn.commo" + jaroslav@1724: "ns.core.operations,org.eclipse.mylyn.commons.core.storage;x-internal:" + jaroslav@1724: "=true,org.eclipse.mylyn.internal.commons.core;x-internal:=true,org.ec" + jaroslav@1724: "lipse.mylyn.internal.commons.core.operations;x-internal:=true" jaroslav@1724: ); jaroslav@1724: Set keep = new TreeSet<>(); jaroslav@1724: Bck2BrwsrJars.exportPublicPackages(attr, keep); jaroslav@1724: jaroslav@1724: assertEquals(keep.size(), 7, "Two: " + keep); jaroslav@1724: 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: } jaroslav@1724: jaroslav@1724: }