diff --git a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/UnmodifiableCollectionsEqualsHashCodeTest.java b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/UnmodifiableCollectionsEqualsHashCodeTest.java new file mode 100755 index 00000000000..cd80507dd29 --- /dev/null +++ b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/UnmodifiableCollectionsEqualsHashCodeTest.java @@ -0,0 +1,58 @@ +package com.sap.sailing.domain.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.junit.Test; + +/** + * Demonstrates how unmodifiable collections' hashCode and equals is useless because it's based on identity and not on + * content. + * + * @author Axel Uhl (D043530) + * + */ +public class UnmodifiableCollectionsEqualsHashCodeTest { + @Test + public void testInequalityOfUnmodifiableCollection() { + List l1 = Arrays.asList(new String[] { "abc", "def" }); + List l2 = new ArrayList<>(l1); + Iterable u1_1 = Collections.unmodifiableCollection(l1); + Iterable u1_2 = Collections.unmodifiableCollection(l1); + Iterable u2_1 = Collections.unmodifiableCollection(l2); + assertEquals(l1, l2); + assertFalse(u1_1.equals(u1_2)); + assertFalse(u1_1.equals(u2_1)); + } + + @Test + public void testInequalityOfUnmodifiableList() { + List l1 = Arrays.asList(new String[] { "abc", "def" }); + List l2 = new ArrayList<>(l1); + Iterable u1_1 = Collections.unmodifiableList(l1); + Iterable u1_2 = Collections.unmodifiableList(l1); + Iterable u2_1 = Collections.unmodifiableList(l2); + assertEquals(l1, l2); + assertEquals(u1_1, u1_2); + assertEquals(u1_1, u2_1); + } + + @Test + public void testInequalityOfUnmodifiableSet() { + Set s1 = new HashSet<>(Arrays.asList(new String[] { "abc", "def" })); + Set s2 = new HashSet<>(s1); + Iterable u1_1 = Collections.unmodifiableSet(s1); + Iterable u1_2 = Collections.unmodifiableSet(s1); + Iterable u2_1 = Collections.unmodifiableSet(s2); + assertEquals(s1, s2); + assertEquals(u1_1, u1_2); + assertEquals(u1_1, u2_1); + } +} diff --git a/java/com.sap.sailing.gwt.ui/SailingGWT Remote Profiling (Run-Mode only).launch b/java/com.sap.sailing.gwt.ui/SailingGWT Remote Profiling (Run-Mode only).launch index 0b8d83049f1..4f72490703a 100644 --- a/java/com.sap.sailing.gwt.ui/SailingGWT Remote Profiling (Run-Mode only).launch +++ b/java/com.sap.sailing.gwt.ui/SailingGWT Remote Profiling (Run-Mode only).launch @@ -1,60 +1,60 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/com.sap.sailing.gwt.ui/SailingGWT.launch b/java/com.sap.sailing.gwt.ui/SailingGWT.launch index 0581b4ca7a1..ee115cc9942 100755 --- a/java/com.sap.sailing.gwt.ui/SailingGWT.launch +++ b/java/com.sap.sailing.gwt.ui/SailingGWT.launch @@ -1,56 +1,56 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +