sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1650959 - in /sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis: internal/referencing/ServicesForMetadataTest.java test/suite/ReferencingTestSuite.java
Date Sun, 11 Jan 2015 19:59:17 GMT
Author: desruisseaux
Date: Sun Jan 11 19:59:16 2015
New Revision: 1650959

URL: http://svn.apache.org/r1650959
Log:
Added tests.

Added:
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.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/ServicesForMetadataTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java?rev=1650959&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java
(added)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java
[UTF-8] Sun Jan 11 19:59:16 2015
@@ -0,0 +1,162 @@
+/*
+ * 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 org.opengis.geometry.Envelope;
+import org.opengis.metadata.extent.GeographicBoundingBox;
+import org.opengis.metadata.extent.VerticalExtent;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.operation.TransformException;
+import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
+import org.apache.sis.metadata.iso.extent.DefaultVerticalExtent;
+import org.apache.sis.metadata.iso.extent.DefaultSpatialTemporalExtent;
+import org.apache.sis.geometry.GeneralEnvelope;
+import org.apache.sis.referencing.CommonCRS;
+import org.apache.sis.referencing.crs.HardCodedCRS;
+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.apache.sis.test.Assert.*;
+import static org.apache.sis.test.TestUtilities.getSingleton;
+
+
+/**
+ * Tests {@link ServicesForMetadata}.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.5
+ * @version 0.5
+ * @module
+ */
+@DependsOn({
+    org.apache.sis.referencing.CRSTest.class,
+    org.apache.sis.referencing.CommonCRSTest.class
+})
+public final strictfp class ServicesForMetadataTest extends TestCase {
+    /**
+     * Tolerance threshold for strict floating point comparisons.
+     */
+    private static final double STRICT = 0;
+
+    /**
+     * Creates a test envelope with the given CRS and initialized with
+     * [-10 … 70]° of longitude, [-20 … 30]° of latitude, [-40 … 60] metres of elevation
+     * and [51000 … 52000] modified Julian days.
+     */
+    @SuppressWarnings("fallthrough")
+    private static Envelope createEnvelope(final CoordinateReferenceSystem crs) {
+        final GeneralEnvelope envelope = new GeneralEnvelope(crs);
+        switch (crs.getCoordinateSystem().getDimension()) {
+            default: throw new AssertionError();
+            case 4: envelope.setRange(3, 51000, 52000); // Fall through
+            case 3: envelope.setRange(2, -10, 70); // Fall through
+            case 2: envelope.setRange(1, -20, 30); // Fall through
+            case 1: envelope.setRange(0, -40, 60);
+            case 0: break;
+        }
+        return envelope;
+    }
+
+    /**
+     * Verifies the values of the given geographic bounding box.
+     */
+    private static void verifySpatialExtent(final GeographicBoundingBox box) {
+        assertEquals(-40, box.getWestBoundLongitude(), STRICT);
+        assertEquals( 60, box.getEastBoundLongitude(), STRICT);
+        assertEquals(-20, box.getSouthBoundLatitude(), STRICT);
+        assertEquals( 30, box.getNorthBoundLatitude(), STRICT);
+        assertEquals(Boolean.TRUE, box.getInclusion());
+    }
+
+    /**
+     * Verifies the values of the given vertical extent.
+     */
+    private static void verifyVerticalExtent(final CommonCRS.Vertical expectedCRS, final
VerticalExtent extent) {
+        assertEquals(-10, extent.getMinimumValue(), STRICT);
+        assertEquals( 70, extent.getMaximumValue(), STRICT);
+        assertEqualsIgnoreMetadata(expectedCRS.crs(), extent.getVerticalCRS());
+    }
+
+
+    /**
+     * Tests (indirectly) {@link ServicesForMetadata#setBounds(Envelope, DefaultGeographicBoundingBox)}
+     * from a three-dimensional envelope.
+     *
+     * @throws TransformException should never happen.
+     */
+    @Test
+    public void testSetGeographicBoundsFrom3D() throws TransformException {
+        final DefaultGeographicBoundingBox box = new DefaultGeographicBoundingBox();
+        box.setBounds(createEnvelope(HardCodedCRS.WGS84_3D));
+        verifySpatialExtent(box);
+    }
+
+    /**
+     * Tests (indirectly) {@link ServicesForMetadata#setBounds(Envelope, DefaultGeographicBoundingBox)}
+     * from a for-dimensional envelope.
+     *
+     * @throws TransformException should never happen.
+     */
+    @Test
+    public void testSetGeographicBoundsFrom4D() throws TransformException {
+        final DefaultGeographicBoundingBox box = new DefaultGeographicBoundingBox();
+        box.setBounds(createEnvelope(HardCodedCRS.GEOID_4D));
+        verifySpatialExtent(box);
+    }
+
+    /**
+     * Tests (indirectly) {@link ServicesForMetadata#setBounds(Envelope, DefaultVerticalExtent)}
+     * from an ellipsoidal height
+     *
+     * @throws TransformException should never happen.
+     */
+    @Test
+    public void testSetVerticalBoundsFromEllipsoid() throws TransformException {
+        final DefaultVerticalExtent extent = new DefaultVerticalExtent();
+        extent.setBounds(createEnvelope(HardCodedCRS.WGS84_3D));
+        verifyVerticalExtent(CommonCRS.Vertical.ELLIPSOIDAL, extent);
+    }
+
+    /**
+     * Tests (indirectly) {@link ServicesForMetadata#setBounds(Envelope, DefaultVerticalExtent)}
+     * from a geoidal height
+     *
+     * @throws TransformException should never happen.
+     */
+    @Test
+    public void testSetVerticalBoundsFromGeoid() throws TransformException {
+        final DefaultVerticalExtent extent = new DefaultVerticalExtent();
+        extent.setBounds(createEnvelope(HardCodedCRS.GEOID_4D));
+        verifyVerticalExtent(CommonCRS.Vertical.MEAN_SEA_LEVEL, extent);
+    }
+
+    /**
+     * Tests (indirectly) {@link ServicesForMetadata#setBounds(Envelope, DefaultSpatialTemporalExtent)}.
+     *
+     * @throws TransformException should never happen.
+     */
+    @Test
+    @DependsOnMethod({"testSetGeographicBoundsFrom4D", "testSetVerticalBoundsFromGeoid"})
+    public void testSetSpatialTemporalBounds() throws TransformException {
+        final DefaultSpatialTemporalExtent extent = new DefaultSpatialTemporalExtent();
+        extent.setBounds(createEnvelope(HardCodedCRS.GEOID_3D));
+        verifySpatialExtent((GeographicBoundingBox) getSingleton(extent.getSpatialExtent()));
+        verifyVerticalExtent(CommonCRS.Vertical.MEAN_SEA_LEVEL, extent.getVerticalExtent());
+    }
+}

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

Propchange: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.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=1650959&r1=1650958&r2=1650959&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] Sun Jan 11 19:59:16 2015
@@ -119,6 +119,7 @@ import org.junit.BeforeClass;
 
     org.apache.sis.distance.LatLonPointRadiusTest.class, // Pending refactoring in a geometry
package.
 
+    org.apache.sis.internal.referencing.ServicesForMetadataTest.class,
     org.apache.sis.test.integration.ReferencingInMetadataTest.class,
     org.apache.sis.test.integration.DefaultMetadataTest.class
 })



Mime
View raw message