From 341891705cb0f38ea99706755e998f27853f183e Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Tue, 30 Sep 2014 14:09:30 -0500 Subject: Bug 445122 - ClassCastException received when System.getProperties().store() runs on 4.4.1 --- .../osgi/tests/bundles/SystemBundleTests.java | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'bundles/org.eclipse.osgi.tests') 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 dd1853ca0..393a5e156 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 @@ -22,6 +22,7 @@ import junit.framework.TestSuite; import org.eclipse.osgi.internal.framework.EquinoxConfiguration; import org.eclipse.osgi.launch.Equinox; import org.eclipse.osgi.service.datalocation.Location; +import org.eclipse.osgi.service.environment.EnvironmentInfo; import org.eclipse.osgi.tests.OSGiTestsActivator; import org.junit.Assert; import org.osgi.framework.*; @@ -2207,6 +2208,30 @@ public class SystemBundleTests extends AbstractBundleTests { equinox.stop(); } + public void testNullConfigurationValueSystemProperties() throws BundleException { + System.setProperty(nullTest, "system"); + File config = OSGiTestsActivator.getContext().getDataFile(getName()); //$NON-NLS-1$ + Map configuration = new HashMap(); + configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath()); + configuration.put("osgi.framework.useSystemProperties", "true"); + configuration.put(nullTest, null); + Equinox equinox = new Equinox(configuration); + equinox.start(); + + String nullValue = equinox.getBundleContext().getProperty(nullTest); + assertNull(nullTest + " is not null: " + nullValue, nullValue); + assertNull("Did not get null system value.", System.getProperties().get(nullTest)); + + // also test EnvironmentInfo effects on system properties + ServiceReference envRef = equinox.getBundleContext().getServiceReference(EnvironmentInfo.class); + EnvironmentInfo envInfo = equinox.getBundleContext().getService(envRef); + envInfo.setProperty(getName(), getName()); + assertEquals("Got wrong value from system properties.", System.getProperty(getName()), getName()); + envInfo.setProperty(getName(), null); + assertNull("Did not get null system value.", System.getProperties().get(getName())); + equinox.stop(); + } + public void testSystemNLFragment() throws BundleException { File config = OSGiTestsActivator.getContext().getDataFile(getName()); //$NON-NLS-1$ Map configuration = new HashMap(); -- cgit v1.2.3