sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1453555 - in /sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis: metadata/PropertyAccessorTest.java metadata/PropertyDescriptorTest.java metadata/iso/citation/HardCodedCitations.java test/suite/MetadataTestSuite.java
Date Wed, 06 Mar 2013 20:58:49 GMT
Author: desruisseaux
Date: Wed Mar  6 20:58:49 2013
New Revision: 1453555

URL: http://svn.apache.org/r1453555
Log:
Added a testDescriptor() case in PropertyAccessorTest.

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/PropertyDescriptorTest.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

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=1453555&r1=1453554&r2=1453555&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] Wed Mar  6 20:58:49 2013
@@ -45,6 +45,7 @@ import org.apache.sis.util.iso.SimpleInt
 import org.apache.sis.metadata.iso.citation.DefaultCitation;
 import org.apache.sis.metadata.iso.citation.HardCodedCitations;
 import org.apache.sis.test.DependsOnMethod;
+import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -69,12 +70,13 @@ import static org.apache.sis.test.TestUt
  * @version 0.3
  * @module
  */
+@DependsOn(PropertyDescriptorTest.class)
 public final strictfp class PropertyAccessorTest extends TestCase {
     /**
      * Creates a new property accessor for the {@link DefaultCitation} class.
      */
     private static PropertyAccessor createPropertyAccessor() {
-        return new PropertyAccessor(HardCodedCitations.ISO, Citation.class, DefaultCitation.class);
+        return new PropertyAccessor(HardCodedCitations.ISO_19115, Citation.class, DefaultCitation.class);
     }
 
     /**
@@ -185,6 +187,17 @@ public final strictfp class PropertyAcce
     }
 
     /**
+     * Tests the {@link PropertyAccessor#descriptor(int)} method.
+     */
+    @Test
+    @DependsOnMethod("testConstructor")
+    public void testDescriptor() {
+        final PropertyAccessor accessor = createPropertyAccessor();
+        PropertyDescriptorTest.validateTitle           (accessor.descriptor(accessor.indexOf("title",
           true)));
+        PropertyDescriptorTest.validatePresentationForm(accessor.descriptor(accessor.indexOf("presentationForm",
true)));
+    }
+
+    /**
      * Tests the {@link PropertyAccessor#get(int, Object)} method.
      */
     @Test

Modified: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyDescriptorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyDescriptorTest.java?rev=1453555&r1=1453554&r2=1453555&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyDescriptorTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyDescriptorTest.java
[UTF-8] Wed Mar  6 20:58:49 2013
@@ -18,9 +18,10 @@ package org.apache.sis.metadata;
 
 import java.util.Locale;
 import org.opengis.util.InternationalString;
+import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.metadata.citation.PresentationForm;
-import org.apache.sis.internal.simple.SimpleCitation;
+import org.apache.sis.metadata.iso.citation.HardCodedCitations;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
@@ -47,7 +48,7 @@ public final strictfp class PropertyDesc
     private static <T> PropertyDescriptor<T> create(final Class<T> elementType,
final String method,
             final String property) throws NoSuchMethodException
     {
-        return new PropertyDescriptor<>(elementType, new SimpleCitation("ISO 19115"),
property,
+        return new PropertyDescriptor<>(elementType, HardCodedCitations.ISO_19115,
property,
                 Citation.class.getMethod(method));
     }
 
@@ -59,10 +60,17 @@ public final strictfp class PropertyDesc
      */
     @Test
     public void testTitle() throws NoSuchMethodException {
-        final PropertyDescriptor<?> descriptor = create(InternationalString.class,
"getTitle", "title");
+        validateTitle(create(InternationalString.class, "getTitle", "title"));
+    }
+
+    /**
+     * Validates a descriptor for {@link Citation#getTitle()}.
+     * This is validation code to be shared with {@link PropertyAccessorTest#testDescriptor()}.
+     */
+    static void validateTitle(final ParameterDescriptor<?> descriptor) {
         assertEquals("ISO 19115",   descriptor.getName().getAuthority().getTitle().toString());
-        assertEquals("CI_Citation", descriptor.getCodeSpace());
-        assertEquals("title",       descriptor.getCode());
+        assertEquals("CI_Citation", descriptor.getName().getCodeSpace());
+        assertEquals("title",       descriptor.getName().getCode());
         final InternationalString remarks = descriptor.getRemarks();
         assertEquals("Name by which the cited resource is known.", remarks.toString(Locale.ENGLISH));
         // Test other locale here, if any.
@@ -80,10 +88,17 @@ public final strictfp class PropertyDesc
      */
     @Test
     public void testPresentationForm() throws NoSuchMethodException {
-        final PropertyDescriptor<?> descriptor = create(PresentationForm.class, "getPresentationForms",
"presentationForm");
+        validatePresentationForm(create(PresentationForm.class, "getPresentationForms", "presentationForm"));
+    }
+
+    /**
+     * Validates a descriptor for {@link Citation#getPresentationForms()}.
+     * This is validation code to be shared with {@link PropertyAccessorTest#testDescriptor()}.
+     */
+    static void validatePresentationForm(final ParameterDescriptor<?> descriptor) {
         assertEquals("ISO 19115",        descriptor.getName().getAuthority().getTitle().toString());
-        assertEquals("CI_Citation",      descriptor.getCodeSpace());
-        assertEquals("presentationForm", descriptor.getCode());
+        assertEquals("CI_Citation",      descriptor.getName().getCodeSpace());
+        assertEquals("presentationForm", descriptor.getName().getCode());
         final InternationalString remarks = descriptor.getRemarks();
         assertEquals("Mode in which the resource is represented.", remarks.toString(Locale.ENGLISH));
         // Test other locale here, if any.

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=1453555&r1=1453554&r2=1453555&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] Wed Mar  6 20:58:49 2013
@@ -38,7 +38,7 @@ import static java.util.Collections.sing
 public final strictfp class HardCodedCitations extends Static {
     /**
      * The <a href="http://www.iso.org/">International Organization for Standardization</a>
-     * organization. An {@linkplain Citation#getAlternateTitles alternate title} for this
+     * 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;
@@ -52,8 +52,20 @@ public final strictfp class HardCodedCit
     }
 
     /**
+     * The ISO 19115 standard.
+     */
+    public static final Citation ISO_19115;
+    static {
+        final DefaultCitation c = new DefaultCitation();
+        c.setTitle(new SimpleInternationalString("ISO 19115"));
+        c.setPresentationForms(singleton(PresentationForm.DOCUMENT_DIGITAL));
+        c.freeze();
+        ISO_19115 = c;
+    }
+
+    /**
      * The <a href="http://www.epsg.org">European Petroleum Survey Group</a>
authority.
-     * An {@linkplain Citation#getAlternateTitles alternate title} for this citation is
+     * An {@linkplain Citation#getAlternateTitles() alternate title} for this citation is
      * "EPSG" (according ISO 19115, alternate titles often contain abbreviations). In
      * addition, this citation contains the "EPSG" {@linkplain Citation#getIdentifiers identifier}.
      */

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=1453555&r1=1453554&r2=1453555&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] Wed Mar  6 20:58:49 2013
@@ -29,8 +29,8 @@ import org.junit.runners.Suite;
  * @module
  */
 @Suite.SuiteClasses({
-    org.apache.sis.metadata.PropertyAccessorTest.class,
-    org.apache.sis.metadata.PropertyDescriptorTest.class
+    org.apache.sis.metadata.PropertyDescriptorTest.class,
+    org.apache.sis.metadata.PropertyAccessorTest.class
 })
 public final strictfp class MetadataTestSuite extends TestSuite {
 }



Mime
View raw message