You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2010/10/19 07:59:17 UTC

svn commit: r1024124 - in /incubator/isis/trunk: alternatives/security/file/ core/progmodel/ core/runtime/src/test/java/org/apache/isis/runtime/authentication/standard/ldap/ core/runtime/src/test/java/org/apache/isis/runtime/fixture/ core/runtime/src/t...

Author: danhaywood
Date: Tue Oct 19 05:59:16 2010
New Revision: 1024124

URL: http://svn.apache.org/viewvc?rev=1024124&view=rev
Log:
improvements to ValueTypeContractTestAbstract; ignoring .classpath etc

Added:
    incubator/isis/trunk/core/runtime/src/test/java/org/apache/isis/runtime/testsystem/tests/TestProxyOid_ValueType.java
Removed:
    incubator/isis/trunk/core/runtime/src/test/java/org/apache/isis/runtime/authentication/standard/ldap/
    incubator/isis/trunk/core/runtime/src/test/java/org/apache/isis/runtime/fixture/
    incubator/isis/trunk/core/runtime/src/test/java/org/apache/isis/runtime/objectstore/
Modified:
    incubator/isis/trunk/alternatives/security/file/   (props changed)
    incubator/isis/trunk/core/progmodel/   (props changed)
    incubator/isis/trunk/core/testsupport/src/main/java/org/apache/isis/testsupport/ValueTypeContractTestAbstract.java
    incubator/isis/trunk/core/testsupport/src/test/java/org/apache/isis/testsupport/ValueTypeContractTestAbstract_BigIntegerTest.java
    incubator/isis/trunk/core/testsupport/src/test/java/org/apache/isis/testsupport/ValueTypeContractTestAbstract_StringIntegerTest.java
    incubator/isis/trunk/support/   (props changed)
    incubator/isis/trunk/support/archetypes/exploration/   (props changed)
    incubator/isis/trunk/support/archetypes/scimpi/   (props changed)

Propchange: incubator/isis/trunk/alternatives/security/file/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Oct 19 05:59:16 2010
@@ -0,0 +1,4 @@
+.settings
+target
+.classpath
+.project

Propchange: incubator/isis/trunk/core/progmodel/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Oct 19 05:59:16 2010
@@ -0,0 +1,4 @@
+.settings
+target
+.classpath
+.project

Added: incubator/isis/trunk/core/runtime/src/test/java/org/apache/isis/runtime/testsystem/tests/TestProxyOid_ValueType.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/core/runtime/src/test/java/org/apache/isis/runtime/testsystem/tests/TestProxyOid_ValueType.java?rev=1024124&view=auto
==============================================================================
--- incubator/isis/trunk/core/runtime/src/test/java/org/apache/isis/runtime/testsystem/tests/TestProxyOid_ValueType.java (added)
+++ incubator/isis/trunk/core/runtime/src/test/java/org/apache/isis/runtime/testsystem/tests/TestProxyOid_ValueType.java Tue Oct 19 05:59:16 2010
@@ -0,0 +1,22 @@
+package org.apache.isis.runtime.testsystem.tests;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.isis.runtime.testsystem.TestProxyOid;
+import org.apache.isis.testsupport.ValueTypeContractTestAbstract;
+
+public class TestProxyOid_ValueType extends ValueTypeContractTestAbstract<TestProxyOid> {
+
+	@Override
+	protected List<TestProxyOid> getObjectsWithSameValue() {
+		return Arrays.asList(new TestProxyOid(1, true), new TestProxyOid(1, true));
+	}
+
+	@Override
+	protected List<TestProxyOid> getObjectsWithDifferentValue() {
+		return Arrays.asList(new TestProxyOid(1, false), new TestProxyOid(2, true));
+	}
+
+
+}

