diff options
author | Thomas Watson | 2015-07-30 12:23:02 +0000 |
---|---|---|
committer | Thomas Watson | 2015-07-30 16:17:08 +0000 |
commit | 0e4556215f426832bb66ab86e2eca9b448bc61e5 (patch) | |
tree | 0f0f5916d402710d24dd6d7291b49a5f21612339 /bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration | |
parent | fc62fed82eceef66aaf1a12b053f9c49ff4a0f54 (diff) | |
download | rt.equinox.framework-0e4556215f426832bb66ab86e2eca9b448bc61e5.tar.gz rt.equinox.framework-0e4556215f426832bb66ab86e2eca9b448bc61e5.tar.xz rt.equinox.framework-0e4556215f426832bb66ab86e2eca9b448bc61e5.zip |
Bug 446571 - Many settings not configurable via config.ini (including
osgi.compatibility.bootdelegation)
Diffstat (limited to 'bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration')
2 files changed, 83 insertions, 1 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/AllTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/AllTests.java index cd71d8f81..e22acfac7 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/AllTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/AllTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2013 IBM Corporation and others. + * Copyright (c) 2004, 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 AllTests { public static Test suite() { TestSuite suite = new TestSuite(AllTests.class.getName()); + suite.addTest(EclipseStarterConfigIniTest.suite()); suite.addTest(EclipseStarterConfigurationAreaTest.suite()); suite.addTest(ReadOnlyConfigurationAreaTest.suite()); suite.addTest(MovableConfigurationAreaTest.suite()); 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); + } + } + } +} |