use of org.apache.sis.util.iso.SimpleInternationalString in project sis by apache.
the class PropertyTypeTest method testWithXLink.
/**
* Implementation of the public {@code test*XLink()} methods.
*
* <ul>
* <li>If {@code useReferenceResolverMock} is {@code false}, then this test uses the default SIS behavior,
* which is to not omit the metadata and still write the XLink for informative purpose.</li>
*
* <li>If {@code useReferenceResolverMock} is {@code true}, then the metadata object shall be replaced
* by the XLink because the {@link ReferenceResolverMock#canSubstituteByReference(MarshalContext,
* Class, Object, XLink)} method returns {@code true}.</li>
* </ul>
*/
private void testWithXLink(final boolean useReferenceResolverMock) {
final XLink link = new XLink();
link.setShow(XLink.Show.REPLACE);
link.setActuate(XLink.Actuate.ON_LOAD);
link.setTitle(new SimpleInternationalString("myLinkTitle"));
metadata.getIdentifierMap().putSpecialized(IdentifierSpace.XLINK, link);
if (useReferenceResolverMock) {
context = ReferenceResolverMock.begin(true);
// XMLTestCase.clearContext() will dispose the context.
}
final PropertyTypeMock property = marshal();
if (!useReferenceResolverMock) {
assertSame(metadata, property.metadata);
} else {
assertNull("metadata", property.metadata);
}
assertNull("nilReason", property.getNilReason());
assertNull("uuidref", property.getUUIDREF());
assertNull("href", property.getHRef());
assertNull("role", property.getRole());
assertNull("arcrole", property.getArcRole());
assertEquals("title", "myLinkTitle", property.getTitle());
assertEquals("show", XLink.Show.REPLACE, property.getShow());
assertEquals("actuate", XLink.Actuate.ON_LOAD, property.getActuate());
}
use of org.apache.sis.util.iso.SimpleInternationalString in project sis by apache.
the class ValueMapTest method createCitation.
/**
* Creates the metadata instance to be used for testing purpose.
* This method creates the following metadata
* (ignoring identifiers, which will be inferred from the ISBN value):
*
* {@preformat text
* Citation
* ├─Title…………………………………………………… Undercurrent
* ├─Edition……………………………………………… <nil:unknown>
* ├─Cited Responsible Parties
* │ └─Individual Name……………… Testsuya Toyoda
* └─ISBN……………………………………………………… 9782505004509
* }
*
* The citation instance is stored in the {@link #citation} field.
* The title and author instances are stored in the {@link #title} and {@link #author} fields.
*
* @return the map view of the citation create by this method.
*/
private Map<String, Object> createCitation() {
title = new SimpleInternationalString("Undercurrent");
author = new DefaultResponsibleParty();
citation = new DefaultCitation(title);
author.setParties(singleton(new DefaultIndividual("Testsuya Toyoda", null, null)));
citation.setCitedResponsibleParties(singleton(author));
citation.setISBN("9782505004509");
citation.setEdition(NilReason.UNKNOWN.createNilObject(InternationalString.class));
return MetadataStandard.ISO_19115.asValueMap(citation, null, KeyNamePolicy.JAVABEANS_PROPERTY, ValueExistencePolicy.NON_EMPTY);
}
use of org.apache.sis.util.iso.SimpleInternationalString in project sis by apache.
the class CustomMetadataTest method testProxy.
/**
* Tests the marshalling of a metadata implemented by {@link Proxy}.
*
* @throws JAXBException if an error occurred during (un)marshalling.
*/
@Test
public void testProxy() throws JAXBException {
/*
* A trivial metadata implementation which return the method name
* for every attribute of type InternationalString.
*/
final InvocationHandler handler = (Object proxy, Method method, Object[] args) -> {
if (method.getReturnType() == InternationalString.class) {
return new SimpleInternationalString(method.getName());
}
return null;
};
Citation data = (Citation) Proxy.newProxyInstance(getClass().getClassLoader(), new Class<?>[] { Citation.class }, handler);
/*
* Wrap the metadata in a DefaultMetadata, and ensure
* we can marshall it without an exception being throw.
*/
data = new DefaultCitation(data);
final String xml = XML.marshal(data);
/*
* A few simple checks.
*/
assertTrue(xml.contains("title"));
assertTrue(xml.contains("edition"));
}
use of org.apache.sis.util.iso.SimpleInternationalString in project sis by apache.
the class DefaultMetadataTest method testParentIdentifier.
/**
* Tests {@link DefaultMetadata#getParentIdentifier()} and {@link DefaultMetadata#setParentIdentifier(String)}
* methods.
*/
@Test
@SuppressWarnings("deprecation")
public void testParentIdentifier() {
final DefaultMetadata metadata = new DefaultMetadata();
assertNull("parentIdentifier", metadata.getParentIdentifier());
metadata.setParentIdentifier("ParentID");
assertEquals("parentIdentifier", "ParentID", metadata.getParentIdentifier());
DefaultCitation c = (DefaultCitation) metadata.getParentMetadata();
assertTitleEquals("parentMetadata", "ParentID", c);
c.setTitle(new SimpleInternationalString("New parent"));
assertEquals("parentIdentifier", "New parent", metadata.getParentIdentifier());
}
use of org.apache.sis.util.iso.SimpleInternationalString in project sis by apache.
the class DefaultKeywordsTest method testConstructor.
/**
* Tests {@link DefaultKeywords#DefaultKeywords(CharSequence[])}.
*/
@Test
public void testConstructor() {
final DefaultKeywords keywords = new DefaultKeywords("Keyword 1", "Keyword 2", "Keyword 3");
assertArrayEquals(new Object[] { new SimpleInternationalString("Keyword 1"), new SimpleInternationalString("Keyword 2"), new SimpleInternationalString("Keyword 3") }, keywords.getKeywords().toArray());
}
Aggregations