Merge branch 'master' of ssh://git.eclipse.org/gitroot/virgo/org.eclipse.virgo.osgi-test-stubs
diff --git a/build.properties b/build.properties
index 8d608ca..24e74e0 100644
--- a/build.properties
+++ b/build.properties
@@ -1,4 +1,4 @@
-version=3.1.0
+version=3.5.0
release.type=integration
javadoc.exclude.package.names=**/aspects/,**/internal
natural.name=osgi-test-stubs
diff --git a/build.versions b/build.versions
index e0c4561..cb49e0b 100644
--- a/build.versions
+++ b/build.versions
@@ -1,4 +1,4 @@
org.aspectj=1.6.6.RELEASE
-org.eclipse.osgi=3.7.0.v20110613
-org.eclipse.osgi.services=3.3.0.v20110110
+org.eclipse.osgi=3.7.1.R37x_v20110808-1106
+org.eclipse.osgi.services=3.3.0.v20110513
org.junit=4.7.0
diff --git a/org.eclipse.virgo.teststubs.osgi/.classpath b/org.eclipse.virgo.teststubs.osgi/.classpath
index f12e826..d4a5050 100644
--- a/org.eclipse.virgo.teststubs.osgi/.classpath
+++ b/org.eclipse.virgo.teststubs.osgi/.classpath
@@ -23,7 +23,7 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="TEST_STUBS_IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-4.7.0.jar" sourcepath="/TEST_STUBS_IVY_CACHE/org.junit/com.springsource.org.junit/4.4.0/com.springsource.org.junit-sources-4.4.0.jar"/>
<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>
- <classpathentry kind="var" path="TEST_STUBS_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi/3.7.0.v20110613/org.eclipse.osgi-3.7.0.v20110613.jar" sourcepath="/TEST_STUBS_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi/3.7.0.v20110613/org.eclipse.osgi-sources-3.7.0.v20110613.jar"/>
- <classpathentry kind="var" path="TEST_STUBS_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi.services/3.3.0.v20110110/org.eclipse.osgi.services-3.3.0.v20110110.jar" sourcepath="/TEST_STUBS_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi.services/3.3.0.v20110110/org.eclipse.osgi.services-sources-3.3.0.v20110110.jar"/>
+ <classpathentry kind="var" path="TEST_STUBS_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi/3.7.1.R37x_v20110808-1106/org.eclipse.osgi-3.7.1.R37x_v20110808-1106.jar" sourcepath="/TEST_STUBS_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi/3.7.1.R37x_v20110808-1106/org.eclipse.osgi-sources-3.7.1.R37x_v20110808-1106.jar"/>
+ <classpathentry kind="var" path="TEST_STUBS_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi.services/3.3.0.v20110513/org.eclipse.osgi.services-3.3.0.v20110513.jar" sourcepath="/TEST_STUBS_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi.services/3.3.0.v20110513/org.eclipse.osgi.services-sources-3.3.0.v20110513.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
diff --git a/org.eclipse.virgo.teststubs.osgi/src/main/java/org/eclipse/virgo/teststubs/osgi/framework/StubBundle.java b/org.eclipse.virgo.teststubs.osgi/src/main/java/org/eclipse/virgo/teststubs/osgi/framework/StubBundle.java
index b01e009..957feb9 100644
--- a/org.eclipse.virgo.teststubs.osgi/src/main/java/org/eclipse/virgo/teststubs/osgi/framework/StubBundle.java
+++ b/org.eclipse.virgo.teststubs.osgi/src/main/java/org/eclipse/virgo/teststubs/osgi/framework/StubBundle.java
@@ -703,7 +703,7 @@
* {@inheritDoc}
*/
public int compareTo(Bundle o) {
- int bundleIdCompare = (new Long(o.getBundleId())).compareTo(this.bundleId);
+ int bundleIdCompare = Long.valueOf(o.getBundleId()).compareTo(this.bundleId);
if (bundleIdCompare != 0) {
return bundleIdCompare;
}
diff --git a/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/framework/StubBundleContextTests.java b/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/framework/StubBundleContextTests.java
index 320f35c..791dd48 100644
--- a/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/framework/StubBundleContextTests.java
+++ b/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/framework/StubBundleContextTests.java
@@ -95,6 +95,11 @@
}
@Test
+ public void getBundleByLocation() {
+ assertNull(this.bundleContext.getBundle("testLocation"));
+ }
+
+ @Test
public void getBundleById() {
StubBundle bundle = new StubBundle(25L, "testSymbolicName", new Version(1, 0, 0), "testLocation");
this.bundleContext.addInstalledBundle(bundle);
@@ -299,6 +304,12 @@
assertNotNull(this.bundleContext.getServiceReference(Object.class));
}
+ @Test
+ public void getServiceReferenceNoMatching() throws InvalidSyntaxException {
+ this.bundleContext.addFilter(new FalseTestFilter());
+ this.bundleContext.registerService(Object.class, new Object(), null);
+ assertEquals(0, this.bundleContext.getServiceReferences(Object.class, "falseTestFilter").size());
+ }
@Test
public void getServiceReferenceTwoValues() throws InvalidSyntaxException {
@@ -391,4 +402,22 @@
}
}
+
+ private static class FalseTestFilter extends TestFilter {
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean match(ServiceReference<?> reference) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getFilterString() {
+ return "falseTestFilter";
+ }
+
+ }
}
diff --git a/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/framework/StubBundleTests.java b/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/framework/StubBundleTests.java
index 5e0b6cf..758d9ae 100644
--- a/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/framework/StubBundleTests.java
+++ b/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/framework/StubBundleTests.java
@@ -24,11 +24,7 @@
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.List;
+import java.util.*;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -36,6 +32,7 @@
import org.osgi.framework.BundleException;
import org.osgi.framework.BundleListener;
import org.osgi.framework.Version;
+import org.osgi.framework.startlevel.BundleStartLevel;
public class StubBundleTests {
@@ -465,6 +462,40 @@
assertContains("state", toString);
}
+ @Test
+ public void compareTo() {
+ assertEquals(0, this.bundle.compareTo(this.bundle));
+ assertEquals(0, this.bundle.compareTo(new StubBundle(DEFAULT_BUNDLE_ID, DEFAULT_SYMBOLIC_NAME, DEFAULT_VERSION, DEFAULT_LOCATION)));
+ assertTrue(0 != this.bundle.compareTo(new StubBundle(2L, DEFAULT_SYMBOLIC_NAME, DEFAULT_VERSION, DEFAULT_LOCATION)));
+ assertTrue(0 != this.bundle.compareTo(new StubBundle(DEFAULT_BUNDLE_ID, "testName", DEFAULT_VERSION, DEFAULT_LOCATION)));
+ assertTrue(0 != this.bundle.compareTo(new StubBundle(DEFAULT_BUNDLE_ID, DEFAULT_SYMBOLIC_NAME, new Version(1, 0, 0), DEFAULT_LOCATION)));
+ assertTrue(0 != this.bundle.compareTo(new StubBundle(DEFAULT_BUNDLE_ID, DEFAULT_SYMBOLIC_NAME, DEFAULT_VERSION, "testLocation")));
+ assertEquals(0, this.bundle.compareTo(new StubBundle()));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void compareToNull() {
+ this.bundle.compareTo(null);
+ }
+
+ @Test
+ public void testGetSignerCertificates() {
+ assertEquals(0, this.bundle.getSignerCertificates(0).size());
+ assertEquals(0, this.bundle.getSignerCertificates(7).size());
+ }
+
+ @Test
+ public void adapt() {
+ assertNull(this.bundle.adapt(null));
+ assertNull(this.bundle.adapt(BundleStartLevel.class));
+ }
+
+ @Test
+ public void getDataFile() {
+ assertNull(this.bundle.getDataFile(null));
+ assertNull(this.bundle.getDataFile("testFile"));
+ }
+
private static final class TestInputStream extends InputStream {
@Override
diff --git a/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/service/component/StubComponentContextTests.java b/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/service/component/StubComponentContextTests.java
new file mode 100755
index 0000000..fef3313
--- /dev/null
+++ b/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/service/component/StubComponentContextTests.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 SAP AG
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SAP AG - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.teststubs.osgi.service.component;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+
+import org.eclipse.virgo.teststubs.osgi.framework.StubBundleContext;
+
+public class StubComponentContextTests {
+
+ private StubBundleContext bundleContext = new StubBundleContext();
+
+ private StubComponentContext componentContext = new StubComponentContext(this.bundleContext);
+
+ @Test
+ public void getProperties() {
+ assertNotNull(this.componentContext.getProperties());
+ assertTrue(0 != this.componentContext.getProperties().size());
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void locateServiceWithName() {
+ this.componentContext.locateService("testName");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void locateServiceWithNameAndServiceReference() {
+ this.componentContext.locateService("testName", new ServiceReference<Object>() {
+
+ public int compareTo(Object reference) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Bundle getBundle() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getProperty(String key) {
+ return null;
+ }
+
+ public String[] getPropertyKeys() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Bundle[] getUsingBundles() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isAssignableTo(Bundle bundle, String className) {
+ throw new UnsupportedOperationException();
+ }
+ });
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void locateServices() {
+ this.componentContext.locateServices("testName");
+ }
+
+ @Test
+ public void getBundleContext() {
+ assertEquals(this.bundleContext, this.componentContext.getBundleContext());
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void getUsingBundle() {
+ this.componentContext.getUsingBundle();
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void getComponentInstance() {
+ this.componentContext.getComponentInstance();
+ }
+
+ @Test
+ public void enableComponent() {
+ this.componentContext.enableComponent("testName");
+ }
+
+ @Test
+ public void disableComponent() {
+ this.componentContext.disableComponent("testName");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void getServiceReference() {
+ this.componentContext.getServiceReference();
+ }
+
+}
diff --git a/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/support/FalseFilterTests.java b/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/support/FalseFilterTests.java
index a9c8305..a4b2970 100644
--- a/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/support/FalseFilterTests.java
+++ b/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/support/FalseFilterTests.java
@@ -15,6 +15,7 @@
import static org.junit.Assert.assertFalse;
import java.util.Dictionary;
+import java.util.Map;
import org.junit.Test;
import org.osgi.framework.ServiceReference;
@@ -25,12 +26,12 @@
private final FalseFilter filter = new FalseFilter();
- @SuppressWarnings("unchecked")
@Test
public void match() {
- assertFalse(filter.match((Dictionary) null));
- assertFalse(filter.match((ServiceReference) null));
+ assertFalse(filter.match((Dictionary<String, ?>) null));
+ assertFalse(filter.match((ServiceReference<?>) null));
assertFalse(filter.matchCase(null));
+ assertFalse(filter.matches((Map<String, ?>) null));
}
@Test
diff --git a/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/support/ObjectClassFilterTests.java b/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/support/ObjectClassFilterTests.java
index bc94427..6df0fdb 100644
--- a/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/support/ObjectClassFilterTests.java
+++ b/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/support/ObjectClassFilterTests.java
@@ -16,7 +16,9 @@
import static org.junit.Assert.assertTrue;
import java.util.Dictionary;
+import java.util.HashMap;
import java.util.Hashtable;
+import java.util.Map;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -60,7 +62,7 @@
assertTrue(this.classFilter.match(objectServiceReference));
assertTrue(this.classNameFilter.match(objectServiceReference));
-
+
ServiceReference<Object> exceptionServiceReference = new ServiceReference<Object>() {
public int compareTo(Object reference) {
@@ -92,6 +94,19 @@
assertFalse(this.classNameFilter.match(exceptionServiceReference));
}
+ @Test
+ public void matches() {
+ Map<String, String[]> classNameMap = new HashMap<String, String[]>();
+ classNameMap.put(Constants.OBJECTCLASS, new String[]{Object.class.getName(), Object.class.getName()});
+
+ assertTrue(this.classFilter.matches(classNameMap));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void matchesWithEmptyMap() {
+ this.classFilter.matches(new HashMap<String, Object>());
+ }
+
@SuppressWarnings("unchecked")
@Test
public void matchDictionaryTrue() {
diff --git a/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/support/PropertiesFilterTests.java b/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/support/PropertiesFilterTests.java
index 022dc89..5e98491 100644
--- a/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/support/PropertiesFilterTests.java
+++ b/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/support/PropertiesFilterTests.java
@@ -116,6 +116,47 @@
}));
}
+ @Test
+ public void matchesSameProperties() {
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put("testKey", "testValue");
+ PropertiesFilter filter = new PropertiesFilter(properties);
+
+ assertTrue(filter.matches(properties));
+
+ properties.put("newTestKey", "newTestValue");
+ assertTrue(filter.matches(properties));
+
+ properties.remove("testKey"); //removes from filter
+ assertTrue(filter.matches(properties));
+ }
+
+ @Test
+ public void matchesNewProperties() {
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put("testKey", "testValue");
+ PropertiesFilter filter = new PropertiesFilter(properties);
+
+ Map<String, Object> newProperties = new HashMap<String, Object>();
+ newProperties.put("testKey", "testValue");
+
+ assertTrue(filter.matches(newProperties));
+
+ newProperties.put("newTestKey", "newTestValue");
+ assertTrue(filter.matches(newProperties));
+
+ newProperties.remove("testKey");
+ assertFalse(filter.matches(newProperties));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void matchesNull() {
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put("testKey", "testValue");
+ PropertiesFilter filter = new PropertiesFilter(properties);
+ filter.matches(null);
+ }
+
@SuppressWarnings("unchecked")
@Test
public void matchDictionary() {
diff --git a/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/support/TrueFilterTests.java b/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/support/TrueFilterTests.java
index 2a17c45..3557e6b 100644
--- a/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/support/TrueFilterTests.java
+++ b/org.eclipse.virgo.teststubs.osgi/src/test/java/org/eclipse/virgo/teststubs/osgi/support/TrueFilterTests.java
@@ -15,6 +15,7 @@
import static org.junit.Assert.assertTrue;
import java.util.Dictionary;
+import java.util.Map;
import org.junit.Test;
import org.osgi.framework.ServiceReference;
@@ -28,6 +29,7 @@
assertTrue(filter.match((Dictionary<String, ?>) null));
assertTrue(filter.match((ServiceReference<?>) null));
assertTrue(filter.matchCase(null));
+ assertTrue(filter.matches((Map<String, ?>) null));
}
@Test
diff --git a/virgo-build b/virgo-build
index b640ab8..f5c53ef 160000
--- a/virgo-build
+++ b/virgo-build
@@ -1 +1 @@
-Subproject commit b640ab8b07e3a56d8878ceb2e3be4b2aacb34f06
+Subproject commit f5c53ef245713f342100d49b8c1c85c491740b31