Anonymous avatar Anonymous committed 3ad1a4a

Added unit tests for MapPropertySet. Updated AbstractPropertySetTest providing support for untyped PropertySets.

git-svn-id: http://svn.opensymphony.com/svn/propertyset/trunk@140 bf3cbcdd-1c1a-0410-9a68-d6f521e3fa7b

Comments (0)

Files changed (2)

src/test/com/opensymphony/module/propertyset/AbstractPropertySetTest.java

     }
 
     public void testGetKeysOfType() {
-        ps.setString("test1", "value1");
-        ps.setString("test2", "value2");
-        ps.setInt("testInt", 14);
-        assertEquals(2, ps.getKeys(PropertySet.STRING).size());
-        assertEquals(1, ps.getKeys(PropertySet.INT).size());
+        if (ps.supportsTypes()) {
+            ps.setString("test1", "value1");
+            ps.setString("test2", "value2");
+            ps.setInt("testInt", 14);
+            assertEquals(2, ps.getKeys(PropertySet.STRING).size());
+            assertEquals(1, ps.getKeys(PropertySet.INT).size());
+        }
     }
 
     public void testGetKeysWithPrefix() {
     }
 
     public void testGetKeysWithPrefixOfType() {
-        ps.setString("test1", "value1");
-        ps.setString("test2", "value2");
-        ps.setString("username", "user1");
-        ps.setInt("testInt", 32);
-        ps.setInt("usernum", 18);
-        assertEquals(2, ps.getKeys("test", PropertySet.STRING).size());
-        assertEquals(1, ps.getKeys("user", PropertySet.STRING).size());
-        assertEquals(1, ps.getKeys("test", PropertySet.INT).size());
-        assertEquals(1, ps.getKeys("user", PropertySet.INT).size());
+        if (ps.supportsTypes()) {
+            ps.setString("test1", "value1");
+            ps.setString("test2", "value2");
+            ps.setString("username", "user1");
+            ps.setInt("testInt", 32);
+            ps.setInt("usernum", 18);
+            assertEquals(2, ps.getKeys("test", PropertySet.STRING).size());
+            assertEquals(1, ps.getKeys("user", PropertySet.STRING).size());
+            assertEquals(1, ps.getKeys("test", PropertySet.INT).size());
+            assertEquals(1, ps.getKeys("user", PropertySet.INT).size());
+        }
     }
 
     public void testGetTypeForBoolean() {

src/test/com/opensymphony/module/propertyset/map/MapPropertySetTest.java

+package com.opensymphony.module.propertyset.map;
+
+import com.opensymphony.module.propertyset.AbstractPropertySetTest;
+
+import java.util.HashMap;
+
+/**
+ * User: bbulger
+ * Date: May 22, 2004
+ */
+public class MapPropertySetTest extends AbstractPropertySetTest {
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        HashMap args = new HashMap();
+        ps = new MapPropertySet();
+        ps.init(null, args);
+    }
+
+    public void testGetMapSetMap() {
+        HashMap map = new HashMap();
+        map.put("key1", "value1");
+        ((MapPropertySet) ps).setMap(map);
+        assertEquals(map, ((MapPropertySet) ps).getMap());
+    }
+
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.