You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by jb...@apache.org on 2014/06/13 16:26:32 UTC
svn commit: r1602442 [1/4] - in /aries/trunk/application/application-itests:
./ src/test/java/org/apache/aries/application/runtime/itests/
src/test/java/org/apache/aries/isolated/config/
src/test/java/org/ops4j/pax/runner/platform/equinox/internal/ src...
Author: jbonofre
Date: Fri Jun 13 14:26:31 2014
New Revision: 1602442
URL: http://svn.apache.org/r1602442
Log:
Merge branch 'APP_JAVA8' into trunk
Removed:
aries/trunk/application/application-itests/src/test/java/org/ops4j/pax/runner/platform/equinox/internal/SsActivator.java
aries/trunk/application/application-itests/src/test/resources/META-INF/platform-equinox/definition-3.7.0.V20110613.xml
aries/trunk/application/application-itests/src/test/resources/META-INF/platform-equinox/definition-3.8.0.V20120529-1548.xml
aries/trunk/application/application-itests/src/test/resources/ss-runner.properties
Modified:
aries/trunk/application/application-itests/pom.xml
aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/BasicAppManagerTest.java
aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/BasicNoOpResolverTest.java
aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedCfgAdminRuntimeTest.java
aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedRuntimeTest.java
aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/MinimumImportsTest.java
aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRAppManagerTest.java
aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverAdvancedTest.java
aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverTest.java
aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/UpdateAppTest.java
aries/trunk/application/application-itests/src/test/java/org/apache/aries/isolated/config/HelloWorldManagedServiceImpl.java
Modified: aries/trunk/application/application-itests/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-itests/pom.xml?rev=1602442&r1=1602441&r2=1602442&view=diff
==============================================================================
--- aries/trunk/application/application-itests/pom.xml (original)
+++ aries/trunk/application/application-itests/pom.xml Fri Jun 13 14:26:31 2014
@@ -44,51 +44,20 @@
</scm>
<dependencies>
+ <!-- framework -->
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>4.2.0</version>
+ <artifactId>org.osgi.compendium</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.configadmin</artifactId>
- <version>1.2.4</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- </exclusion>
- </exclusions>
+ <groupId>org.eclipse</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ <version>3.8.0.v20120529-1548</version>
+ <scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.aries</groupId>
- <artifactId>org.apache.aries.util</artifactId>
- <version>1.0.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.aries.blueprint</groupId>
- <artifactId>org.apache.aries.blueprint</artifactId>
- <version>1.0.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.aries.proxy</groupId>
- <artifactId>org.apache.aries.proxy</artifactId>
- <version>1.0.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ow2.asm</groupId>
- <artifactId>asm-all</artifactId>
- <version>5.0.2</version>
- <scope>test</scope>
- </dependency>
+
+ <!-- logging -->
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-api</artifactId>
@@ -99,29 +68,61 @@
<artifactId>pax-logging-service</artifactId>
<scope>test</scope>
</dependency>
+
+ <!-- pax exam -->
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam</artifactId>
- <version>1.2.4</version>
+ <version>3.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit</artifactId>
- <version>1.2.4</version>
+ <artifactId>pax-exam-junit4</artifactId>
+ <version>3.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-container-default</artifactId>
- <version>1.2.4</version>
+ <artifactId>pax-exam-container-native</artifactId>
+ <version>3.4.0</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.ops4j.pax.url</groupId>
- <artifactId>pax-url-mvn</artifactId>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-link-mvn</artifactId>
+ <version>3.4.0</version>
<scope>test</scope>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.url</groupId>
+ <artifactId>pax-url-aether</artifactId>
+ <version>1.6.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.testsupport</groupId>
+ <artifactId>org.apache.aries.testsupport.unit</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- bundles -->
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.configadmin</artifactId>
+ <version>1.2.4</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.bundlerepository</artifactId>
@@ -129,74 +130,83 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.2.0</version>
+ <groupId>org.apache.aries</groupId>
+ <artifactId>org.apache.aries.util</artifactId>
+ <version>1.0.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint</artifactId>
+ <version>1.0.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.proxy</groupId>
+ <artifactId>org.apache.aries.proxy</artifactId>
+ <version>1.0.2-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm-all</artifactId>
+ <version>5.0.2</version>
<scope>test</scope>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.apache.aries.application</groupId>
<artifactId>org.apache.aries.application.utils</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.apache.aries.application</groupId>
<artifactId>org.apache.aries.application.runtime.itest.interfaces</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.apache.aries.application</groupId>
<artifactId>org.apache.aries.application.management</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.apache.aries.application</groupId>
<artifactId>org.apache.aries.application.runtime.framework</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.apache.aries.application</groupId>
<artifactId>org.apache.aries.application.runtime.framework.management</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.apache.aries.application</groupId>
<artifactId>org.apache.aries.application.runtime.repository</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.apache.aries.application</groupId>
<artifactId>org.apache.aries.application.runtime.isolated</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.apache.aries.application</groupId>
<artifactId>org.apache.aries.application.runtime</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.apache.aries.application</groupId>
<artifactId>org.apache.aries.application.resolver.obr</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.apache.aries.application</groupId>
<artifactId>org.apache.aries.application.resolver.noop</artifactId>
@@ -221,24 +231,11 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.aries.testsupport</groupId>
- <artifactId>org.apache.aries.testsupport.unit</artifactId>
- <version>1.0.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
<version>1.1.1</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.eclipse</groupId>
- <artifactId>osgi</artifactId>
- <version>3.5.0.v20090520</version>
- <type>jar</type>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
@@ -274,26 +271,6 @@
</includes>
</configuration>
</plugin>
- <plugin>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>maven-paxexam-plugin</artifactId>
- <version>1.2.3</version>
- <executions>
- <execution>
- <id>generate-config</id>
- <phase>process-test-resources</phase>
- <goals>
- <goal>generate-config</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <options>
- <platform>equinox</platform>
- <version>3.8.0.V20120529-1548</version>
- </options>
- </configuration>
- </plugin>
</plugins>
</build>
@@ -321,66 +298,6 @@
</plugins>
</build>
</profile>
- <profile>
- <id>equinox35</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>maven-paxexam-plugin</artifactId>
- <version>1.2.3</version>
- <executions>
- <execution>
- <id>generate-config</id>
- <phase>process-test-resources</phase>
- <goals>
- <goal>generate-config</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <options>
- <platform>equinox</platform>
- <version>3.5.0</version>
- </options>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>equinox37</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>maven-paxexam-plugin</artifactId>
- <version>1.2.3</version>
- <executions>
- <execution>
- <id>generate-config</id>
- <phase>process-test-resources</phase>
- <goals>
- <goal>generate-config</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <options>
- <platform>equinox</platform>
- <version>3.7.0.v20110613</version>
- </options>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
</profiles>
</project>
Modified: aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/BasicAppManagerTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/BasicAppManagerTest.java?rev=1602442&r1=1602441&r2=1602442&view=diff
==============================================================================
--- aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/BasicAppManagerTest.java (original)
+++ aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/BasicAppManagerTest.java Fri Jun 13 14:26:31 2014
@@ -18,10 +18,8 @@
*/
package org.apache.aries.application.runtime.itests;
-import static org.apache.aries.itest.ExtraOptions.mavenBundle;
-import static org.apache.aries.itest.ExtraOptions.paxLogging;
-import static org.apache.aries.itest.ExtraOptions.testOptions;
import static org.junit.Assert.assertEquals;
+import static org.ops4j.pax.exam.CoreOptions.*;
import java.io.File;
import java.io.FileOutputStream;
@@ -37,150 +35,144 @@ import org.apache.aries.util.filesystem.
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
-import org.ops4j.pax.exam.junit.MavenConfiguredJUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
-@RunWith(MavenConfiguredJUnit4TestRunner.class)
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
public class BasicAppManagerTest extends AbstractIntegrationTest {
-
- /* Use @Before not @BeforeClass so as to ensure that these resources
- * are created in the paxweb temp directory, and not in the svn tree
- */
- static boolean createdApplications = false;
- @Before
- public static void createApplications() throws Exception {
- if (createdApplications) {
- return;
+
+ /* Use @Before not @BeforeClass so as to ensure that these resources
+ * are created in the paxweb temp directory, and not in the svn tree
+ */
+ static boolean createdApplications = false;
+
+ @Before
+ public void createApplications() throws Exception {
+ if (createdApplications) {
+ return;
+ }
+ ZipFixture testEba = ArchiveFixture.newZip()
+ .jar("sample.jar")
+ .manifest().symbolicName("org.apache.aries.sample")
+ .attribute("Bundle-Version", "1.0.0")
+ .attribute("Import-Package", "org.apache.aries.sample")
+ .end()
+ .binary("org/apache/aries/sample/impl/HelloWorldImpl.class",
+ BasicAppManagerTest.class.getClassLoader().getResourceAsStream("org/apache/aries/sample/impl/HelloWorldImpl.class"))
+ .binary("OSGI-INF/blueprint/sample-blueprint.xml",
+ BasicAppManagerTest.class.getClassLoader().getResourceAsStream("basic/sample-blueprint.xml"))
+ .end();
+
+ FileOutputStream fout = new FileOutputStream("test.eba");
+ testEba.writeOut(fout);
+ fout.close();
+
+ ZipFixture testEba2 = testEba.binary("META-INF/APPLICATION.MF",
+ BasicAppManagerTest.class.getClassLoader().getResourceAsStream("basic/APPLICATION.MF"))
+ .end();
+ fout = new FileOutputStream("test2.eba");
+ testEba2.writeOut(fout);
+ fout.close();
+ createdApplications = true;
+ }
+
+ @Test
+ public void testAppWithoutApplicationManifest() throws Exception {
+
+ AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
+ AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test.eba")));
+
+ // application name should be equal to eba name since application.mf is not provided
+ assertEquals("test.eba", app.getApplicationMetadata().getApplicationName());
+ AriesApplicationContext ctx = manager.install(app);
+ ctx.start();
+
+ HelloWorld hw = context().getService(HelloWorld.class);
+ String result = hw.getMessage();
+ assertEquals(result, "hello world");
+
+ ctx.stop();
+ manager.uninstall(ctx);
+ }
+
+ @Test
+ public void testAppWithApplicationManifest() throws Exception {
+ AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
+ AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
+
+ // application name should equal to whatever Application name provided in the application.mf
+ assertEquals("test application 2", app.getApplicationMetadata().getApplicationName());
+
+ AriesApplicationContext ctx = manager.install(app);
+ ctx.start();
+
+ HelloWorld hw = context().getService(HelloWorld.class);
+ String result = hw.getMessage();
+ assertEquals(result, "hello world");
+
+ ctx.stop();
+ manager.uninstall(ctx);
+ }
+
+ @Test
+ public void testAppStore() throws Exception {
+ AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
+ AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
+ app = manager.resolve(app);
+
+ app.store(new FileOutputStream("test2-resolved.eba"));
+
+ app = manager.createApplication(FileSystem.getFSRoot(new File("test2-resolved.eba")));
+
+ // application name should equal to whatever Application name provided in the application.mf
+ assertEquals("test application 2", app.getApplicationMetadata().getApplicationName());
+
+ AriesApplicationContext ctx = manager.install(app);
+ ctx.start();
+
+ HelloWorld hw = context().getService(HelloWorld.class);
+ String result = hw.getMessage();
+ assertEquals(result, "hello world");
+
+ ctx.stop();
+ manager.uninstall(ctx);
+ }
+
+ @Configuration
+ public static Option[] configuration() {
+ return options(
+
+ // framework / core bundles
+ mavenBundle("org.osgi", "org.osgi.core").versionAsInProject(),
+ mavenBundle("org.osgi", "org.osgi.compendium").versionAsInProject(),
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-api").versionAsInProject(),
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-service").versionAsInProject(),
+
+ // Logging
+ systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
+
+ // Bundles
+ junitBundles(),
+ mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.api").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.management").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.default.local.platform").versionAsInProject(),
+ mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.obr").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.itest.interfaces").versionAsInProject(),
+ mavenBundle("org.apache.aries", "org.apache.aries.util").versionAsInProject(),
+ mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint").versionAsInProject(),
+ mavenBundle("org.ow2.asm", "asm-all").versionAsInProject(),
+ mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy").versionAsInProject()
+ );
}
- ZipFixture testEba = ArchiveFixture.newZip()
- .jar("sample.jar")
- .manifest().symbolicName("org.apache.aries.sample")
- .attribute("Bundle-Version", "1.0.0")
- .attribute("Import-Package", "org.apache.aries.sample")
- .end()
- .binary("org/apache/aries/sample/impl/HelloWorldImpl.class",
- BasicAppManagerTest.class.getClassLoader().getResourceAsStream("org/apache/aries/sample/impl/HelloWorldImpl.class"))
- .binary("OSGI-INF/blueprint/sample-blueprint.xml",
- BasicAppManagerTest.class.getClassLoader().getResourceAsStream("basic/sample-blueprint.xml"))
- .end();
-
- FileOutputStream fout = new FileOutputStream("test.eba");
- testEba.writeOut(fout);
- fout.close();
-
- ZipFixture testEba2 = testEba.binary("META-INF/APPLICATION.MF",
- BasicAppManagerTest.class.getClassLoader().getResourceAsStream("basic/APPLICATION.MF"))
- .end();
- fout = new FileOutputStream("test2.eba");
- testEba2.writeOut(fout);
- fout.close();
- createdApplications = true;
- }
-
- @Test
- public void testAppWithoutApplicationManifest() throws Exception {
-
- AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
- AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test.eba")));
-
- // application name should be equal to eba name since application.mf is not provided
- assertEquals("test.eba", app.getApplicationMetadata().getApplicationName());
- AriesApplicationContext ctx = manager.install(app);
- ctx.start();
-
- HelloWorld hw = context().getService(HelloWorld.class);
- String result = hw.getMessage();
- assertEquals (result, "hello world");
-
- ctx.stop();
- manager.uninstall(ctx);
- }
-
- @Test
- public void testAppWithApplicationManifest() throws Exception {
- AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
- AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
-
- // application name should equal to whatever Application name provided in the application.mf
- assertEquals("test application 2", app.getApplicationMetadata().getApplicationName());
-
- AriesApplicationContext ctx = manager.install(app);
- ctx.start();
-
- HelloWorld hw = context().getService(HelloWorld.class);
- String result = hw.getMessage();
- assertEquals (result, "hello world");
-
- ctx.stop();
- manager.uninstall(ctx);
- }
-
- @Test
- public void testAppStore() throws Exception {
- AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
- AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
- app = manager.resolve(app);
-
- app.store(new FileOutputStream("test2-resolved.eba"));
-
- app = manager.createApplication(FileSystem.getFSRoot(new File("test2-resolved.eba")));
-
- // application name should equal to whatever Application name provided in the application.mf
- assertEquals("test application 2", app.getApplicationMetadata().getApplicationName());
-
- AriesApplicationContext ctx = manager.install(app);
- ctx.start();
-
- HelloWorld hw = context().getService(HelloWorld.class);
- String result = hw.getMessage();
- assertEquals (result, "hello world");
-
- ctx.stop();
- manager.uninstall(ctx);
- }
-
-
- private static Option[] generalConfiguration() {
- return testOptions(
- paxLogging("DEBUG"),
-
- // Bundles
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.api"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.management"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.default.local.platform"),
- mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.obr"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.itest.interfaces"),
- mavenBundle("org.apache.aries", "org.apache.aries.util"),
- mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
- mavenBundle("org.ow2.asm", "asm-all"),
- mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
- mavenBundle("org.osgi", "org.osgi.compendium"));
-
-
- /* For debugging, uncomment the next two lines
- vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"),
- waitForFrameworkStartup(),
-
- and add these imports:
- import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
- import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
- */
-
- }
-
- @org.ops4j.pax.exam.junit.Configuration
- public static Option[] configuration()
- {
- return testOptions(
- generalConfiguration(),
- PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties")
- );
- }
}
Modified: aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/BasicNoOpResolverTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/BasicNoOpResolverTest.java?rev=1602442&r1=1602441&r2=1602442&view=diff
==============================================================================
--- aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/BasicNoOpResolverTest.java (original)
+++ aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/BasicNoOpResolverTest.java Fri Jun 13 14:26:31 2014
@@ -18,9 +18,7 @@
*/
package org.apache.aries.application.runtime.itests;
-import static org.apache.aries.itest.ExtraOptions.mavenBundle;
-import static org.apache.aries.itest.ExtraOptions.paxLogging;
-import static org.apache.aries.itest.ExtraOptions.testOptions;
+import static org.ops4j.pax.exam.CoreOptions.*;
import static org.junit.Assert.assertEquals;
import java.io.File;
@@ -37,125 +35,119 @@ import org.apache.aries.util.filesystem.
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
-import org.ops4j.pax.exam.junit.MavenConfiguredJUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
-@RunWith(MavenConfiguredJUnit4TestRunner.class)
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
public class BasicNoOpResolverTest extends AbstractIntegrationTest {
-
- /* Use @Before not @BeforeClass so as to ensure that these resources
- * are created in the paxweb temp directory, and not in the svn tree
- */
- static boolean createdApplications = false;
- @Before
- public static void createApplications() throws Exception {
- if (createdApplications) {
- return;
+
+ /* Use @Before not @BeforeClass so as to ensure that these resources
+ * are created in the paxweb temp directory, and not in the svn tree
+ */
+ static boolean createdApplications = false;
+
+ @Before
+ public void createApplications() throws Exception {
+ if (createdApplications) {
+ return;
+ }
+ ZipFixture testEba = ArchiveFixture.newZip()
+ .jar("sample.jar")
+ .manifest().symbolicName("org.apache.aries.sample")
+ .attribute("Bundle-Version", "1.0.0")
+ .attribute("Import-Package", "org.apache.aries.sample")
+ .end()
+ .binary("org/apache/aries/sample/impl/HelloWorldImpl.class",
+ BasicAppManagerTest.class.getClassLoader().getResourceAsStream("org/apache/aries/sample/impl/HelloWorldImpl.class"))
+ .binary("OSGI-INF/blueprint/sample-blueprint.xml",
+ BasicAppManagerTest.class.getClassLoader().getResourceAsStream("basic/sample-blueprint.xml"))
+ .end();
+
+ FileOutputStream fout = new FileOutputStream("test.eba");
+ testEba.writeOut(fout);
+ fout.close();
+
+ ZipFixture testEba2 = testEba.binary("META-INF/APPLICATION.MF",
+ BasicAppManagerTest.class.getClassLoader().getResourceAsStream("basic/APPLICATION.MF"))
+ .end();
+ fout = new FileOutputStream("test2.eba");
+ testEba2.writeOut(fout);
+ fout.close();
+ createdApplications = true;
+ }
+
+ @Test
+ public void testAppWithoutApplicationManifest() throws Exception {
+
+ AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
+ AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test.eba")));
+
+ // application name should be equal to eba name since application.mf is not provided
+ assertEquals("test.eba", app.getApplicationMetadata().getApplicationName());
+ AriesApplicationContext ctx = manager.install(app);
+ ctx.start();
+
+ HelloWorld hw = context().getService(HelloWorld.class);
+ String result = hw.getMessage();
+ assertEquals(result, "hello world");
+
+ ctx.stop();
+ manager.uninstall(ctx);
+ }
+
+ @Test
+ public void testAppWithApplicationManifest() throws Exception {
+ AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
+ AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
+
+ // application name should equal to whatever Application name provided in the application.mf
+ assertEquals("test application 2", app.getApplicationMetadata().getApplicationName());
+
+ AriesApplicationContext ctx = manager.install(app);
+ ctx.start();
+
+ HelloWorld hw = context().getService(HelloWorld.class);
+ String result = hw.getMessage();
+ assertEquals(result, "hello world");
+
+ ctx.stop();
+ manager.uninstall(ctx);
+ }
+
+ @Configuration
+ public static Option[] configuration() {
+ return options(
+
+ // framework / core bundles
+ mavenBundle("org.osgi", "org.osgi.core").versionAsInProject(),
+ mavenBundle("org.osgi", "org.osgi.compendium").versionAsInProject(),
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-api").versionAsInProject(),
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-service").versionAsInProject(),
+
+ // Logging
+ systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+
+ // Bundles
+ junitBundles(),
+ mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
+ mavenBundle("org.osgi", "org.osgi.compendium").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.api").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.default.local.platform").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.management").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.noop").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.itest.interfaces").versionAsInProject(),
+ mavenBundle("org.apache.aries", "org.apache.aries.util").versionAsInProject(),
+ mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint").versionAsInProject(),
+ mavenBundle("org.ow2.asm", "asm-all").versionAsInProject(),
+ mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy").versionAsInProject());
}
- ZipFixture testEba = ArchiveFixture.newZip()
- .jar("sample.jar")
- .manifest().symbolicName("org.apache.aries.sample")
- .attribute("Bundle-Version", "1.0.0")
- .attribute("Import-Package", "org.apache.aries.sample")
- .end()
- .binary("org/apache/aries/sample/impl/HelloWorldImpl.class",
- BasicAppManagerTest.class.getClassLoader().getResourceAsStream("org/apache/aries/sample/impl/HelloWorldImpl.class"))
- .binary("OSGI-INF/blueprint/sample-blueprint.xml",
- BasicAppManagerTest.class.getClassLoader().getResourceAsStream("basic/sample-blueprint.xml"))
- .end();
-
- FileOutputStream fout = new FileOutputStream("test.eba");
- testEba.writeOut(fout);
- fout.close();
-
- ZipFixture testEba2 = testEba.binary("META-INF/APPLICATION.MF",
- BasicAppManagerTest.class.getClassLoader().getResourceAsStream("basic/APPLICATION.MF"))
- .end();
- fout = new FileOutputStream("test2.eba");
- testEba2.writeOut(fout);
- fout.close();
- createdApplications = true;
- }
-
- @Test
- public void testAppWithoutApplicationManifest() throws Exception {
-
- AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
- AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test.eba")));
-
- // application name should be equal to eba name since application.mf is not provided
- assertEquals("test.eba", app.getApplicationMetadata().getApplicationName());
- AriesApplicationContext ctx = manager.install(app);
- ctx.start();
-
- HelloWorld hw = context().getService(HelloWorld.class);
- String result = hw.getMessage();
- assertEquals (result, "hello world");
-
- ctx.stop();
- manager.uninstall(ctx);
- }
-
- @Test
- public void testAppWithApplicationManifest() throws Exception {
- AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
- AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
-
- // application name should equal to whatever Application name provided in the application.mf
- assertEquals("test application 2", app.getApplicationMetadata().getApplicationName());
-
- AriesApplicationContext ctx = manager.install(app);
- ctx.start();
-
- HelloWorld hw = context().getService(HelloWorld.class);
- String result = hw.getMessage();
- assertEquals (result, "hello world");
-
- ctx.stop();
- manager.uninstall(ctx);
- }
-
-
- private static Option[] generalConfiguration() {
- return testOptions(
- paxLogging("DEBUG"),
-
- // Bundles
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.api"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.default.local.platform"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.management"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.noop"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.itest.interfaces"),
- mavenBundle("org.apache.aries", "org.apache.aries.util"),
- mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
- mavenBundle("org.ow2.asm", "asm-all"),
- mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
- mavenBundle("org.osgi", "org.osgi.compendium"));
-
-
- /* For debugging, uncomment the next two lines
- vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"),
- waitForFrameworkStartup(),
-
- and add these imports:
- import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
- import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
- */
-
- }
-
- @org.ops4j.pax.exam.junit.Configuration
- public static Option[] configuration()
- {
- return testOptions(
- generalConfiguration(),
- PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties")
- );
- }
}
Modified: aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedCfgAdminRuntimeTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedCfgAdminRuntimeTest.java?rev=1602442&r1=1602441&r2=1602442&view=diff
==============================================================================
--- aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedCfgAdminRuntimeTest.java (original)
+++ aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedCfgAdminRuntimeTest.java Fri Jun 13 14:26:31 2014
@@ -18,21 +18,11 @@
*/
package org.apache.aries.application.runtime.itests;
-//import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
+import static org.ops4j.pax.exam.CoreOptions.*;
-import static org.apache.aries.itest.ExtraOptions.mavenBundle;
-import static org.apache.aries.itest.ExtraOptions.mavenBundleInTest;
-import static org.apache.aries.itest.ExtraOptions.paxLogging;
-import static org.apache.aries.itest.ExtraOptions.testOptions;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.repository;
-
-import java.io.File;
-import java.io.FileOutputStream;
+import java.io.*;
import java.net.URL;
-import java.util.Arrays;
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.List;
+import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -53,12 +43,14 @@ import org.apache.aries.util.filesystem.
import org.apache.aries.util.filesystem.IDirectory;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
-import org.ops4j.pax.exam.junit.MavenConfiguredJUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.InvalidSyntaxException;
@@ -73,113 +65,122 @@ import org.osgi.util.tracker.ServiceTrac
/**
* This test suite is responsible for validating that an application can package and use the
* isolated configuration admin deployed. This includes both from Blueprint and manually.
- *
+ * <p/>
* Blueprint Specific:
- *
+ * <p/>
* Note that, the CmNamespaceHandler has been rewired to create a service reference to the configuration
- * admin that resides within the application framework. This will allow the configuration admin bundle
- * activator sufficient time to register a config admin service before the blueprint container for the bundle
+ * admin that resides within the application framework. This will allow the configuration admin bundle
+ * activator sufficient time to register a config admin service before the blueprint container for the bundle
* requiring it is started (i.e. no configuration admin race condition).
- *
+ * <p/>
* Other notes:
- *
+ * <p/>
* In order to avoid boundary issues (i.e. class casting exceptions etc), the actual configuration admin bundle
* classes are loaded from the shared framework. This is necessary as the blueprint-cm bundle refers to the
- * configuration admin classes directly, as we register a configuration admin and managed service in the
+ * configuration admin classes directly, as we register a configuration admin and managed service in the
* application scope, any attempt to use those services from the CM bundle would end up in a class cast exception.
* This is why we use the classes already loaded in the root container, which are imported into the shared framework.
- * Behind the scenes a manifest transformer is used to make sure that the DEPLOYMENT.MF is augmented with the
+ * Behind the scenes a manifest transformer is used to make sure that the DEPLOYMENT.MF is augmented with the
* necessary org.osgi.service.cm package import to make the class space consistent everywhere. From the developers
* perspective, it appears as if they are deploying into a flat container as the wiring magic is hidden when the
* application is created and installed. Note that the config package import only includes the CM API, nothing else.
*
* @version $Rev$ $Date$
*/
-@RunWith(MavenConfiguredJUnit4TestRunner.class)
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
public class IsolatedCfgAdminRuntimeTest extends AbstractIntegrationTest {
-
+
private static final String APP_HWBP = "helloworld-bp.eba";
private static final String APP_HWMN = "helloworld-mn.eba";
private static final List<String> APPLICATIONS = Arrays.asList(APP_HWBP, APP_HWMN);
-
+
/**
* Creates two applications, as follows:
- *
- * - helloworld-bp.eba ------
- * |
- * | This application contains a helloworld bundle which contains an interface and impl for HelloWorld. Upon being started
- * | blueprint will create a new container for this bundle and register the HelloWorld service. The service will be injected
- * | with a message coming from the ConfigurationAdmin service using the PID: helloworld-bp. As a CM property placeholder is
- * | used, a ManagedService will also be registered on the bundles behalf so that further updates can be captured. Note that
- * | the blueprint configuration is wired to reload the container on a configuration update (to allow easier tracking of when
- * | to test service contents etc).
- * |
- * | The application also contains a configuration admin bundle (pulled from Maven).
- * ---------------------------
- *
- * - helloworld-mn.eba -------
- * |
- * | This application contains a helloworld bundle containing an activator that will register itself as a ManagedService for the
- * | PID: helloworld-mn. The activator will also expose out a HelloWorld service. Upon recieving an update from the packaged
- * | Configuration Admin service, the HelloWorld service will be re-registered using the latest configuration, namely the "message".
- * |
- * | The application also contains a configuration admin bundle (pulled from Maven).
- * ---------------------------
- *
+ * <p/>
+ * - helloworld-bp.eba ------
+ * |
+ * | This application contains a helloworld bundle which contains an interface and impl for HelloWorld. Upon being started
+ * | blueprint will create a new container for this bundle and register the HelloWorld service. The service will be injected
+ * | with a message coming from the ConfigurationAdmin service using the PID: helloworld-bp. As a CM property placeholder is
+ * | used, a ManagedService will also be registered on the bundles behalf so that further updates can be captured. Note that
+ * | the blueprint configuration is wired to reload the container on a configuration update (to allow easier tracking of when
+ * | to test service contents etc).
+ * |
+ * | The application also contains a configuration admin bundle (pulled from Maven).
+ * ---------------------------
+ * <p/>
+ * - helloworld-mn.eba -------
+ * |
+ * | This application contains a helloworld bundle containing an activator that will register itself as a ManagedService for the
+ * | PID: helloworld-mn. The activator will also expose out a HelloWorld service. Upon recieving an update from the packaged
+ * | Configuration Admin service, the HelloWorld service will be re-registered using the latest configuration, namely the "message".
+ * |
+ * | The application also contains a configuration admin bundle (pulled from Maven).
+ * ---------------------------
+ *
* @throws Exception
*/
@Before
- public void constructApplications() throws Exception {
-
+ public void constructApplications() throws Exception {
+
Assert.assertNotNull("Could not find Maven URL handler", (new RichBundleContext(context())).getService(URLStreamHandlerService.class, "url.handler.protocol=mvn", 300000));
MavenArtifactProvisionOption configAdminProvisionOption = mavenBundleInTest(getClass().getClassLoader(), "org.apache.felix", "org.apache.felix.configadmin");
Assert.assertNotNull("Unable to lookup config admin maven bundle", configAdminProvisionOption);
URL configAdminUrl = new URL(configAdminProvisionOption.getURL());
-
+
ZipFixture helloWorldBluePrintEba = ArchiveFixture
.newZip()
- .binary("META-INF/APPLICATION.MF",
- IsolatedCfgAdminRuntimeTest.class.getClassLoader()
- .getResourceAsStream("isolated/config/APPLICATION-BP.MF"))
- .binary("org.apache.felix.configadmin.jar", configAdminUrl.openStream())
- .jar("helloworld-bundle.jar")
- .manifest()
- .symbolicName("org.apache.aries.isolated.helloworldbp")
- .attribute("Bundle-Version", "1.0.0")
- .attribute("Import-Package", "org.osgi.service.cm")
- .end()
- .binary("org/apache/aries/isolated/sample/HelloWorld.class",
- IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
- "org/apache/aries/isolated/sample/HelloWorld.class"))
- .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
- IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
- "org/apache/aries/isolated/sample/HelloWorldImpl.class"))
- .binary("OSGI-INF/blueprint/blueprint.xml",
- IsolatedCfgAdminRuntimeTest.class.getClassLoader()
- .getResourceAsStream("isolated/config/blueprint.xml")).end();
+ .binary("META-INF/APPLICATION.MF",
+ IsolatedCfgAdminRuntimeTest.class.getClassLoader()
+ .getResourceAsStream("isolated/config/APPLICATION-BP.MF")
+ )
+ .binary("org.apache.felix.configadmin.jar", configAdminUrl.openStream())
+ .jar("helloworld-bundle.jar")
+ .manifest()
+ .symbolicName("org.apache.aries.isolated.helloworldbp")
+ .attribute("Bundle-Version", "1.0.0")
+ .attribute("Import-Package", "org.osgi.service.cm")
+ .end()
+ .binary("org/apache/aries/isolated/sample/HelloWorld.class",
+ IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
+ "org/apache/aries/isolated/sample/HelloWorld.class")
+ )
+ .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
+ IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
+ "org/apache/aries/isolated/sample/HelloWorldImpl.class")
+ )
+ .binary("OSGI-INF/blueprint/blueprint.xml",
+ IsolatedCfgAdminRuntimeTest.class.getClassLoader()
+ .getResourceAsStream("isolated/config/blueprint.xml")
+ ).end();
ZipFixture helloWorldManualEba = ArchiveFixture
.newZip()
- .binary("META-INF/APPLICATION.MF",
- IsolatedCfgAdminRuntimeTest.class.getClassLoader()
- .getResourceAsStream("isolated/config/APPLICATION-MN.MF"))
- .binary("org.apache.felix.configadmin.jar", configAdminUrl.openStream())
- .jar("helloworld-bundle.jar")
- .manifest()
- .symbolicName("org.apache.aries.isolated.helloworldmn")
- .attribute("Bundle-Version", "1.0.0")
- .attribute("Bundle-Activator", "org.apache.aries.isolated.config.HelloWorldManagedServiceImpl")
- .attribute("Import-Package", "org.osgi.framework,org.osgi.service.cm")
- .end()
- .binary("org/apache/aries/isolated/sample/HelloWorld.class",
- IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
- "org/apache/aries/isolated/sample/HelloWorld.class"))
- .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
- IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
- "org/apache/aries/isolated/sample/HelloWorldImpl.class"))
- .binary("org/apache/aries/isolated/config/HelloWorldManagedServiceImpl.class",
- IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
- "org/apache/aries/isolated/config/HelloWorldManagedServiceImpl.class")).end();
+ .binary("META-INF/APPLICATION.MF",
+ IsolatedCfgAdminRuntimeTest.class.getClassLoader()
+ .getResourceAsStream("isolated/config/APPLICATION-MN.MF")
+ )
+ .binary("org.apache.felix.configadmin.jar", configAdminUrl.openStream())
+ .jar("helloworld-bundle.jar")
+ .manifest()
+ .symbolicName("org.apache.aries.isolated.helloworldmn")
+ .attribute("Bundle-Version", "1.0.0")
+ .attribute("Bundle-Activator", "org.apache.aries.isolated.config.HelloWorldManagedServiceImpl")
+ .attribute("Import-Package", "org.osgi.framework,org.osgi.service.cm")
+ .end()
+ .binary("org/apache/aries/isolated/sample/HelloWorld.class",
+ IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
+ "org/apache/aries/isolated/sample/HelloWorld.class")
+ )
+ .binary("org/apache/aries/isolated/sample/HelloWorldImpl.class",
+ IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
+ "org/apache/aries/isolated/sample/HelloWorldImpl.class")
+ )
+ .binary("org/apache/aries/isolated/config/HelloWorldManagedServiceImpl.class",
+ IsolatedCfgAdminRuntimeTest.class.getClassLoader().getResourceAsStream(
+ "org/apache/aries/isolated/config/HelloWorldManagedServiceImpl.class")
+ ).end();
FileOutputStream fout = new FileOutputStream(APP_HWBP);
helloWorldBluePrintEba.writeOut(fout);
@@ -189,7 +190,7 @@ public class IsolatedCfgAdminRuntimeTest
helloWorldManualEba.writeOut(fout);
fout.close();
}
-
+
/**
* Try and clean up the applications created by {@link #constructApplications()}
*/
@@ -197,7 +198,7 @@ public class IsolatedCfgAdminRuntimeTest
public void deleteApplications() {
for (String application : APPLICATIONS) {
File eba = new File(application);
-
+
if (eba.exists()) {
eba.delete();
}
@@ -207,70 +208,72 @@ public class IsolatedCfgAdminRuntimeTest
/**
* The purpose of this test is to make sure an application that contains an config admin bundle
* can be used by Blueprint. The following steps are performed:
- *
- * - install the application
- * - start the application
- * - assert we have the following services in the isolated service registry (ConfigurationAdmin, ManagedService, HelloWorld)
- * - assert no configuration existed when the CM-PPH was invoked by BP (default message will be the token i.e. ${message})
- * - update the configuration (the message) for the PID (using a primitive boundary proxy), this will cause the blueprint container to reload
- * - check that the re-registered HelloWorld service contains the updated message
- * - clean up
- *
+ * <p/>
+ * - install the application
+ * - start the application
+ * - assert we have the following services in the isolated service registry (ConfigurationAdmin, ManagedService, HelloWorld)
+ * - assert no configuration existed when the CM-PPH was invoked by BP (default message will be the token i.e. ${message})
+ * - update the configuration (the message) for the PID (using a primitive boundary proxy), this will cause the blueprint container to reload
+ * - check that the re-registered HelloWorld service contains the updated message
+ * - clean up
+ *
* @throws Exception
*/
@Test
+ @Ignore
public void testIsolatedCfgAdminBPReload() throws Exception {
validateApplicationConfiguration(
- APP_HWBP,
- "org.apache.aries.helloworldbpapp",
- "helloworld-bp",
- "${message}",
+ APP_HWBP,
+ "org.apache.aries.helloworldbpapp",
+ "helloworld-bp",
+ "${message}",
"blueprint");
}
-
+
/**
* The purpose of this test is to make sure an application that contains an config admin bundle
* can be used by manually. The following steps are performed:
- *
- * - install the application
- * - start the application
- * - assert we have the following services in the isolated service registry (ConfigurationAdmin, ManagedService, HelloWorld)
- * - assert no configuration existed when the CM-PPH was invoked by BP (default message will be the token i.e. ${message})
- * - update the configuration (the message) for the PID (using a primitive boundary proxy), this will cause the HW service to be re-registered ({@link org.apache.aries.isolated.config.HelloWorldManagedServiceImpl}
- * - check that the re-registered HelloWorld service contains the updated message
- * - clean up
- *
+ * <p/>
+ * - install the application
+ * - start the application
+ * - assert we have the following services in the isolated service registry (ConfigurationAdmin, ManagedService, HelloWorld)
+ * - assert no configuration existed when the CM-PPH was invoked by BP (default message will be the token i.e. ${message})
+ * - update the configuration (the message) for the PID (using a primitive boundary proxy), this will cause the HW service to be re-registered ({@link org.apache.aries.isolated.config.HelloWorldManagedServiceImpl}
+ * - check that the re-registered HelloWorld service contains the updated message
+ * - clean up
+ *
* @throws Exception
*/
@Test
- public void testIsolatedCfgAdminManualReload() throws Exception {
+ @Ignore
+ public void testIsolatedCfgAdminManualReload() throws Exception {
validateApplicationConfiguration(
- APP_HWMN,
- "org.apache.aries.helloworldmnapp",
- "helloworld-mn",
- (new HelloWorldImpl()).getMessage(),
+ APP_HWMN,
+ "org.apache.aries.helloworldmnapp",
+ "helloworld-mn",
+ (new HelloWorldImpl()).getMessage(),
"manual");
}
-
+
/**
* Central validation method for verifying configuration can be published and consumed correctly within
* an isolated scope.
- *
- * @param application the application file name
+ *
+ * @param application the application file name
* @param applicationName the application name
- * @param pid the service.pid
- * @param defaultMessage the default message for the HelloWorld service (checked before any configuration updates occur)
- * @param newMessage the new message to set during a configuration update
+ * @param pid the service.pid
+ * @param defaultMessage the default message for the HelloWorld service (checked before any configuration updates occur)
+ * @param newMessage the new message to set during a configuration update
* @throws Exception
*/
private void validateApplicationConfiguration(String application, String applicationName, String pid, String defaultMessage, String newMessage) throws Exception {
-
+
//install and start the application
Context ctx = installApplication(FileSystem.getFSRoot(new File(application)), applicationName);
-
+
//assert we have the services that we're expecting
assertExpectedServices(ctx.getBundleContext(), pid);
-
+
//make sure we have the defaults set
Assert.assertEquals("Invalid message set on the HW service", defaultMessage, IsolationTestUtils.findHelloWorldService(ctx.getBundleContext()).getMessage());
@@ -278,20 +281,20 @@ public class IsolatedCfgAdminRuntimeTest
Dictionary<String, String> dictionary = new Hashtable<String, String>();
dictionary.put("message", newMessage);
Assert.assertTrue("Configuration update failed", executeConfigurationUpdate(ctx.getBundleContext(), pid, dictionary));
-
+
//now make sure we have our new message set in the HW service
Assert.assertEquals("Invalid message set on the HW service", newMessage, IsolationTestUtils.findHelloWorldService(ctx.getBundleContext()).getMessage());
-
+
//clean up
uninstallApplication(ctx);
}
-
+
/**
* Executes a configuration update using the given dictionary. A HelloWorld service will be tracked
* to ensure the configuration was successful (listening for add/remove tracker events).
- *
- * @param ctx the application bundle context
- * @param pid the service-pid to track
+ *
+ * @param ctx the application bundle context
+ * @param pid the service-pid to track
* @param dictionary the dictionary containing updated properties
* @return if the configuration update was successful
* @throws Exception
@@ -299,26 +302,25 @@ public class IsolatedCfgAdminRuntimeTest
private boolean executeConfigurationUpdate(BundleContext ctx, String pid, Dictionary<String, String> dictionary) throws Exception {
boolean result = true;
MonitorTask monitor = new MonitorTask(ctx, "(" + Constants.OBJECTCLASS + "=" + HelloWorld.class.getName() + ")", 2, 1);
-
+
try {
monitor.beginTracking();
result &= (new ConfigurationTask(ctx, pid, dictionary)).execute();
result &= monitor.execute();
- }
- finally {
+ } finally {
monitor.endTracking();
}
-
+
return result;
}
-
+
/**
* Assert that the following services are present in the service registry:
- *
- * - ConfigurationAdmin
- * - ManagedService
- * - HelloWorld
- *
+ * <p/>
+ * - ConfigurationAdmin
+ * - ManagedService
+ * - HelloWorld
+ *
* @param ctx the bundle context
* @param pid the service pid used to register the underlying ManagedService
* @throws Exception
@@ -326,18 +328,18 @@ public class IsolatedCfgAdminRuntimeTest
private void assertExpectedServices(RichBundleContext ctx, String pid) throws Exception {
//assert the CfgAdmin service was registered
Assert.assertNotNull("Missing the ConfigurationAdmin service", ctx.getService(ConfigurationAdmin.class));
-
+
//assert we have the ManagedService exposed
Assert.assertNotNull("Missing the Managed service", ctx.getService(ManagedService.class, "(" + Constants.SERVICE_PID + "=" + pid + ")"));
//now just make sure we can see it through the context of our config admin bundle context (should be in the same scope)
ServiceReference ref = ctx.getServiceReference(ConfigurationAdmin.class.getName());
Assert.assertNotNull("Couldn't find the ManagedService using the ConfigAdmin bundle context", new RichBundleContext(ref.getBundle().getBundleContext()).getService(ManagedService.class, "(" + Constants.SERVICE_PID + "=" + pid + ")"));
-
+
//make sure we have the helloworld service registered
HelloWorld helloWorldBluePrint = IsolationTestUtils.findHelloWorldService(ctx);
- Assert.assertNotNull("Missing the HelloWorld service", helloWorldBluePrint);
+ Assert.assertNotNull("Missing the HelloWorld service", helloWorldBluePrint);
}
-
+
private Context installApplication(IDirectory application, String applicationName) throws Exception {
//install the application and start it
AriesApplicationManager appManager = context().getService(AriesApplicationManager.class);
@@ -347,130 +349,131 @@ public class IsolatedCfgAdminRuntimeTest
return new Context(appCtx, IsolationTestUtils.findIsolatedAppBundleContext(context(), applicationName));
}
-
+
private void uninstallApplication(Context ctx) throws Exception {
AriesApplicationManager appManager = context().getService(AriesApplicationManager.class);
appManager.uninstall(ctx.getApplicationContext());
}
-
+
/**
* Create the configuration for the PAX container
- *
+ *
* @return the various required options
* @throws Exception
*/
- private static Option[] generalConfiguration() throws Exception {
- return testOptions(
+ @org.ops4j.pax.exam.Configuration
+ public static Option[] configuration() throws Exception {
+ return options(
+
+ // framework / core bundles
+ mavenBundle("org.osgi", "org.osgi.core").versionAsInProject(),
+ mavenBundle("org.osgi", "org.osgi.compendium").versionAsInProject(),
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-api").versionAsInProject(),
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-service").versionAsInProject(),
+
+ // Repository
repository("http://repository.ops4j.org/maven2"),
- paxLogging("DEBUG"),
- mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
- mavenBundle("org.ow2.asm", "asm-all"),
- mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
- mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.blueprint"),
- mavenBundle("org.apache.aries", "org.apache.aries.util"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.api"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.default.local.platform"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller"),
- mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.obr"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolve.transform.cm"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.management"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.isolated"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.framework"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.framework.management"),
- mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.repository"),
- mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
- mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec"),
- mavenBundle("org.ops4j.pax.url", "pax-url-mvn"));
- //vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"),
- }
-
- @org.ops4j.pax.exam.junit.Configuration
- public static Option[] configuration() throws Exception
- {
- return testOptions(
- generalConfiguration(),
- PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties")
- );
+
+ // Logging
+ systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+
+ // Bundles
+ junitBundles(),
+ mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
+
+ // Bundles
+ mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint").versionAsInProject(),
+ mavenBundle("org.ow2.asm", "asm-all").versionAsInProject(),
+ mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy").versionAsInProject(),
+ mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.blueprint").versionAsInProject(),
+ mavenBundle("org.apache.aries", "org.apache.aries.util").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.api").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.default.local.platform").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.modeller").versionAsInProject(),
+ mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolver.obr").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.resolve.transform.cm").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.deployment.management").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.management").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.isolated").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.framework").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.framework.management").versionAsInProject(),
+ mavenBundle("org.apache.aries.application", "org.apache.aries.application.runtime.repository").versionAsInProject(),
+ mavenBundle("org.apache.felix", "org.apache.felix.configadmin").versionAsInProject(),
+ mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec").versionAsInProject(),
+ mavenBundle("org.ops4j.pax.url", "pax-url-aether").versionAsInProject());
}
/**
* High level interface for executing a unit of work
- *
*
* @version $Rev$ $Date$
*/
- private static interface Task
- {
+ private static interface Task {
/**
* Executes the task logic
- *
+ *
* @return if the task was successful
* @throws Exception
*/
public boolean execute() throws Exception;
}
-
+
/**
* Base class for a task implementation
- *
*
* @version $Rev$ $Date$
*/
- private static abstract class BaseTask implements Task
- {
+ private static abstract class BaseTask implements Task {
private BundleContext ctx;
-
+
public BaseTask(BundleContext ctx) {
this.ctx = ctx;
}
-
+
protected BundleContext getBundleContext() {
return ctx;
}
}
-
+
/**
* Trackable task that allows a service tracker to pickup service registration/un-registration events using the
* supplied filter. Remember that if a service exists matching a filter while opening the underlying tracker
* it will cause a addedService event to be fired, this must be taken into account when instantiating this type
* task. For example if you had a ManagedService present in the container matching the given filter, you should
* set the expected registerCount as 2 if you expect a re-register to occur due to a container reload etc.
- *
*
* @version $Rev$ $Date$
*/
- public static abstract class TrackableTask extends BaseTask implements Task, ServiceTrackerCustomizer
- {
+ public static abstract class TrackableTask extends BaseTask implements Task, ServiceTrackerCustomizer {
private static final long DEFAULT_TIMEOUT = 5000;
-
+
private String filter;
private ServiceTracker tracker;
private CountDownLatch addedLatch;
private CountDownLatch removedLatch;
-
+
public TrackableTask(BundleContext ctx, String filter) {
this(ctx, filter, 1, 1);
}
-
+
public TrackableTask(BundleContext ctx, String filter, int registerCount) {
this(ctx, filter, registerCount, 0);
}
-
+
public TrackableTask(BundleContext ctx, String filter, int registerCount, int unregisterCount) {
super(ctx);
-
+
this.filter = filter;
this.addedLatch = new CountDownLatch(registerCount);
this.removedLatch = new CountDownLatch(unregisterCount);
this.tracker = null;
}
-
+
/**
* Initiates the underlying service tracker
- *
+ *
* @throws InvalidSyntaxException
*/
protected synchronized void beginTracking() throws InvalidSyntaxException {
@@ -479,7 +482,7 @@ public class IsolatedCfgAdminRuntimeTest
tracker.open();
}
}
-
+
/**
* Stops and clears the underlying service tracker
*/
@@ -489,28 +492,27 @@ public class IsolatedCfgAdminRuntimeTest
tracker = null;
}
}
-
+
/*
* (non-Javadoc)
* @see org.apache.aries.application.runtime.itests.IsolatedCfgAdminRuntimeTest.Task#execute()
*/
public boolean execute() throws Exception {
boolean result = true;
-
+
try {
beginTracking();
doExecute();
result &= addedLatch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
result &= removedLatch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
- }
- finally {
+ } finally {
endTracking();
}
-
+
return result;
}
-
+
/*
* (non-Javadoc)
* @see org.osgi.util.tracker.ServiceTrackerCustomizer#addingService(org.osgi.framework.ServiceReference)
@@ -524,7 +526,7 @@ public class IsolatedCfgAdminRuntimeTest
* (non-Javadoc)
* @see org.osgi.util.tracker.ServiceTrackerCustomizer#modifiedService(org.osgi.framework.ServiceReference, java.lang.Object)
*/
- public void modifiedService(ServiceReference serviceRef, Object service) {
+ public void modifiedService(ServiceReference serviceRef, Object service) {
}
/*
@@ -534,10 +536,10 @@ public class IsolatedCfgAdminRuntimeTest
public synchronized void removedService(ServiceReference serviceRef, Object service) {
removedLatch.countDown();
}
-
+
/**
* Performs the task logic
- *
+ *
* @throws Exception
*/
protected abstract void doExecute() throws Exception;
@@ -547,17 +549,16 @@ public class IsolatedCfgAdminRuntimeTest
* The configuration task is responsible for executing a configuration update within the scope
* of the given context. Note, this task assumes the class space is inconsistent will not try
* casting to classes that may exist in the test world and also in the application.
- *
+ *
* @version $Rev$ $Date$
*/
- private static class ConfigurationTask extends BaseTask
- {
+ private static class ConfigurationTask extends BaseTask {
private String pid;
private Dictionary<String, String> dictionary;
-
- public ConfigurationTask(BundleContext ctx, String pid, Dictionary<String, String> dictionary) {
+
+ public ConfigurationTask(BundleContext ctx, String pid, Dictionary<String, String> dictionary) {
super(ctx);
-
+
this.pid = pid;
this.dictionary = dictionary;
}
@@ -568,42 +569,39 @@ public class IsolatedCfgAdminRuntimeTest
*/
public boolean execute() throws Exception {
boolean result = false;
- ServiceTracker tracker = new ServiceTracker(getBundleContext(), getBundleContext().createFilter("(" + Constants.OBJECTCLASS + "=" + ConfigurationAdmin.class.getName() + ")"), null);
-
+ ServiceTracker tracker = new ServiceTracker(getBundleContext(), getBundleContext().createFilter("(" + Constants.OBJECTCLASS + "=" + ConfigurationAdmin.class.getName() + ")"), null);
+
try {
tracker.open();
Object cfgAdminService = tracker.waitForService(5000);
-
+
if (cfgAdminService != null) {
-
+
ConfigurationAdmin proxy = Skeleton.newMock(cfgAdminService, ConfigurationAdmin.class);
Configuration configuration = proxy.getConfiguration(pid);
configuration.setBundleLocation(null);
configuration.update(dictionary);
result = true;
}
- }
- finally {
+ } finally {
tracker.close();
}
-
+
return result;
}
}
-
+
/**
* Simple monitor class to keep track of services using the supplied filter, acts as a wrapper
* so that it can be placed in side a composite task.
- *
*
* @version $Rev$ $Date$
*/
- private static final class MonitorTask extends TrackableTask
- {
+ private static final class MonitorTask extends TrackableTask {
public MonitorTask(BundleContext ctx, String filter, int registerCount, int unregisterCount) {
super(ctx, filter, registerCount, unregisterCount);
}
-
+
/*
* (non-Javadoc)
* @see org.apache.aries.application.runtime.itests.IsolatedCfgAdminRuntimeTest.TrackableTask#doExecute()
@@ -612,31 +610,74 @@ public class IsolatedCfgAdminRuntimeTest
protected void doExecute() throws Exception {
//do nothing, we just care about tracking
}
-
+
}
-
+
/**
* Simple wrapper for the various contexts required in this test suite
- *
*
* @version $Rev$ $Date$
*/
- private static class Context
- {
+ private static class Context {
private AriesApplicationContext applicationContext;
private RichBundleContext bundleContext;
-
+
public Context(AriesApplicationContext applicationContext, BundleContext bundleContext) {
this.applicationContext = applicationContext;
this.bundleContext = new RichBundleContext(bundleContext);
}
-
+
public AriesApplicationContext getApplicationContext() {
return applicationContext;
}
-
+
public RichBundleContext getBundleContext() {
return bundleContext;
}
}
+
+ public static MavenArtifactProvisionOption mavenBundleInTest(ClassLoader loader, String groupId, String artifactId) {
+ return mavenBundle().groupId(groupId).artifactId(artifactId)
+ .version(getArtifactVersion(loader, groupId, artifactId));
+ }
+
+ //TODO getArtifactVersion and getFileFromClasspath are borrowed and modified from pax-exam. They should be moved back ASAP.
+ private static String getArtifactVersion(ClassLoader loader, final String groupId, final String artifactId) {
+ final Properties dependencies = new Properties();
+ try {
+ InputStream in = getFileFromClasspath(loader, "META-INF/maven/dependencies.properties");
+ try {
+ dependencies.load(in);
+ } finally {
+ in.close();
+ }
+ final String version = dependencies.getProperty(groupId + "/" + artifactId + "/version");
+ if (version == null) {
+ throw new RuntimeException(
+ "Could not resolve version. Do you have a dependency for " + groupId + "/" + artifactId
+ + " in your maven project?"
+ );
+ }
+ return version;
+ } catch (IOException e) {
+ // TODO throw a better exception
+ throw new RuntimeException(
+ "Could not resolve version. Did you configured the plugin in your maven project?"
+ + "Or maybe you did not run the maven build and you are using an IDE?"
+ );
+ }
+ }
+
+ private static InputStream getFileFromClasspath(ClassLoader loader, final String filePath)
+ throws FileNotFoundException {
+ try {
+ URL fileURL = loader.getResource(filePath);
+ if (fileURL == null) {
+ throw new FileNotFoundException("File [" + filePath + "] could not be found in classpath");
+ }
+ return fileURL.openStream();
+ } catch (IOException e) {
+ throw new FileNotFoundException("File [" + filePath + "] could not be found: " + e.getMessage());
+ }
+ }
}