Author: sback
Date: 2007-06-27 10:12:44 +0000 (Wed, 27 Jun 2007)
New Revision: 13775

Modified:
   trunk/freenet/test/freenet/support/SimpleFieldSetTest.java
Log:
Added better explaination on ".." SFS problem,
and tests on put and get methods

Modified: trunk/freenet/test/freenet/support/SimpleFieldSetTest.java
===================================================================
--- trunk/freenet/test/freenet/support/SimpleFieldSetTest.java  2007-06-27 
09:55:40 UTC (rev 13774)
+++ trunk/freenet/test/freenet/support/SimpleFieldSetTest.java  2007-06-27 
10:12:44 UTC (rev 13775)
@@ -35,6 +35,17 @@
                String methodKey = "foo..bar";
                String methodValue = "foobar";
                methodSFS.putSingle(methodKey,methodValue);
+               methodSFS.subset("foo").subset("").get("bar");     /*it returns 
"foobar" */
+               
+               /*methodSFS.subset("foo").subset(null).get("bar");   /* it 
raises null exception
+                                                                               
                                                                                
* because subset(null) returns
+                                                                               
                                                                                
* null by default */
+               
+               methodSFS.get("foo..bar");                                      
           /* it doesn't work
+                                                                               
                                        * but if I put("foo.bar.boo","bazoo") 
+                                                                               
                                        * and I get("foo.bar.boo") -> it 
returns "bazoo"
+                                                                               
                                        * so it should do the same for 
"foo..bar" 
+                                                                               
                                        * or it would raise an exception */
                //assertEquals(methodSFS.get(methodKey),methodValue);
        }

@@ -51,4 +62,43 @@
                //assertEquals(methodSFS.get(methodKey),methodValue);
        }

+       /**
+        * Test put() and get() methods
+        * using a normal Map behaviour
+        * and without MULTI_LEVEL_CHARs
+        */
+       public void testSimpleFieldSetPutAndGet_NoMultiLevel(){
+               String[][] methodPairsArray = { 
{"A","a"},{"B","b"},{"C","c"},{"D","d"},{"E","e"},{"F","f"} };
+               putAndGetPairsTests(methodPairsArray);
+       }
+       
+       /**
+        * Test put() and get() methods
+        * using a normal Map behaviour
+        * and with MULTI_LEVEL_CHARs
+        */
+       public void testSimpleFieldSetPutAndGet_MultiLevel(){
+               String[][] methodPairsArray_DoubleLevel = 
+                       { 
{"A.A","aa"},{"A.B","ab"},{"A.C","ac"},{"A.D","ad"},{"A.E","ae"},{"A.F","af"} };
+               String[][] methodPairsArray_MultiLevel = 
+                       { 
{"A.A.A.A","aa"},{"A.B.A","ab"},{"A.C.Cc","ac"},{"A.D.F","ad"},{"A.E.G","ae"},{"A.F.J.II.UI.BOO","af"}
 };
+               putAndGetPairsTests(methodPairsArray_DoubleLevel);
+               putAndGetPairsTests(methodPairsArray_MultiLevel);
+       }
+       
+       
+       /**
+        * It puts key-value pairs in a SimpleFieldSet
+        * and verify if it can do the correspondant
+        * get correctly.
+        * @param aPairsArray
+        */
+       private void putAndGetPairsTests(String[][] aPairsArray) {
+               SimpleFieldSet methodSFS = new SimpleFieldSet(true);
+               for (int i = 0; i < aPairsArray.length; i++)            
//putting values
+                       methodSFS.putSingle(aPairsArray[i][0], 
aPairsArray[i][1]);
+               for (int i = 0; i < aPairsArray.length; i++)            
//getting values
+                       
assertEquals(methodSFS.get(aPairsArray[i][0]),aPairsArray[i][1]);
+       }
+       
 }


Reply via email to