aboutsummaryrefslogtreecommitdiffstats
path: root/bundle-plugin-test
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2019-10-19 16:31:03 +0200
committergjoranv <gv@verizonmedia.com>2019-10-23 12:26:58 +0200
commitaaec0de4e4e7ae3fd0776c594b76bbe16fe30bfb (patch)
tree9951d4305728fbe3c70f5647333968ca79013701 /bundle-plugin-test
parente87cd4be6d717807246d20204954739118160126 (diff)
Restructure bundle-plugin-test to allow multiple test bundles.
Diffstat (limited to 'bundle-plugin-test')
-rw-r--r--bundle-plugin-test/integration-test/pom.xml91
-rw-r--r--bundle-plugin-test/integration-test/src/test/java/com/yahoo/BundleIT.java (renamed from bundle-plugin-test/src/test/java/com/yahoo/BundleIT.java)41
-rw-r--r--bundle-plugin-test/pom.xml80
-rw-r--r--bundle-plugin-test/test-bundles/main/pom.xml83
-rw-r--r--bundle-plugin-test/test-bundles/main/src/main/java/InDefaultPackage.java (renamed from bundle-plugin-test/src/main/java/InDefaultPackage.java)0
-rw-r--r--bundle-plugin-test/test-bundles/main/src/main/java/com/yahoo/test/SimpleSearcher.java (renamed from bundle-plugin-test/src/main/java/com/yahoo/test/SimpleSearcher.java)0
-rw-r--r--bundle-plugin-test/test-bundles/main/src/main/java/com/yahoo/test/SimpleSearcher2.java (renamed from bundle-plugin-test/src/main/java/com/yahoo/test/SimpleSearcher2.java)0
-rw-r--r--bundle-plugin-test/test-bundles/main/src/main/java/com/yahoo/test/package-info.java (renamed from bundle-plugin-test/src/main/java/com/yahoo/test/package-info.java)0
-rw-r--r--bundle-plugin-test/test-bundles/main/src/main/resources/configdefinitions/test.def (renamed from bundle-plugin-test/src/main/resources/configdefinitions/test.def)0
-rw-r--r--bundle-plugin-test/test-bundles/pom.xml48
10 files changed, 255 insertions, 88 deletions
diff --git a/bundle-plugin-test/integration-test/pom.xml b/bundle-plugin-test/integration-test/pom.xml
new file mode 100644
index 00000000000..62204f23999
--- /dev/null
+++ b/bundle-plugin-test/integration-test/pom.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0"?>
+<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.yahoo.vespa.bundle-plugin</groupId>
+ <artifactId>bundle-plugin-test</artifactId>
+ <version>7-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>integration-test</artifactId>
+ <version>7-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>config</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>vespajlib</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.yahoo.vespa.bundle-plugin</groupId>
+ <artifactId>main</artifactId>
+ <classifier>bundle</classifier>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>2.9</version>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <trimStackTrace>false</trimStackTrace>
+ <systemPropertyVariables>
+ <test.bundle.path>${project.build.directory}/dependency</test.bundle.path>
+ <redirectTestOutputToFile>${test.hide}</redirectTestOutputToFile>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <includeScope>compile</includeScope>
+ <excludeTransitive>true</excludeTransitive>
+ <stripVersion>true</stripVersion>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/bundle-plugin-test/src/test/java/com/yahoo/BundleIT.java b/bundle-plugin-test/integration-test/src/test/java/com/yahoo/BundleIT.java
index 932b78a5c8d..2ed1d7f0bc6 100644
--- a/bundle-plugin-test/src/test/java/com/yahoo/BundleIT.java
+++ b/bundle-plugin-test/integration-test/src/test/java/com/yahoo/BundleIT.java
@@ -4,14 +4,15 @@ package com.yahoo;
import com.yahoo.osgi.maven.ProjectBundleClassPaths;
import com.yahoo.vespa.config.VespaVersion;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.file.Paths;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.Collection;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
@@ -19,6 +20,7 @@ import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
import static com.yahoo.osgi.maven.ProjectBundleClassPaths.CLASSPATH_MAPPINGS_FILENAME;
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.containsString;
@@ -31,16 +33,19 @@ import static org.junit.Assert.assertThat;
/**
* Verifies the bundle jar file built and its manifest.
+ *
* @author Tony Vaagenes
*/
public class BundleIT {
+ static final String TEST_BUNDLE_PATH = System.getProperty("test.bundle.path", ".") + "/";
+
private JarFile jarFile;
private Attributes mainAttributes;
@Before
public void setup() {
try {
- File componentJar = findBundleJar();
+ File componentJar = findBundleJar("main");
jarFile = new JarFile(componentJar);
Manifest manifest = jarFile.getManifest();
mainAttributes = manifest.getMainAttributes();
@@ -49,11 +54,11 @@ public class BundleIT {
}
}
- private File findBundleJar() {
- File[] componentFile = new File("target").listFiles(new FilenameFilter() {
+ private File findBundleJar(String bundleName) {
+ File[] componentFile = new File(TEST_BUNDLE_PATH).listFiles(new FilenameFilter() {
@Override
public boolean accept(File file, String fileName) {
- return fileName.endsWith("-deploy.jar") || fileName.endsWith("-jar-with-dependencies.jar");
+ return fileName.endsWith("-bundle.jar");
}
});
@@ -75,7 +80,7 @@ public class BundleIT {
@Test
public void require_that_bundle_symbolic_name_matches_pom_artifactId() {
- assertThat(mainAttributes.getValue("Bundle-SymbolicName"), is("bundle-plugin-test"));
+ assertThat(mainAttributes.getValue("Bundle-SymbolicName"), is("main"));
}
@Test
@@ -141,17 +146,25 @@ public class BundleIT {
assertThat(webInfUrl, containsString("/WEB-INF/web.xml"));
}
+ // TODO Vespa 8: Remove, the classpath mappings file is only needed for jersey resources to work in the application test framework.
+ // When this test is removed, also remove the maven-resources-plugin from the 'main' test bundle's pom.
+ @Rule
+ public TemporaryFolder tempFolder = new TemporaryFolder();
@SuppressWarnings("unchecked")
@Test
- public void bundle_class_path_mappings_are_generated() throws URISyntaxException, IOException {
- URL mappingsUrl = getClass().getResource("/" + CLASSPATH_MAPPINGS_FILENAME);
+ public void bundle_class_path_mappings_are_generated() throws Exception {
+ ZipEntry classpathMappingsEntry = jarFile.getEntry(CLASSPATH_MAPPINGS_FILENAME);
+
assertNotNull(
- "Could not find " + CLASSPATH_MAPPINGS_FILENAME + " in the test output directory",
- mappingsUrl);
+ "Could not find " + CLASSPATH_MAPPINGS_FILENAME + " in the test bundle",
+ classpathMappingsEntry);
+
+ Path mappingsFile = tempFolder.newFile(CLASSPATH_MAPPINGS_FILENAME).toPath();
+ Files.copy(jarFile.getInputStream(classpathMappingsEntry), mappingsFile, REPLACE_EXISTING);
- ProjectBundleClassPaths bundleClassPaths = ProjectBundleClassPaths.load(Paths.get(mappingsUrl.toURI()));
+ ProjectBundleClassPaths bundleClassPaths = ProjectBundleClassPaths.load(mappingsFile);
- assertThat(bundleClassPaths.mainBundle.bundleSymbolicName, is("bundle-plugin-test"));
+ assertThat(bundleClassPaths.mainBundle.bundleSymbolicName, is("main"));
Collection<String> mainBundleClassPaths = bundleClassPaths.mainBundle.classPathElements;
diff --git a/bundle-plugin-test/pom.xml b/bundle-plugin-test/pom.xml
index 3ba9bf7b4b6..b27f6edc5f8 100644
--- a/bundle-plugin-test/pom.xml
+++ b/bundle-plugin-test/pom.xml
@@ -11,80 +11,12 @@
<version>7-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
- <groupId>com.yahoo.vespa</groupId>
+ <groupId>com.yahoo.vespa.bundle-plugin</groupId>
<artifactId>bundle-plugin-test</artifactId>
<version>7-SNAPSHOT</version>
- <packaging>container-plugin</packaging>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.yahoo.vespa</groupId>
- <artifactId>container-dev</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>com.yahoo.vespa</groupId>
- <artifactId>vespajlib</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>com.yahoo.vespa</groupId>
- <artifactId>jrt</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <!-- Added to verify that module-info.class can be handled by bundle-plugin without throwing an exception. -->
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
- <version>2.3.0</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>com.yahoo.vespa</groupId>
- <artifactId>bundle-plugin</artifactId>
- <version>${project.version}</version>
- <extensions>true</extensions>
- <configuration>
- <Import-Package>
- manualImport.withoutVersion,
- manualImport.withVersion;version="12.3.4",
- multiple.packages.with.the.same.version1;multiple.packages.with.the.same.version2;version="[1,2)"
- </Import-Package>
- <WebInfUrl>/WEB-INF/web.xml</WebInfUrl>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- <version>2.9</version>
- <executions>
- <execution>
- <id>integration-test</id>
- <goals>
- <goal>integration-test</goal>
- </goals>
- </execution>
- <execution>
- <id>verify</id>
- <goals>
- <goal>verify</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+ <packaging>pom</packaging>
+ <modules>
+ <module>integration-test</module>
+ <module>test-bundles</module>
+ </modules>
</project>
diff --git a/bundle-plugin-test/test-bundles/main/pom.xml b/bundle-plugin-test/test-bundles/main/pom.xml
new file mode 100644
index 00000000000..1c02a516fe8
--- /dev/null
+++ b/bundle-plugin-test/test-bundles/main/pom.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0"?>
+<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.yahoo.vespa.bundle-plugin</groupId>
+ <artifactId>test-bundles</artifactId>
+ <version>7-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>main</artifactId>
+ <version>7-SNAPSHOT</version>
+ <packaging>container-plugin</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>container-dev</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>jrt</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <!-- Added to verify that module-info.class can be handled by bundle-plugin without throwing an exception. -->
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.3.0</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <Import-Package>
+ manualImport.withoutVersion,
+ manualImport.withVersion;version="12.3.4",
+ multiple.packages.with.the.same.version1;multiple.packages.with.the.same.version2;version="[1,2)"
+ </Import-Package>
+ <WebInfUrl>/WEB-INF/web.xml</WebInfUrl>
+ </configuration>
+ </plugin>
+ <plugin>
+ <!-- Trick to copy bundle-plugin.bundle-classpath-mappings.json from target/test-classes to target/classes -->
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-resources</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.outputDirectory}</outputDirectory>
+ <overwrite>true</overwrite>
+ <resources>
+ <resource>
+ <directory>${project.build.testOutputDirectory}</directory>
+ <includes>
+ <include>bundle-plugin.bundle-classpath-mappings.json</include>
+ </includes>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/bundle-plugin-test/src/main/java/InDefaultPackage.java b/bundle-plugin-test/test-bundles/main/src/main/java/InDefaultPackage.java
index a650916d653..a650916d653 100644
--- a/bundle-plugin-test/src/main/java/InDefaultPackage.java
+++ b/bundle-plugin-test/test-bundles/main/src/main/java/InDefaultPackage.java
diff --git a/bundle-plugin-test/src/main/java/com/yahoo/test/SimpleSearcher.java b/bundle-plugin-test/test-bundles/main/src/main/java/com/yahoo/test/SimpleSearcher.java
index dddca3f4d59..dddca3f4d59 100644
--- a/bundle-plugin-test/src/main/java/com/yahoo/test/SimpleSearcher.java
+++ b/bundle-plugin-test/test-bundles/main/src/main/java/com/yahoo/test/SimpleSearcher.java
diff --git a/bundle-plugin-test/src/main/java/com/yahoo/test/SimpleSearcher2.java b/bundle-plugin-test/test-bundles/main/src/main/java/com/yahoo/test/SimpleSearcher2.java
index 3220171de13..3220171de13 100644
--- a/bundle-plugin-test/src/main/java/com/yahoo/test/SimpleSearcher2.java
+++ b/bundle-plugin-test/test-bundles/main/src/main/java/com/yahoo/test/SimpleSearcher2.java
diff --git a/bundle-plugin-test/src/main/java/com/yahoo/test/package-info.java b/bundle-plugin-test/test-bundles/main/src/main/java/com/yahoo/test/package-info.java
index 5774fc8d5f2..5774fc8d5f2 100644
--- a/bundle-plugin-test/src/main/java/com/yahoo/test/package-info.java
+++ b/bundle-plugin-test/test-bundles/main/src/main/java/com/yahoo/test/package-info.java
diff --git a/bundle-plugin-test/src/main/resources/configdefinitions/test.def b/bundle-plugin-test/test-bundles/main/src/main/resources/configdefinitions/test.def
index b4ba9ec518a..b4ba9ec518a 100644
--- a/bundle-plugin-test/src/main/resources/configdefinitions/test.def
+++ b/bundle-plugin-test/test-bundles/main/src/main/resources/configdefinitions/test.def
diff --git a/bundle-plugin-test/test-bundles/pom.xml b/bundle-plugin-test/test-bundles/pom.xml
new file mode 100644
index 00000000000..680f43ba057
--- /dev/null
+++ b/bundle-plugin-test/test-bundles/pom.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.yahoo.vespa.bundle-plugin</groupId>
+ <artifactId>bundle-plugin-test</artifactId>
+ <version>7-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>test-bundles</artifactId>
+ <version>7-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <!-- Trick to package bundles before test phase to allow running 'mvn test' -->
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>bundle-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <id>package-test-bundles</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>generate-osgi-manifest</goal>
+ <goal>assemble-container-plugin</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <!-- The integration-test module should use the bundle jars instead of the ordinary artifacts. -->
+ <AttachBundle>true</AttachBundle>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <modules>
+ <module>main</module>
+ </modules>
+</project>