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/08/27 15:34:04 UTC
svn commit: r1517813 - in /sis/branches/JDK7/profiles/sis-french-profile/src:
main/java/org/apache/sis/profile/france/
test/java/org/apache/sis/internal/profile/fra/
test/java/org/apache/sis/profile/ test/java/org/apache/sis/profile/france/
test/java/o...
Author: desruisseaux
Date: Tue Aug 27 13:34:04 2013
New Revision: 1517813
URL: http://svn.apache.org/r1517813
Log:
Added tests. This complete (for now) SIS-129.
Added:
sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DataIdentificationTest.java (with props)
sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/profile/
sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/profile/france/
sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/profile/france/FrenchProfileTest.java (with props)
sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/test/
sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/test/suite/
sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/test/suite/FrenchProfileSuite.java (with props)
Modified:
sis/branches/JDK7/profiles/sis-french-profile/src/main/java/org/apache/sis/profile/france/FrenchProfile.java
sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DirectReferenceSystemTest.java
Modified: sis/branches/JDK7/profiles/sis-french-profile/src/main/java/org/apache/sis/profile/france/FrenchProfile.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/profiles/sis-french-profile/src/main/java/org/apache/sis/profile/france/FrenchProfile.java?rev=1517813&r1=1517812&r2=1517813&view=diff
==============================================================================
--- sis/branches/JDK7/profiles/sis-french-profile/src/main/java/org/apache/sis/profile/france/FrenchProfile.java [UTF-8] (original)
+++ sis/branches/JDK7/profiles/sis-french-profile/src/main/java/org/apache/sis/profile/france/FrenchProfile.java [UTF-8] Tue Aug 27 13:34:04 2013
@@ -40,7 +40,7 @@ public final class FrenchProfile extends
* Returns the given metadata object as an AFNOR-compliant instance.
* The current implementation recognizes the following types:
*
- * <table>
+ * <table class="sis">
* <tr><th>GeoAPI type</th> <th>AFNOR XML element</th></tr>
* <tr><td>{@link org.opengis.metadata.identification.DataIdentification}</td> <td>{@code FRA_DataIdentification}</td>
* <tr><td>{@link org.opengis.metadata.constraint.Constraints}</td> <td>{@code FRA_Constraints}</td>
@@ -86,28 +86,23 @@ public final class FrenchProfile extends
* AFNOR requires the reference systems to be either <cite>direct</cite> or <cite>indirect</cite>.
* Those two cases are represented by the following schema fragments:
*
- * <table class="sis">
- * <tr><th>Direct</th><th>Indirect</th></tr>
- * <tr><td>
+ * <p><b>Direct:</b></p>
* {@preformat xml
* <complexType name="FRA_DirectReferenceSystem_Type">
* <complexContent>
- * <extension base="{http://www.isotc211.org/2005/gmd}MD_ReferenceSystem_Type">
- * </extension>
+ * <extension base="{http://www.isotc211.org/2005/gmd}MD_ReferenceSystem_Type"/>
* </complexContent>
* </complexType>
* }
- * </td><td>
+ *
+ * <p><b>Indirect:</b></p>
* {@preformat xml
* <complexType name="FRA_IndirectReferenceSystem_Type">
* <complexContent>
- * <extension base="{http://www.isotc211.org/2005/gmd}MD_ReferenceSystem_Type">
- * </extension>
+ * <extension base="{http://www.isotc211.org/2005/gmd}MD_ReferenceSystem_Type"/>
* </complexContent>
* </complexType>
* }
- * </td></tr>
- * </table>
*
* @param rs The reference system to make AFNOR-compliant, or {@code null}.
* @param indirect {@code false} for {@code FRA_DirectReferenceSystem},
Added: sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DataIdentificationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DataIdentificationTest.java?rev=1517813&view=auto
==============================================================================
--- sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DataIdentificationTest.java (added)
+++ sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DataIdentificationTest.java [UTF-8] Tue Aug 27 13:34:04 2013
@@ -0,0 +1,67 @@
+/*
+ * 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.profile.fra;
+
+import javax.xml.bind.JAXBException;
+import org.apache.sis.xml.XML;
+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 (un)marshalling of French profile of data identification.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @version 0.4
+ * @since 0.4
+ * @module
+ */
+public final strictfp class DataIdentificationTest extends TestCase {
+ @Test
+ public void testMarshalling() throws JAXBException {
+ final String xml =
+ "<fra:FRA_DataIdentification xmlns:gmd=\"http://www.isotc211.org/2005/gmd\"" +
+ " xmlns:gco=\"http://www.isotc211.org/2005/gco\"" +
+ " xmlns:fra=\"http://www.cnig.gouv.fr/2005/fra\">\n" +
+ " <gmd:citation>\n" +
+ " <gmd:CI_Citation>\n" +
+ " <gmd:title>\n" +
+ " <gco:CharacterString>Main documentation.</gco:CharacterString>\n" +
+ " </gmd:title>\n" +
+ " </gmd:CI_Citation>\n" +
+ " </gmd:citation>\n" +
+ " <fra:relatedCitation>\n" +
+ " <gmd:CI_Citation>\n" +
+ " <gmd:title>\n" +
+ " <gco:CharacterString>Related documentation.</gco:CharacterString>\n" +
+ " </gmd:title>\n" +
+ " </gmd:CI_Citation>\n" +
+ " </fra:relatedCitation>\n" +
+ "</fra:FRA_DataIdentification>";
+
+ final Object id = XML.unmarshal(xml);
+ assertInstanceOf("Expected an AFNOR instance.", DataIdentification.class, id);
+ assertEquals("citation", "Main documentation.", ((DataIdentification) id).getCitation().getTitle().toString());
+ assertEquals("relatedCitations", "Related documentation.", getSingleton(((DataIdentification) id).getRelatedCitations()).getTitle().toString());
+
+ final String actual = XML.marshal(id);
+ assertXmlEquals(xml, actual, "xmlns:*");
+ }
+}
Propchange: sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DataIdentificationTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DataIdentificationTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified: sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DirectReferenceSystemTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DirectReferenceSystemTest.java?rev=1517813&r1=1517812&r2=1517813&view=diff
==============================================================================
--- sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DirectReferenceSystemTest.java [UTF-8] (original)
+++ sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/internal/profile/fra/DirectReferenceSystemTest.java [UTF-8] Tue Aug 27 13:34:04 2013
@@ -34,7 +34,7 @@ import static org.apache.sis.test.TestUt
/**
- * Tests (un)marshalling of French profile of metadata.
+ * Tests (un)marshalling of French profile of reference system.
*
* @author Cédric Briançon (Geomatys)
* @author Guilhem Legal (Geomatys)
Added: sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/profile/france/FrenchProfileTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/profile/france/FrenchProfileTest.java?rev=1517813&view=auto
==============================================================================
--- sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/profile/france/FrenchProfileTest.java (added)
+++ sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/profile/france/FrenchProfileTest.java [UTF-8] Tue Aug 27 13:34:04 2013
@@ -0,0 +1,89 @@
+/*
+ * 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.profile.france;
+
+import org.opengis.referencing.ReferenceSystem;
+import org.opengis.metadata.constraint.Constraints;
+import org.opengis.metadata.constraint.LegalConstraints;
+import org.opengis.metadata.constraint.SecurityConstraints;
+import org.apache.sis.metadata.iso.constraint.DefaultConstraints;
+import org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints;
+import org.apache.sis.metadata.iso.constraint.DefaultSecurityConstraints;
+import org.apache.sis.internal.jaxb.metadata.ReferenceSystemMetadata;
+import org.apache.sis.internal.profile.fra.IndirectReferenceSystem;
+import org.apache.sis.internal.profile.fra.DirectReferenceSystem;
+import org.apache.sis.metadata.iso.ImmutableIdentifier;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.opengis.test.Assert.*;
+import static org.apache.sis.test.TestUtilities.getSingleton;
+
+
+/**
+ * Tests {@link FrenchProfile}.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @version 0.4
+ * @since 0.4
+ * @module
+ */
+public final strictfp class FrenchProfileTest extends TestCase {
+ /**
+ * Tests {@link FrenchProfile#toAFNOR(Object)} with {@link Constraints},
+ * {@link LegalConstraints} and {@link SecurityConstraints} objects.
+ */
+ @Test
+ public void testConstraintsToAFNOR() {
+ Constraints std, fra;
+
+ std = new DefaultConstraints("Some constraints.");
+ fra = (Constraints) FrenchProfile.toAFNOR(std);
+ assertNotSame("Expected a copy.", std, fra);
+ assertSame ("Already an AFNOR instance.", fra, FrenchProfile.toAFNOR(fra));
+ assertEquals ("Some constraints.", getSingleton(fra.getUseLimitations()).toString());
+
+ std = new DefaultLegalConstraints("Some legal constraints.");
+ fra = (LegalConstraints) FrenchProfile.toAFNOR(std);
+ assertNotSame("Expected a copy.", std, fra);
+ assertSame ("Already an AFNOR instance.", fra, FrenchProfile.toAFNOR(fra));
+ assertEquals ("Some legal constraints.", getSingleton(fra.getUseLimitations()).toString());
+
+ std = new DefaultSecurityConstraints("Some security constraints.");
+ fra = (SecurityConstraints) FrenchProfile.toAFNOR(std);
+ assertNotSame("Expected a copy.", std, fra);
+ assertSame ("Already an AFNOR instance.", fra, FrenchProfile.toAFNOR(fra));
+ assertEquals ("Some security constraints.", getSingleton(fra.getUseLimitations()).toString());
+ }
+
+ /**
+ * Tests {@link FrenchProfile#toAFNOR(ReferenceSystem, boolean)}.
+ */
+ @Test
+ public void testReferenceSystemToAFNOR() {
+ ReferenceSystem std, fra;
+
+ std = new ReferenceSystemMetadata(new ImmutableIdentifier(null, "EPSG", "4326"));
+ fra = FrenchProfile.toAFNOR(std, false);
+ assertInstanceOf("Expected AFNOR instance.", DirectReferenceSystem.class, fra);
+ assertSame("Already an AFNOR instance.", fra, FrenchProfile.toAFNOR(fra));
+
+ fra = FrenchProfile.toAFNOR(std, true);
+ assertInstanceOf("Expected AFNOR instance.", IndirectReferenceSystem.class, fra);
+ assertSame("Already an AFNOR instance.", fra, FrenchProfile.toAFNOR(fra));
+ }
+}
Propchange: sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/profile/france/FrenchProfileTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/profile/france/FrenchProfileTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Added: sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/test/suite/FrenchProfileSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/test/suite/FrenchProfileSuite.java?rev=1517813&view=auto
==============================================================================
--- sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/test/suite/FrenchProfileSuite.java (added)
+++ sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/test/suite/FrenchProfileSuite.java [UTF-8] Tue Aug 27 13:34:04 2013
@@ -0,0 +1,46 @@
+/*
+ * 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.test.suite;
+
+import org.apache.sis.test.TestSuite;
+import org.junit.runners.Suite;
+import org.junit.BeforeClass;
+
+
+/**
+ * All tests from the {@code sis-french-profile} module, in approximative dependency order.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.4
+ * @version 0.4
+ * @module
+ */
+@Suite.SuiteClasses({
+ org.apache.sis.internal.profile.fra.DirectReferenceSystemTest.class,
+ org.apache.sis.internal.profile.fra.DataIdentificationTest.class,
+ org.apache.sis.profile.france.FrenchProfileTest.class
+})
+public final strictfp class FrenchProfileSuite extends TestSuite {
+ /**
+ * Verifies the list of tests before to run the suite.
+ * See {@link #verifyTestList(Class, Class[])} for more information.
+ */
+ @BeforeClass
+ public static void verifyTestList() {
+ verifyTestList(UtilityTestSuite.class, BASE_TEST_CLASSES);
+ }
+}
Propchange: sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/test/suite/FrenchProfileSuite.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK7/profiles/sis-french-profile/src/test/java/org/apache/sis/test/suite/FrenchProfileSuite.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8