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"));
}
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));
}
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));
}
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));
}
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());
}
Aggregations