Author: sback
Date: 2007-07-21 16:11:36 +0000 (Sat, 21 Jul 2007)
New Revision: 14241

Modified:
   trunk/freenet/test/freenet/support/Base64Test.java
   trunk/freenet/test/freenet/support/HexUtilTest.java
   trunk/freenet/test/freenet/support/LRUHashtableTest.java
   trunk/freenet/test/freenet/support/LRUQueueTest.java
   trunk/freenet/test/freenet/support/MultiValueTableTest.java
   trunk/freenet/test/freenet/support/SimpleFieldSetTest.java
   trunk/freenet/test/freenet/support/SizeUtilTest.java
   trunk/freenet/test/freenet/support/TimeUtilTest.java
   trunk/freenet/test/freenet/support/URLEncoderDecoderTest.java
Log:
Layout readabilty improved

Modified: trunk/freenet/test/freenet/support/Base64Test.java
===================================================================
--- trunk/freenet/test/freenet/support/Base64Test.java  2007-07-21 16:00:42 UTC 
(rev 14240)
+++ trunk/freenet/test/freenet/support/Base64Test.java  2007-07-21 16:11:36 UTC 
(rev 14241)
@@ -33,8 +33,15 @@
         * to verify if it encode works correctly.
         */
        public void testEncode() {
-               String toEncode = "Man is distinguished, not only by his 
reason, but by this singular passion from other animals, which is a lust of the 
mind, that by a perseverance of delight in the continued and indefatigable 
generation of knowledge, exceeds the short vehemence of any carnal pleasure.";
-               String expectedResult = 
"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4";
+               String toEncode = "Man is distinguished, not only by his 
reason, but by this singular " +
+                               "passion from other animals, which is a lust of 
the mind, that by a perseverance " +
+                               "of delight in the continued and indefatigable 
generation of knowledge, exceeds " +
+                               "the short vehemence of any carnal pleasure.";
+               String expectedResult = 
"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ" +
+                               
"1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIG"
 +
+                               
"x1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY"
 +
+                               
"29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRz"
 +
+                               
"IHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4";
                byte[] aByteArrayToEncode = toEncode.getBytes();
                assertEquals(Base64.encode(aByteArrayToEncode),expectedResult);
        }
