Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2010-02-02 22:51:39 +0000
committerThomas Watson2010-02-02 22:51:39 +0000
commitdea62a89605620349cc98937d43af30cb9b68146 (patch)
tree79ac2221039d96426f8522081b3f4a73b8f3e422 /bundles/org.eclipse.osgi.tests
parentf40631cb0d34d3c608083d00d7930a93fc8cef83 (diff)
downloadrt.equinox.framework-dea62a89605620349cc98937d43af30cb9b68146.tar.gz
rt.equinox.framework-dea62a89605620349cc98937d43af30cb9b68146.tar.xz
rt.equinox.framework-dea62a89605620349cc98937d43af30cb9b68146.zip
Bug 300911 - Disabling tracing does not notify listeners
Diffstat (limited to 'bundles/org.eclipse.osgi.tests')
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/debugoptions/DebugOptionsTestCase.java71
1 files changed, 71 insertions, 0 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/debugoptions/DebugOptionsTestCase.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/debugoptions/DebugOptionsTestCase.java
index 650e246af..aa0eb868f 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/debugoptions/DebugOptionsTestCase.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/debugoptions/DebugOptionsTestCase.java
@@ -221,6 +221,77 @@ public class DebugOptionsTestCase extends CoreTest {
}
+ public void testSetOptionsWhenDisabled() {
+
+ // enable tracing initially.
+ if (!debugOptions.isDebugEnabled()) {
+ debugOptions.setDebugEnabled(true);
+ }
+ // create a new key to add.
+ String testKey = getName() + "/debug/disableCheck";
+ // set its value to 'ok'
+ debugOptions.setOption(testKey, "ok");
+ // make sure the right value is added
+ String actualValue = debugOptions.getOption(testKey, "not ok");
+ assertEquals("The correct option value was not returned from the debug option: " + testKey, "ok", actualValue);
+ // disable tracing
+ debugOptions.setDebugEnabled(false);
+ // check for the value
+ actualValue = debugOptions.getOption(testKey, "not ok");
+ assertEquals("The 'default' value supplied was not returned when tracing is disabled.", "not ok", actualValue);
+ // try setting the value to "ok" (this should be a no-op and return the 'default' value)
+ debugOptions.setOption(testKey, "ok");
+ actualValue = debugOptions.getOption(testKey, "not ok");
+ assertEquals("The 'default' value supplied was not returned when tracing is disabled.", "not ok", actualValue);
+ // remove the option and check for the value (it should still exist after re-enabling tracing)
+ debugOptions.removeOption(testKey);
+ // re-enable tracing
+ debugOptions.setDebugEnabled(true);
+ // check that the value is still the initial "ok"
+ actualValue = debugOptions.getOption(testKey, "not ok");
+ assertEquals("The value after re-enabling tracing is invalid.", "ok", actualValue);
+ }
+
+ public void testStringValues() {
+
+ if (!debugOptions.isDebugEnabled()) {
+ debugOptions.setDebugEnabled(true);
+ }
+ // create a new key to add.
+ String testKey = getName() + "/debug/stringValue";
+ // set its value to 'test'
+ debugOptions.setOption(testKey, "test");
+ // check to make sure the value returned is correct
+ String actualValue = debugOptions.getOption(testKey, "default");
+ assertEquals("The correct option value was not returned from the debug option: " + testKey, "test", actualValue);
+ // remove the option and check for the value (it should not exist so the default value should be returned)
+ debugOptions.removeOption(testKey);
+ actualValue = debugOptions.getOption(testKey, "default");
+ assertEquals("The 'default' value supplied was not returned when the key does not exist in the DebugOptions.", "default", actualValue);
+ }
+
+ public void testIntegerValues() {
+
+ if (!debugOptions.isDebugEnabled()) {
+ debugOptions.setDebugEnabled(true);
+ }
+ // create a new key to add.
+ String testKey = getName() + "/debug/intValue";
+ // set its value to 42.
+ debugOptions.setOption(testKey, "42");
+ // check to make sure the value returned is correct
+ int actualValue = debugOptions.getIntegerOption(testKey, 0);
+ assertEquals("The correct option value was not returned from the debug option: " + testKey, 42, actualValue);
+ // set the value of this key so that a NumberFormatException will occur
+ debugOptions.setOption(testKey, "test");
+ actualValue = debugOptions.getIntegerOption(testKey, 0);
+ assertEquals("The 'default' value supplied was not returned when a NumberFormatException occurs.", 0, actualValue);
+ // remove the option and check for the value (it should not exist so the default value should be returned)
+ debugOptions.removeOption(testKey);
+ actualValue = debugOptions.getIntegerOption(testKey, 0);
+ assertEquals("The 'default' value supplied was not returned when the key does not exist in the DebugOptions.", 0, actualValue);
+ }
+
public void testBooleanValues() {
if (!debugOptions.isDebugEnabled()) {
debugOptions.setDebugEnabled(true);

Back to the top