use of org.geotoolkit.inspire.xml.LanguagesType in project geotoolkit by Geomatys.
the class CswXMLBindingTest method InspireMarshalingTest.
/**
* Test capabilities with INSPIRE extendedCapabilities unmarshalling.
*/
@Test
public void InspireMarshalingTest() throws Exception {
Marshaller marshaller = pool.acquireMarshaller();
String expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:Capabilities version=\"2.0.2\" xmlns:ins=\"http://www.inspire.org\" xmlns:ows=\"http://www.opengis.net/ows\"" + " xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n" + " <ows:OperationsMetadata>\n" + " <ows:ExtendedCapabilities>\n" + " <ins:MultiLingualCapabilities>\n" + " <ins:Languages>\n" + " <ins:Language>GER</ins:Language>\n" + " <ins:Language>DUT</ins:Language>\n" + " </ins:Languages>\n" + " <ins:TranslatedCapabilities>\n" + " <ins:Document language=\"GER\" xlink:href=\"http://www.somehost.com/capabilities_german.xml\"/>\n" + " <ins:Document language=\"DUT\" xlink:href=\"http://www.somehost.com/capabilities_dutch.xml\"/>\n" + " </ins:TranslatedCapabilities>\n" + " </ins:MultiLingualCapabilities>\n" + " </ows:ExtendedCapabilities>\n" + " </ows:OperationsMetadata>\n" + "</csw:Capabilities>\n";
OperationsMetadata om = new OperationsMetadata();
LanguagesType languages = new LanguagesType(Arrays.asList("GER", "DUT"));
List<DocumentType> docs = Arrays.asList(new DocumentType("http://www.somehost.com/capabilities_german.xml", "GER"), new DocumentType("http://www.somehost.com/capabilities_dutch.xml", "DUT"));
TranslatedCapabilitiesType trans = new TranslatedCapabilitiesType(docs);
InspireCapabilitiesType inspireCapa = new InspireCapabilitiesType(languages, trans);
MultiLingualCapabilities m = new MultiLingualCapabilities();
m.setMultiLingualCapabilities(inspireCapa);
om.setExtendedCapabilities(m);
Capabilities capa = new Capabilities(null, null, om, "2.0.2", null, null);
StringWriter sw = new StringWriter();
marshaller.marshal(capa, sw);
String result = sw.toString();
assertXmlEquals(expResult, result, "xmlns:*");
pool.recycle(marshaller);
}
use of org.geotoolkit.inspire.xml.LanguagesType in project geotoolkit by Geomatys.
the class CswXMLBindingTest method InspireUnmarshalingTest.
/**
* Test capabilities with INSPIRE extendedCapabilities unmarshalling.
*/
@Test
public void InspireUnmarshalingTest() throws Exception {
Unmarshaller unmarshaller = pool.acquireUnmarshaller();
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:Capabilities version=\"2.0.2\" xmlns:ows=\"http://www.opengis.net/ows\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\">\n" + " <ows:OperationsMetadata>\n" + " <ows:ExtendedCapabilities>\n" + " <ins:MultiLingualCapabilities xmlns:ins=\"http://www.inspire.org\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n" + " <ins:Languages>\n" + " <ins:Language>GER</ins:Language>\n" + " <ins:Language>DUT</ins:Language>\n" + " </ins:Languages>\n" + " <ins:TranslatedCapabilities>\n" + " <ins:Document xlink:href=\"http://www.somehost.com/capabilities_german.xml\" language=\"GER\"/>\n" + " <ins:Document xlink:href=\"http://www.somehost.com/capabilities_dutch.xml\" language=\"DUT\"/>\n" + " </ins:TranslatedCapabilities>\n" + " </ins:MultiLingualCapabilities>\n" + " </ows:ExtendedCapabilities>\n" + " </ows:OperationsMetadata>\n" + "</csw:Capabilities>\n";
Capabilities result = (Capabilities) unmarshaller.unmarshal(new StringReader(xml));
OperationsMetadata om = new OperationsMetadata();
LanguagesType languages = new LanguagesType(Arrays.asList("GER", "DUT"));
List<DocumentType> docs = Arrays.asList(new DocumentType("http://www.somehost.com/capabilities_german.xml", "GER"), new DocumentType("http://www.somehost.com/capabilities_dutch.xml", "DUT"));
TranslatedCapabilitiesType trans = new TranslatedCapabilitiesType(docs);
InspireCapabilitiesType inspireCapa = new InspireCapabilitiesType(languages, trans);
MultiLingualCapabilities m = new MultiLingualCapabilities();
m.setMultiLingualCapabilities(inspireCapa);
om.setExtendedCapabilities(m);
Capabilities expResult = new Capabilities(null, null, om, "2.0.2", null, null);
assertEquals(expResult, result);
pool.recycle(unmarshaller);
}
Aggregations