Search in sources :

Example 76 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class TreeNodeTest method testGetNameForMultiOccurrences.

/**
 * Tests {@link TreeNode#getName()} on a metadata with more than one entry in collections.
 * Those names <em>shall</em> contain numbering like <cite>"(1 of 2)"</cite>.
 */
@Test
@DependsOnMethod("testGetNameForSingleton")
public void testGetNameForMultiOccurrences() {
    final DefaultCitation citation = TreeNodeChildrenTest.metadataWithMultiOccurrences();
    assertColumnContentEquals(create(citation, Citation.class), TableColumn.NAME, "Citation", "Title", "Alternate title (1 of 2)", "Alternate title (2 of 2)", "Edition", "Presentation form (1 of 2)", "Presentation form (2 of 2)", "Other citation details");
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) Citation(org.opengis.metadata.citation.Citation) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 77 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class TreeTableViewTest method testSerialization.

/**
 * Tests serialization.
 *
 * @throws Exception if an error occurred during the serialization process.
 */
@Test
@DependsOnMethod("testToString")
public void testSerialization() throws Exception {
    final Object original = create(ValueExistencePolicy.COMPACT);
    final Object deserialized;
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    try (ObjectOutputStream out = new ObjectOutputStream(buffer)) {
        out.writeObject(original);
    }
    // Now reads the object we just serialized.
    final byte[] data = buffer.toByteArray();
    try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data))) {
        deserialized = in.readObject();
    }
    assertMultilinesEquals(EXPECTED, formatNameAndValue((TreeTableView) deserialized));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 78 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class CitationsTest method testGetCodeSpace.

/**
 * Tests {@link Citations#getCodeSpace(Citation)} with some ignorable characters.
 * Ignorable character used in this test are:
 *
 * <ul>
 *   <li>200B: zero width space</li>
 *   <li>2060: word joiner</li>
 * </ul>
 */
@Test
@DependsOnMethod("testGetIdentifier")
public void testGetCodeSpace() {
    final SimpleCitation citation = new SimpleCitation(" Valid\u2060Id\u200Bentifier ");
    assertEquals("ValidIdentifier", Citations.getCodeSpace(citation));
    assertNull("Shall not be taken as a valid identifier.", Citations.getCodeSpace(new SimpleCitation("Proj.4")));
    assertEquals("Shall fallback on the the identifier space name.", "TheProj4Space", Citations.getCodeSpace(new Proj4()));
}
Also used : SimpleCitation(org.apache.sis.internal.simple.SimpleCitation) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 79 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class DefaultLineageTest method testLegacySourceImagery.

/**
 * Tests the marshalling of a legacy {@code "gmi:LE_Source"} element.
 * This test starts with the same metadata than {@link #testLegacySource()} and adds
 * an ISO 19115-2 specific property. Consequently the XML name, which was originally
 * {@code "gmd:LI_Source"}, shall become {@code "gmi:LE_Source"}.
 *
 * @throws JAXBException if an error occurred while marshalling the XML.
 */
@Test
@DependsOnMethod("testLegacySource")
public void testLegacySourceImagery() throws JAXBException {
    String actual = marshal(create(true), VERSION_2007);
    assertXmlEquals("<gmd:LI_Lineage xmlns:gmd=\"" + LegacyNamespaces.GMD + '"' + " xmlns:gmi=\"" + LegacyNamespaces.GMI + '"' + " xmlns:gco=\"" + LegacyNamespaces.GCO + "\">\n" + "  <gmd:source>\n" + "    <gmi:LE_Source>\n" + "      <gmd:description>\n" + "        <gco:CharacterString>Description of source data level.</gco:CharacterString>\n" + "      </gmd:description>\n" + "      <gmi:processedLevel>\n" + "        <gmd:MD_Identifier>\n" + "          <gmd:code>\n" + "            <gco:CharacterString>DummyLevel</gco:CharacterString>\n" + "          </gmd:code>\n" + "        </gmd:MD_Identifier>\n" + "      </gmi:processedLevel>\n" + "    </gmi:LE_Source>\n" + "  </gmd:source>\n" + "</gmd:LI_Lineage>", actual, "xmlns:*");
    verify(unmarshal(DefaultLineage.class, actual));
}
Also used : SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 80 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class LanguageCodeTest method testLanguageCodeWithoutAttributes.

/**
 * Tests the unmarshalling using the {@code <gmd:LanguageCode>} construct without attributes.
 * The adapter is expected to parse the element value. XML fragment:
 *
 * {@preformat xml
 *   <gmd:MD_Metadata>
 *     <gmd:language>
 *       <gmd:LanguageCode>jpn</gmd:LanguageCode>
 *     </gmd:language>
 *   </gmd:MD_Metadata>
 * }
 *
 * @throws JAXBException if an error occurs while unmarshalling the language.
 */
@Test
@DependsOnMethod("testMarshalLanguageCode")
public void testLanguageCodeWithoutAttributes() throws JAXBException {
    final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
    final String xml = getMetadataXML(LANGUAGE_CODE_WITHOUT_ATTRIBUTE);
    final Metadata metadata = (Metadata) unmarshal(unmarshaller, xml);
    assertEquals(Locale.JAPANESE, metadata.getLanguage());
    pool.recycle(unmarshaller);
}
Also used : Metadata(org.opengis.metadata.Metadata) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Aggregations

DependsOnMethod (org.apache.sis.test.DependsOnMethod)298 Test (org.junit.Test)296 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)27 ProjectedCRS (org.opengis.referencing.crs.ProjectedCRS)23 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)21 CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)21 Rectangle (java.awt.Rectangle)19 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)19 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)18 GeographicCRS (org.opengis.referencing.crs.GeographicCRS)15 Random (java.util.Random)11 Matrix (org.opengis.referencing.operation.Matrix)11 HashMap (java.util.HashMap)10 IdentifiedObject (org.opengis.referencing.IdentifiedObject)8 ReferenceIdentifier (org.opengis.referencing.ReferenceIdentifier)8 MathTransform (org.opengis.referencing.operation.MathTransform)8 DefaultFeatureType (org.apache.sis.feature.DefaultFeatureType)7 DefaultFeatureTypeTest (org.apache.sis.feature.DefaultFeatureTypeTest)7 DirectPosition2D (org.apache.sis.geometry.DirectPosition2D)7 GeneralParameterDescriptor (org.opengis.parameter.GeneralParameterDescriptor)7