You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2015/06/08 13:25:38 UTC

svn commit: r1684152 - /sling/trunk/bundles/api/src/test/java/org/apache/sling/api/wrappers/ValueMapDecoratorTest.java

Author: kwin
Date: Mon Jun  8 11:25:38 2015
New Revision: 1684152

URL: http://svn.apache.org/r1684152
Log:
fix formatting

Modified:
    sling/trunk/bundles/api/src/test/java/org/apache/sling/api/wrappers/ValueMapDecoratorTest.java

Modified: sling/trunk/bundles/api/src/test/java/org/apache/sling/api/wrappers/ValueMapDecoratorTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/test/java/org/apache/sling/api/wrappers/ValueMapDecoratorTest.java?rev=1684152&r1=1684151&r2=1684152&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/test/java/org/apache/sling/api/wrappers/ValueMapDecoratorTest.java (original)
+++ sling/trunk/bundles/api/src/test/java/org/apache/sling/api/wrappers/ValueMapDecoratorTest.java Mon Jun  8 11:25:38 2015
@@ -28,113 +28,123 @@ import org.junit.Ignore;
 import org.junit.Test;
 
 public class ValueMapDecoratorTest {
-	
-	private Map<String, Object> map;
-	private ValueMap valueMap;
-	
-	@Before
-	public void setUp() {
-		map = new HashMap<String,Object>();
-		valueMap = new ValueMapDecorator(map);
-	}
-
-	// SLING-4178
-	@Test
-	public void testIncompatibleTypeInArray() {
-		map.put("prop1", new String[] {"test", "test2"});
-		map.put("prop2", "test");
-		Assert.assertNull("Not convertible type should return null", valueMap.get("prop1", Integer[].class));
-		Assert.assertNull("Not convertible type should return null", valueMap.get("prop2", Integer[].class));
-	}
-	
-	// SLING-662
-	@Test
-	public void testGettingArraysFromSingleValueEntries() {
-		map.put("prop1", "test");
-		map.put("prop2", "1");
-		Assert.assertArrayEquals("Even though the underlying entry is single-value if should be enclosed in a single element array", new String[] {"test"}, valueMap.get("prop1", String[].class));
-		Assert.assertArrayEquals("Even though the underlying entry is single-value if should be enclosed in a single element array", new Integer[] {1}, valueMap.get("prop2", Integer[].class));
-	}
-	
-	@Test
-	public void testGettingArraysFromMultiValueEntries() {
-		map.put("prop1", new String[] {"test", "test2"});
-		map.put("prop2", new String[] {"1", "2"});
-		Assert.assertArrayEquals("Could not get values from underlying array", new String[] {"test", "test2"}, valueMap.get("prop1", String[].class));
-		Assert.assertArrayEquals("Conversion to Integer was not possible", new Integer[] {1, 2}, valueMap.get("prop2", Integer[].class));
-	}
-	
-	@Test
-	@Ignore("SLING-4658")
-	public void testGettingSingleValuesFromMultiValueEntries() {
-		map.put("prop1", new String[] {"test", "test2"});
-		map.put("prop2", new String[] {"1", "2"});
-		Assert.assertEquals("First element from underlying array should be returned", "test", valueMap.get("prop1", String.class));
-		Assert.assertEquals("First element from underlying array should be returned", Integer.valueOf(1), valueMap.get("prop1", Integer.class));
-	}
-	
-	@Test
-	public void testGettingInvalidEntryWithDefaultValue() {
-		Assert.assertEquals(Integer.valueOf(1), valueMap.get("prop1", 1));
-		Assert.assertEquals("test", valueMap.get("prop1", "test"));
-	}
-	
-	@Test
-	public void testPrimitiveTypes() {
-		map.put("prop1", new String[] {"1", "2"});
-		Assert.assertNull("ValueMap should not support conversion to primitive type", valueMap.get("prop1", int.class));
-		Assert.assertNull("ValueMap should not support conversion to array of primitive type", valueMap.get("prop1", int[].class));
-	}
-	
-	@Test 
-	public void testEqualsAndHashCodeOfEqualValueMapsWithNonArrayTypes() {
-	        map.put("prop1", "some string");
-                ValueMapDecorator valueMap2 = new ValueMapDecorator(map);
-                Assert.assertTrue("Two ValueMapDecorators based on the same map should be equal", valueMap.equals(valueMap2));
-                Assert.assertEquals("Two equal ValueMapDecorators should have the same hash code", valueMap.hashCode(), valueMap2.hashCode());
-                
-                ValueMapDecorator valueMap3 = new ValueMapDecorator(new HashMap<String, Object>());
-                valueMap3.put("prop1", "some string");
-                Assert.assertEquals(valueMap, valueMap3);
-                Assert.assertEquals("Two equal ValueMapDecorators should have the same hash code", valueMap.hashCode(), valueMap3.hashCode());
-                
-                Assert.assertEquals(map, valueMap);
-                Assert.assertEquals(valueMap, map);
-	}
-	
-	@Ignore("SLING-4784")
-	@Test
-        public void testEqualsAndHashCodeOfEqualValueMapsWithArrayTypes() {
-                map.put("prop1", new String[] {"1", "2"});
-                ValueMapDecorator valueMap2 = new ValueMapDecorator(map);
-                Assert.assertTrue("Two ValueMapDecorators based on the same map should be equal", valueMap.equals(valueMap2));
-                Assert.assertEquals("Two equal ValueMapDecorators should have the same hash code", valueMap.hashCode(), valueMap2.hashCode());
-                
-                ValueMapDecorator valueMap3 = new ValueMapDecorator(new HashMap<String, Object>());
-                valueMap3.put("prop1", new String[] {"1", "2"});
-                Assert.assertEquals(valueMap, valueMap3);
-                Assert.assertEquals("Two equal ValueMapDecorators should have the same hash code", valueMap.hashCode(), valueMap3.hashCode());
-        }
-	
-	@Test 
-        public void testEqualsOfInequalValueMapsWithNonArrayTypes() {
-                valueMap.put("prop", "value");
-                ValueMapDecorator valueMap2 = new ValueMapDecorator(new HashMap<String, Object>());
-                valueMap2.put("prop", "value2");
-                Assert.assertFalse("Two ValueMapDecorators based on maps with different entries should not be equal", valueMap.equals(valueMap2));
-                
-        }
-	
-	@Test 
-        public void testEqualsOfInequalValueMapsWithArrayTypes() {
-                valueMap.put("prop", new String[] {"1", "2"});
-                ValueMapDecorator valueMap2 = new ValueMapDecorator(new HashMap<String, Object>());
-                valueMap2.put("prop", new String[] {"3", "4"});
-                Assert.assertFalse("Two ValueMapDecorators based on maps with different entries should not be equal", valueMap.equals(valueMap2));
-        }
-	
-	@Test 
-        public void testEqualsOfValueMapAndUnderlyingMap() {
-                
-        }
+
+    private Map<String, Object> map;
+    private ValueMap valueMap;
+
+    @Before
+    public void setUp() {
+        map = new HashMap<String, Object>();
+        valueMap = new ValueMapDecorator(map);
+    }
+
+    // SLING-4178
+    @Test
+    public void testIncompatibleTypeInArray() {
+        map.put("prop1", new String[] { "test", "test2" });
+        map.put("prop2", "test");
+        Assert.assertNull("Not convertible type should return null", valueMap.get("prop1", Integer[].class));
+        Assert.assertNull("Not convertible type should return null", valueMap.get("prop2", Integer[].class));
+    }
+
+    // SLING-662
+    @Test
+    public void testGettingArraysFromSingleValueEntries() {
+        map.put("prop1", "test");
+        map.put("prop2", "1");
+        Assert.assertArrayEquals(
+                "Even though the underlying entry is single-value if should be enclosed in a single element array",
+                new String[] { "test" }, valueMap.get("prop1", String[].class));
+        Assert.assertArrayEquals(
+                "Even though the underlying entry is single-value if should be enclosed in a single element array",
+                new Integer[] { 1 }, valueMap.get("prop2", Integer[].class));
+    }
+
+    @Test
+    public void testGettingArraysFromMultiValueEntries() {
+        map.put("prop1", new String[] { "test", "test2" });
+        map.put("prop2", new String[] { "1", "2" });
+        Assert.assertArrayEquals("Could not get values from underlying array", new String[] { "test", "test2" },
+                valueMap.get("prop1", String[].class));
+        Assert.assertArrayEquals("Conversion to Integer was not possible", new Integer[] { 1, 2 },
+                valueMap.get("prop2", Integer[].class));
+    }
+
+    @Test
+    @Ignore("SLING-4658")
+    public void testGettingSingleValuesFromMultiValueEntries() {
+        map.put("prop1", new String[] { "test", "test2" });
+        map.put("prop2", new String[] { "1", "2" });
+        Assert.assertEquals("First element from underlying array should be returned", "test",
+                valueMap.get("prop1", String.class));
+        Assert.assertEquals("First element from underlying array should be returned", Integer.valueOf(1),
+                valueMap.get("prop1", Integer.class));
+    }
+
+    @Test
+    public void testGettingInvalidEntryWithDefaultValue() {
+        Assert.assertEquals(Integer.valueOf(1), valueMap.get("prop1", 1));
+        Assert.assertEquals("test", valueMap.get("prop1", "test"));
+    }
+
+    @Test
+    public void testPrimitiveTypes() {
+        map.put("prop1", new String[] { "1", "2" });
+        Assert.assertNull("ValueMap should not support conversion to primitive type", valueMap.get("prop1", int.class));
+        Assert.assertNull("ValueMap should not support conversion to array of primitive type",
+                valueMap.get("prop1", int[].class));
+    }
+
+    @Test
+    public void testEqualsAndHashCodeOfEqualValueMapsWithNonArrayTypes() {
+        map.put("prop1", "some string");
+        ValueMapDecorator valueMap2 = new ValueMapDecorator(map);
+        Assert.assertTrue("Two ValueMapDecorators based on the same map should be equal", valueMap.equals(valueMap2));
+        Assert.assertEquals("Two equal ValueMapDecorators should have the same hash code", valueMap.hashCode(),
+                valueMap2.hashCode());
+
+        ValueMapDecorator valueMap3 = new ValueMapDecorator(new HashMap<String, Object>());
+        valueMap3.put("prop1", "some string");
+        Assert.assertEquals(valueMap, valueMap3);
+        Assert.assertEquals("Two equal ValueMapDecorators should have the same hash code", valueMap.hashCode(),
+                valueMap3.hashCode());
+
+        Assert.assertEquals(map, valueMap);
+        Assert.assertEquals(valueMap, map);
+    }
+
+    @Ignore("SLING-4784")
+    @Test
+    public void testEqualsAndHashCodeOfEqualValueMapsWithArrayTypes() {
+        map.put("prop1", new String[] { "1", "2" });
+        ValueMapDecorator valueMap2 = new ValueMapDecorator(map);
+        Assert.assertTrue("Two ValueMapDecorators based on the same map should be equal", valueMap.equals(valueMap2));
+        Assert.assertEquals("Two equal ValueMapDecorators should have the same hash code", valueMap.hashCode(),
+                valueMap2.hashCode());
+
+        ValueMapDecorator valueMap3 = new ValueMapDecorator(new HashMap<String, Object>());
+        valueMap3.put("prop1", new String[] { "1", "2" });
+        Assert.assertEquals(valueMap, valueMap3);
+        Assert.assertEquals("Two equal ValueMapDecorators should have the same hash code", valueMap.hashCode(),
+                valueMap3.hashCode());
+    }
+
+    @Test
+    public void testEqualsOfInequalValueMapsWithNonArrayTypes() {
+        valueMap.put("prop", "value");
+        ValueMapDecorator valueMap2 = new ValueMapDecorator(new HashMap<String, Object>());
+        valueMap2.put("prop", "value2");
+        Assert.assertFalse("Two ValueMapDecorators based on maps with different entries should not be equal",
+                valueMap.equals(valueMap2));
+
+    }
+
+    @Test
+    public void testEqualsOfInequalValueMapsWithArrayTypes() {
+        valueMap.put("prop", new String[] { "1", "2" });
+        ValueMapDecorator valueMap2 = new ValueMapDecorator(new HashMap<String, Object>());
+        valueMap2.put("prop", new String[] { "3", "4" });
+        Assert.assertFalse("Two ValueMapDecorators based on maps with different entries should not be equal",
+                valueMap.equals(valueMap2));
+    }
 }