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/16 23:58:57 UTC
svn commit: r1468626 - in /sis/branches/JDK7:
sis-metadata/src/test/java/org/apache/sis/metadata/
sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/
sis-metadata/src/test/java/org/apache/sis/test/suite/
sis-referencing/src/test/java/org/a...
Author: desruisseaux
Date: Tue Apr 16 21:58:57 2013
New Revision: 1468626
URL: http://svn.apache.org/r1468626
Log:
Ported a few tests.
Added:
sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java (with props)
Modified:
sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java
Added: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java?rev=1468626&view=auto
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java (added)
+++ sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java [UTF-8] Tue Apr 16 21:58:57 2013
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.metadata;
+
+import java.util.Set;
+import java.util.Map;
+import java.util.HashSet;
+import java.util.Collection;
+import org.opengis.metadata.citation.Citation;
+import org.opengis.metadata.quality.Completeness;
+import org.apache.sis.metadata.iso.citation.DefaultCitation;
+import org.apache.sis.metadata.iso.citation.HardCodedCitations;
+import org.apache.sis.metadata.iso.quality.AbstractCompleteness;
+import org.apache.sis.util.iso.SimpleInternationalString;
+import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.opengis.test.Assert.*;
+import org.apache.sis.test.DependsOnMethod;
+
+
+/**
+ * Tests the {@link MetadataStandard} class.
+ * Unless otherwise specified, the tests use the {@link MetadataStandard#ISO_19115} constant.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.3 (derived from geotk-2.4)
+ * @version 0.3
+ * @module
+ */
+@DependsOn(PropertyAccessorTest.class)
+public final strictfp class MetadataStandardTest extends TestCase {
+ /**
+ * Tests {@link MetadataStandard#getInterface(Class)}.
+ */
+ @Test
+ public void testGetInterface() {
+ final MetadataStandard std = MetadataStandard.ISO_19115;
+ assertEquals(Citation.class, std.getInterface(DefaultCitation.class));
+ assertEquals(Completeness.class, std.getInterface(AbstractCompleteness.class));
+ }
+
+ /**
+ * Tests {@link MetadataStandard#getInterface(Class)} for an invalid type.
+ * A {@link ClassCastException} is expected.
+ */
+ @Test
+ public void testGetWrongInterface() {
+ final MetadataStandard std = new MetadataStandard(HardCodedCitations.ISO, "org.opengis.dummy.");
+ try {
+ std.getInterface(DefaultCitation.class);
+ fail("No dummy interface expected.");
+ } catch (ClassCastException e) {
+ // This is the expected exception.
+ assertTrue(e.getMessage().contains("DefaultCitation"));
+ }
+ }
+
+ /**
+ * Tests the shallow copy. For this test, we need to use a class that doesn't have any {@code getIdentifiers()}
+ * method inherited from GeoAPI interfaces. The class will inherit the {@code getIdentifiers()} method defined
+ * by SIS in the parent class, which doesn't have corresponding {@code setIdentifiers(...)} method.
+ */
+ @Test
+ public void testShallowCopy() {
+ final AbstractCompleteness source = new AbstractCompleteness();
+ final AbstractCompleteness target = new AbstractCompleteness();
+ source.setMeasureDescription(new SimpleInternationalString("Some description"));
+ target.getStandard().shallowCopy(source, target);
+ assertEquals("Copy of measureDescription:", "Some description", target.getMeasureDescription().toString());
+ assertEquals("Copy of measureDescription:", source, target);
+
+ source.setMeasureDescription(null);
+ target.getStandard().shallowCopy(source, target);
+ assertEquals("Measure description should not have been removed, since we skipped null values.",
+ "Some description", target.getMeasureDescription().toString());
+ }
+
+ /**
+ * Tests the {@link MetadataStandard#equals(Object, Object, ComparisonMode)} method.
+ */
+ @Test
+ public void testEquals() {
+ final MetadataStandard std = MetadataStandard.ISO_19115;
+
+ // Self equality test
+ DefaultCitation instance = HardCodedCitations.EPSG;
+ assertFalse(std.equals(instance, HardCodedCitations.GEOTIFF, ComparisonMode.STRICT));
+ assertTrue (std.equals(instance, HardCodedCitations.EPSG, ComparisonMode.STRICT));
+
+ // Test comparison with a copy
+ instance = new DefaultCitation(HardCodedCitations.EPSG);
+ assertFalse(std.equals(instance, HardCodedCitations.GEOTIFF, ComparisonMode.STRICT));
+ assertTrue (std.equals(instance, HardCodedCitations.EPSG, ComparisonMode.STRICT));
+
+ // test comparison with a modified copy
+ instance.setTitle(new SimpleInternationalString("A dummy title"));
+ assertFalse(std.equals(instance, HardCodedCitations.EPSG, ComparisonMode.STRICT));
+ }
+
+ /**
+ * Tests the {@link MetadataStandard#asMap(Object, KeyNamePolicy, ValueExistencePolicy)} implementation.
+ * Note: this test duplicates {@link PropertyMapTest}, but is done here again because other tests in this
+ * class depend on it.
+ */
+ @Test
+ public void testMap() {
+ final DefaultCitation instance = new DefaultCitation(HardCodedCitations.EPSG);
+ final Map<String,Object> map = MetadataStandard.ISO_19115.asMap(instance,
+ KeyNamePolicy.JAVABEANS_PROPERTY, ValueExistencePolicy.NON_EMPTY);
+ assertFalse("The properties map shall not be empty.", map.isEmpty());
+ assertEquals("Unexpected number of properties.", 4, map.size());
+ /*
+ * Verify the set of keys in the PropertyMap.
+ *
+ * Note: the iterator order (and consequently, the order of elements in the following
+ * string representation) is determined by the @XmlType(…) annotation and verified by
+ * PropertyAccessorTest.testConstructor().
+ */
+ final Set<String> keys = map.keySet();
+ assertEquals("[title, alternateTitles, identifiers, presentationForms]", keys.toString());
+ assertTrue ("Shall exist and be defined.", keys.contains("title"));
+ assertTrue ("Shall exist and be defined.", keys.contains("getTitle"));
+ assertTrue ("Shall exist and be defined.", keys.contains("identifier"));
+ assertTrue ("Shall exist and be defined.", keys.contains("identifiers"));
+ assertTrue ("Shall exist and be defined.", keys.contains("getIdentifiers"));
+ assertFalse ("Shall exist but be undefined.", keys.contains("ISBN"));
+ assertFalse ("Shall not exists.", keys.contains("dummy"));
+ /*
+ * Verifies values.
+ */
+ assertEquals("title", "European Petroleum Survey Group", map.get("title").toString());
+ assertEquals("title", "European Petroleum Survey Group", map.get("getTitle").toString());
+ final Object identifiers = map.get("identifiers");
+ assertInstanceOf("identifiers", Collection.class, identifiers);
+ HardCodedCitations.assertIdentifiersFor("EPSG", (Collection<?>) identifiers);
+ }
+
+ /**
+ * Tests {@link MetadataStandard#hashCode(Object)} using {@link HashSet}
+ * as the reference implementation for hash code values.
+ */
+ @Test
+ @DependsOnMethod("testMap")
+ public void testHashCode() {
+ final MetadataStandard std = MetadataStandard.ISO_19115;
+ final DefaultCitation instance = HardCodedCitations.EPSG;
+ final Map<String,Object> map = std.asMap(instance,
+ KeyNamePolicy.JAVABEANS_PROPERTY, ValueExistencePolicy.NON_EMPTY);
+ assertFalse(map.isEmpty()); // Actually 'testMap()' job, but verified for safety.
+ assertEquals("hashCode()", new HashSet<>(map.values()).hashCode(), std.hashCode(instance));
+ }
+}
Propchange: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java?rev=1468626&r1=1468625&r2=1468626&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java [UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java [UTF-8] Tue Apr 16 21:58:57 2013
@@ -176,10 +176,10 @@ public final strictfp class PropertyAcce
final Class<?> type = GeographicCRS.class;
assertMappingEquals(new PropertyAccessor(HardCodedCitations.ISO, type, type),
//……Declaring type……………………………Method……………………………………………JavaBeans……………………………UML identifier………………Sentence…………………………………Type…………………………………………………………
-/*Required*/GeographicCRS.class, "getCoordinateSystem", "coordinateSystem", "coordinateSystem", "Coordinate system", EllipsoidalCS.class, // Covariant return type
+ GeographicCRS.class, "getCoordinateSystem", "coordinateSystem", "coordinateSystem", "Coordinate system", EllipsoidalCS.class, // Covariant return type
GeodeticCRS.class, "getDatum", "datum", "datum", "Datum", GeodeticDatum.class, // Covariant return type
IdentifiedObject.class, "getName", "name", "name", "Name", ReferenceIdentifier.class,
-/*Optional*/IdentifiedObject.class, "getAlias", "alias", "alias", "Alias", GenericName[].class,
+ IdentifiedObject.class, "getAlias", "alias", "alias", "Alias", GenericName[].class,
ReferenceSystem.class, "getDomainOfValidity", "domainOfValidity", "domainOfValidity", "Domain of validity", Extent.class,
IdentifiedObject.class, "getIdentifiers", "identifiers", "identifier", "Identifiers", ReferenceIdentifier[].class,
IdentifiedObject.class, "getRemarks", "remarks", "remarks", "Remarks", InternationalString.class,
@@ -203,23 +203,23 @@ public final strictfp class PropertyAcce
@Test
@DependsOnMethod("testConstructor")
public void testGet() {
- final Citation citation = HardCodedCitations.ISO;
+ final DefaultCitation instance = HardCodedCitations.ISO;
final PropertyAccessor accessor = createPropertyAccessor();
// Singleton value (not a collection)
- final Object title = accessor.get(accessor.indexOf("title", true), citation);
+ final Object title = accessor.get(accessor.indexOf("title", true), instance);
assertInstanceOf("title", InternationalString.class, title);
- assertEquals("International Organization for Standardization", title.toString());
+ assertEquals("title", "International Organization for Standardization", title.toString());
// Collection of InternationalStrings
- final Object alternateTitles = accessor.get(accessor.indexOf("alternateTitles", true), citation);
+ final Object alternateTitles = accessor.get(accessor.indexOf("alternateTitles", true), instance);
assertInstanceOf("alternateTitles", Collection.class, alternateTitles);
- assertEquals("ISO", getSingleton((Collection<?>) alternateTitles).toString());
+ assertEquals("alternateTitles", "ISO", getSingleton((Collection<?>) alternateTitles).toString());
// Collection of Identifiers
- final Object identifiers = accessor.get(accessor.indexOf("identifiers", true), citation);
+ final Object identifiers = accessor.get(accessor.indexOf("identifiers", true), instance);
assertInstanceOf("identifiers", Collection.class, identifiers);
- HardCodedCitations.assertIdentifiersForEPSG((Collection<?>) identifiers);
+ HardCodedCitations.assertIdentifiersFor("ISO", (Collection<?>) identifiers);
}
/**
@@ -229,24 +229,22 @@ public final strictfp class PropertyAcce
@Test
@DependsOnMethod("testGet")
public void testSet() {
- final Citation citation = new DefaultCitation();
+ final DefaultCitation instance = new DefaultCitation();
final PropertyAccessor accessor = createPropertyAccessor();
- {
- final Object newValue = new SimpleInternationalString("Some title");
- final int index = accessor.indexOf("title", true);
- final Object oldValue = accessor.set(index, citation, newValue, true);
- assertNull(oldValue);
- assertSame(newValue, accessor.get(index, citation));
- assertSame(newValue, citation.getTitle());
- }
- if (false) { // TODO
- final Object newValue = "Some ISBN code";
- final int index = accessor.indexOf("ISBN", true);
- final Object oldValue = accessor.set(index, citation, newValue, true);
- assertNull(oldValue);
- assertSame(newValue, accessor.get(index, citation));
- assertSame(newValue, citation.getISBN());
- }
+ Object newValue;
+ int index;
+
+ newValue = new SimpleInternationalString("Some title");
+ index = accessor.indexOf("title", true);
+ assertNull("title", accessor.set(index, instance, newValue, true));
+ assertSame("title", newValue, accessor.get(index, instance));
+ assertSame("title", newValue, instance.getTitle());
+
+ newValue = "Some ISBN code";
+ index = accessor.indexOf("ISBN", true);
+ assertNull("ISBN", accessor.set(index, instance, newValue, true));
+ assertSame("ISBN", newValue, accessor.get(index, instance));
+ assertSame("ISBN", newValue, instance.getISBN());
}
/**
@@ -258,16 +256,16 @@ public final strictfp class PropertyAcce
@DependsOnMethod("testSet")
public void testSetWithConversion() {
final String expected = "Some title";
- final Citation citation = new DefaultCitation();
+ final DefaultCitation instance = new DefaultCitation();
final PropertyAccessor accessor = createPropertyAccessor();
final int index = accessor.indexOf("title", true);
- final Object oldValue = accessor.set(index, citation, expected, true);
- final Object value = accessor.get(index, citation);
+ final Object oldValue = accessor.set(index, instance, expected, true);
+ final Object value = accessor.get(index, instance);
- assertNull(oldValue);
+ assertNull("title", oldValue);
assertInstanceOf("title", InternationalString.class, value);
- assertSame(expected, value.toString());
- assertSame(value, citation.getTitle());
+ assertSame("title", expected, value.toString());
+ assertSame("title", value, instance.getTitle());
}
/**
@@ -299,27 +297,27 @@ public final strictfp class PropertyAcce
final String text2 = "Yet an other title";
final InternationalString title1 = new SimpleInternationalString(text1);
final InternationalString title2 = new SimpleInternationalString(text2);
- final Citation citation = new DefaultCitation();
+ final DefaultCitation instance = new DefaultCitation();
final PropertyAccessor accessor = createPropertyAccessor();
- final int index = accessor.indexOf("alternateTitle", true);
+ final int index = accessor.indexOf("alternateTitles", true);
// Insert the first value. Old collection shall be empty.
- Object oldValue = accessor.set(index, citation, conversion ? text1 : title1, true);
- assertInstanceOf("alternateTitle", Collection.class, oldValue);
- assertTrue(((Collection<?>) oldValue).isEmpty());
+ Object oldValue = accessor.set(index, instance, conversion ? text1 : title1, true);
+ assertInstanceOf("alternateTitles", Collection.class, oldValue);
+ assertTrue("alternateTitles", ((Collection<?>) oldValue).isEmpty());
// Insert the second value. Old collection shall contains the first value.
- oldValue = accessor.set(index, citation, conversion ? text2 : title2, true);
- assertInstanceOf("alternateTitle", Collection.class, oldValue);
+ oldValue = accessor.set(index, instance, conversion ? text2 : title2, true);
+ assertInstanceOf("alternateTitles", Collection.class, oldValue);
oldValue = getSingleton((Collection<?>) oldValue);
- assertSame(text1, oldValue.toString());
+ assertSame("alternateTitles", text1, oldValue.toString());
if (!conversion) {
assertSame("InternationalString should have been stored as-is.", title1, oldValue);
}
// Check final collection content.
final List<InternationalString> expected = Arrays.asList(title1, title2);
- assertEquals(expected, accessor.get(index, citation));
+ assertEquals("alternateTitles", expected, accessor.get(index, instance));
}
/**
@@ -327,8 +325,8 @@ public final strictfp class PropertyAcce
*/
@Test
public void testShallowCopy() {
- final Citation original = HardCodedCitations.ISO;
- final Citation copy = new DefaultCitation();
+ final DefaultCitation original = HardCodedCitations.ISO;
+ final DefaultCitation copy = new DefaultCitation();
final PropertyAccessor accessor = createPropertyAccessor();
assertTrue("The copy should have modified the destination.", accessor.shallowCopy(original, copy));
assertEquals("International Organization for Standardization", copy.getTitle().toString());
@@ -346,35 +344,29 @@ public final strictfp class PropertyAcce
* Tests the equals methods.
*/
@Test
- @DependsOnMethod("testShallowCopy")
public void testEquals() {
- Citation citation = HardCodedCitations.EPSG;
+ DefaultCitation citation = HardCodedCitations.EPSG;
final PropertyAccessor accessor = createPropertyAccessor();
assertFalse(accessor.equals(citation, HardCodedCitations.GEOTIFF, ComparisonMode.STRICT));
assertTrue (accessor.equals(citation, HardCodedCitations.EPSG, ComparisonMode.STRICT));
- /*
- * Same test than above, but on a copy of the EPSG constant.
- */
- citation = new DefaultCitation();
- assertTrue (accessor.shallowCopy(HardCodedCitations.EPSG, citation));
+
+ // Same test than above, but on a copy of the EPSG constant.
+ citation = new DefaultCitation(HardCodedCitations.EPSG);
assertFalse(accessor.equals(citation, HardCodedCitations.GEOTIFF, ComparisonMode.STRICT));
assertTrue (accessor.equals(citation, HardCodedCitations.EPSG, ComparisonMode.STRICT));
- /*
- * Identifiers shall be stored in different collection instances with equal content.
- */
+
+ // Identifiers shall be stored in different collection instances with equal content.
final int index = accessor.indexOf("identifiers", true);
final Object source = accessor.get(index, HardCodedCitations.EPSG);
final Object target = accessor.get(index, citation);
assertInstanceOf("identifiers", Collection.class, source);
assertInstanceOf("identifiers", Collection.class, target);
-// assertNotSame(source, target); // TODO: require non-empty collection.
- assertEquals (source, target);
- HardCodedCitations.assertIdentifiersForEPSG((Collection<?>) source);
- HardCodedCitations.assertIdentifiersForEPSG((Collection<?>) target);
- /*
- * Set the identifiers to null, which should clear the collection.
- */
-// TODO assertEquals("Expected the previous value.", source, accessor.set(index, citation, null, true));
+ assertNotSame("Distinct objects shall have distinct collections.", source, target);
+ assertEquals ("The two collections shall have the same content.", source, target);
+ HardCodedCitations.assertIdentifiersFor("EPSG", (Collection<?>) target);
+
+ // Set the identifiers to null, which should clear the collection.
+ assertEquals("Expected the previous value.", source, accessor.set(index, citation, null, true));
final Object value = accessor.get(index, citation);
assertNotNull("Should have replaced null by an empty collection.", value);
assertTrue("Should have replaced null by an empty collection.", ((Collection<?>) value).isEmpty());
@@ -385,19 +377,19 @@ public final strictfp class PropertyAcce
*/
@Test
public void testHashCode() {
- final DefaultCitation citation = new DefaultCitation();
+ final DefaultCitation instance = new DefaultCitation();
final PropertyAccessor accessor = createPropertyAccessor();
- int hashCode = accessor.hashCode(citation);
+ int hashCode = accessor.hashCode(instance);
assertEquals("Empty metadata.", 0, hashCode);
final InternationalString title = new SimpleInternationalString("Some title");
- citation.setTitle(title);
- hashCode = accessor.hashCode(citation);
+ instance.setTitle(title);
+ hashCode = accessor.hashCode(instance);
assertEquals("Metadata with a single value.", title.hashCode(), hashCode);
final InternationalString alternateTitle = new SimpleInternationalString("An other title");
- citation.setAlternateTitles(singleton(alternateTitle));
- hashCode = accessor.hashCode(citation);
+ instance.setAlternateTitles(singleton(alternateTitle));
+ hashCode = accessor.hashCode(instance);
assertEquals("Metadata with two values.", title.hashCode() + Arrays.asList(alternateTitle).hashCode(), hashCode);
}
}
Modified: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java?rev=1468626&r1=1468625&r2=1468626&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java [UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/HardCodedCitations.java [UTF-8] Tue Apr 16 21:58:57 2013
@@ -20,6 +20,7 @@ import java.util.Collection;
import org.opengis.metadata.Identifier;
import org.opengis.metadata.citation.Citation;
import org.opengis.metadata.citation.PresentationForm;
+import org.apache.sis.metadata.iso.DefaultIdentifier;
import org.apache.sis.util.iso.SimpleInternationalString;
import org.apache.sis.util.Static;
@@ -29,6 +30,10 @@ import static java.util.Collections.sing
/**
* Hard-coded citation constants used for testing purpose only.
+ * We use those hard-coded constants instead than the ones defined in the
+ * {@link org.apache.sis.metadata.iso.citation.Citations} class in order
+ * to protect the test suite against any change in the definition of the
+ * above-cited public constants.
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3 (derived from geotk-2.4)
@@ -41,12 +46,12 @@ public final strictfp class HardCodedCit
* organization. An {@linkplain Citation#getAlternateTitles() alternate title} for this
* citation is "ISO" (according ISO 19115, alternate titles often contain abbreviations).
*/
- public static final Citation ISO;
+ public static final DefaultCitation ISO;
static {
- final DefaultCitation c = new DefaultCitation();
- c.setTitle(new SimpleInternationalString("International Organization for Standardization"));
+ final DefaultCitation c = new DefaultCitation("International Organization for Standardization");
c.setAlternateTitles(singleton(new SimpleInternationalString("ISO")));
c.setPresentationForms(singleton(PresentationForm.DOCUMENT_DIGITAL));
+ c.getIdentifiers().add(new DefaultIdentifier("ISO"));
c.freeze();
ISO = c;
}
@@ -54,10 +59,9 @@ public final strictfp class HardCodedCit
/**
* The ISO 19115 standard.
*/
- public static final Citation ISO_19115;
+ public static final DefaultCitation ISO_19115;
static {
- final DefaultCitation c = new DefaultCitation();
- c.setTitle(new SimpleInternationalString("ISO 19115"));
+ final DefaultCitation c = new DefaultCitation("ISO 19115");
c.setPresentationForms(singleton(PresentationForm.DOCUMENT_DIGITAL));
c.freeze();
ISO_19115 = c;
@@ -69,12 +73,12 @@ public final strictfp class HardCodedCit
* "EPSG" (according ISO 19115, alternate titles often contain abbreviations). In
* addition, this citation contains the "EPSG" {@linkplain Citation#getIdentifiers identifier}.
*/
- public static final Citation EPSG;
+ public static final DefaultCitation EPSG;
static {
- final DefaultCitation c = new DefaultCitation();
- c.setTitle(new SimpleInternationalString("European Petroleum Survey Group"));
+ final DefaultCitation c = new DefaultCitation("European Petroleum Survey Group");
c.setAlternateTitles(singleton(new SimpleInternationalString("EPSG")));
c.setPresentationForms(singleton(PresentationForm.TABLE_DIGITAL));
+ c.getIdentifiers().add(new DefaultIdentifier("EPSG"));
c.freeze();
EPSG = c;
}
@@ -82,10 +86,9 @@ public final strictfp class HardCodedCit
/**
* The <a href="http://www.remotesensing.org/geotiff/geotiff.html">GeoTIFF</a> specification.
*/
- public static final Citation GEOTIFF;
+ public static final DefaultCitation GEOTIFF;
static {
- final DefaultCitation c = new DefaultCitation();
- c.setTitle(new SimpleInternationalString("GeoTIFF"));
+ final DefaultCitation c = new DefaultCitation("GeoTIFF");
c.setPresentationForms(singleton(PresentationForm.DOCUMENT_DIGITAL));
c.freeze();
GEOTIFF = c;
@@ -98,15 +101,21 @@ public final strictfp class HardCodedCit
}
/**
- * Asserts that the given identifiers are for the {@link HardCodedCitations#EPSG} constant.
+ * Asserts that the given {@linkplain Identifier#getCode() identifier code}
+ * is found in the collection of identifiers.
*
+ * @param expected The expected identifier code (typically {@code "ISO"} or {@code "EPSG"}).
* @param identifiers The collection to validate. Should be a collection of {@link Identifier}.
*/
- public static void assertIdentifiersForEPSG(final Collection<?> identifiers) {
+ public static void assertIdentifiersFor(final String expected, final Collection<?> identifiers) {
assertNotNull("identifiers", identifiers);
+ int count = 0;
for (final Object id : identifiers) {
assertInstanceOf("identifier", Identifier.class, id);
- // TODO: check for EPSG identifiers here.
+ if (((Identifier) id).getCode().equals(expected)) {
+ count++;
+ }
}
+ assertEquals("Unexpected amount of identifiers.", 1, count);
}
}
Modified: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1468626&r1=1468625&r2=1468626&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] Tue Apr 16 21:58:57 2013
@@ -31,7 +31,8 @@ import org.junit.runners.Suite;
@Suite.SuiteClasses({
org.apache.sis.internal.metadata.MetadataUtilitiesTest.class,
org.apache.sis.metadata.PropertyDescriptorTest.class,
- org.apache.sis.metadata.PropertyAccessorTest.class
+ org.apache.sis.metadata.PropertyAccessorTest.class,
+ org.apache.sis.metadata.MetadataStandardTest.class
})
public final strictfp class MetadataTestSuite extends TestSuite {
}
Modified: sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java?rev=1468626&r1=1468625&r2=1468626&view=diff
==============================================================================
--- sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java [UTF-8] (original)
+++ sis/branches/JDK7/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java [UTF-8] Tue Apr 16 21:58:57 2013
@@ -480,10 +480,10 @@ public strictfp class GeneralEnvelopeTes
assertEquals( 40, envelope.getUpper(1), STRICT);
validate(envelope);
- assertEquals("BOX(6 10, 6 10)", new GeneralEnvelope("POINT(6 10)").toString());
+ assertEquals("BOX(6 10, 6 10)", new GeneralEnvelope("POINT(6 10)").toString());
assertEquals("BOX3D(6 10 3, 6 10 3)", new GeneralEnvelope("POINT M [ 6 10 3 ] ").toString());
- assertEquals("BOX(3 4, 20 50)", new GeneralEnvelope("LINESTRING(3 4,10 50,20 25)").toString());
- assertEquals("BOX(1 1, 6 5)", new GeneralEnvelope(
+ assertEquals("BOX(3 4, 20 50)", new GeneralEnvelope("LINESTRING(3 4,10 50,20 25)").toString());
+ assertEquals("BOX(1 1, 6 5)", new GeneralEnvelope(
"MULTIPOLYGON(((1 1,5 1,5 5,1 5,1 1),(2 2, 3 2, 3 3, 2 3,2 2)),((3 3,6 2,6 4,3 3)))").toString());
assertEquals("BOX(3 6, 7 10)", new GeneralEnvelope("GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(3 8,7 10))").toString());
assertEquals(0, new GeneralEnvelope("BOX()").getDimension());