From 01705ccfef4a08cebd98a4eb4251e7032b1eac98 Mon Sep 17 00:00:00 2001 From: gjoranv Date: Wed, 7 Nov 2018 21:06:56 +0100 Subject: Improve integration test - Add nested classes - Put back commented assert and remove stale comment + Add comment to replace jrt.jar. It's compile scoped and had a much smaller dependency tree when it was added compared to now. Now, it adds loads of Import-Packages, increasing the risk of invalidating the integration test that verifies that the required imports have been added to the manifest. --- .../main/java/com/yahoo/test/SimpleSearcher2.java | 22 +++++++++++++++++++--- .../src/test/java/com/yahoo/BundleIT.java | 13 ++++++++++--- 2 files changed, 29 insertions(+), 6 deletions(-) (limited to 'bundle-plugin-test') diff --git a/bundle-plugin-test/src/main/java/com/yahoo/test/SimpleSearcher2.java b/bundle-plugin-test/src/main/java/com/yahoo/test/SimpleSearcher2.java index c92f029ade6..8a852886254 100644 --- a/bundle-plugin-test/src/main/java/com/yahoo/test/SimpleSearcher2.java +++ b/bundle-plugin-test/src/main/java/com/yahoo/test/SimpleSearcher2.java @@ -3,10 +3,26 @@ package com.yahoo.test; /** - * A searcher adding a new hit. - * TODO: add annotation check - * @author Joe Developer + * Test class for integration tests. Used to verify that nested classes are visited. + * + * Do not replace the fully qualified class names with imports! */ public class SimpleSearcher2 extends SimpleSearcher { public void dummy() {} + + private class InnerClassProcessor extends com.yahoo.processing.Processor { + @Override + public com.yahoo.processing.Response process(com.yahoo.processing.Request request, + com.yahoo.processing.execution.Execution execution) { + return null; + } + } + + private class NestedStaticClass { + private com.yahoo.metrics.simple.Counter counter; + + @com.google.inject.Inject + public NestedStaticClass() { } + } + } diff --git a/bundle-plugin-test/src/test/java/com/yahoo/BundleIT.java b/bundle-plugin-test/src/test/java/com/yahoo/BundleIT.java index 10f8f4e976c..5b4fdda06f7 100644 --- a/bundle-plugin-test/src/test/java/com/yahoo/BundleIT.java +++ b/bundle-plugin-test/src/test/java/com/yahoo/BundleIT.java @@ -4,7 +4,6 @@ package com.yahoo; import com.yahoo.osgi.maven.ProjectBundleClassPaths; import com.yahoo.vespa.config.VespaVersion; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import java.io.File; @@ -81,9 +80,15 @@ public class BundleIT { @Test public void require_that_manifest_contains_inferred_imports() { String importPackage = mainAttributes.getValue("Import-Package"); + + // From SimpleSearcher assertThat(importPackage, containsString("com.yahoo.prelude.hitfield")); - //Not available from jdisc at the moment, scope temporarily changed to compile. - //assertThat(importPackage, containsString("org.json")); + assertThat(importPackage, containsString("org.json")); + + // From SimpleSearcher2 + assertThat(importPackage, containsString("com.yahoo.processing")); + assertThat(importPackage, containsString("com.yahoo.metrics.simple")); + assertThat(importPackage, containsString("com.google.inject")); } @Test @@ -104,6 +109,8 @@ public class BundleIT { } @Test + // TODO: use another jar than jrt, which now pulls in a lot of dependencies that pollute the manifest of the + // generated bundle. (It's compile scoped in pom.xml to be added to the bundle-cp.) public void require_that_manifest_contains_bundle_class_path() { String bundleClassPath = mainAttributes.getValue("Bundle-ClassPath"); assertThat(bundleClassPath, containsString(".,")); -- cgit v1.2.3