Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2015-03-18 03:12:29 +0000
committerThomas Watson2015-03-18 03:12:29 +0000
commite084bbca47aca2b0d2db640b3707238615c26cb1 (patch)
tree051515840dcdd95adb3fedde2faaaf7f63a68810
parent721e1e1dcbbb41f8a19547c6e7244dc0d68ef9f9 (diff)
downloadrt.equinox.framework-e084bbca47aca2b0d2db640b3707238615c26cb1.tar.gz
rt.equinox.framework-e084bbca47aca2b0d2db640b3707238615c26cb1.tar.xz
rt.equinox.framework-e084bbca47aca2b0d2db640b3707238615c26cb1.zip
Bug 462423 - URLStreamHandlerService registrations
- Add a testcase Change-Id: Iee15b54c61b853ce42e987016bb4c13bfb55c3e4
-rw-r--r--bundles/org.eclipse.osgi.tests/.classpath1
-rw-r--r--bundles/org.eclipse.osgi.tests/build.properties5
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/test.protocol.handler/META-INF/MANIFEST.MF5
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/test.protocol.handler/test/protocol/handler/Activator.java53
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleTests.java3
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java5
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/URLHandlerTests.java34
7 files changed, 102 insertions, 4 deletions
diff --git a/bundles/org.eclipse.osgi.tests/.classpath b/bundles/org.eclipse.osgi.tests/.classpath
index 8e39802d6..aa1bad3a2 100644
--- a/bundles/org.eclipse.osgi.tests/.classpath
+++ b/bundles/org.eclipse.osgi.tests/.classpath
@@ -130,5 +130,6 @@
<classpathentry kind="src" output="bundle_tests/test.system.nls" path="bundles_src/test.system.nls"/>
<classpathentry kind="src" output="bundle_tests/test.bug449484" path="bundles_src/test.bug449484"/>
<classpathentry kind="src" output="bundle_tests/wrapper.hooks.a" path="bundles_src/wrapper.hooks.a"/>
+ <classpathentry kind="src" output="bundle_tests/test.protocol.handler" path="bundles_src/test.protocol.handler"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/bundles/org.eclipse.osgi.tests/build.properties b/bundles/org.eclipse.osgi.tests/build.properties
index d2699ba3d..e654843ba 100644
--- a/bundles/org.eclipse.osgi.tests/build.properties
+++ b/bundles/org.eclipse.osgi.tests/build.properties
@@ -264,6 +264,8 @@ source.bundle_tests/test.bug449484.jar = bundles_src/test.bug449484/
manifest.bundle_tests/test.bug449484.jar = META-INF/MANIFEST.MF
source.bundle_tests/wrapper.hooks.a.jar = bundles_src/wrapper.hooks.a/
manifest.bundle_tests/wrapper.hooks.a.jar = META-INF/MANIFEST.MF
+source.bundle_tests/test.protocol.handler.jar = bundles_src/test.protocol.handler/
+manifest.bundle_tests/test.protocol.handler.jar = META-INF/MANIFEST.MF
jars.compile.order = bundle_tests/ext.framework.b.jar,\
osgitests.jar,\
@@ -391,4 +393,5 @@ jars.compile.order = bundle_tests/ext.framework.b.jar,\
bundle_tests/test.bug438904.global.jar,\
bundle_tests/test.system.nls.jar,\
bundle_tests/test.bug449484.jar,\
- bundle_tests/wrapper.hooks.a.jar
+ bundle_tests/wrapper.hooks.a.jar,\
+ bundle_tests/test.protocol.handler.jar
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.protocol.handler/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/test.protocol.handler/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..9c1517710
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/test.protocol.handler/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: test.protocol.handler
+Bundle-Activator: test.protocol.handler.Activator
+Import-Package: org.osgi.framework, org.osgi.service.url
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.protocol.handler/test/protocol/handler/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.protocol.handler/test/protocol/handler/Activator.java
new file mode 100644
index 000000000..3b317e6cc
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/test.protocol.handler/test/protocol/handler/Activator.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2015 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package test.protocol.handler;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.url.*;
+
+public class Activator extends AbstractURLStreamHandlerService implements BundleActivator {
+ BundleContext bc;
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ bc = context;
+ Dictionary<String, String> props = new Hashtable<String, String>();
+ props.put(URLConstants.URL_HANDLER_PROTOCOL, "testing1");
+ context.registerService(URLStreamHandlerService.class, this, props);
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ // nothing
+ }
+
+ @Override
+ public URLConnection openConnection(URL u) {
+ return new URLConnection(u) {
+
+ @Override
+ public void connect() throws IOException {
+ try {
+ bc.getBundle();
+ } catch (IllegalStateException e) {
+ throw new IOException(e);
+ }
+ return;
+ }
+ };
+ }
+}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleTests.java
index 558268b4e..01fb4ffe3 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2013 IBM Corporation and others.
+ * Copyright (c) 2006, 2015 IBM Corporation and others.
* 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
@@ -16,6 +16,7 @@ import junit.framework.TestSuite;
public class BundleTests {
public static Test suite() {
TestSuite suite = new TestSuite(BundleTests.class.getName());
+ suite.addTest(URLHandlerTests.suite());
suite.addTest(PersistedBundleTests.suite());
suite.addTest(CascadeConfigTests.suite());
suite.addTest(DiscardBundleTests.suite());
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
index d367c4f97..bc0173116 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2014 IBM Corporation and others.
+ * Copyright (c) 2008, 2015 IBM Corporation and others.
* 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
@@ -1323,6 +1323,7 @@ public class SystemBundleTests extends AbstractBundleTests {
}
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox2.getState()); //$NON-NLS-1$
handlerReg.unregister();
+ System.getProperties().remove("test.url");
}
public void testUUID() {
@@ -2259,7 +2260,7 @@ public class SystemBundleTests extends AbstractBundleTests {
EquinoxLocations.PROP_CONFIG_AREA, //
EquinoxLocations.PROP_INSTALL_AREA, //
EclipseStarter.PROP_LOGFILE //
- );
+ );
Properties systemProperties = (Properties) System.getProperties().clone();
Map<String, Object> configuration = new HashMap<String, Object>();
for (Object key : systemProperties.keySet()) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/URLHandlerTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/URLHandlerTests.java
new file mode 100644
index 000000000..3751a22e0
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/URLHandlerTests.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2015 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osgi.tests.bundles;
+
+import java.net.URL;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.osgi.framework.Bundle;
+
+public class URLHandlerTests extends AbstractBundleTests {
+ public static Test suite() {
+ return new TestSuite(URLHandlerTests.class);
+ }
+
+ public void testURLHandlerUnregister() throws Exception {
+ Bundle test = installer.installBundle("test.protocol.handler"); //$NON-NLS-1$
+ test.start();
+ URL testURL = new URL("testing1://test");
+ testURL.openConnection().connect();
+ test.stop();
+ test.start();
+ testURL = new URL("testing1://test");
+ testURL.openConnection().connect();
+ }
+
+}

Back to the top