Modified: incubator/isis/trunk/core/testsupport/src/main/java/org/apache/isis/testsupport/ValueTypeContractTestAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/core/testsupport/src/main/java/org/apache/isis/testsupport/ValueTypeContractTestAbstract.java?rev=1024124&r1=1024123&r2=1024124&view=diff
==============================================================================
--- incubator/isis/trunk/core/testsupport/src/main/java/org/apache/isis/testsupport/ValueTypeContractTestAbstract.java (original)
+++ incubator/isis/trunk/core/testsupport/src/main/java/org/apache/isis/testsupport/ValueTypeContractTestAbstract.java Tue Oct 19 05:59:16 2010
@@ -4,56 +4,75 @@ import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.assertThat;
 import static org.junit.matchers.JUnitMatchers.*;
 
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Before;
 import org.junit.Test;
 
 /**
  * Contract test for value types ({@link #equals(Object)} and {@link #hashCode()}).
  */
-public abstract class ValueTypeContractTestAbstract {
+public abstract class ValueTypeContractTestAbstract<T> {
 	
-	@Test
-	public void symmetric() throws Exception {
-		Object o1 = getObject();
-		assertThat(o1.equals(o1), is(true));
+	@Before
+	public void setUp() throws Exception {
+		assertSizeAtLeast(getObjectsWithSameValue(), 2);
+		assertSizeAtLeast(getObjectsWithDifferentValue(), 1);
 	}
 
+	private void assertSizeAtLeast(List<T> objects, int i) {
+		assertThat(objects, is(notNullValue()));
+		assertThat(objects.size(), is(greaterThan(i-1)));
+	}
+	
+	
 	@Test
 	public void notEqualToNull() throws Exception {
-		Object o1 = getObject();
-		assertThat(o1.equals(null), is(false));
+		for(T o1: getObjectsWithSameValue()) {
+			assertThat(o1.equals(null), is(false));
+		}
+		for(T o1: getObjectsWithDifferentValue()) {
+			assertThat(o1.equals(null), is(false));
+		}
 	}
 
 	@Test
-	public void reflexiveWhenEqual() throws Exception {
-		Object o1 = getObject();
-		Object o2 = getObjectWithSameValue();
-		assertThat(o1.equals(o2), is(true));
-		assertThat(o2.equals(o1), is(true));
+	public void reflexiveAndSymmetric() throws Exception {
+		for(T o1: getObjectsWithSameValue()) {
+			for(T o2: getObjectsWithSameValue()) {
+				assertThat(o1.equals(o2), is(true));
+				assertThat(o2.equals(o1), is(true));
+				assertThat(o1.hashCode(), is(equalTo(o2.hashCode())));
+			}
+		}
 	}
 
 	@Test
-	public void reflexiveWhenNotEqual() throws Exception {
-		Object o1 = getObject();
-		Object o2 = getObjectWithDifferentValue();
-		assertThat(o1.equals(o2), is(false));
-		assertThat(o2.equals(o1), is(false));
+	public void notEqual() throws Exception {
+		for(T o1: getObjectsWithSameValue()) {
+			for(T o2: getObjectsWithDifferentValue()) {
+				assertThat(o1.equals(o2), is(false));
+				assertThat(o2.equals(o1), is(false));
+			}
+		}
 	}
 
 	@Test
 	public void transitiveWhenEqual() throws Exception {
-		Object o1 = getObject();
-		Object o2 = getObjectWithSameValue();
-		Object o3 = getAnotherObjectWithSameValue();
-		assertThat(o1.equals(o2), is(true));
-		assertThat(o2.equals(o3), is(true));
-		
-		assertThat(o1.equals(o3), is(true));
+		for(T o1: getObjectsWithSameValue()) {
+			for(T o2: getObjectsWithSameValue()) {
+				for(Object o3: getObjectsWithSameValue()) {
+					assertThat(o1.equals(o2), is(true));
+					assertThat(o2.equals(o3), is(true));
+					assertThat(o1.equals(o3), is(true));
+				}
+			}
+		}
 	}
 
-	protected abstract Object getObject();
-	protected abstract Object getObjectWithSameValue();
-	protected abstract Object getAnotherObjectWithSameValue();
+	protected abstract List<T> getObjectsWithSameValue();
+	protected abstract List<T> getObjectsWithDifferentValue();
 
-	protected abstract Object getObjectWithDifferentValue();
 
 }

Modified: incubator/isis/trunk/core/testsupport/src/test/java/org/apache/isis/testsupport/ValueTypeContractTestAbstract_BigIntegerTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/core/testsupport/src/test/java/org/apache/isis/testsupport/ValueTypeContractTestAbstract_BigIntegerTest.java?rev=1024124&r1=1024123&r2=1024124&view=diff
==============================================================================
--- incubator/isis/trunk/core/testsupport/src/test/java/org/apache/isis/testsupport/ValueTypeContractTestAbstract_BigIntegerTest.java (original)
+++ incubator/isis/trunk/core/testsupport/src/test/java/org/apache/isis/testsupport/ValueTypeContractTestAbstract_BigIntegerTest.java Tue Oct 19 05:59:16 2010
@@ -1,27 +1,19 @@
 package org.apache.isis.testsupport;
 
 import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
 
-public class ValueTypeContractTestAbstract_BigIntegerTest extends ValueTypeContractTestAbstract {
+public class ValueTypeContractTestAbstract_BigIntegerTest extends ValueTypeContractTestAbstract<BigInteger> {
 
 	@Override
-	protected Object getObject() {
-		return new BigInteger("1");
+	protected List<BigInteger> getObjectsWithSameValue() {
+		return Arrays.asList(new BigInteger("1"), new BigInteger("1"));
 	}
 
 	@Override
-	protected Object getObjectWithSameValue() {
-		return new BigInteger("1");
-	}
-
-	@Override
-	protected Object getAnotherObjectWithSameValue() {
-		return new BigInteger("1");
-	}
-
-	@Override
-	protected Object getObjectWithDifferentValue() {
-		return new BigInteger("2");
+	protected List<BigInteger> getObjectsWithDifferentValue() {
+		return Arrays.asList(new BigInteger("2"));
 	}
 
 }

Modified: incubator/isis/trunk/core/testsupport/src/test/java/org/apache/isis/testsupport/ValueTypeContractTestAbstract_StringIntegerTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/core/testsupport/src/test/java/org/apache/isis/testsupport/ValueTypeContractTestAbstract_StringIntegerTest.java?rev=1024124&r1=1024123&r2=1024124&view=diff
==============================================================================
--- incubator/isis/trunk/core/testsupport/src/test/java/org/apache/isis/testsupport/ValueTypeContractTestAbstract_StringIntegerTest.java (original)
+++ incubator/isis/trunk/core/testsupport/src/test/java/org/apache/isis/testsupport/ValueTypeContractTestAbstract_StringIntegerTest.java Tue Oct 19 05:59:16 2010
@@ -1,27 +1,18 @@
 package org.apache.isis.testsupport;
 
-import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
 
-public class ValueTypeContractTestAbstract_StringIntegerTest extends ValueTypeContractTestAbstract {
+public class ValueTypeContractTestAbstract_StringIntegerTest extends ValueTypeContractTestAbstract<String> {
 
 	@Override
-	protected Object getObject() {
-		return new String("1");
+	protected List<String> getObjectsWithSameValue() {
+		return Arrays.asList(new String("1"), new String("1"));
 	}
 
 	@Override
-	protected Object getObjectWithSameValue() {
-		return new String("1");
-	}
-
-	@Override
-	protected Object getAnotherObjectWithSameValue() {
-		return new String("1");
-	}
-
-	@Override
-	protected Object getObjectWithDifferentValue() {
-		return new String("2");
+	protected List<String> getObjectsWithDifferentValue() {
+		return Arrays.asList(new String("1 "), new String(" 1"), new String("2"));
 	}
 
 }

Propchange: incubator/isis/trunk/support/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Oct 19 05:59:16 2010
@@ -1 +1,3 @@
 target
+.settings
+.project

Propchange: incubator/isis/trunk/support/archetypes/exploration/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Oct 19 05:59:16 2010
@@ -1 +1,4 @@
 target
+.settings
+.classpath
+.project

Propchange: incubator/isis/trunk/support/archetypes/scimpi/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Oct 19 05:59:16 2010
@@ -1 +1,4 @@
 target
+.settings
+.classpath
+.project