@@ -46,8 +53,15 @@
         * to verify if it decode an already encoded string correctly.
         */     
        public void testDecode() {
-               String toDecode = 
"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
-               String expectedResult = "Man is distinguished, not only by his 
reason, but by this singular passion from other animals, which is a lust of the 
mind, that by a perseverance of delight in the continued and indefatigable 
generation of knowledge, exceeds the short vehemence of any carnal pleasure.";
+               String toDecode = 
"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ" +
+                               
"1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIG"
 +
+                               
"x1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY"
 +
+                               
"29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRz"
 +
+                               
"IHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
+               String expectedResult = "Man is distinguished, not only by his 
reason, but by this singular " +
+                               "passion from other animals, which is a lust of 
the mind, that by a perseverance " +
+                               "of delight in the continued and indefatigable 
generation of knowledge, exceeds " +
+                               "the short vehemence of any carnal pleasure.";
                try {
                        String decodedString = new 
String(Base64.decode(toDecode));
                        assertEquals(decodedString,expectedResult);
@@ -66,11 +80,13 @@
                byte[] bytesDecoded;
                byte[] bytesToEncode = new byte[5];

-               bytesToEncode[0] = 127;         //byte upper bound
+               //byte upper bound
+               bytesToEncode[0] = 127;
                bytesToEncode[1] = 64;
                bytesToEncode[2] = 0;
                bytesToEncode[3] = -64;
-               bytesToEncode[4] = -128;        //byte lower bound
+               //byte lower bound
+               bytesToEncode[4] = -128;        

                String aBase64EncodedString = Base64.encode(bytesToEncode);

@@ -88,15 +104,19 @@
         */
        public void testEncodePadding() {
                byte[][] methodBytesArray = {
-                               {4,4,4},        //three byte Array -> no 
padding char expected  
-                               {4,4},          //two byte Array -> one padding 
char expected
-                               {4}};           //one byte Array -> two 
padding-chars expected  
+                               //three byte Array -> no padding char expected
+                               {4,4,4},                
+                               //two byte Array -> one padding char expected
+                               {4,4},          
+                               //one byte Array -> two padding-chars expected  
+                               {4}};           
                String encoded;

                for (int i = 0; i<methodBytesArray.length; i++) {
                        encoded = Base64.encode(methodBytesArray[i],true);
                        if (i == 0)
-                               assertEquals(encoded.indexOf('='),-1);  //no 
occurrences expected
+                               //no occurrences expected
+                               assertEquals(encoded.indexOf('='),-1);
                        else
                                
assertEquals(encoded.indexOf('='),encoded.length()-i);
                }
@@ -109,7 +129,8 @@
         * characters.
         */
        public void testIllegalBaseCharacter() {
-               String illegalCharString = "abcd=fghilmn";              //TODO: 
check many other possibile cases!
+//             TODO: check many other possibile cases!
+               String illegalCharString = "abcd=fghilmn";
                try {
                        Base64.decode(illegalCharString);
                        fail("Expected IllegalBase64Exception not thrown"); }
@@ -127,11 +148,12 @@
         *  where -> number MOD 4 = 1).
         */
        public void testIllegalBaseLength() {
-               String illegalLengthString = "a";               //most 
interesting case
+               //most interesting case
+               String illegalLengthString = "a";
                try {
                        Base64.decode(illegalLengthString);
                        fail("Expected IllegalBase64Exception not thrown"); }
                catch (IllegalBase64Exception exception) {
                        assertSame("illegal Base64 
length",exception.getMessage()); }
        }
-}
+}
\ No newline at end of file

Modified: trunk/freenet/test/freenet/support/HexUtilTest.java
===================================================================
--- trunk/freenet/test/freenet/support/HexUtilTest.java 2007-07-21 16:00:42 UTC 
(rev 14240)
+++ trunk/freenet/test/freenet/support/HexUtilTest.java 2007-07-21 16:11:36 UTC 
(rev 14241)
@@ -144,7 +144,8 @@
         * against all possible values until 256 bytes
         */
        public void testCountBytesForBits_int() {
-               assertEquals(HexUtil.countBytesForBits(0),0);   //border case
+               //border case
+               assertEquals(HexUtil.countBytesForBits(0),0);
                for (int expectedBytesCount = 1; expectedBytesCount < 256; 
expectedBytesCount++)
                        for (int bits = (expectedBytesCount-1)*8+1; bits <= 
(expectedBytesCount)*8; bits++)
                                
assertEquals(HexUtil.countBytesForBits(bits),expectedBytesCount);
@@ -345,19 +346,26 @@
                byte[] outputArray = new byte[1];
                BitSet methodBitSet = new BitSet(8);

-               methodBitSet.flip(0); /* 0x01 */
+               /* 0x01 */
+               methodBitSet.flip(0);
                expectedByteArray[0] = (byte)1;
-               outputArray = HexUtil.bitsToBytes(methodBitSet,0); /* 0x01 & 
0x00 == 0x01 */
+               /* 0x01 & 0x00 == 0x01 */
+               outputArray = HexUtil.bitsToBytes(methodBitSet,0);
                assertFalse(Arrays.equals(expectedByteArray,outputArray));
-               outputArray = HexUtil.bitsToBytes(methodBitSet,1); /* 0x01 & 
0x01 == 0x01 */
+               /* 0x01 & 0x01 == 0x01 */
+               outputArray = HexUtil.bitsToBytes(methodBitSet,1);
                assertTrue(Arrays.equals(expectedByteArray,outputArray));

-               methodBitSet.flip(7); /* 0x80 */
-               methodBitSet.flip(3); /* 0x08 */
+               /* 0x80 */
+               methodBitSet.flip(7);
+               /* 0x08 */
+               methodBitSet.flip(3);
                expectedByteArray[0] = (byte)128+8+1;
-               outputArray = HexUtil.bitsToBytes(methodBitSet,3); /* 0x89 & 
0x08 == 0x89 */
+               /* 0x89 & 0x08 == 0x89 */
+               outputArray = HexUtil.bitsToBytes(methodBitSet,3);
                assertFalse(Arrays.equals(expectedByteArray,outputArray));
-               outputArray = HexUtil.bitsToBytes(methodBitSet,8); /* 0x89 & 
0xff == 0x89 */
+               /* 0x89 & 0xff == 0x89 */
+               outputArray = HexUtil.bitsToBytes(methodBitSet,8);
                assertTrue(Arrays.equals(expectedByteArray,outputArray));
        }
 }

Modified: trunk/freenet/test/freenet/support/LRUHashtableTest.java
===================================================================
--- trunk/freenet/test/freenet/support/LRUHashtableTest.java    2007-07-21 
16:00:42 UTC (rev 14240)
+++ trunk/freenet/test/freenet/support/LRUHashtableTest.java    2007-07-21 
16:11:36 UTC (rev 14241)
@@ -38,8 +38,10 @@
        private Object[][] createSampleKeyVal(int size) {
                Object[][] sampleObjects = new Object[size][2];
                for (int i=0; i<sampleObjects.length;i++) {
-                       sampleObjects[i][0] = new Integer(i);           //key
-                       sampleObjects[i][1] = new Object(); }           //value
+                       //key
+                       sampleObjects[i][0] = new Integer(i);
+                       //value
+                       sampleObjects[i][1] = new Object(); }           
                return sampleObjects;
        }

@@ -80,7 +82,8 @@
        public void testPushNull() {
                LRUHashtable methodLRUht = 
createSampleHashTable(sampleElemsNumber);
                try {
-                       methodLRUht.push(new Object(),null);}           //a 
null value is admitted
+                       //a null value is admitted
+                       methodLRUht.push(new Object(),null);}           
                catch (NullPointerException anException) { 
                        fail("Not expected exception thrown : " + 
anException.getMessage()); }
                try {

Modified: trunk/freenet/test/freenet/support/LRUQueueTest.java
===================================================================
--- trunk/freenet/test/freenet/support/LRUQueueTest.java        2007-07-21 
16:00:42 UTC (rev 14240)
+++ trunk/freenet/test/freenet/support/LRUQueueTest.java        2007-07-21 
16:11:36 UTC (rev 14241)
@@ -79,9 +79,11 @@
                Enumeration methodEnum = aLRUQueue.elements();
                int counter = 0;
                while (methodEnum.hasMoreElements()) {
-                       if (counter == size-2)          //next-to-last object
+                       //next-to-last object
+                       if (counter == size-2)
                                retVal &= 
(methodEnum.nextElement()).equals(nextToLast);
-                       else if (counter == size-1)             //last object
+                       //last object
+                       else if (counter == size-1)
                                retVal &= 
(methodEnum.nextElement()).equals(last);
                        else
                                methodEnum.nextElement();
@@ -286,5 +288,4 @@
                        methodLRUQueue.pop();
                assertTrue(methodLRUQueue.isEmpty());
        }
-
-}
+}
\ No newline at end of file

Modified: trunk/freenet/test/freenet/support/MultiValueTableTest.java
===================================================================
--- trunk/freenet/test/freenet/support/MultiValueTableTest.java 2007-07-21 
16:00:42 UTC (rev 14240)
+++ trunk/freenet/test/freenet/support/MultiValueTableTest.java 2007-07-21 
16:11:36 UTC (rev 14241)
@@ -119,7 +119,8 @@
         * MultiValueTable
         */
        public void testPut() {
-               
assertNotNull(createSampleMultiValueTable(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom));
+               assertNotNull(
+                               
createSampleMultiValueTable(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom));
        }

        /**
@@ -129,7 +130,8 @@
        public void testGet() {
                MultiValueTable methodMVTable = new MultiValueTable();
                assertNull(methodMVTable.get(new Object()));
-               Object[][] sampleObjects = 
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
+               Object[][] sampleObjects = 
+                       
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
                methodMVTable = fillMultiValueTable(sampleObjects);
                for(int i=0;i<sampleObjects.length;i++)
                        
assertEquals(methodMVTable.get(sampleObjects[i][0]),((List)sampleObjects[i][1]).get(0));
@@ -144,7 +146,8 @@
        public void testContainsKey() {
                MultiValueTable methodMVTable = new MultiValueTable();
                assertFalse(methodMVTable.containsKey(new Object()));
-               Object[][] sampleObjects = 
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
+               Object[][] sampleObjects = 
+                       
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
                methodMVTable = fillMultiValueTable(sampleObjects);
                for(int i=0;i<sampleObjects.length;i++)
                        
assertTrue(methodMVTable.containsKey(sampleObjects[i][0]));
@@ -161,7 +164,8 @@
        public void testContainsElement() {
                MultiValueTable methodMVTable = new MultiValueTable();
                assertFalse(methodMVTable.containsElement(new Object(),new 
Object()));
-               Object[][] sampleObjects = 
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
+               Object[][] sampleObjects = 
+                       
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
                methodMVTable = fillMultiValueTable(sampleObjects);
                Iterator iter;
                for(int i=0;i<sampleObjects.length;i++) {
@@ -179,7 +183,8 @@
                MultiValueTable methodMVTable = new MultiValueTable();
                //TODO: verifies if an Exception is necessary
                methodMVTable.getAll(new Object());
-               Object[][] sampleObjects = 
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
+               Object[][] sampleObjects = 
+                       
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
                methodMVTable = fillMultiValueTable(sampleObjects);
                Iterator iter;
                Enumeration methodEnumeration;
@@ -197,7 +202,8 @@
        public void testCountAll() {
                MultiValueTable methodMVTable = new MultiValueTable();
                assertEquals(methodMVTable.countAll(new Object()),0);
-               Object[][] sampleObjects = 
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
+               Object[][] sampleObjects = 
+                       
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
                methodMVTable = fillMultiValueTable(sampleObjects);
                for(int i=0;i<sampleObjects.length;i++)
                        
assertEquals(((List)(sampleObjects[i][1])).size(),methodMVTable.countAll(sampleObjects[i][0]));
@@ -210,7 +216,8 @@
        public void testGetSync() {
                MultiValueTable methodMVTable = new MultiValueTable();
                assertNull(methodMVTable.getSync(new Object()));
-               Object[][] sampleObjects = 
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
+               Object[][] sampleObjects = 
+                       
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
                methodMVTable = fillMultiValueTable(sampleObjects);
                for(int i=0;i<sampleObjects.length;i++)
                        
assertEquals(methodMVTable.getSync(sampleObjects[i][0]),((List)sampleObjects[i][1]));
@@ -223,7 +230,8 @@
        public void testGetArray() {
                MultiValueTable methodMVTable = new MultiValueTable();
                assertNull(methodMVTable.getArray(new Object()));
-               Object[][] sampleObjects = 
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
+               Object[][] sampleObjects = 
+                       
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
                methodMVTable = fillMultiValueTable(sampleObjects);
                for(int i=0;i<sampleObjects.length;i++)
                        
assertTrue(Arrays.equals(((List)(sampleObjects[i][1])).toArray(),methodMVTable.getArray(sampleObjects[i][0])));
@@ -239,7 +247,8 @@
                MultiValueTable methodMVTable = new MultiValueTable();
                //TODO: shouldn't it raise an exception?
                methodMVTable.remove(new Object());
-               Object[][] sampleObjects = 
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
+               Object[][] sampleObjects = 
+                       
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
                methodMVTable = fillMultiValueTable(sampleObjects);
                for(int i=0;i<sampleObjects.length;i++)
                        methodMVTable.remove(sampleObjects[i][0]);
@@ -253,7 +262,8 @@
        public void testIsEmpty() {
                MultiValueTable methodMVTable = new MultiValueTable();
                assertTrue(methodMVTable.isEmpty());
-               Object[][] sampleObjects = 
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
+               Object[][] sampleObjects = 
+                       
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
                methodMVTable = fillMultiValueTable(sampleObjects);
                assertFalse(methodMVTable.isEmpty());
                for(int i=0;i<sampleObjects.length;i++)
@@ -267,7 +277,8 @@
         * Finally it verifies the result of isEmpty() method.
         */
        public void testClear() {
-               Object[][] sampleObjects = 
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
+               Object[][] sampleObjects = 
+                       
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
                MultiValueTable methodMVTable = 
fillMultiValueTable(sampleObjects);
                methodMVTable.clear();
                for(int i=0;i<sampleObjects.length;i++)
@@ -281,7 +292,8 @@
         * removed and if the result of isEmpty() method is correct.
         */
        public void testRemoveElement() {
-               Object[][] sampleObjects = 
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
+               Object[][] sampleObjects = 
+                       
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
                MultiValueTable methodMVTable = 
fillMultiValueTable(sampleObjects);
                Object methodValue;
                Iterator iter;
@@ -302,7 +314,8 @@
         * correctly present in the resulting Enumeration
         */
        public void testKeys() {
-               Object[][] sampleObjects = 
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
+               Object[][] sampleObjects = 
+                       
createSampleKeyMultiVal(sampleKeyNumber,sampleMaxValueNumber,sampleIsRandom);
                MultiValueTable methodMVTable = 
fillMultiValueTable(sampleObjects);
                //TODO: shouldn't it respect keys order?
                int j = sampleObjects.length-1;

Modified: trunk/freenet/test/freenet/support/SimpleFieldSetTest.java
===================================================================
--- trunk/freenet/test/freenet/support/SimpleFieldSetTest.java  2007-07-21 
16:00:42 UTC (rev 14240)
+++ trunk/freenet/test/freenet/support/SimpleFieldSetTest.java  2007-07-21 
16:11:36 UTC (rev 14241)
@@ -37,12 +37,13 @@
        /* A double string array used across all tests 
         * it must not be changed in order to perform tests
         * correctly */
-       private static final String[][] SAMPLE_STRING_PAIRS = 
-               {  {"foo","bar"},                       //directSubset
-                  {"foo.bar","foobar"},        
-                  {"foo.bar.boo.far","foobar"},
-                  {"foo2","foobar.fooboo.foofar.foofoo"},
-                  {"foo3",KEY_VALUE_SEPARATOR+"bar"} };
+       private static final String[][] SAMPLE_STRING_PAIRS = {  
+               //directSubset
+               {"foo","bar"},                  
+               {"foo.bar","foobar"},   
+               {"foo.bar.boo.far","foobar"},
+               {"foo2","foobar.fooboo.foofar.foofoo"},
+               {"foo3",KEY_VALUE_SEPARATOR+"bar"} };

        private static final String SAMPLE_END_MARKER = "END";

@@ -79,7 +80,8 @@
         * and without MULTI_LEVEL_CHARs
         */
        public void testSimpleFieldSetPutAndGet_NoMultiLevel(){
-               String[][] methodPairsArray = { 
{"A","a"},{"B","b"},{"C","c"},{"D","d"},{"E","e"},{"F","f"} };
+               String[][] methodPairsArray = { 
+                               
{"A","a"},{"B","b"},{"C","c"},{"D","d"},{"E","e"},{"F","f"} };
                assertTrue(checkPutAndGetPairs(methodPairsArray));
        }

@@ -89,10 +91,20 @@
         * 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"}
 };
+               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"} };
                assertTrue(checkPutAndGetPairs(methodPairsArray_DoubleLevel));
                assertTrue(checkPutAndGetPairs(methodPairsArray_MultiLevel));
        }
@@ -108,7 +120,8 @@
        private boolean checkPutAndGetPairs(String[][] aPairsArray) {
                boolean retValue = true;
                SimpleFieldSet methodSFS = new SimpleFieldSet(true);
-               for (int i = 0; i < aPairsArray.length; i++)            
//putting values
+               //putting values
+               for (int i = 0; i < aPairsArray.length; i++)
                        methodSFS.putSingle(aPairsArray[i][0], 
aPairsArray[i][1]);
                for (int i = 0; i < aPairsArray.length; i++)            
//getting values
                        retValue &= 
methodSFS.get(aPairsArray[i][0]).equals(aPairsArray[i][1]);
@@ -125,15 +138,24 @@
         */
        public void testSimpleFieldSetSubset_String() {
                SimpleFieldSet methodSFS = new SimpleFieldSet(true);
-               String[][] methodPairsArray_MultiLevel =
-                       { 
{"A","A","aa"},{"A","B","ab"},{"A","C","ac"},{"A","D","ad"},{"A","E","ae"},{"A","F","af"}
 };
-               for (int i = 0; i < methodPairsArray_MultiLevel.length; i++)    
        //putting values
+               String[][] methodPairsArray_MultiLevel = { 
+                               {"A","A","aa"},
+                               {"A","B","ab"},
+                               {"A","C","ac"},
+                               {"A","D","ad"},
+                               {"A","E","ae"},
+                               {"A","F","af"} };
+               //putting values
+               for (int i = 0; i < methodPairsArray_MultiLevel.length; i++)
                        methodSFS.putSingle(methodPairsArray_MultiLevel[i][0] 
-                                           + SimpleFieldSet.MULTI_LEVEL_CHAR + 
methodPairsArray_MultiLevel[i][1], 
+                                           + SimpleFieldSet.MULTI_LEVEL_CHAR 
+                                           + 
methodPairsArray_MultiLevel[i][1], 
                                            methodPairsArray_MultiLevel[i][2]);
-               for (int i = 0; i < methodPairsArray_MultiLevel.length; i++)    
        //getting subsets and then values
+               //getting subsets and then values
+               for (int i = 0; i < methodPairsArray_MultiLevel.length; i++)
                        assertEquals(
-                                       
methodSFS.subset(methodPairsArray_MultiLevel[i][0]).get(methodPairsArray_MultiLevel[i][1]),
+                                       methodSFS.subset(
+                                                       
methodPairsArray_MultiLevel[i][0]).get(methodPairsArray_MultiLevel[i][1]),
                                        methodPairsArray_MultiLevel[i][2]);
                
assertTrue(checkSimpleFieldSetSize(methodSFS,methodPairsArray_MultiLevel.length));
        }
@@ -150,7 +172,8 @@
                SimpleFieldSet methodNewSFS = 
this.sfsFromStringPairs(methodAppendedString);
                methodSFS.putAllOverwrite(methodNewSFS);
                for (int i=0; i < SAMPLE_STRING_PAIRS.length; i++)
-                       
assertEquals(methodSFS.get(SAMPLE_STRING_PAIRS[i][0]),SAMPLE_STRING_PAIRS[i][1]+methodAppendedString);
+                       assertEquals(methodSFS.get(SAMPLE_STRING_PAIRS[i][0]),
+                                       
SAMPLE_STRING_PAIRS[i][1]+methodAppendedString);
        }

        /**
@@ -161,7 +184,8 @@
                SimpleFieldSet methodSFS = new SimpleFieldSet(true);
                methodSFS.put(methodKey,sfsFromSampleStringPairs());
                for (int i=0; i < SAMPLE_STRING_PAIRS.length; i++)
-                       
assertEquals(methodSFS.get(methodKey+SimpleFieldSet.MULTI_LEVEL_CHAR+SAMPLE_STRING_PAIRS[i][0]),
+                       assertEquals(
+                                       
methodSFS.get(methodKey+SimpleFieldSet.MULTI_LEVEL_CHAR+SAMPLE_STRING_PAIRS[i][0]),
                                        SAMPLE_STRING_PAIRS[i][1]);
        }

@@ -204,8 +228,10 @@
         */
        private SimpleFieldSet sfsFromStringPairs(String aSuffix) {
                SimpleFieldSet methodSFS = new SimpleFieldSet(true);
-               for (int i = 0; i < SAMPLE_STRING_PAIRS.length; i++)    
//creating new 
-                       
methodSFS.putSingle(SAMPLE_STRING_PAIRS[i][0],SAMPLE_STRING_PAIRS[i][1]+aSuffix);
+               //creating new
+               for (int i = 0; i < SAMPLE_STRING_PAIRS.length; i++) 
+                       methodSFS.putSingle(SAMPLE_STRING_PAIRS[i][0],
+                                       SAMPLE_STRING_PAIRS[i][1]+aSuffix);
                return methodSFS;
        }

@@ -264,8 +290,10 @@

                for (int i = 0; i < methodPairsArray.length; i++) {
                        try {
-                               
assertEquals(methodSFS.getInt(Integer.toString(methodPairsArray[i][0])),methodPairsArray[i][1]);
-                               
assertEquals(methodSFS.getInt(Integer.toString(methodPairsArray[i][0]),5),methodPairsArray[i][1]);
+                               
assertEquals(methodSFS.getInt(Integer.toString(methodPairsArray[i][0])),
+                                               methodPairsArray[i][1]);
+                               
assertEquals(methodSFS.getInt(Integer.toString(methodPairsArray[i][0]),5),
+                                               methodPairsArray[i][1]);
                        } catch (FSParseException aException) {
                                fail("Not expected exception thrown : " + 
aException.getMessage()); }
                }
@@ -291,8 +319,10 @@

                for (int i = 0; i < methodPairsArray.length; i++) {
                        try {
-                               
assertEquals(methodSFS.getLong(Long.toString(methodPairsArray[i][0])),methodPairsArray[i][1]);
-                               
assertEquals(methodSFS.getLong(Long.toString(methodPairsArray[i][0]),5),methodPairsArray[i][1]);
+                               
assertEquals(methodSFS.getLong(Long.toString(methodPairsArray[i][0])),
+                                               methodPairsArray[i][1]);
+                               
assertEquals(methodSFS.getLong(Long.toString(methodPairsArray[i][0]),5),
+                                               methodPairsArray[i][1]);
                        } catch (FSParseException aException) {
                                fail("Not expected exception thrown : " + 
aException.getMessage()); }
                }
@@ -318,8 +348,10 @@

                for (int i = 0; i < methodPairsArray.length; i++) {
                        try {
-                               
assertEquals(methodSFS.getChar(String.valueOf(methodPairsArray[i][0])),methodPairsArray[i][1]);
-                               
assertEquals(methodSFS.getChar(String.valueOf(methodPairsArray[i][0]),'5'),methodPairsArray[i][1]);
+                               
assertEquals(methodSFS.getChar(String.valueOf(methodPairsArray[i][0])),
+                                               methodPairsArray[i][1]);
+                               
assertEquals(methodSFS.getChar(String.valueOf(methodPairsArray[i][0]),'5'),
+                                               methodPairsArray[i][1]);
                        } catch (FSParseException aException) {
                                fail("Not expected exception thrown : " + 
aException.getMessage()); }
                }
@@ -345,8 +377,10 @@

                for (int i = 0; i < methodPairsArray.length; i++) {
                        try {
-                               
assertEquals(methodSFS.getShort(Short.toString(methodPairsArray[i][0])),methodPairsArray[i][1]);
-                               
assertEquals(methodSFS.getShort(Short.toString(methodPairsArray[i][0]),(short)5),methodPairsArray[i][1]);
+                               
assertEquals(methodSFS.getShort(Short.toString(methodPairsArray[i][0])),
+                                               methodPairsArray[i][1]);
+                               
assertEquals(methodSFS.getShort(Short.toString(methodPairsArray[i][0]),(short)5),
+                                               methodPairsArray[i][1]);
                        } catch (FSParseException aException) {
                                fail("Not expected exception thrown : " + 
aException.getMessage()); }
                }
@@ -373,9 +407,11 @@
                for (int i = 0; i < methodPairsArray.length; i++) {
                        try {
                                //there is no assertEquals(Double,Double) so we 
are obliged to do this way -_-
-                               
assertEquals(Double.compare((methodSFS.getDouble(Double.toString(methodPairsArray[i][0]))),
+                               assertEquals(
+                                               
Double.compare((methodSFS.getDouble(Double.toString(methodPairsArray[i][0]))),
                                                                                
        methodPairsArray[i][1]),0);
-                               
assertEquals(Double.compare(methodSFS.getDouble(Double.toString(methodPairsArray[i][0]),(double)5),
+                               assertEquals(
+                                               
Double.compare(methodSFS.getDouble(Double.toString(methodPairsArray[i][0]),(double)5),
                                                                                
        methodPairsArray[i][1]),0);
                        } catch (FSParseException aException) {
                                fail("Not expected exception thrown : " + 
aException.getMessage()); }
@@ -408,7 +444,8 @@
                try {
                        SimpleFieldSet methodSFS = new 
SimpleFieldSet(methodStringToParse,false,false);
                        for (int i=0; i < methodStringPairs.length; i++)
-                               
assertEquals(methodSFS.get(methodStringPairs[i][0]),methodStringPairs[i][1]);
+                               
assertEquals(methodSFS.get(methodStringPairs[i][0]),
+                                               methodStringPairs[i][1]);
                } catch (IOException aException) {
                        fail("Not expected exception thrown : " + 
aException.getMessage()); }
        }
@@ -424,7 +461,8 @@
                try {
                        SimpleFieldSet methodSFS = new 
SimpleFieldSet(methodBufferedReader,false,false);
                        for (int i=0; i < methodStringPairs.length; i++)
-                               
assertEquals(methodSFS.get(methodStringPairs[i][0]),methodStringPairs[i][1]);
+                               
assertEquals(methodSFS.get(methodStringPairs[i][0]),
+                                               methodStringPairs[i][1]);
                } catch (IOException aException) {
                        fail("Not expected exception thrown : " + 
aException.getMessage()); }
        }
@@ -437,8 +475,10 @@
        private SimpleFieldSet sfsFromSampleStringPairs() {
                SimpleFieldSet methodSFS = new SimpleFieldSet(true);
                for (int i = 0; i < SAMPLE_STRING_PAIRS.length; i++)
-                       
methodSFS.putSingle(SAMPLE_STRING_PAIRS[i][0],SAMPLE_STRING_PAIRS[i][1]);
-               
assertTrue(checkSimpleFieldSetSize(methodSFS,SAMPLE_STRING_PAIRS.length));
+                       methodSFS.putSingle(SAMPLE_STRING_PAIRS[i][0],
+                                       SAMPLE_STRING_PAIRS[i][1]);
+               assertTrue(checkSimpleFieldSetSize(methodSFS,
+                               SAMPLE_STRING_PAIRS.length));
                return methodSFS;
        }

@@ -450,7 +490,8 @@
                SimpleFieldSet methodSFS = new 
SimpleFieldSet(sfsFromSampleStringPairs());
                String[][] methodStringPairs = SAMPLE_STRING_PAIRS;
                for (int i=0; i < methodStringPairs.length; i++)
-                       
assertEquals(methodSFS.get(methodStringPairs[i][0]),methodStringPairs[i][1]);
+                       assertEquals(methodSFS.get(methodStringPairs[i][0]),
+                                       methodStringPairs[i][1]);
        }

        /**
@@ -580,7 +621,8 @@
                methodSFS.removeValue("foo");
                assertNull(methodSFS.get(SAMPLE_STRING_PAIRS[0][0]));
                for(int i=1;i<SAMPLE_STRING_PAIRS.length;i++)
-                       
assertEquals(methodSFS.get(SAMPLE_STRING_PAIRS[i][0]),SAMPLE_STRING_PAIRS[i][1]);
+                       assertEquals(methodSFS.get(SAMPLE_STRING_PAIRS[i][0]),
+                                       SAMPLE_STRING_PAIRS[i][1]);
        }

        /**
@@ -591,9 +633,11 @@
                methodSFS.removeSubset("foo");
                for(int i = 1; i< 3; i++)
                        assertNull(methodSFS.get(SAMPLE_STRING_PAIRS[i][0]));
-               
assertEquals(methodSFS.get(SAMPLE_STRING_PAIRS[0][0]),SAMPLE_STRING_PAIRS[0][1]);
+               assertEquals(methodSFS.get(SAMPLE_STRING_PAIRS[0][0]),
+                               SAMPLE_STRING_PAIRS[0][1]);
                for(int i = 3; i< 5; i++)
-                       
assertEquals(methodSFS.get(SAMPLE_STRING_PAIRS[i][0]),SAMPLE_STRING_PAIRS[i][1]);
+                       assertEquals(methodSFS.get(SAMPLE_STRING_PAIRS[i][0]),
+                                       SAMPLE_STRING_PAIRS[i][1]);
        }

        /**

Modified: trunk/freenet/test/freenet/support/SizeUtilTest.java
===================================================================
--- trunk/freenet/test/freenet/support/SizeUtilTest.java        2007-07-21 
16:00:42 UTC (rev 14240)
+++ trunk/freenet/test/freenet/support/SizeUtilTest.java        2007-07-21 
16:11:36 UTC (rev 14241)
@@ -25,25 +25,36 @@
 public class SizeUtilTest extends TestCase {

        String[][] valAndExpected = {
-                       {"1","B"},                                              
                        //one byte
-                       {"1024","KiB"},                                         
                //one kilobyte
-                       {"1048576","MiB"},                                      
                //one megabyte
-                       {"1073741824","GiB"},                                   
        //one gigabyte
-                       {"1099511627776","TiB"},                                
        //one terabyte
-                       //{"1125899906842624","1.0 PiB"},                       
//one petabyte
-                       //{"1152921504606846976", "1.0 EiB"},           //one 
exabyte
-                       //{"1180591620717411303424", "1.0 ZiB"},        //one 
zettabyte
-                       //{"1208925819614629174706176","1.0 YiB"},      //one 
yottabyte
+                       //one byte
+                       {"1","B"},
+                       //one kilobyte
+                       {"1024","KiB"},
+                       //one megabyte
+                       {"1048576","MiB"},                                      
                
+                       //one gigabyte
+                       {"1073741824","GiB"},                                   
        
+                       //one terabyte
+                       {"1099511627776","TiB"},                                
        
+                       //one petabyte
+                       //{"1125899906842624","1.0 PiB"},                       
+                       //one exabyte
+                       //{"1152921504606846976", "1.0 EiB"},           
+                       //one zettabyte
+                       //{"1180591620717411303424", "1.0 ZiB"},        
+                       //one yottabyte
+                       //{"1208925819614629174706176","1.0 YiB"},      
        };

        public void testFormatSizeLong() {
                Long methodLong;
                methodLong = Long.valueOf(valAndExpected[0][0]);
-               assertEquals(SizeUtil.formatSize(methodLong.longValue()),"1 
"+valAndExpected[0][1]);
+               assertEquals(SizeUtil.formatSize(methodLong.longValue()),
+                               "1 "+valAndExpected[0][1]);

                for(int i = 1; i < valAndExpected.length; i++) {
                        methodLong = Long.valueOf(valAndExpected[i][0]);
-                       
assertEquals(SizeUtil.formatSize(methodLong.longValue()),"1.0 
"+valAndExpected[i][1]); }
+                       
assertEquals(SizeUtil.formatSize(methodLong.longValue()),
+                                       "1.0 "+valAndExpected[i][1]); }
        }

        /**

Modified: trunk/freenet/test/freenet/support/TimeUtilTest.java
===================================================================
--- trunk/freenet/test/freenet/support/TimeUtilTest.java        2007-07-21 
16:00:42 UTC (rev 14240)
+++ trunk/freenet/test/freenet/support/TimeUtilTest.java        2007-07-21 
16:11:36 UTC (rev 14241)
@@ -26,7 +26,8 @@
  */
 public class TimeUtilTest extends TestCase {

-       private long oneForTermLong = 694861001;        //1w+1d+1h+1m+1s+1ms
+       //1w+1d+1h+1m+1s+1ms
+       private long oneForTermLong = 694861001;

        protected void setUp() throws Exception {
                Locale.setDefault(Locale.US);
@@ -38,7 +39,8 @@
         */
        public void testFormatTime_LongIntBoolean_MaxValue() {
                String expectedForMaxLongValue = "15250284452w3d7h12m55.807s";
-               
assertEquals(TimeUtil.formatTime(Long.MAX_VALUE,6,true),expectedForMaxLongValue);
+               assertEquals(TimeUtil.formatTime(Long.MAX_VALUE,6,true),
+                               expectedForMaxLongValue);
        }

        /**
@@ -47,7 +49,8 @@
         */
        public void testFormatTime_LongInt() {
                String expectedForMaxLongValue = "15250284452w3d7h12m55s";
-               
assertEquals(TimeUtil.formatTime(Long.MAX_VALUE,6),expectedForMaxLongValue);
+               assertEquals(TimeUtil.formatTime(Long.MAX_VALUE,6),
+                               expectedForMaxLongValue);
        }

        /**
@@ -55,8 +58,10 @@
         * trying the biggest long value
         */
        public void testFormatTime_Long() {
-               String expectedForMaxLongValue = "15250284452w3d";      //it 
uses two terms by default
-               
assertEquals(TimeUtil.formatTime(Long.MAX_VALUE),expectedForMaxLongValue);
+               //it uses two terms by default
+               String expectedForMaxLongValue = "15250284452w3d";
+               assertEquals(TimeUtil.formatTime(Long.MAX_VALUE),
+                               expectedForMaxLongValue);
        }

        /**
@@ -68,15 +73,21 @@
        public void testFormatTime_KnownValues() {
                Long methodLong;
                String[][] valAndExpected = {
-                               {"604800000","1w"},     //one week
-                               {"86400000","1d"},      //one day
-                               {"3600000","1h"},       //one hour
-                               {"60000","1m"},         //one minute
-                               {"1000","1s"}           //one second
+                               //one week
+                               {"604800000","1w"},     
+                               //one day
+                               {"86400000","1d"},      
+                               //one hour
+                               {"3600000","1h"},       
+                               //one minute
+                               {"60000","1m"},         
+                               //one second
+                               {"1000","1s"}           
                };
                for(int i = 0; i < valAndExpected.length; i++) {
                        methodLong = Long.valueOf(valAndExpected[i][0]);
-                       
assertEquals(TimeUtil.formatTime(methodLong.longValue()),valAndExpected[i][1]); 
}       
+                       
assertEquals(TimeUtil.formatTime(methodLong.longValue()),
+                                       valAndExpected[i][1]); }        
        }

        /**
@@ -87,16 +98,24 @@
         */
        public void testFormatTime_LongIntBoolean_maxTerms() {
                String[] valAndExpected = {
-                               "",                                     //0 
terms
-                               "1w",                           //1 term
-                               "1w1d",                         //2 terms
-                               "1w1d1h",                       //3 terms
-                               "1w1d1h1m",                     //4 terms
-                               "1w1d1h1m1s",           //5 terms
-                               "1w1d1h1m1.001s"        //6 terms
+                               //0 terms
+                               "",                                     
+                               //1 term
+                               "1w",                           
+                               //2 terms
+                               "1w1d",                         
+                               //3 terms
+                               "1w1d1h",                       
+                               //4 terms
+                               "1w1d1h1m",                     
+                               //5 terms
+                               "1w1d1h1m1s",           
+                               //6 terms
+                               "1w1d1h1m1.001s"        
                };
                for(int i = 0; i < valAndExpected.length; i++)
-                       
assertEquals(TimeUtil.formatTime(oneForTermLong,i,true),valAndExpected[i]);
+                       assertEquals(TimeUtil.formatTime(oneForTermLong,i,true),
+                                       valAndExpected[i]);
        }

        /**

Modified: trunk/freenet/test/freenet/support/URLEncoderDecoderTest.java
===================================================================
--- trunk/freenet/test/freenet/support/URLEncoderDecoderTest.java       
2007-07-21 16:00:42 UTC (rev 14240)
+++ trunk/freenet/test/freenet/support/URLEncoderDecoderTest.java       
2007-07-21 16:11:36 UTC (rev 14241)
@@ -38,10 +38,13 @@
         */
        public void testEncodeDecodeString_notSafeBaseChars() {
                String[] toEncode = {
-                               URLEncoder.safeURLCharacters,                   
//safe chars
+                               //safe chars
+                               URLEncoder.safeURLCharacters,
                                prtblAscii,
-                               "%%%",          //triple % char, if badly 
encoded it will generate an exception
-                               ""                      //no chars
+                               //triple % char, if badly encoded it will 
generate an exception
+                               "%%%",
+                               //no chars
+                               ""
                };

                try {
@@ -75,9 +78,11 @@
        private boolean areCorrectlyEncodedDecoded(String[] toEncode) throws 
URLEncodedFormatException {
                boolean retValue = true;
                String[] encoded = new String[toEncode.length];
-               for (int i = 0; i < encoded.length; i++)        //encoding
+               //encoding
+               for (int i = 0; i < encoded.length; i++)        
                        encoded[i] = URLEncoder.encode(toEncode[i]);
-               for (int i = 0; i < encoded.length; i++)        //decoding
+               //decoding
+               for (int i = 0; i < encoded.length; i++)
                        retValue &= 
(URLDecoder.decode(encoded[i],false)).equals(toEncode[i]);
                return retValue;
        }
@@ -98,8 +103,10 @@
                                expectedResult = "%"+ HexUtil.bytesToHex(
                                                //since safe chars are only 
US-ASCII
                                                toEncode.getBytes("US-ASCII")); 
-                               
assertEquals(URLEncoder.encode(toEncode,toEncode,false),expectedResult);
-                               
assertEquals(URLEncoder.encode(toEncode,toEncode,true),expectedResult);
+                               
assertEquals(URLEncoder.encode(toEncode,toEncode,false),
+                                               expectedResult);
+                               
assertEquals(URLEncoder.encode(toEncode,toEncode,true),
+                                               expectedResult);
                        } catch (UnsupportedEncodingException anException) {
                                fail("Not expected exception thrown : " + 
anException.getMessage()); }
                }
@@ -143,7 +150,8 @@
                String toDecode = 
"123456789abcde"+prtblAscii+stressedUTF_8Chars;

                for (int i = 0; i<toDecode.length(); i++)
-                       
assertTrue(isDecodeRaisingEncodedException("%"+toDecode.substring(i,i+1),false));
+                       assertTrue(
+                                       
isDecodeRaisingEncodedException("%"+toDecode.substring(i,i+1),false));
        }

        /**


Reply via email to