You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2009/08/20 17:58:10 UTC
svn commit: r806231 - in /sling/trunk/installer/osgi:
installer/src/main/java/org/apache/sling/osgi/installer/
installer/src/main/java/org/apache/sling/osgi/installer/impl/
installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/
installer/s...
Author: bdelacretaz
Date: Thu Aug 20 15:58:09 2009
New Revision: 806231
URL: http://svn.apache.org/viewvc?rev=806231&view=rev
Log:
SLING-1078 - bundle priorities added
Added:
sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java (with props)
sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundlePrioritiesTest.java (with props)
Modified:
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java
sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java
sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java
sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java
Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java?rev=806231&r1=806230&r2=806231&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java Thu Aug 20 15:58:09 2009
@@ -31,6 +31,10 @@
private final String digest;
private final InputStream inputStream;
private final Dictionary<String, Object> dictionary;
+ private int priority;
+
+ /** Default resource priority */
+ public static final int DEFAULT_PRIORITY = 100;
/** Create an empty data object, used when removing resources */
public InstallableResource(String url) {
@@ -39,6 +43,7 @@
this.inputStream = null;
this.dictionary = null;
this.digest = null;
+ this.priority = DEFAULT_PRIORITY;
}
/** Create a data object that wraps an InputStream
@@ -56,6 +61,7 @@
this.inputStream = is;
this.dictionary = null;
this.digest = digest;
+ this.priority = DEFAULT_PRIORITY;
}
/** Create a data object that wraps a Dictionary. Digest will be computed
@@ -73,6 +79,7 @@
this.inputStream = null;
this.dictionary = d;
this.digest = null;
+ this.priority = DEFAULT_PRIORITY;
}
@Override
@@ -94,19 +101,40 @@
return url;
}
+ /** Return this resource's extension, based on its URL */
public String getExtension() {
return extension;
}
+ /** Return an input stream with the data of this resource. Null if resource
+ * contains a dictionary instead. Caller is responsible for closing the stream.
+ */
public InputStream getInputStream() {
return inputStream;
}
+ /** Return this resource's dictionary. Null if resource contains an InputStream instead */
public Dictionary<String, Object> getDictionary() {
return dictionary;
}
-
+
+ /** Return this resource's digest. Not necessarily an actual md5 or other digest of the
+ * data, can be any string that changes if the data changes.
+ */
public String getDigest() {
return digest;
}
+
+ /** Return the priority of this resource. Priorities are used to decide which
+ * resource to install when several are registered for the same OSGi entity
+ * (bundle, config, etc.)
+ */
+ public int getPriority() {
+ return priority;
+ }
+
+ /** Set the priority of this resource */
+ public void setPriority(int priority) {
+ this.priority = priority;
+ }
}
Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java?rev=806231&r1=806230&r2=806231&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java Thu Aug 20 15:58:09 2009
@@ -50,6 +50,8 @@
void setInstallable(boolean installable);
ResourceType getResourceType();
String getUrlScheme();
+ int getPriority();
+ long getSerialNumber();
/** Attributes include the bundle symbolic name, bundle version, etc. */
Map<String, Object> getAttributes();
Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java?rev=806231&r1=806230&r2=806231&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java Thu Aug 20 15:58:09 2009
@@ -35,18 +35,47 @@
}
int compareBundles(RegisteredResource a, RegisteredResource b) {
+
+ boolean isSnapshot = false;
+ // Order first by symbolic name
final String nameA = (String)a.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME);
final String nameB = (String)b.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME);
int result = nameA.compareTo(nameB);
+ // Then by version
if(result == 0) {
final Version va = (Version)a.getAttributes().get(Constants.BUNDLE_VERSION);
final Version vb = (Version)b.getAttributes().get(Constants.BUNDLE_VERSION);
+ isSnapshot = va.toString().contains(BundleTaskCreator.MAVEN_SNAPSHOT_MARKER);
// higher version has more priority, must come first so invert comparison
result = vb.compareTo(va);
}
+ // Then by priority, higher values first
+ if(result == 0) {
+ if(a.getPriority() < b.getPriority()) {
+ result = 1;
+ } else if(a.getPriority() > b.getPriority()) {
+ result = -1;
+ }
+ }
+
+ if(result == 0) {
+ if(isSnapshot) {
+ // For snapshots, compare serial numbers so that snapshots registered
+ // later get priority
+ if(a.getSerialNumber() < b.getSerialNumber()) {
+ result = 1;
+ } else if(a.getSerialNumber() > b.getSerialNumber()) {
+ result = -1;
+ }
+ } else {
+ // Non-snapshot: compare digests
+ result = a.getDigest().compareTo(b.getDigest());
+ }
+ }
+
return result;
}
Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java?rev=806231&r1=806230&r2=806231&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java Thu Aug 20 15:58:09 2009
@@ -65,6 +65,9 @@
private final Map<String, Object> attributes = new HashMap<String, Object>();
private static long fileNumber;
private boolean installable = true;
+ private final int priority;
+ private final long serialNumber;
+ private static long serialNumberCounter = System.currentTimeMillis();
static enum ResourceType {
BUNDLE,
@@ -88,6 +91,8 @@
url = input.getUrl();
urlScheme = getUrlScheme(url);
resourceType = computeResourceType(input.getExtension());
+ priority = input.getPriority();
+ serialNumber = getNextSerialNumber();
if(resourceType == RegisteredResource.ResourceType.BUNDLE) {
if(input.getInputStream() == null) {
@@ -131,9 +136,15 @@
}
}
+ private static long getNextSerialNumber() {
+ synchronized (RegisteredResourceImpl.class) {
+ return serialNumberCounter++;
+ }
+ }
+
@Override
public String toString() {
- return getClass().getSimpleName() + " " + url + " (" + digest + ")";
+ return getClass().getSimpleName() + " " + url + ", digest=" + digest + ", serialNumber=" + serialNumber;
}
protected File getDataFile(BundleContext ctx) throws IOException {
@@ -320,4 +331,12 @@
public String getUrlScheme() {
return urlScheme;
}
+
+ public int getPriority() {
+ return priority;
+ }
+
+ public long getSerialNumber() {
+ return serialNumber;
+ }
}
\ No newline at end of file
Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java?rev=806231&r1=806230&r2=806231&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java Thu Aug 20 15:58:09 2009
@@ -24,6 +24,7 @@
import org.apache.sling.osgi.installer.impl.RegisteredResource;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
+import org.osgi.service.log.LogService;
/** Update a bundle from a RegisteredResource. Creates
* a bundleStartTask to restart the bundle if it was
@@ -61,6 +62,9 @@
}
b.stop();
b.update(resource.getInputStream());
+ if(ctx.getLogService() != null) {
+ ctx.getLogService().log(LogService.LOG_DEBUG, "Bundle updated: " + b.getBundleId() + "/" + b.getSymbolicName());
+ }
ctx.incrementCounter(OsgiInstaller.OSGI_TASKS_COUNTER);
}
Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java?rev=806231&r1=806230&r2=806231&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java Thu Aug 20 15:58:09 2009
@@ -24,6 +24,7 @@
import java.util.HashMap;
import java.util.Map;
+import org.apache.sling.osgi.installer.InstallableResource;
import org.osgi.framework.Constants;
import org.osgi.framework.Version;
@@ -33,11 +34,44 @@
private final Map<String, Object> attributes = new HashMap<String, Object>();
private boolean installable = true;
private final String digest;
+ private final int priority;
+ private final long serialNumber;
+ private static long serialNumberCounter = System.currentTimeMillis();
- MockBundleResource(String symbolicName, String version) {
+ MockBundleResource(String symbolicName, String version) {
+ this(symbolicName, version, InstallableResource.DEFAULT_PRIORITY);
+ }
+
+ MockBundleResource(String symbolicName, String version, int priority) {
attributes.put(Constants.BUNDLE_SYMBOLICNAME, symbolicName);
attributes.put(Constants.BUNDLE_VERSION, new Version(version));
digest = symbolicName + "." + version;
+ this.priority = priority;
+ serialNumber = getNextSerialNumber();
+ }
+
+ MockBundleResource(String symbolicName, String version, int priority, String digest) {
+ attributes.put(Constants.BUNDLE_SYMBOLICNAME, symbolicName);
+ attributes.put(Constants.BUNDLE_VERSION, new Version(version));
+ this.digest = digest;
+ this.priority = priority;
+ serialNumber = getNextSerialNumber();
+ }
+
+ private static long getNextSerialNumber() {
+ synchronized (MockBundleResource.class) {
+ return serialNumberCounter++;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName()
+ + ", n=" + attributes.get(Constants.BUNDLE_SYMBOLICNAME)
+ + ", v= " + attributes.get(Constants.BUNDLE_VERSION)
+ + ", d=" + digest
+ + ", p=" + priority
+ ;
}
public void cleanup() {
@@ -86,4 +120,12 @@
public void setInstallable(boolean installable) {
this.installable = installable;
}
+
+ public int getPriority() {
+ return priority;
+ }
+
+ public long getSerialNumber() {
+ return serialNumber;
+ }
}
Added: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java?rev=806231&view=auto
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java (added)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java Thu Aug 20 15:58:09 2009
@@ -0,0 +1,122 @@
+/*
+ * 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.osgi.installer.impl;
+
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.junit.Test;
+
+public class RegisteredResourceComparatorTest {
+
+ private void assertOrder(List<RegisteredResource> toTest, RegisteredResource[] inOrder) {
+ assertEquals("Expected sizes to match", toTest.size(), inOrder.length);
+ Collections.sort(toTest, new RegisteredResourceComparator());
+ int i = 0;
+ for(RegisteredResource r : toTest) {
+ final RegisteredResource ref = inOrder[i];
+ assertSame("At index " + i + ", expected toTest and ref to match", ref, r);
+ i++;
+ }
+ }
+
+ private void assertOrder(RegisteredResource[] inOrder) {
+ final List<RegisteredResource> toTest = new ArrayList<RegisteredResource>();
+ for(int i = inOrder.length - 1 ; i >= 0; i--) {
+ toTest.add(inOrder[i]);
+ }
+ assertOrder(toTest, inOrder);
+ toTest.clear();
+ for(RegisteredResource r : inOrder) {
+ toTest.add(r);
+ }
+ assertOrder(toTest, inOrder);
+ }
+
+ @Test
+ public void testBundleName() {
+ final RegisteredResource [] inOrder = {
+ new MockBundleResource("a", "1.0", 10),
+ new MockBundleResource("b", "1.0", 10),
+ new MockBundleResource("c", "1.0", 10),
+ new MockBundleResource("d", "1.0", 10),
+ };
+ assertOrder(inOrder);
+ }
+
+ @Test
+ public void testBundleVersion() {
+ final RegisteredResource [] inOrder = {
+ new MockBundleResource("a", "1.2.51", 10),
+ new MockBundleResource("a", "1.2.4", 10),
+ new MockBundleResource("a", "1.1.0", 10),
+ new MockBundleResource("a", "1.0.6", 10),
+ new MockBundleResource("a", "1.0.0", 10),
+ };
+ assertOrder(inOrder);
+ }
+
+ @Test
+ public void testBundlePriority() {
+ final RegisteredResource [] inOrder = {
+ new MockBundleResource("a", "1.0.0", 101),
+ new MockBundleResource("a", "1.0.0", 10),
+ new MockBundleResource("a", "1.0.0", 0),
+ new MockBundleResource("a", "1.0.0", -5),
+ };
+ assertOrder(inOrder);
+ }
+
+ @Test
+ public void testComposite() {
+ final RegisteredResource [] inOrder = {
+ new MockBundleResource("a", "1.2.0"),
+ new MockBundleResource("a", "1.0.0"),
+ new MockBundleResource("b", "1.0.0", 2),
+ new MockBundleResource("b", "1.0.0", 0),
+ new MockBundleResource("c", "1.5.0", -5),
+ new MockBundleResource("c", "1.4.0", 50),
+ };
+ assertOrder(inOrder);
+ }
+
+ @Test
+ public void testDigest() {
+ final RegisteredResource [] inOrder = {
+ new MockBundleResource("a", "1.2.0", 0, "digestA"),
+ new MockBundleResource("a", "1.2.0", 0, "digestB"),
+ new MockBundleResource("a", "1.2.0", 0, "digestC"),
+ };
+ assertOrder(inOrder);
+ }
+
+ @Test
+ public void testSnapshotSerialNumber() {
+ // Verify that snapshots with a higher serial number come first
+ final RegisteredResource [] inOrder = new RegisteredResource [3];
+ inOrder[2] = new MockBundleResource("a", "1.2.0.SNAPSHOT", 0, "digestC");
+ inOrder[1] = new MockBundleResource("a", "1.2.0.SNAPSHOT", 0, "digestB");
+ inOrder[0] = new MockBundleResource("a", "1.2.0.SNAPSHOT", 0, "digestA");
+ assertOrder(inOrder);
+ }
+}
\ No newline at end of file
Propchange: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Added: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundlePrioritiesTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundlePrioritiesTest.java?rev=806231&view=auto
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundlePrioritiesTest.java (added)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundlePrioritiesTest.java Thu Aug 20 15:58:09 2009
@@ -0,0 +1,85 @@
+/*
+ * 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.osgi.installer.it;
+
+import static org.junit.Assert.assertNull;
+
+import java.io.IOException;
+
+import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.OsgiInstaller;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.Bundle;
+
+@RunWith(JUnit4TestRunner.class)
+public class BundlePrioritiesTest extends OsgiInstallerTestBase {
+ @org.ops4j.pax.exam.junit.Configuration
+ public static Option[] configuration() {
+ return defaultConfiguration();
+ }
+
+ @Before
+ public void setUp() {
+ setupInstaller();
+ }
+
+ @After
+ public void tearDown() {
+ super.tearDown();
+ }
+
+ @Test
+ /** Use snapshots, it's the only bundles which are updated even if their version doesn't change */
+ public void testPrioritiesUsingSnapshots() throws IOException {
+ // Install test bundle
+ final String symbolicName = "osgi-installer-snapshot-test";
+ assertNull("Snapshot test bundle must be absent before installing", findBundle(symbolicName));
+
+ final int lowPriority = InstallableResource.DEFAULT_PRIORITY - 1;
+ final int highPriority = InstallableResource.DEFAULT_PRIORITY + 1;
+
+ {
+ resetCounters();
+ installer.addResource(getInstallableResource(
+ getTestBundle(BUNDLE_BASE_NAME + "-snap.jar"), "digest1"));
+ // wait for two tasks: install and start
+ waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2);
+ assertBundle("Initial install", symbolicName, null, Bundle.ACTIVE);
+ }
+
+ {
+ installer.addResource(getInstallableResource(
+ getTestBundle(BUNDLE_BASE_NAME + "-snap.jar"), "digest2", lowPriority));
+ assertNoOsgiTasks("Low-priority snapshot updated must be ignored");
+ }
+
+ {
+ resetCounters();
+ installer.addResource(getInstallableResource(
+ getTestBundle(BUNDLE_BASE_NAME + "-snap.jar"), "digest3", highPriority));
+ // wait for two tasks: update and restart
+ waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2);
+ }
+
+ assertNoOsgiTasks("At end of test");
+ }
+}
Propchange: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundlePrioritiesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundlePrioritiesTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java?rev=806231&r1=806230&r2=806231&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java (original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java Thu Aug 20 15:58:09 2009
@@ -192,11 +192,17 @@
}
protected InstallableResource getInstallableResource(File testBundle, String digest) throws IOException {
+ return getInstallableResource(testBundle, digest, InstallableResource.DEFAULT_PRIORITY);
+ }
+
+ protected InstallableResource getInstallableResource(File testBundle, String digest, int priority) throws IOException {
final String url = URL_SCHEME + ":" + testBundle.getAbsolutePath();
if(digest == null) {
digest = testBundle.getAbsolutePath() + testBundle.lastModified();
}
- return new InstallableResource(url, new FileInputStream(testBundle), digest);
+ final InstallableResource result = new InstallableResource(url, new FileInputStream(testBundle), digest);
+ result.setPriority(priority);
+ return result;
}
protected void waitForConfigAdmin(boolean shouldBePresent) throws InterruptedException {
Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java?rev=806231&r1=806230&r2=806231&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java (original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java Thu Aug 20 15:58:09 2009
@@ -29,6 +29,8 @@
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertFalse;
@@ -71,7 +73,7 @@
}
@Test
- public void removeAndReaddBundlesTest() throws IOException {
+ public void removeAndReaddBundlesTest() throws IOException, BundleException {
{
final List<InstallableResource> r = new ArrayList<InstallableResource>();
r.add(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testB-1.0.jar")));
@@ -126,9 +128,13 @@
final String info = "After re-adding missing bundles";
assertBundle(info, "osgi-installer-testB", "1.0", Bundle.ACTIVE);
- assertBundle(info, "osgi-installer-needsB", "1.0", Bundle.ACTIVE);
assertBundle(info, "osgi-installer-testbundle", "1.2", Bundle.ACTIVE);
assertBundle(info, "osgi-installer-snapshot-test", "1.0.0.SNAPSHOT", Bundle.ACTIVE);
+
+ final Bundle b = findBundle("osgi-installer-needsB");
+ b.start();
+ assertBundle("After reinstalling testB, needsB must be startable, ",
+ "osgi-installer-needsB", "1.0", Bundle.ACTIVE);
}
}
}