sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1469780 - in /sis/branches/JDK7: sis-referencing/src/test/java/org/apache/sis/test/suite/ sis-utility/src/main/java/org/apache/sis/internal/simple/ sis-utility/src/main/java/org/apache/sis/util/ sis-utility/src/main/java/org/apache/sis/uti...
Date Fri, 19 Apr 2013 11:15:02 GMT
Author: desruisseaux
Date: Fri Apr 19 11:15:02 2013
New Revision: 1469780

URL: http://svn.apache.org/r1469780
Log:
Minor adjustments: hashMapCapacity(int) not needed for IdentityHashMap,
test suite shall validate test cases (order, parent) before execution.

Modified:
    sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
    sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java
    sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java

Modified: sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1469780&r1=1469779&r2=1469780&view=diff
==============================================================================
--- sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Fri Apr 19 11:15:02 2013
@@ -18,6 +18,7 @@ package org.apache.sis.test.suite;
 
 import org.apache.sis.test.TestSuite;
 import org.junit.runners.Suite;
+import org.junit.BeforeClass;
 
 
 /**
@@ -40,4 +41,11 @@ import org.junit.runners.Suite;
     org.apache.sis.geometry.Envelope2DTest.class
 })
 public final strictfp class ReferencingTestSuite extends TestSuite {
+    /**
+     * Verifies the list of tests before the suite is run.
+     */
+    @BeforeClass
+    public static void verifyTestList() {
+        verifyTestList(MetadataTestSuite.class);
+    }
 }

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java?rev=1469780&r1=1469779&r2=1469780&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java
[UTF-8] Fri Apr 19 11:15:02 2013
@@ -151,7 +151,7 @@ public class SimpleReferenceIdentifier i
      */
     @Override
     public int hashCode() {
-        return Objects.hash(authority, code);
+        return Objects.hash(authority, code) ^ (int) serialVersionUID;
     }
 
     /**

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Numbers.java?rev=1469780&r1=1469779&r2=1469780&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Numbers.java [UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Numbers.java [UTF-8] Fri
Apr 19 11:15:02 2013
@@ -61,7 +61,7 @@ public final class Numbers extends Stati
      *        less objects since <code>IdentityHashMap</code> implementation
doesn't need the chain
      *        of objects created by <code>HashMap</code>.}
      */
-    private static final Map<Class<?>,Numbers> MAPPING = new IdentityHashMap<>(16);
+    private static final Map<Class<?>,Numbers> MAPPING = new IdentityHashMap<>(11);
     static {
         new Numbers(BigDecimal.class, true, false, BIG_DECIMAL);
         new Numbers(BigInteger.class, false, true, BIG_INTEGER);

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java?rev=1469780&r1=1469779&r2=1469780&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
[UTF-8] Fri Apr 19 11:15:02 2013
@@ -217,7 +217,8 @@ public final class Containers extends St
      * for the default <cite>load factor</cite>, which is 0.75.
      *
      * <p>The same calculation can be used for {@link java.util.LinkedHashMap} and
-     * {@link java.util.HashSet} as well, which are built on top of {@code HashMap}.</p>
+     * {@link java.util.HashSet} as well, which are built on top of {@code HashMap}.
+     * However it is not needed for {@link java.util.IdentityHashMap}.</p>
      *
      * @param count The number of elements to be put into the hash map or hash set.
      * @return The minimal initial capacity to be given to the hash map constructor.

Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java?rev=1469780&r1=1469779&r2=1469780&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java [UTF-8]
(original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java [UTF-8]
Fri Apr 19 11:15:02 2013
@@ -16,9 +16,13 @@
  */
 package org.apache.sis.test;
 
+import java.util.Map;
+import java.util.IdentityHashMap;
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
 
+import static org.junit.Assert.*;
+
 
 /**
  * Base class of Apache SIS test suites (except the ones that extend GeoAPI suites).
@@ -35,4 +39,39 @@ public abstract strictfp class TestSuite
      */
     protected TestSuite() {
     }
+
+    /**
+     * Verifies the list of tests before the suite is run.
+     * Subclasses shall invoke this method as below:
+     *
+     * {@preformat java
+     *    &#64;BeforeClass
+     *    public static void verifyTestList() {
+     *        verifyTestList(MetadataTestSuite.class);
+     *    }
+     * }
+     *
+     * @param suite The suite for which to verify order.
+     */
+    protected static void verifyTestList(final Class<? extends TestSuite> suite) {
+        final Class<?>[] testCases = suite.getAnnotation(Suite.SuiteClasses.class).value();
+        final Map<Class<?>,Boolean> done = new IdentityHashMap<>(testCases.length);
+        for (final Class<?> testCase : testCases) {
+            if (!TestCase.class.isAssignableFrom(testCase)) {
+                fail("Class " + testCase.getCanonicalName() + " does not extends TestCase.");
+            }
+            final DependsOn dependencies = testCase.getAnnotation(DependsOn.class);
+            if (dependencies != null) {
+                for (final Class<?> dependency : dependencies.value()) {
+                    if (!done.containsKey(dependency)) {
+                        fail("Class " + testCase.getCanonicalName() + " depends on " + dependency.getCanonicalName()
+                                + ", but the dependency has not been found before the test.");
+                    }
+                }
+            }
+            if (done.put(testCase, Boolean.TRUE) != null) {
+                fail("Class " + testCase.getCanonicalName() + " is declared twice.");
+            }
+        }
+    }
 }

Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1469780&r1=1469779&r2=1469780&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
[UTF-8] Fri Apr 19 11:15:02 2013
@@ -18,6 +18,7 @@ package org.apache.sis.test.suite;
 
 import org.apache.sis.test.TestSuite;
 import org.junit.runners.Suite;
+import org.junit.BeforeClass;
 
 
 /**
@@ -108,4 +109,11 @@ import org.junit.runners.Suite;
     org.apache.sis.internal.jaxb.IdentifierMapWithSpecialCasesTest.class
 })
 public final strictfp class UtilityTestSuite extends TestSuite {
+    /**
+     * Verifies the list of tests before the suite is run.
+     */
+    @BeforeClass
+    public static void verifyTestList() {
+        verifyTestList(MetadataTestSuite.class);
+    }
 }



Mime
View raw message