Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigIniTest.java')
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigIniTest.java81
1 files changed, 81 insertions, 0 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigIniTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigIniTest.java
new file mode 100644
index 000000000..2e2cf4f02
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigIniTest.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * 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.configuration;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.eclipse.core.tests.session.ConfigurationSessionTestSuite;
+import org.eclipse.osgi.tests.OSGiTest;
+import org.eclipse.osgi.tests.OSGiTestsActivator;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+public class EclipseStarterConfigIniTest extends OSGiTest {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(EclipseStarterConfigIniTest.class.getName());
+
+ ConfigurationSessionTestSuite falseCompatBootDelegation = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, EclipseStarterConfigIniTest.class.getName());
+ String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET;
+ for (int i = 0; i < ids.length; i++)
+ falseCompatBootDelegation.addBundle(ids[i]);
+ falseCompatBootDelegation.addBundle(PI_OSGI_TESTS);
+ falseCompatBootDelegation.addTest(new EclipseStarterConfigIniTest("testFalseCompatBootDelegation"));
+ falseCompatBootDelegation.setConfigIniValue("osgi.compatibility.bootdelegation", "false");
+ suite.addTest(falseCompatBootDelegation);
+
+ ConfigurationSessionTestSuite defaultCompatBootDelegation = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, EclipseStarterConfigIniTest.class.getName());
+ for (int i = 0; i < ids.length; i++)
+ defaultCompatBootDelegation.addBundle(ids[i]);
+ defaultCompatBootDelegation.addBundle(PI_OSGI_TESTS);
+ defaultCompatBootDelegation.addTest(new EclipseStarterConfigIniTest("testDefaultCompatBootDelegation"));
+ suite.addTest(defaultCompatBootDelegation);
+ return suite;
+ }
+
+ public EclipseStarterConfigIniTest(String name) {
+ super(name);
+ }
+
+ public void testFalseCompatBootDelegation() throws Exception {
+ doTestCompatBootDelegation(true);
+ }
+
+ public void testDefaultCompatBootDelegation() throws Exception {
+ doTestCompatBootDelegation(false);
+ }
+
+ public void doTestCompatBootDelegation(boolean expectFailure) throws Exception {
+ BundleContext context = OSGiTestsActivator.getContext();
+ ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
+ ZipOutputStream zipOut = new ZipOutputStream(bytesOut);
+ zipOut.putNextEntry(new ZipEntry("nothing"));
+ zipOut.closeEntry();
+ zipOut.close();
+ Bundle b = context.installBundle(getName(), new ByteArrayInputStream(bytesOut.toByteArray()));
+ String testClassName = javax.net.SocketFactory.class.getName();
+ // The bundle does not import anything so should not find javax stuff
+ try {
+ b.loadClass(testClassName);
+ if (expectFailure) {
+ fail("Expected to fail to load VM class from bundle that does not import it");
+ }
+ } catch (ClassNotFoundException e) {
+ if (!expectFailure) {
+ fail("Expected to successfully load VM class from bundle that does not import it", e);
+ }
+ }
+ }
+}

Back to the top