sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1793477 - in /sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis: internal/referencing/DefinitionVerifierTest.java test/suite/ReferencingTestSuite.java
Date Tue, 02 May 2017 12:00:29 GMT
Author: desruisseaux
Date: Tue May  2 12:00:29 2017
New Revision: 1793477

URL: http://svn.apache.org/viewvc?rev=1793477&view=rev
Log:
Add test.

Added:
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/DefinitionVerifierTest.java
  (with props)
Modified:
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java

Added: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/DefinitionVerifierTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/DefinitionVerifierTest.java?rev=1793477&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/DefinitionVerifierTest.java
(added)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/DefinitionVerifierTest.java
[UTF-8] Tue May  2 12:00:29 2017
@@ -0,0 +1,104 @@
+/*
+ * 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.internal.referencing;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.logging.LogRecord;
+import java.util.logging.SimpleFormatter;
+import org.opengis.util.FactoryException;
+import org.apache.sis.referencing.CommonCRS;
+import org.apache.sis.referencing.NamedIdentifier;
+import org.apache.sis.referencing.crs.HardCodedCRS;
+import org.apache.sis.referencing.crs.DefaultGeographicCRS;
+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.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * Tests {@link DefinitionVerifier}.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 0.8
+ * @since   0.8
+ * @module
+ */
+@DependsOn(org.apache.sis.referencing.CRSTest.class)
+public final strictfp class DefinitionVerifierTest extends TestCase {
+    /**
+     * Tests with a CRS which is conform to the authoritative definition.
+     *
+     * @throws FactoryException if an error occurred while querying the authority factory.
+     */
+    @Test
+    public void testConformCRS() throws FactoryException {
+        final DefaultGeographicCRS crs = HardCodedCRS.WGS84_φλ;
+        final DefinitionVerifier ver = DefinitionVerifier.withAuthority(crs, null, false);
+        assertNotNull("Should replace by EPSG:4326", ver);
+        assertNotSame("Should replace by EPSG:4326", crs, ver.authoritative);
+        assertSame   ("Should replace by EPSG:4326", CommonCRS.WGS84.geographic(), ver.authoritative);
+        assertNull   ("Should be silent.", ver.warning(true));
+    }
+
+    /**
+     * Tests with a CRS which is conform to the authoritative definition.
+     *
+     * @throws FactoryException if an error occurred while querying the authority factory.
+     */
+    @Test
+    @DependsOnMethod("testConformCRS")
+    public void testNormalizedCRS() throws FactoryException {
+        final DefaultGeographicCRS crs = HardCodedCRS.WGS84;
+        assertNull("No replacement without EPSG code.", DefinitionVerifier.withAuthority(crs,
null, false));
+        final DefinitionVerifier ver = DefinitionVerifier.withAuthority(crs, null, true);
+        assertNotNull("Should replace by normalized CRS", ver);
+        assertNotSame("Should replace by normalized CRS", crs, ver.authoritative);
+        assertSame   ("Should replace by normalized CRS", CommonCRS.WGS84.normalizedGeographic(),
ver.authoritative);
+        assertNull   ("Should be silent.", ver.warning(true));
+    }
+
+    /**
+     * Tests with a CRS having wrong axis order.
+     *
+     * @throws FactoryException if an error occurred while querying the authority factory.
+     */
+    @Test
+    @DependsOnMethod("testNormalizedCRS")
+    public void testDifferentAxisOrder() throws FactoryException {
+        final Map<String,Object> properties = new HashMap<>(4);
+        properties.put(DefaultGeographicCRS.NAME_KEY, "WGS 84");
+        properties.put(DefaultGeographicCRS.IDENTIFIERS_KEY, new NamedIdentifier(HardCodedCitations.EPSG,
"4326"));
+        DefaultGeographicCRS crs = HardCodedCRS.WGS84;
+        crs = new DefaultGeographicCRS(properties, crs.getDatum(), crs.getCoordinateSystem());
+
+        final DefinitionVerifier ver = DefinitionVerifier.withAuthority(crs, null, false);
+        assertNotNull("Should replace by normalized CRS", ver);
+        assertNotSame("Should replace by normalized CRS", crs, ver.authoritative);
+        assertSame   ("Should replace by normalized CRS", CommonCRS.WGS84.normalizedGeographic(),
ver.authoritative);
+
+        final LogRecord warning = ver.warning(true);
+        assertNotNull("Should emit a warning.", warning);
+        final String message = new SimpleFormatter().formatMessage(warning);
+        assertTrue(message, message.contains("WGS 84"));
+        assertTrue(message, message.contains("EPSG:4326"));
+    }
+}

Propchange: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/DefinitionVerifierTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/DefinitionVerifierTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1793477&r1=1793476&r2=1793477&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Tue May  2 12:00:29 2017
@@ -219,6 +219,7 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.AuthorityFactoriesTest.class,
     org.apache.sis.referencing.cs.CodesTest.class,
     org.apache.sis.referencing.CRSTest.class,
+    org.apache.sis.internal.referencing.DefinitionVerifierTest.class,
 
     // Coordinate operation finders are last, since they need everything else.
     org.apache.sis.referencing.operation.CoordinateOperationRegistryTest.class,



Mime
View raw message