You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2013/04/19 19:25:50 UTC
svn commit: r1469961 - in /sis/branches/JDK6: ./
sis-metadata/src/main/java/org/apache/sis/metadata/
sis-metadata/src/test/java/org/apache/sis/metadata/
sis-metadata/src/test/java/org/apache/sis/test/suite/
sis-referencing/src/test/java/org/apache/sis/...
Author: desruisseaux
Date: Fri Apr 19 17:25:49 2013
New Revision: 1469961
URL: http://svn.apache.org/r1469961
Log:
Merge from the JDK7 branch.
Added:
sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java
- copied, changed from r1469956, sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java
sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java
- copied, changed from r1469956, sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java
sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java
- copied, changed from r1469956, sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java
sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java
- copied, changed from r1469956, sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java
Modified:
sis/branches/JDK6/ (props changed)
sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java
sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/test/AssertTest.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/test/XMLComparatorTest.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java
Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
Merged /sis/branches/JDK7:r1469597-1469956
Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java?rev=1469961&r1=1469960&r2=1469961&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java [UTF-8] Fri Apr 19 17:25:49 2013
@@ -32,6 +32,7 @@ import org.apache.sis.util.resources.Err
import org.apache.sis.util.collection.TreeTable;
import org.apache.sis.util.collection.CheckedContainer;
import org.apache.sis.internal.util.SystemListener;
+import org.apache.sis.internal.simple.SimpleCitation;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -116,8 +117,8 @@ public class MetadataStandard {
final String[] acronyms = {"CoordinateSystem", "CS", "CoordinateReferenceSystem", "CRS"};
ISO_19111 = new StandardImplementation("ISO 19111", "org.opengis.referencing.", "org.apache.sis.referencing.", prefix, acronyms);
ISO_19115 = new StandardImplementation("ISO 19115", "org.opengis.metadata.", "org.apache.sis.metadata.iso.", prefix, null);
- ISO_19119 = new StandardImplementation("ISO 19119", "org.opengis.service.", null, null, null);
- ISO_19123 = new StandardImplementation("ISO 19123", "org.opengis.coverage.", null, null, null);
+ ISO_19119 = new MetadataStandard ("ISO 19119", "org.opengis.service.");
+ ISO_19123 = new MetadataStandard ("ISO 19123", "org.opengis.coverage.");
INSTANCES = new MetadataStandard[] {
ISO_19111,
ISO_19115,
@@ -179,8 +180,8 @@ public class MetadataStandard {
* @param citation Bibliographical reference to the international standard.
* @param interfacePackage The root package for metadata interfaces.
*/
- MetadataStandard(final Citation citation, final String interfacePackage) {
- this.citation = citation;
+ MetadataStandard(final String citation, final String interfacePackage) {
+ this.citation = new SimpleCitation(citation);
this.interfacePackage = interfacePackage;
this.accessors = new IdentityHashMap<Class<?>,Object>();
}
@@ -520,6 +521,11 @@ public class MetadataStandard {
* <ul>
* <li>The {@linkplain CheckedContainer#getElementType() element type} is the type of property values
* as defined by {@link TypeValuePolicy#ELEMENT_TYPE}.</li>
+ *
+ * {@note The rational for implementing <code>CheckedContainer</code> is to consider each
+ * <code>ExtendedElementInformation</code> instance as the set of all possible values for
+ * the property. If the information had a <code>contains(E)</code> method, it would return
+ * <code>true</code> if the given value is valid for that property.}
* </ul>
* </li>
* </ul>
Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java?rev=1469961&r1=1469960&r2=1469961&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java [UTF-8] Fri Apr 19 17:25:49 2013
@@ -36,6 +36,7 @@ import org.apache.sis.util.Classes;
import org.apache.sis.util.Numbers;
import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.Utilities;
+import org.apache.sis.util.Workaround;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.ObjectConverter;
@@ -471,13 +472,20 @@ final class PropertyAccessor {
* or {@code null} if the index is out of bounds.
*/
@SuppressWarnings("fallthrough")
+ @Workaround(library="JDK", version="1.7") // Actually apply to String.intern() below.
final String name(final int index, final KeyNamePolicy keyPolicy) {
if (index >= 0 && index < names.length) {
switch (keyPolicy) {
case UML_IDENTIFIER: {
final UML uml = getters[index].getAnnotation(UML.class);
if (uml != null) {
- return uml.identifier();
+ /*
+ * Workaround here: I though that annotation strings were interned like any other
+ * constants, but it doesn't seem to be the case as of JDK7. To check if a future
+ * JDK release still needs this explicit call to String.intern(), try to remove
+ * the ".intern()" part and run the NameMapTest.testStringIntern() method.
+ */
+ return uml.identifier().intern();
}
// Fallthrough
}
Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java?rev=1469961&r1=1469960&r2=1469961&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java [UTF-8] Fri Apr 19 17:25:49 2013
@@ -43,7 +43,12 @@ import org.apache.sis.util.logging.Loggi
* but other types are allowed), instances of {@code PropertyInformation} are obtained
* indirectly by the {@link MetadataStandard#asInformationMap(Class, KeyNamePolicy)} method.
*
- * @param <T> The value type, either the method return type if not a collection,
+ * {@note The rational for implementing <code>CheckedContainer</code> is to consider each
+ * <code>ExtendedElementInformation</code> instance as the set of all possible values
+ * for the property. If the information had a <code>contains(E)</code> method, it would
+ * return <code>true</code> if the given value is valid for that property.}
+ *
+ * @param <E> The value type, either the method return type if not a collection,
* or the type of elements in the collection otherwise.
*
* @author Martin Desruisseaux (Geomatys)
@@ -56,8 +61,8 @@ import org.apache.sis.util.logging.Loggi
* @see <a href="https://issues.apache.org/jira/browse/SIS-80">SIS-80</a>
*/
@Immutable
-final class PropertyInformation<T> extends SimpleReferenceIdentifier
- implements ExtendedElementInformation, CheckedContainer<T>
+final class PropertyInformation<E> extends SimpleReferenceIdentifier
+ implements ExtendedElementInformation, CheckedContainer<E>
{
/**
* For cross-versions compatibility.
@@ -78,7 +83,7 @@ final class PropertyInformation<T> exten
* @see #getDataType()
* @see #getElementType()
*/
- private final Class<T> elementType;
+ private final Class<E> elementType;
/**
* The minimum number of occurrences.
@@ -121,7 +126,7 @@ final class PropertyInformation<T> exten
*/
@SuppressWarnings({"unchecked","rawtypes"})
PropertyInformation(final Citation standard, final String property, final Method getter,
- final Class<T> elementType, final ValueRange range)
+ final Class<E> elementType, final ValueRange range)
{
super(standard, property);
parent = getter.getDeclaringClass();
@@ -247,7 +252,7 @@ final class PropertyInformation<T> exten
* returns the type of elements in the array or collection.
*/
@Override
- public Class<T> getElementType() {
+ public Class<E> getElementType() {
return elementType;
}
Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java?rev=1469961&r1=1469960&r2=1469961&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java [UTF-8] Fri Apr 19 17:25:49 2013
@@ -20,7 +20,6 @@ import java.util.Map;
import java.util.IdentityHashMap;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.logging.Logging;
-import org.apache.sis.internal.simple.SimpleCitation;
/**
@@ -79,7 +78,7 @@ final class StandardImplementation exten
StandardImplementation(final String citation, final String interfacePackage,
final String implementationPackage, final String[] prefix, final String[] acronyms)
{
- super(new SimpleCitation(citation), interfacePackage);
+ super(citation, interfacePackage);
this.implementationPackage = implementationPackage;
this.prefix = prefix;
this.acronyms = acronyms;
Copied: sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java (from r1469956, sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java?p2=sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java&p1=sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java&r1=1469956&r2=1469961&rev=1469961&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/InformationMapTest.java [UTF-8] Fri Apr 19 17:25:49 2013
@@ -67,7 +67,7 @@ public final strictfp class InformationM
final Map<String,ExtendedElementInformation> descriptions = MetadataStandard.ISO_19115.asInformationMap(
EnvironmentalRecord.class, KeyNamePolicy.UML_IDENTIFIER);
- final Set<String> expected = new HashSet<>(Arrays.asList(
+ final Set<String> expected = new HashSet<String>(Arrays.asList(
"averageAirTemperature", "maxAltitude", "maxRelativeHumidity", "meteorologicalConditions"
));
assertEquals(expected, descriptions.keySet());
Modified: sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java?rev=1469961&r1=1469960&r2=1469961&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java [UTF-8] Fri Apr 19 17:25:49 2013
@@ -18,18 +18,12 @@ package org.apache.sis.metadata;
import java.util.Set;
import java.util.Map;
+import java.util.List;
import java.util.HashSet;
import java.util.Collection;
-import java.util.Date;
-import org.opengis.util.InternationalString;
-import org.opengis.metadata.Identifier;
-import org.opengis.metadata.citation.Series;
import org.opengis.metadata.citation.Citation;
-import org.opengis.metadata.citation.CitationDate;
-import org.opengis.metadata.citation.ResponsibleParty;
-import org.opengis.metadata.citation.PresentationForm;
import org.opengis.metadata.quality.Completeness;
-import org.opengis.metadata.ExtendedElementInformation;
+import org.opengis.coverage.grid.RectifiedGrid;
import org.apache.sis.metadata.iso.citation.DefaultCitation;
import org.apache.sis.metadata.iso.citation.HardCodedCitations;
import org.apache.sis.metadata.iso.quality.AbstractCompleteness;
@@ -41,19 +35,28 @@ import org.apache.sis.test.TestCase;
import org.junit.Test;
import static org.opengis.test.Assert.*;
-import static java.util.AbstractMap.SimpleEntry;
/**
* Tests the {@link MetadataStandard} class.
- * Unless otherwise specified, the tests use the {@link MetadataStandard#ISO_19115} constant.
+ * Unless otherwise specified, all tests use the {@link MetadataStandard#ISO_19115} constant.
+ *
+ * <p>The following methods are not (or few) tested by this class, because they are tested by
+ * dedicated classes named according the implementation class doing the actual work:</p>
+ *
+ * <ul>
+ * <li>{@link MetadataStandard#asNameMap(Class, KeyNamePolicy, KeyNamePolicy)}, tested by {@link NameMapTest}</li>
+ * <li>{@link MetadataStandard#asTypeMap(Class, KeyNamePolicy, TypeValuePolicy)}, tested by {@link TypeMapTest}</li>
+ * <li>{@link MetadataStandard#asInformationMap(Class, KeyNamePolicy)}, tested by {@link InformationMapTest}</li>
+ * </ul>
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3 (derived from geotk-2.4)
* @version 0.3
* @module
*/
-@DependsOn({PropertyAccessorTest.class, PropertyInformationTest.class})
+@DependsOn({PropertyAccessorTest.class, InformationMapTest.class,
+ NameMapTest.class, TypeMapTest.class, ValueMapTest.class})
public final strictfp class MetadataStandardTest extends TestCase {
/**
* Tests {@link MetadataStandard#getInterface(Class)}.
@@ -71,7 +74,7 @@ public final strictfp class MetadataStan
*/
@Test
public void testGetWrongInterface() {
- final MetadataStandard std = new MetadataStandard(HardCodedCitations.ISO, "org.opengis.dummy.");
+ final MetadataStandard std = new MetadataStandard("SIS", "org.apache.sis.dummy.");
try {
std.getInterface(DefaultCitation.class);
fail("No dummy interface expected.");
@@ -124,82 +127,9 @@ public final strictfp class MetadataStan
}
/**
- * Tests the {@link MetadataStandard#asName(Class, KeyNamePolicy, KeyNamePolicy)} implementation.
- * The properties used in this test are listed in {@link PropertyAccessorTest#testConstructor()}.
- *
- * @see PropertyAccessorTest#testConstructor()
- */
- @Test
- public void testNameMap() {
- final Map<String,String> map = MetadataStandard.ISO_19115.asNameMap(
- Citation.class, KeyNamePolicy.UML_IDENTIFIER, KeyNamePolicy.JAVABEANS_PROPERTY);
- assertArrayEquals(new Object[] {
- new SimpleEntry<String,String>("title", "title"),
- new SimpleEntry<String,String>("alternateTitle", "alternateTitles"),
- new SimpleEntry<String,String>("date", "dates"),
- new SimpleEntry<String,String>("edition", "edition"),
- new SimpleEntry<String,String>("editionDate", "editionDate"),
- new SimpleEntry<String,String>("identifier", "identifiers"),
- new SimpleEntry<String,String>("citedResponsibleParty", "citedResponsibleParties"),
- new SimpleEntry<String,String>("presentationForm", "presentationForms"),
- new SimpleEntry<String,String>("series", "series"),
- new SimpleEntry<String,String>("otherCitationDetails", "otherCitationDetails"),
- new SimpleEntry<String,String>("collectiveTitle", "collectiveTitle"),
- new SimpleEntry<String,String>("ISBN", "ISBN"),
- new SimpleEntry<String,String>("ISSN", "ISSN")
- }, map.entrySet().toArray());
-
- assertEquals("alternateTitles", map.get("alternateTitle"));
- assertNull("Shall not exists.", map.get("dummy"));
- }
-
- /**
- * Tests the {@link MetadataStandard#asType(Class, KeyNamePolicy, TypeValuePolicy)} implementation.
- * The properties used in this test are listed in {@link PropertyAccessorTest#testConstructor()}.
- *
- * @see PropertyAccessorTest#testConstructor()
- */
- @Test
- public void testTypeMap() {
- final Map<String,Class<?>> map = MetadataStandard.ISO_19115.asTypeMap(
- Citation.class, KeyNamePolicy.UML_IDENTIFIER, TypeValuePolicy.ELEMENT_TYPE);
- assertArrayEquals(new Object[] {
- new SimpleEntry<String,Class<?>>("title", InternationalString.class),
- new SimpleEntry<String,Class<?>>("alternateTitle", InternationalString.class),
- new SimpleEntry<String,Class<?>>("date", CitationDate.class),
- new SimpleEntry<String,Class<?>>("edition", InternationalString.class),
- new SimpleEntry<String,Class<?>>("editionDate", Date.class),
- new SimpleEntry<String,Class<?>>("identifier", Identifier.class),
- new SimpleEntry<String,Class<?>>("citedResponsibleParty", ResponsibleParty.class),
- new SimpleEntry<String,Class<?>>("presentationForm", PresentationForm.class),
- new SimpleEntry<String,Class<?>>("series", Series.class),
- new SimpleEntry<String,Class<?>>("otherCitationDetails", InternationalString.class),
- new SimpleEntry<String,Class<?>>("collectiveTitle", InternationalString.class),
- new SimpleEntry<String,Class<?>>("ISBN", String.class),
- new SimpleEntry<String,Class<?>>("ISSN", String.class)
- }, map.entrySet().toArray());
-
- assertEquals(InternationalString.class, map.get("alternateTitle"));
- assertNull("Shall not exists.", map.get("dummy"));
- }
-
- /**
- * Tests the {@link MetadataStandard#asInformationMap(Class, KeyNamePolicy)} implementation.
- * Note: this test duplicates {@link PropertyInformationTest}, but is done here again as an
- * integration test.
- */
- @Test
- public void testInformationMap() {
- final Map<String,ExtendedElementInformation> map = MetadataStandard.ISO_19115.asInformationMap(
- Citation.class, KeyNamePolicy.JAVABEANS_PROPERTY);
- PropertyInformationTest.validateTitle(map.get("title"));
- PropertyInformationTest.validatePresentationForm(map.get("presentationForms"));
- assertNull("Shall not exists.", map.get("dummy"));
- }
-
- /**
* Tests the {@link MetadataStandard#asValueMap(Object, KeyNamePolicy, ValueExistencePolicy)} implementation.
- * Note: this test duplicates {@link ValueMapTest}, but is done here again as an integration test.
+ * This test duplicates {@link ValueMapTest}, but is done here again as an integration test and because many
+ * {@code MetadataStandard} methods depend on it ({@code equals}, {@code hashCode}, {@code prune}, <i>etc.</i>).
*/
@Test
public void testValueMap() {
@@ -250,4 +180,35 @@ public final strictfp class MetadataStan
assertEquals("hashCode()", new HashSet<Object>(map.values()).hashCode() + Citation.class.hashCode(),
std.hashCode(instance));
}
+
+ /**
+ * Tests the {@link MetadataStandard#ISO_19123} constant. Getters shall
+ * be accessible even if there is no implementation on the classpath.
+ */
+ @Test
+ public void testWithoutImplementation() {
+ final MetadataStandard std = MetadataStandard.ISO_19123;
+ assertFalse("isMetadata(Citation)", std.isMetadata(Citation.class));
+ assertFalse("isMetadata(DefaultCitation)", std.isMetadata(DefaultCitation.class));
+ assertTrue ("isMetadata(RectifiedGrid)", std.isMetadata(RectifiedGrid.class));
+ /*
+ * Ensure that the getters have been found.
+ */
+ final Map<String,String> names = std.asNameMap(RectifiedGrid.class, KeyNamePolicy.UML_IDENTIFIER, KeyNamePolicy.JAVABEANS_PROPERTY);
+ assertFalse("Getters should have been found even if there is no implementation.", names.isEmpty());
+ assertEquals("dimension", names.get("dimension"));
+ assertEquals("cells", names.get("cell"));
+ /*
+ * Ensure that the type are recognized, especially RectifiedGrid.getOffsetVectors()
+ * which is of type List<double[]>.
+ */
+ Map<String,Class<?>> types;
+ types = std.asTypeMap(RectifiedGrid.class, KeyNamePolicy.UML_IDENTIFIER, TypeValuePolicy.PROPERTY_TYPE);
+ assertEquals("The return type is the int primitive type.", Integer.TYPE, types.get("dimension"));
+ assertEquals("The offset vectors are stored in a List.", List.class, types.get("offsetVectors"));
+
+ types = std.asTypeMap(RectifiedGrid.class, KeyNamePolicy.UML_IDENTIFIER, TypeValuePolicy.ELEMENT_TYPE);
+ assertEquals("As elements in a list of dimensions.", Integer.class, types.get("dimension"));
+ assertEquals("As elements in the list of offset vectors.", double[].class, types.get("offsetVectors"));
+ }
}
Copied: sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java (from r1469956, sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java?p2=sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java&p1=sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java&r1=1469956&r2=1469961&rev=1469961&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/NameMapTest.java [UTF-8] Fri Apr 19 17:25:49 2013
@@ -52,19 +52,19 @@ public final strictfp class NameMapTest
final Map<String,String> map = MetadataStandard.ISO_19115.asNameMap(
Citation.class, KeyNamePolicy.UML_IDENTIFIER, KeyNamePolicy.JAVABEANS_PROPERTY);
assertArrayEquals(new Object[] {
- new SimpleEntry<>("title", "title"),
- new SimpleEntry<>("alternateTitle", "alternateTitles"),
- new SimpleEntry<>("date", "dates"),
- new SimpleEntry<>("edition", "edition"),
- new SimpleEntry<>("editionDate", "editionDate"),
- new SimpleEntry<>("identifier", "identifiers"),
- new SimpleEntry<>("citedResponsibleParty", "citedResponsibleParties"),
- new SimpleEntry<>("presentationForm", "presentationForms"),
- new SimpleEntry<>("series", "series"),
- new SimpleEntry<>("otherCitationDetails", "otherCitationDetails"),
- new SimpleEntry<>("collectiveTitle", "collectiveTitle"),
- new SimpleEntry<>("ISBN", "ISBN"),
- new SimpleEntry<>("ISSN", "ISSN")
+ new SimpleEntry<String,String>("title", "title"),
+ new SimpleEntry<String,String>("alternateTitle", "alternateTitles"),
+ new SimpleEntry<String,String>("date", "dates"),
+ new SimpleEntry<String,String>("edition", "edition"),
+ new SimpleEntry<String,String>("editionDate", "editionDate"),
+ new SimpleEntry<String,String>("identifier", "identifiers"),
+ new SimpleEntry<String,String>("citedResponsibleParty", "citedResponsibleParties"),
+ new SimpleEntry<String,String>("presentationForm", "presentationForms"),
+ new SimpleEntry<String,String>("series", "series"),
+ new SimpleEntry<String,String>("otherCitationDetails", "otherCitationDetails"),
+ new SimpleEntry<String,String>("collectiveTitle", "collectiveTitle"),
+ new SimpleEntry<String,String>("ISBN", "ISBN"),
+ new SimpleEntry<String,String>("ISSN", "ISSN")
}, map.entrySet().toArray());
assertEquals("alternateTitles", map.get("alternateTitle"));
@@ -76,7 +76,7 @@ public final strictfp class NameMapTest
*/
@Test
public void testSentences() {
- final Map<String,String> map, expected = new HashMap<>();
+ final Map<String,String> map, expected = new HashMap<String,String>();
map = MetadataStandard.ISO_19115.asNameMap(EnvironmentalRecord.class, JAVABEANS_PROPERTY, SENTENCE);
assertNull(expected.put("averageAirTemperature", "Average air temperature"));
assertNull(expected.put("maxAltitude", "Max altitude"));
Modified: sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java?rev=1469961&r1=1469960&r2=1469961&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java [UTF-8] Fri Apr 19 17:25:49 2013
@@ -143,11 +143,12 @@ public final strictfp class PropertyAcce
* Tests the constructor with the {@link DefaultCitation} implementation.
* The order of properties shall be the order declared in the {@code XmlType.propOrder} annotation.
* This test may need to be updated if a future GeoAPI release modifies the {@link Citation} interface.
- * Other tests that depends on {@link Citation} property order are {@link MetadataStandardTest#testNameMap()}
- * and {@link MetadataStandardTest#testTypeMap()}</p>
+ * Other tests that depends on {@link Citation} property order are {@link NameMapTest#testEntrySet()},
+ * {@link TypeMapTest#testEntrySet()} and most tests in {@link ValueMapTest}.
*
- * @see MetadataStandardTest#testNameMap()
- * @see MetadataStandardTest#testTypeMap()
+ * @see NameMapTest#testEntrySet()
+ * @see TypeMapTest#testEntrySet()
+ * @see ValueMapTest
*/
@Test
public void testConstructor() {
Copied: sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java (from r1469956, sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java?p2=sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java&p1=sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java&r1=1469956&r2=1469961&rev=1469961&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/TypeMapTest.java [UTF-8] Fri Apr 19 17:25:49 2013
@@ -62,19 +62,19 @@ public final strictfp class TypeMapTest
final Map<String,Class<?>> map = MetadataStandard.ISO_19115.asTypeMap(
Citation.class, KeyNamePolicy.UML_IDENTIFIER, TypeValuePolicy.ELEMENT_TYPE);
assertArrayEquals(new Object[] {
- new SimpleEntry<>("title", InternationalString.class),
- new SimpleEntry<>("alternateTitle", InternationalString.class),
- new SimpleEntry<>("date", CitationDate.class),
- new SimpleEntry<>("edition", InternationalString.class),
- new SimpleEntry<>("editionDate", Date.class),
- new SimpleEntry<>("identifier", Identifier.class),
- new SimpleEntry<>("citedResponsibleParty", ResponsibleParty.class),
- new SimpleEntry<>("presentationForm", PresentationForm.class),
- new SimpleEntry<>("series", Series.class),
- new SimpleEntry<>("otherCitationDetails", InternationalString.class),
- new SimpleEntry<>("collectiveTitle", InternationalString.class),
- new SimpleEntry<>("ISBN", String.class),
- new SimpleEntry<>("ISSN", String.class)
+ new SimpleEntry<String,Class<?>>("title", InternationalString.class),
+ new SimpleEntry<String,Class<?>>("alternateTitle", InternationalString.class),
+ new SimpleEntry<String,Class<?>>("date", CitationDate.class),
+ new SimpleEntry<String,Class<?>>("edition", InternationalString.class),
+ new SimpleEntry<String,Class<?>>("editionDate", Date.class),
+ new SimpleEntry<String,Class<?>>("identifier", Identifier.class),
+ new SimpleEntry<String,Class<?>>("citedResponsibleParty", ResponsibleParty.class),
+ new SimpleEntry<String,Class<?>>("presentationForm", PresentationForm.class),
+ new SimpleEntry<String,Class<?>>("series", Series.class),
+ new SimpleEntry<String,Class<?>>("otherCitationDetails", InternationalString.class),
+ new SimpleEntry<String,Class<?>>("collectiveTitle", InternationalString.class),
+ new SimpleEntry<String,Class<?>>("ISBN", String.class),
+ new SimpleEntry<String,Class<?>>("ISSN", String.class)
}, map.entrySet().toArray());
assertEquals(InternationalString.class, map.get("alternateTitle"));
Copied: sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java (from r1469956, sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java?p2=sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java&p1=sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java&r1=1469956&r2=1469961&rev=1469961&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java [UTF-8] Fri Apr 19 17:25:49 2013
@@ -136,10 +136,10 @@ public final strictfp class ValueMapTest
final Map<String,Object> map = createCitation();
assertEquals(1, citation.getIdentifiers().size());
assertArrayEquals(new SimpleEntry<?,?>[] {
- new SimpleEntry<>("title", title),
- new SimpleEntry<>("identifiers", citation.getIdentifiers()),
- new SimpleEntry<>("citedResponsibleParties", singletonList(author)),
- new SimpleEntry<>("ISBN", "9782505004509")
+ new SimpleEntry<String,Object>("title", title),
+ new SimpleEntry<String,Object>("identifiers", citation.getIdentifiers()),
+ new SimpleEntry<String,Object>("citedResponsibleParties", singletonList(author)),
+ new SimpleEntry<String,Object>("ISBN", "9782505004509")
}, map.entrySet().toArray());
}
@@ -158,13 +158,13 @@ public final strictfp class ValueMapTest
assertTrue ("'all' should be a larger map than 'map'.", all.entrySet().containsAll(map.entrySet()));
assertFalse("'all' should be a larger map than 'map'.", map.entrySet().containsAll(all.entrySet()));
assertArrayEquals(new SimpleEntry<?,?>[] {
- new SimpleEntry<>("title", title),
- new SimpleEntry<>("alternateTitles", emptyList()),
- new SimpleEntry<>("dates", emptyList()),
- new SimpleEntry<>("identifiers", citation.getIdentifiers()),
- new SimpleEntry<>("citedResponsibleParties", singletonList(author)),
- new SimpleEntry<>("presentationForms", emptySet()),
- new SimpleEntry<>("ISBN", "9782505004509")
+ new SimpleEntry<String,Object>("title", title),
+ new SimpleEntry<String,Object>("alternateTitles", emptyList()),
+ new SimpleEntry<String,Object>("dates", emptyList()),
+ new SimpleEntry<String,Object>("identifiers", citation.getIdentifiers()),
+ new SimpleEntry<String,Object>("citedResponsibleParties", singletonList(author)),
+ new SimpleEntry<String,Object>("presentationForms", emptySet()),
+ new SimpleEntry<String,Object>("ISBN", "9782505004509")
}, all.entrySet().toArray());
}
@@ -183,19 +183,19 @@ public final strictfp class ValueMapTest
assertTrue ("'all' should be a larger map than 'map'.", all.entrySet().containsAll(map.entrySet()));
assertFalse("'all' should be a larger map than 'map'.", map.entrySet().containsAll(all.entrySet()));
assertArrayEquals(new SimpleEntry<?,?>[] {
- new SimpleEntry<>("title", title),
- new SimpleEntry<>("alternateTitles", emptyList()),
- new SimpleEntry<>("dates", emptyList()),
- new SimpleEntry<>("edition", null),
- new SimpleEntry<>("editionDate", null),
- new SimpleEntry<>("identifiers", citation.getIdentifiers()),
- new SimpleEntry<>("citedResponsibleParties", singletonList(author)),
- new SimpleEntry<>("presentationForms", emptySet()),
- new SimpleEntry<>("series", null),
- new SimpleEntry<>("otherCitationDetails", null),
- new SimpleEntry<>("collectiveTitle", null),
- new SimpleEntry<>("ISBN", "9782505004509"),
- new SimpleEntry<>("ISSN", null)
+ new SimpleEntry<String,Object>("title", title),
+ new SimpleEntry<String,Object>("alternateTitles", emptyList()),
+ new SimpleEntry<String,Object>("dates", emptyList()),
+ new SimpleEntry<String,Object>("edition", null),
+ new SimpleEntry<String,Object>("editionDate", null),
+ new SimpleEntry<String,Object>("identifiers", citation.getIdentifiers()),
+ new SimpleEntry<String,Object>("citedResponsibleParties", singletonList(author)),
+ new SimpleEntry<String,Object>("presentationForms", emptySet()),
+ new SimpleEntry<String,Object>("series", null),
+ new SimpleEntry<String,Object>("otherCitationDetails", null),
+ new SimpleEntry<String,Object>("collectiveTitle", null),
+ new SimpleEntry<String,Object>("ISBN", "9782505004509"),
+ new SimpleEntry<String,Object>("ISSN", null)
}, all.entrySet().toArray());
}
@@ -220,8 +220,8 @@ public final strictfp class ValueMapTest
assertNull("ISBN shall have been removed.", citation.getISBN());
assertTrue("ISBN shall have been removed.", citation.getIdentifiers().isEmpty());
assertArrayEquals(new SimpleEntry<?,?>[] {
- new SimpleEntry<>("title", title),
- new SimpleEntry<>("citedResponsibleParties", singletonList(author))
+ new SimpleEntry<String,Object>("title", title),
+ new SimpleEntry<String,Object>("citedResponsibleParties", singletonList(author))
}, map.entrySet().toArray());
/*
* Add a value. Result shall be:
@@ -235,9 +235,9 @@ public final strictfp class ValueMapTest
assertNull(map.put("presentationForm", DOCUMENT_HARDCOPY));
assertEquals(DOCUMENT_HARDCOPY, getSingleton(citation.getPresentationForms()));
assertArrayEquals(new SimpleEntry<?,?>[] {
- new SimpleEntry<>("title", title),
- new SimpleEntry<>("citedResponsibleParties", singletonList(author)),
- new SimpleEntry<>("presentationForms", singleton(DOCUMENT_HARDCOPY))
+ new SimpleEntry<String,Object>("title", title),
+ new SimpleEntry<String,Object>("citedResponsibleParties", singletonList(author)),
+ new SimpleEntry<String,Object>("presentationForms", singleton(DOCUMENT_HARDCOPY))
}, map.entrySet().toArray());
/*
* Add back the ISBN value. Result shall be:
@@ -254,11 +254,11 @@ public final strictfp class ValueMapTest
assertEquals("9782505004509", citation.getISBN());
assertEquals("ISBN shall appears in the identifier list.", 1, citation.getIdentifiers().size());
assertArrayEquals(new SimpleEntry<?,?>[] {
- new SimpleEntry<>("title", title),
- new SimpleEntry<>("identifiers", citation.getIdentifiers()),
- new SimpleEntry<>("citedResponsibleParties", singletonList(author)),
- new SimpleEntry<>("presentationForms", singleton(DOCUMENT_HARDCOPY)),
- new SimpleEntry<>("ISBN", "9782505004509")
+ new SimpleEntry<String,Object>("title", title),
+ new SimpleEntry<String,Object>("identifiers", citation.getIdentifiers()),
+ new SimpleEntry<String,Object>("citedResponsibleParties", singletonList(author)),
+ new SimpleEntry<String,Object>("presentationForms", singleton(DOCUMENT_HARDCOPY)),
+ new SimpleEntry<String,Object>("ISBN", "9782505004509")
}, map.entrySet().toArray());
}
}
Modified: sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1469961&r1=1469960&r2=1469961&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] Fri Apr 19 17:25:49 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;
/**
@@ -32,7 +33,19 @@ import org.junit.runners.Suite;
org.apache.sis.internal.metadata.MetadataUtilitiesTest.class,
org.apache.sis.metadata.PropertyInformationTest.class,
org.apache.sis.metadata.PropertyAccessorTest.class,
+ org.apache.sis.metadata.NameMapTest.class,
+ org.apache.sis.metadata.TypeMapTest.class,
+ org.apache.sis.metadata.InformationMapTest.class,
+ org.apache.sis.metadata.ValueMapTest.class,
org.apache.sis.metadata.MetadataStandardTest.class
})
public final strictfp class MetadataTestSuite extends TestSuite {
+ /**
+ * Verifies the list of tests before to run the suite.
+ * See {@link #verifyTestList(Class)} for more information.
+ */
+ @BeforeClass
+ public static void verifyTestList() {
+ verifyTestList(MetadataTestSuite.class);
+ }
}
Modified: sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1469961&r1=1469960&r2=1469961&view=diff
==============================================================================
--- sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] Fri Apr 19 17:25:49 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,12 @@ import org.junit.runners.Suite;
org.apache.sis.geometry.Envelope2DTest.class
})
public final strictfp class ReferencingTestSuite extends TestSuite {
+ /**
+ * Verifies the list of tests before to run the suite.
+ * See {@link #verifyTestList(Class)} for more information.
+ */
+ @BeforeClass
+ public static void verifyTestList() {
+ verifyTestList(ReferencingTestSuite.class);
+ }
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java?rev=1469961&r1=1469960&r2=1469961&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java [UTF-8] Fri Apr 19 17:25:49 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/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java?rev=1469961&r1=1469960&r2=1469961&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] Fri Apr 19 17:25:49 2013
@@ -18,6 +18,7 @@ package org.apache.sis.internal.util;
import java.util.*;
import org.apache.sis.util.Static;
+import org.apache.sis.util.collection.CodeListSet;
/**
@@ -28,7 +29,7 @@ import org.apache.sis.util.Static;
* <ul>
* <li>{@link #toCollection(Object) toCollection} for wrapping or copying arbitrary objects to
* list or collection.</li>
- * <li>{@link #modifiableCopy(Collection) modifiableCopy} method for taking a snapshot of an arbitrary
+ * <li>{@link #copy(Collection, boolean) copy} method for taking a snapshot of an arbitrary
* implementation into an unsynchronized, modifiable, in-memory object.</li>
* <li>{@link #unmodifiableOrCopy(Set) unmodifiableOrCopy} methods, which may be slightly more
* compact than the standard {@link Collections#unmodifiableSet(Set)} equivalent
@@ -193,6 +194,8 @@ public final class CollectionsExt extend
* <tr><td>{@link List} or other {@link Collection}</td><td class="sep">{@link ArrayList}</td></tr>
* </table>
*
+ * This method may not preserve the {@link org.apache.sis.util.collection.CheckedContainer} interface.
+ *
* @param <E> The type of elements in the collection.
* @param collection The collection to copy, or {@code null}.
* @return A copy of the given collection, or {@code null} if the given collection was null.
@@ -217,6 +220,12 @@ public final class CollectionsExt extend
if (type == HashSet.class || type == LinkedHashSet.class) {
return (Collection<E>) ((HashSet<E>) collection).clone();
}
+ if (collection instanceof EnumSet<?>) {
+ return ((EnumSet) collection).clone();
+ }
+ if (collection instanceof CodeListSet<?>) {
+ return ((CodeListSet) collection).clone();
+ }
return new LinkedHashSet<E>(collection);
}
if (collection instanceof Queue<?>) {
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Numbers.java?rev=1469961&r1=1469960&r2=1469961&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Numbers.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Numbers.java [UTF-8] Fri Apr 19 17:25:49 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<Class<?>,Numbers>(16);
+ private static final Map<Class<?>,Numbers> MAPPING = new IdentityHashMap<Class<?>,Numbers>(11);
static {
new Numbers(BigDecimal.class, true, false, BIG_DECIMAL);
new Numbers(BigInteger.class, false, true, BIG_INTEGER);
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java?rev=1469961&r1=1469960&r2=1469961&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java [UTF-8] Fri Apr 19 17:25:49 2013
@@ -216,7 +216,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/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java?rev=1469961&r1=1469960&r2=1469961&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8] Fri Apr 19 17:25:49 2013
@@ -106,7 +106,13 @@ public final class Types extends Static
if (uml != null) {
final String id = uml.identifier();
if (id != null && !id.isEmpty()) {
- return id;
+ /*
+ * Workaround: I though that annotation strings were interned like any other constants,
+ * but it does not seem to be the case as of JDK7. To verify if this explicit call to
+ * String.intern() is still needed in a future JDK release, see the workaround comment
+ * in the org.apache.sis.metadata.PropertyAccessor.name(…) method.
+ */
+ return id.intern();
}
}
}
Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java?rev=1469961&r1=1469960&r2=1469961&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java [UTF-8] Fri Apr 19 17:25:49 2013
@@ -42,7 +42,7 @@ import static org.apache.sis.test.TestUt
* @version 0.3
* @module
*/
-@DependsOn(IdentifierMapAdapter.class)
+@DependsOn(IdentifierMapAdapterTest.class)
public final strictfp class IdentifierMapWithSpecialCasesTest extends IdentifierMapAdapterTest {
/**
* The HREF string to replace by {@link XLink#toString()}.
Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/test/AssertTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/test/AssertTest.java?rev=1469961&r1=1469960&r2=1469961&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/test/AssertTest.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/test/AssertTest.java [UTF-8] Fri Apr 19 17:25:49 2013
@@ -17,6 +17,7 @@
package org.apache.sis.internal.test;
import org.junit.Test;
+import org.apache.sis.test.TestCase;
import static org.apache.sis.test.Assert.*;
@@ -29,7 +30,7 @@ import static org.apache.sis.test.Assert
* @version 0.3
* @module
*/
-public final strictfp class AssertTest {
+public final strictfp class AssertTest extends TestCase {
/**
* Tests the {@link Assert#assertMultilinesEquals(String, String)} method.
*/
Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/test/XMLComparatorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/test/XMLComparatorTest.java?rev=1469961&r1=1469960&r2=1469961&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/test/XMLComparatorTest.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/test/XMLComparatorTest.java [UTF-8] Fri Apr 19 17:25:49 2013
@@ -16,6 +16,7 @@
*/
package org.apache.sis.internal.test;
+import org.apache.sis.test.TestCase;
import org.apache.sis.test.XMLComparator;
import org.junit.Test;
@@ -30,7 +31,7 @@ import static org.junit.Assert.*;
* @version 0.3
* @module
*/
-public final strictfp class XMLComparatorTest {
+public final strictfp class XMLComparatorTest extends TestCase {
/**
* Tests the {@link XMLComparator#ignoredAttributes} and {@link XMLComparator#ignoredNodes}
* sets.
Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java?rev=1469961&r1=1469960&r2=1469961&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java [UTF-8] Fri Apr 19 17:25:49 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,47 @@ public abstract strictfp class TestSuite
*/
protected TestSuite() {
}
+
+ /**
+ * Verifies the list of tests before the suite is run.
+ * This method verifies the following conditions:
+ *
+ * <ul>
+ * <li>Every class shall extend either the SIS {@link TestCase} or the GeoAPI {@link org.opengis.test.TestCase}.</li>
+ * <li>No class shall be declared twice.</li>
+ * <li>If a test depends on another test, then the other test shall be before the dependant test.</li>
+ * </ul>
+ *
+ * Subclasses shall invoke this method as below:
+ *
+ * {@preformat java
+ * @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<Class<?>,Boolean>(testCases.length);
+ for (final Class<?> testCase : testCases) {
+ if (!TestCase.class.isAssignableFrom(testCase) && !org.opengis.test.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/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1469961&r1=1469960&r2=1469961&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8] Fri Apr 19 17:25:49 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;
/**
@@ -92,8 +93,8 @@ import org.junit.runners.Suite;
// Converters
org.apache.sis.internal.converter.AngleConverterTest.class,
- org.apache.sis.internal.converter.PathConverterTest.class,
org.apache.sis.internal.converter.StringConverterTest.class,
+ org.apache.sis.internal.converter.PathConverterTest.class,
org.apache.sis.internal.converter.FallbackConverterTest.class,
org.apache.sis.internal.converter.ConverterRegistryTest.class,
org.apache.sis.internal.converter.SystemRegistryTest.class,
@@ -108,4 +109,12 @@ 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 to run the suite.
+ * See {@link #verifyTestList(Class)} for more information.
+ */
+ @BeforeClass
+ public static void verifyTestList() {
+ verifyTestList(UtilityTestSuite.class);
+ }
}
Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java?rev=1469961&r1=1469960&r2=1469961&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java [UTF-8] Fri Apr 19 17:25:49 2013
@@ -33,7 +33,7 @@ import static org.junit.Assert.*;
* @version 0.3
* @module
*/
-@DependsOn(ArraysExt.class)
+@DependsOn(ArraysExtTest.class)
public final strictfp class LocalesTest extends TestCase {
/**
* Tests the {@link Locales#getAvailableLanguages()} method.