Search in sources :

Example 11 with NameFactory

use of org.opengis.util.NameFactory in project sis by apache.

the class DefaultFeatureTypeTest method testQualifiedAndUnqualifiedNames.

/**
 * Tests two names having the same tip, but where only one of the two names have a namespace.
 *
 * @since 0.8
 */
@Test
@DependsOnMethod("testQualifiedNames")
public void testQualifiedAndUnqualifiedNames() {
    final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
    final DefaultAttributeType<String> a1 = new DefaultAttributeType<>(name(factory.createGenericName(null, "sis", "identifier")), String.class, 1, 1, null);
    final DefaultAttributeType<String> a2 = new DefaultAttributeType<>(name(factory.createGenericName(null, "identifier")), String.class, 1, 1, null);
    final DefaultFeatureType feature = new DefaultFeatureType(name("City"), false, null, a1, a2);
    assertSame("sis:identifier", a1, feature.getProperty("sis:identifier"));
    assertSame("identifier", a2, feature.getProperty("identifier"));
}
Also used : InternationalString(org.opengis.util.InternationalString) NameFactory(org.opengis.util.NameFactory) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 12 with NameFactory

use of org.opengis.util.NameFactory in project sis by apache.

the class NameMarshallingTest method testScopedName.

/**
 * Tests XML of a {@link org.opengis.util.ScopedName}.
 *
 * @throws JAXBException if (un)marshalling failed.
 */
@Test
public void testScopedName() throws JAXBException {
    final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
    final GenericName name = factory.createGenericName(null, "myScope", "myName");
    assertEquals("myScope:myName", name.toString());
    final String expected = "<gml:IO_IdentifiedObject xmlns:gml=\"" + Namespaces.GML + '"' + " xmlns:gco=\"" + LegacyNamespaces.GCO + "\">\n" + "  <gml:alias>\n" + "    <gco:ScopedName>myScope:myName</gco:ScopedName>\n" + "  </gml:alias>\n" + "</gml:IO_IdentifiedObject>\n";
    final String actual = marshal(name);
    assertXmlEquals(expected, actual, "xmlns:*");
    assertEquals(name, unmarshal(expected));
}
Also used : GenericName(org.opengis.util.GenericName) NameFactory(org.opengis.util.NameFactory) Test(org.junit.Test)

Example 13 with NameFactory

use of org.opengis.util.NameFactory in project sis by apache.

the class NameMarshallingTest method testLocalNameWithScope.

/**
 * Tests XML of a {@link LocalName} with a scope.
 *
 * @throws JAXBException if (un)marshalling failed.
 */
@Test
@DependsOnMethod("testLocalName")
public void testLocalNameWithScope() throws JAXBException {
    final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
    final NameSpace scope = factory.createNameSpace(factory.createLocalName(null, "A code space"), null);
    final LocalName name = factory.createLocalName(scope, "A name in a scope");
    assertEquals("A name in a scope", name.toString());
    final String expected = "<gml:IO_IdentifiedObject xmlns:gml=\"" + Namespaces.GML + '"' + " xmlns:gco=\"" + LegacyNamespaces.GCO + "\">\n" + "  <gml:alias>\n" + "    <gco:LocalName codeSpace=\"A code space\">A name in a scope</gco:LocalName>\n" + "  </gml:alias>\n" + "</gml:IO_IdentifiedObject>\n";
    final String actual = marshal(name);
    assertXmlEquals(expected, actual, "xmlns:*");
    assertEquals(name, unmarshal(expected));
}
Also used : NameSpace(org.opengis.util.NameSpace) NameFactory(org.opengis.util.NameFactory) LocalName(org.opengis.util.LocalName) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 14 with NameFactory

use of org.opengis.util.NameFactory in project sis by apache.

the class NameMarshallingTest method testLocalName.

/**
 * Tests XML of a {@link LocalName}.
 *
 * @throws JAXBException if (un)marshalling failed.
 */
@Test
public void testLocalName() throws JAXBException {
    final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
    final LocalName name = factory.createLocalName(null, "An ordinary local name");
    assertEquals("An ordinary local name", name.toString());
    final String expected = "<gml:IO_IdentifiedObject xmlns:gml=\"" + Namespaces.GML + '"' + " xmlns:gco=\"" + LegacyNamespaces.GCO + "\">\n" + "  <gml:alias>\n" + "    <gco:LocalName>An ordinary local name</gco:LocalName>\n" + "  </gml:alias>\n" + "</gml:IO_IdentifiedObject>\n";
    final String actual = marshal(name);
    assertXmlEquals(expected, actual, "xmlns:*");
    assertEquals(name, unmarshal(expected));
}
Also used : NameFactory(org.opengis.util.NameFactory) LocalName(org.opengis.util.LocalName) Test(org.junit.Test)

Example 15 with NameFactory

use of org.opengis.util.NameFactory in project sis by apache.

the class BuilderTest method testAddName.

/**
 * Tests {@link Builder#addName(CharSequence)} without codespace.
 */
@Test
public void testAddName() {
    final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
    // Expected values to be used later in the test.
    final String name = "Mercator (variant A)";
    final LocalName alias1 = factory.createLocalName(null, "Mercator (1SP)");
    final LocalName alias2 = factory.createLocalName(null, "Mercator_1SP");
    final LocalName alias3 = factory.createLocalName(null, "CT_Mercator");
    assertTrue("That name should not have a scope.", alias1.scope().isGlobal());
    assertTrue("That name should not have a scope.", alias2.scope().isGlobal());
    assertTrue("That name should not have a scope.", alias3.scope().isGlobal());
    assertEquals("Mercator (1SP)", alias1.toString());
    assertEquals("Mercator_1SP", alias2.toString());
    assertEquals("CT_Mercator", alias3.toString());
    // The test.
    final BuilderMock builder = new BuilderMock();
    // EPSG version 7.6 and later.
    assertSame(builder, builder.addName("Mercator (variant A)"));
    // EPSG before version 7.6.
    assertSame(builder, builder.addName("Mercator (1SP)"));
    // OGC
    assertSame(builder, builder.addName("Mercator_1SP"));
    // GeoTIFF
    assertSame(builder, builder.addName("CT_Mercator"));
    builder.onCreate(false);
    assertEquals(name, builder.getName());
    assertArrayEquals(new GenericName[] { alias1, alias2, alias3 }, builder.getAliases());
}
Also used : NameFactory(org.opengis.util.NameFactory) LocalName(org.opengis.util.LocalName) Test(org.junit.Test)

Aggregations

NameFactory (org.opengis.util.NameFactory)20 Test (org.junit.Test)13 DependsOnMethod (org.apache.sis.test.DependsOnMethod)6 GenericName (org.opengis.util.GenericName)5 LocalName (org.opengis.util.LocalName)5 InternationalString (org.opengis.util.InternationalString)4 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)2 NameSpace (org.opengis.util.NameSpace)2 ConcurrentModificationException (java.util.ConcurrentModificationException)1 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)1 IdentifiedObjectMock (org.apache.sis.test.mock.IdentifiedObjectMock)1 DefaultNameFactory (org.apache.sis.util.iso.DefaultNameFactory)1 Citation (org.opengis.metadata.citation.Citation)1 ResponsibleParty (org.opengis.metadata.citation.ResponsibleParty)1 Constraints (org.opengis.metadata.constraint.Constraints)1 Format (org.opengis.metadata.distribution.Format)1 Extent (org.opengis.metadata.extent.Extent)1 MaintenanceInformation (org.opengis.metadata.maintenance.MaintenanceInformation)1