summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2011-04-12 19:33:59 (EDT)
committer Ryan D. Brooks2011-04-12 19:33:59 (EDT)
commitb9d33c4952e3950cb00fc795e7f6eca5f6fcd274 (patch)
tree1bf1a85d9f509ca5b608cd4c06f14c7539c4f1f8
parent12873602645b7729cb0d6498f40d45c839308c27 (diff)
downloadorg.eclipse.osee-b9d33c4952e3950cb00fc795e7f6eca5f6fcd274.zip
org.eclipse.osee-b9d33c4952e3950cb00fc795e7f6eca5f6fcd274.tar.gz
org.eclipse.osee-b9d33c4952e3950cb00fc795e7f6eca5f6fcd274.tar.bz2
bug[bgz_342652]: UserSettings attribute is persisted upon shutdown despite no deliberate change
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/mock/MockPropertyStore.java10
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/mock/PropertyStoreTestUtil.java16
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/type/PropertyStoreTest.java24
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/type/PropertyStoreWriterTest.java7
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/PropertyStore.java38
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/PropertyStoreWriter.java19
6 files changed, 70 insertions, 44 deletions
diff --git a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/mock/MockPropertyStore.java b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/mock/MockPropertyStore.java
index d17bc51..6741fa8 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/mock/MockPropertyStore.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/mock/MockPropertyStore.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.framework.jdk.core.test.mock;
-import java.util.Properties;
+import java.util.Map;
import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
/**
@@ -28,7 +28,7 @@ public class MockPropertyStore extends PropertyStore {
super(id);
}
- public MockPropertyStore(Properties properties) {
+ public MockPropertyStore(Map<String, Object> properties) {
super(properties);
}
@@ -38,17 +38,17 @@ public class MockPropertyStore extends PropertyStore {
}
@Override
- public Properties getItems() {
+ public Map<String, Object> getItems() {
return super.getItems();
}
@Override
- public Properties getArrays() {
+ public Map<String, Object> getArrays() {
return super.getArrays();
}
@Override
- public Properties getPropertyStores() {
+ public Map<String, Object> getPropertyStores() {
return super.getPropertyStores();
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/mock/PropertyStoreTestUtil.java b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/mock/PropertyStoreTestUtil.java
index 576004e..6d89d29 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/mock/PropertyStoreTestUtil.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/mock/PropertyStoreTestUtil.java
@@ -10,8 +10,10 @@
*******************************************************************************/
package org.eclipse.osee.framework.jdk.core.test.mock;
+import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
+import java.util.TreeMap;
import org.junit.Assert;
/**
@@ -47,7 +49,7 @@ public final class PropertyStoreTestUtil {
return store;
}
- public static MockPropertyStore createPropertyStore(Properties properties) {
+ public static MockPropertyStore createPropertyStore(Map<String, Object> properties) {
MockPropertyStore store = new MockPropertyStore(properties);
Assert.assertEquals(properties, store.getItems());
Assert.assertEquals(String.valueOf(properties.hashCode()), store.getId());
@@ -63,9 +65,9 @@ public final class PropertyStoreTestUtil {
checkPropertiesEqual(expected.getPropertyStores(), actual.getPropertyStores());
}
- public static void checkPropertiesEqual(Properties expected, Properties actual) {
+ public static void checkPropertiesEqual(Map<String, Object> expected, Map<String, Object> actual) {
Assert.assertEquals(expected.size(), actual.size());
- for (Entry<Object, Object> expectedEntry : expected.entrySet()) {
+ for (Entry<String, Object> expectedEntry : expected.entrySet()) {
Object expectedValue = expectedEntry.getValue();
Object actualValue = actual.get(expectedEntry.getKey());
if (expectedValue instanceof String[]) {
@@ -78,4 +80,12 @@ public final class PropertyStoreTestUtil {
}
}
+ public static Map<String, Object> convertPropertiesToMap(Properties props) {
+ Map<String, Object> result = new TreeMap<String, Object>();
+ for (Entry<Object, Object> entry : props.entrySet()) {
+ result.put((String) entry.getKey(), entry.getValue());
+ }
+ return result;
+ }
+
}
diff --git a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/type/PropertyStoreTest.java b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/type/PropertyStoreTest.java
index bd137f8..670b646 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/type/PropertyStoreTest.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/type/PropertyStoreTest.java
@@ -14,7 +14,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
-import java.util.Properties;
+import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import org.eclipse.osee.framework.jdk.core.test.mock.MockPropertyStore;
@@ -31,7 +31,8 @@ public class PropertyStoreTest {
@org.junit.Test
public void testCreateWithProperties() {
- Properties properties = (Properties) System.getProperties().clone();
+ Map<String, Object> properties = PropertyStoreTestUtil.convertPropertiesToMap(System.getProperties());
+
MockPropertyStore store1 = PropertyStoreTestUtil.createPropertyStore(properties);
PropertyStoreTestUtil.checkPropertiesEqual(properties, store1.getItems());
Assert.assertTrue(!properties.equals(store1.getArrays()));
@@ -87,9 +88,11 @@ public class PropertyStoreTest {
store1.put("key3", new String[] {"entry1", "entry2", "entry3"});
store1.put("key4", new String[] {"entry4", "entry5"});
- Assert.assertEquals(
- "Id:[ID] Data:{key2=543, key1=12.3} Arrays:{key3=[entry1, entry2, entry3], key4=[entry4, entry5]}",
- store1.toString());
+ String strStore1 = store1.toString();
+ String expected =
+ "Id:[ID] Data:{key1=12.3, key2=543} Arrays:{key3=[entry1, entry2, entry3], key4=[entry4, entry5]}";
+
+ Assert.assertEquals(expected, strStore1);
}
@org.junit.Test
@@ -154,7 +157,8 @@ public class PropertyStoreTest {
store1.put("key6.5", "");
store1.put("key7", new String[] {"entry1", "entry2", "entry3"});
store1.put("key8", new String[] {"entry4", "entry5", "entry6"});
- MockPropertyStore nested = PropertyStoreTestUtil.createPropertyStore(System.getProperties());
+ MockPropertyStore nested =
+ PropertyStoreTestUtil.createPropertyStore(PropertyStoreTestUtil.convertPropertiesToMap(System.getProperties()));
store1.put("key9", nested);
Set<String> set1 = new TreeSet<String>(store1.keySet());
@@ -210,7 +214,9 @@ public class PropertyStoreTest {
store1.put("key6", 543L);
store1.put("key7", new String[] {"entry1", "entry2", "entry3"});
store1.put("key8", new String[] {"entry4", "entry5", "entry6"});
- store1.put("key9", PropertyStoreTestUtil.createPropertyStore(System.getProperties()));
+ store1.put(
+ "key9",
+ PropertyStoreTestUtil.createPropertyStore(PropertyStoreTestUtil.convertPropertiesToMap(System.getProperties())));
store1.save(outputStream);
@@ -233,7 +239,9 @@ public class PropertyStoreTest {
store1.put("key6", 543L);
store1.put("key7", new String[] {"entry1", "entry2", "entry3"});
store1.put("key8", new String[] {"entry4", "entry5", "entry6"});
- store1.put("key9", PropertyStoreTestUtil.createPropertyStore(System.getProperties()));
+ store1.put(
+ "key9",
+ PropertyStoreTestUtil.createPropertyStore(PropertyStoreTestUtil.convertPropertiesToMap(System.getProperties())));
store1.save(writer);
diff --git a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/type/PropertyStoreWriterTest.java b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/type/PropertyStoreWriterTest.java
index 926ff1f..8f27de2 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/type/PropertyStoreWriterTest.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/test/type/PropertyStoreWriterTest.java
@@ -44,9 +44,12 @@ public class PropertyStoreWriterTest {
store.put("key6.5", "");
store.put("key7", new String[] {"entry1", "entry2", "entry3"});
store.put("key8", new String[] {"entry4", "entry5", "entry6"});
- nested = PropertyStoreTestUtil.createPropertyStore(System.getProperties());
+ nested =
+ PropertyStoreTestUtil.createPropertyStore(PropertyStoreTestUtil.convertPropertiesToMap(System.getProperties()));
nested.put("inner array 1", new String[] {"value1", "value2"});
- nested.put("inner store 1", PropertyStoreTestUtil.createPropertyStore(System.getProperties()));
+ nested.put(
+ "inner store 1",
+ PropertyStoreTestUtil.createPropertyStore(PropertyStoreTestUtil.convertPropertiesToMap(System.getProperties())));
store.put("key9", nested);
}
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/PropertyStore.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/PropertyStore.java
index 11a123d..f618cf5 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/PropertyStore.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/PropertyStore.java
@@ -19,9 +19,10 @@ import java.io.StringWriter;
import java.io.Writer;
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
-import java.util.Properties;
import java.util.Set;
+import java.util.TreeMap;
import java.util.TreeSet;
import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.jdk.core.util.Strings;
@@ -38,11 +39,11 @@ public class PropertyStore implements IPropertyStore, Serializable {
private static final String EXCEPTION_MESSAGE = "No setting found for key: [%s]";
private String storeId;
- private final Properties storageData;
- private final Properties storageArrays;
- private final Properties storageProperties;
+ private final Map<String, Object> storageData;
+ private final Map<String, Object> storageArrays;
+ private final Map<String, Object> storageProperties;
- private PropertyStore(String storeId, Properties storageData, Properties storageArrays, Properties storageProperties) {
+ private PropertyStore(String storeId, Map<String, Object> storageData, Map<String, Object> storageArrays, Map<String, Object> storageProperties) {
super();
this.storeId = storeId;
this.storageData = storageData;
@@ -51,20 +52,25 @@ public class PropertyStore implements IPropertyStore, Serializable {
}
public PropertyStore(String storeId) {
- this(storeId, new Properties(), new Properties(), new Properties());
+ this(storeId, new TreeMap<String, Object>(), new TreeMap<String, Object>(), new TreeMap<String, Object>());
}
public PropertyStore() {
this(EMPTY_STRING);
}
- public PropertyStore(Properties properties) {
- this(Integer.toString(properties.hashCode()), properties, new Properties(), new Properties());
+ public PropertyStore(Map<String, Object> properties) {
+ this(Integer.toString(properties.hashCode()), properties, new TreeMap<String, Object>(),
+ new TreeMap<String, Object>());
}
@Override
public String get(String key) {
- return storageData.getProperty(key, EMPTY_STRING);
+ String result = EMPTY_STRING;
+ if (storageData.containsKey(key)) {
+ result = (String) storageData.get(key);
+ }
+ return result;
}
@Override
@@ -167,7 +173,7 @@ public class PropertyStore implements IPropertyStore, Serializable {
if (value == null) {
value = EMPTY_STRING;
}
- storageData.setProperty(key, value);
+ storageData.put(key, value);
}
@Override
@@ -187,15 +193,15 @@ public class PropertyStore implements IPropertyStore, Serializable {
this.storeId = name;
}
- protected Properties getItems() {
+ protected Map<String, Object> getItems() {
return storageData;
}
- protected Properties getArrays() {
+ protected Map<String, Object> getArrays() {
return storageArrays;
}
- protected Properties getPropertyStores() {
+ protected Map<String, Object> getPropertyStores() {
return storageProperties;
}
@@ -287,7 +293,7 @@ public class PropertyStore implements IPropertyStore, Serializable {
private boolean areStorageArraysEqual(PropertyStore other) {
boolean result = other.storageArrays.size() == storageArrays.size();
if (result) {
- for (Entry<Object, Object> expectedEntry : storageArrays.entrySet()) {
+ for (Entry<String, Object> expectedEntry : storageArrays.entrySet()) {
Object expectedValue = expectedEntry.getValue();
Object actualValue = other.storageArrays.get(expectedEntry.getKey());
String[] expArray = (String[]) expectedValue;
@@ -320,9 +326,9 @@ public class PropertyStore implements IPropertyStore, Serializable {
return result;
}
- public int getPropertiesHashCode(Properties properties) {
+ public int getPropertiesHashCode(Map<String, Object> properties) {
int result = 0;
- for (Entry<Object, Object> entry : properties.entrySet()) {
+ for (Entry<String, Object> entry : properties.entrySet()) {
result += entry.getKey().hashCode();
Object value = entry.getValue();
if (value instanceof String[]) {
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/PropertyStoreWriter.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/PropertyStoreWriter.java
index c222d6e..db19463 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/PropertyStoreWriter.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/PropertyStoreWriter.java
@@ -27,7 +27,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Properties;
import java.util.Stack;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
@@ -70,9 +69,9 @@ public class PropertyStoreWriter {
out.startTag(TAG_SECTION, attributes);
attributes.clear();
- Properties items = store.getItems();
- for (Entry<Object, Object> entry : items.entrySet()) {
- String key = (String) entry.getKey();
+ Map<String, Object> items = store.getItems();
+ for (Entry<String, Object> entry : items.entrySet()) {
+ String key = entry.getKey();
attributes.put(TAG_KEY, key == null ? "" : key);
String value = (String) entry.getValue();
attributes.put(TAG_VALUE, value == null ? "" : value);
@@ -80,9 +79,9 @@ public class PropertyStoreWriter {
}
attributes.clear();
- Properties arrayItems = store.getArrays();
- for (Entry<Object, Object> entry : arrayItems.entrySet()) {
- String key = (String) entry.getKey();
+ Map<String, Object> arrayItems = store.getArrays();
+ for (Entry<String, Object> entry : arrayItems.entrySet()) {
+ String key = entry.getKey();
attributes.put(TAG_KEY, key == null ? "" : key);
out.startTag(TAG_LIST, attributes);
@@ -107,9 +106,9 @@ public class PropertyStoreWriter {
private void processInnerStores(PropertyStore store, XMLWriter out) {
Map<String, String> attributes = new HashMap<String, String>(2);
- Properties properties = store.getPropertyStores();
- for (Entry<Object, Object> entry : properties.entrySet()) {
- String key = (String) entry.getKey();
+ Map<String, Object> properties = store.getPropertyStores();
+ for (Entry<String, Object> entry : properties.entrySet()) {
+ String key = entry.getKey();
attributes.put(TAG_KEY, key == null ? "" : key);
out.startTag(TAG_INNER, attributes);
PropertyStore innerStore = (PropertyStore) entry.getValue();