Author: bdelacretaz
Date: Tue Jul 7 12:16:01 2009
New Revision: 791809
URL: http://svn.apache.org/viewvc?rev=791809&view=rev
Log:
SLING-905 - testBundleDependencies added, checks that bundle installs are
retried
Added:
sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/a/
sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/a/ClassA.java
(with props)
sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/b/
sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/b/ClassB.java
(with props)
Modified:
sling/trunk/contrib/extensions/jcrinstall/it/pom.xml
sling/trunk/contrib/extensions/jcrinstall/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/OsgiControllerTest.java
Modified: sling/trunk/contrib/extensions/jcrinstall/it/pom.xml
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/it/pom.xml?rev=791809&r1=791808&r2=791809&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/jcrinstall/it/pom.xml (original)
+++ sling/trunk/contrib/extensions/jcrinstall/it/pom.xml Tue Jul 7 12:16:01
2009
@@ -194,12 +194,40 @@
</goals>
<configuration>
<classifier>testB-1.0</classifier>
+ <includes>
+ <include>**/a/**</include>
+ <include>META-INF/**</include>
+ </includes>
<archive>
<manifestEntries>
<Manifest-Version>2</Manifest-Version>
<Bundle-Name>JCRinstall test
bundle</Bundle-Name>
<Bundle-SymbolicName>jcrinstall-testB</Bundle-SymbolicName>
<Bundle-Version>1.0</Bundle-Version>
+
<Export-Package>org.apache.sling.jcr.jcrinstall.it.a;version="1.0"</Export-Package>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </execution>
+ <execution>
+ <id>needsB-1.0</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ <configuration>
+ <classifier>needsB</classifier>
+ <includes>
+ <include>**/b/**</include>
+ <include>META-INF/**</include>
+ </includes>
+ <archive>
+ <manifestEntries>
+ <Manifest-Version>2</Manifest-Version>
+ <Bundle-Name>JCRinstall test
bundle</Bundle-Name>
+
<Bundle-SymbolicName>jcrinstall-needsB</Bundle-SymbolicName>
+ <Bundle-Version>1.0</Bundle-Version>
+
<Import-Package>org.apache.sling.jcr.jcrinstall.it.a;version="1.0"</Import-Package>
</manifestEntries>
</archive>
</configuration>
Added:
sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/a/ClassA.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/a/ClassA.java?rev=791809&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/a/ClassA.java
(added)
+++
sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/a/ClassA.java
Tue Jul 7 12:16:01 2009
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.jcr.jcrinstall.it.a;
+
+/** Dummy class used in test bundles */
+public class ClassA {
+}
Propchange:
sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/a/ClassA.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/a/ClassA.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Added:
sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/b/ClassB.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/b/ClassB.java?rev=791809&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/b/ClassB.java
(added)
+++
sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/b/ClassB.java
Tue Jul 7 12:16:01 2009
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.jcr.jcrinstall.it.b;
+
+import org.apache.sling.jcr.jcrinstall.it.a.ClassA;
+
+/** Dummy class used in test bundles */
+public class ClassB {
+ ClassA a = new ClassA();
+}
Propchange:
sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/b/ClassB.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/b/ClassB.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Modified:
sling/trunk/contrib/extensions/jcrinstall/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/OsgiControllerTest.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/OsgiControllerTest.java?rev=791809&r1=791808&r2=791809&view=diff
==============================================================================
---
sling/trunk/contrib/extensions/jcrinstall/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/OsgiControllerTest.java
(original)
+++
sling/trunk/contrib/extensions/jcrinstall/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/OsgiControllerTest.java
Tue Jul 7 12:16:01 2009
@@ -20,6 +20,7 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.ops4j.pax.exam.CoreOptions.felix;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
@@ -46,10 +47,17 @@
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
-/** Test the OsgiController running in the OSGi framework */
+/** Test the OsgiController running in the OSGi framework
+ *
+ * This is a rather big test class, as Pax Exam currently starts
+ * the framework for each test class - having all tests here
+ * (as long as it's practical) allows them to run faster.
+ *
+ */
@RunWith(JUnit4TestRunner.class)
public class OsgiControllerTest {
public final static String POM_VERSION =
System.getProperty("jcrinstall.pom.version");
+ public final static String JAR_EXT = ".jar";
@Inject
protected BundleContext bundleContext;
@@ -170,7 +178,7 @@
@Test
public void testInstallUpgradeDowngradeBundle() throws Exception {
final String symbolicName = "jcrinstall-testbundle";
- final String uri = symbolicName + ".jar";
+ final String uri = symbolicName + JAR_EXT;
final String BUNDLE_VERSION = "Bundle-Version";
assertNull("Test bundle must not be present before test",
findBundle(symbolicName));
@@ -253,7 +261,7 @@
// Execute some OsgiController operations
final String symbolicName = "jcrinstall-testbundle";
- final String uri = symbolicName + ".jar";
+ final String uri = symbolicName + JAR_EXT;
final String BUNDLE_VERSION = "Bundle-Version";
c.scheduleInstallOrUpdate(uri,
new
SimpleFileInstallableData(getTestBundle("org.apache.sling.jcr.jcrinstall.it-" +
POM_VERSION + "-testbundle-1.1.jar")));
@@ -273,6 +281,46 @@
assertEquals("Bundle A must be started", Bundle.ACTIVE,
findBundle("jcrinstall-testA").getState());
assertEquals("Bundle B must be stopped", Bundle.RESOLVED,
findBundle("jcrinstall-testB").getState());
}
+
+ /** needsB bundle requires testB, try loading needsB first,
+ * then testB, and verify that in the end needsB is started
+ */
+ @Test
+ public void testBundleDependencies() throws Exception {
+ final OsgiController c = getService(OsgiController.class);
+
+ final String testB = "jcrinstall-testB";
+ final String needsB = "jcrinstall-needsB";
+
+ {
+ final Bundle b = findBundle(testB);
+ if(b != null) {
+ c.scheduleUninstall(testB + JAR_EXT);
+ c.executeScheduledOperations();
+ }
+ assertNull(testB + " bundle must not be installed before test",
findBundle(testB));
+ }
+
+ // without testB, needsB must not start
+ {
+ c.scheduleInstallOrUpdate(needsB + JAR_EXT,
+ new
SimpleFileInstallableData(getTestBundle("org.apache.sling.jcr.jcrinstall.it-" +
POM_VERSION + "-needsB.jar")));
+ c.executeScheduledOperations();
+ final Bundle b = findBundle(needsB);
+ assertNotNull(needsB + " must be installed", b);
+ assertFalse(needsB + " must not be started, testB not present",
b.getState() == Bundle.ACTIVE);
+ }
+
+ // now install testB -> needsB must start
+ {
+ c.scheduleInstallOrUpdate(testB + JAR_EXT,
+ new
SimpleFileInstallableData(getTestBundle("org.apache.sling.jcr.jcrinstall.it-" +
POM_VERSION + "-testB-1.0.jar")));
+ c.executeScheduledOperations();
+ final Bundle b = findBundle(needsB);
+ assertNotNull(needsB + " must be installed", b);
+ assertTrue(needsB + " must be started now that testB is
installed", b.getState() == Bundle.ACTIVE);
+ }
+ }
@org.ops4j.pax.exam.junit.Configuration
public static Option[] configuration() {