summaryrefslogtreecommitdiffstats
path: root/bundle-plugin/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'bundle-plugin/src/test/java')
-rw-r--r--bundle-plugin/src/test/java/com/yahoo/container/plugin/bundle/AnalyzeBundleTest.java9
-rw-r--r--bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/PackageTallyTest.java24
-rw-r--r--bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java5
3 files changed, 36 insertions, 2 deletions
diff --git a/bundle-plugin/src/test/java/com/yahoo/container/plugin/bundle/AnalyzeBundleTest.java b/bundle-plugin/src/test/java/com/yahoo/container/plugin/bundle/AnalyzeBundleTest.java
index 8cccf0598ab..a09604b842b 100644
--- a/bundle-plugin/src/test/java/com/yahoo/container/plugin/bundle/AnalyzeBundleTest.java
+++ b/bundle-plugin/src/test/java/com/yahoo/container/plugin/bundle/AnalyzeBundleTest.java
@@ -11,8 +11,10 @@ import org.junit.rules.ExpectedException;
import java.io.File;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import static com.yahoo.container.plugin.classanalysis.TestUtilities.throwableMessage;
import static org.hamcrest.CoreMatchers.containsString;
@@ -28,6 +30,7 @@ import static org.junit.Assert.assertThat;
*/
public class AnalyzeBundleTest {
private final List<ExportPackages.Export> exports;
+ private final Set<String> exportedPackageNames;
private final Map<String, ExportPackages.Export> exportsByPackageName;
File jarDir = new File("src/test/resources/jar");
@@ -37,6 +40,7 @@ public class AnalyzeBundleTest {
File simple = new File(jarDir, "simple1.jar");
PublicPackages pp = AnalyzeBundle.publicPackagesAggregated(Arrays.asList(notOsgi, simple));
this.exports = pp.exports;
+ this.exportedPackageNames = pp.exportedPackageNames();
this.exportsByPackageName = ExportPackages.exportsByPackageName(exports);
}
@@ -55,6 +59,11 @@ public class AnalyzeBundleTest {
assertThat(exportsByPackageName.keySet(), hasItem("com.yahoo.sample.exported.package"));
}
+ @Test
+ public void exported_class_names_can_be_retrieved() {
+ assertThat(exportedPackageNames, is(new HashSet<>(exports.get(0).getPackageNames())));
+ }
+
@Rule
public ExpectedException exception = ExpectedException.none();
diff --git a/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/PackageTallyTest.java b/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/PackageTallyTest.java
new file mode 100644
index 00000000000..e80562c2c13
--- /dev/null
+++ b/bundle-plugin/src/test/java/com/yahoo/container/plugin/classanalysis/PackageTallyTest.java
@@ -0,0 +1,24 @@
+// Copyright 2019 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.container.plugin.classanalysis;
+
+import org.junit.Test;
+
+import java.util.Set;
+
+import static java.util.Collections.emptyMap;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * @author gjoranv
+ */
+public class PackageTallyTest {
+
+ @Test
+ public void referenced_packages_missing_from_are_detected() {
+ PackageTally tally = new PackageTally(emptyMap(), Set.of("p1", "java.util", "com.yahoo.api.annotations", "missing"));
+ Set<String> missingPackages = tally.referencedPackagesMissingFrom(Set.of("p1"));
+ assertThat(missingPackages, is(Set.of("missing")));
+ }
+
+}
diff --git a/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java b/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java
index 23960323a31..b76151c790e 100644
--- a/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java
+++ b/bundle-plugin/src/test/java/com/yahoo/container/plugin/osgi/ImportPackageTest.java
@@ -109,8 +109,9 @@ public class ImportPackageTest {
is("com.yahoo.exported;version=\"[1.2.3,2)\""));
}
- private static Set<Import> calculateImports(Set<String> referencedPackages, Set<String> implementedPackages,
- Map<String, Export> exportedPackages) {
+ private static Set<Import> calculateImports(Set<String> referencedPackages,
+ Set<String> implementedPackages,
+ Map<String, Export> exportedPackages) {
return new HashSet<>(ImportPackages.calculateImports(referencedPackages, implementedPackages, exportedPackages).values());
}