Search in sources :

Example 1 with DocumentType

use of org.geotoolkit.inspire.xml.DocumentType 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);
}
Also used : OperationsMetadata(org.geotoolkit.ows.xml.v100.OperationsMetadata) Marshaller(javax.xml.bind.Marshaller) LanguagesType(org.geotoolkit.inspire.xml.LanguagesType) StringWriter(java.io.StringWriter) MultiLingualCapabilities(org.geotoolkit.inspire.xml.MultiLingualCapabilities) Capabilities(org.geotoolkit.csw.xml.v202.Capabilities) InspireCapabilitiesType(org.geotoolkit.inspire.xml.InspireCapabilitiesType) DocumentType(org.geotoolkit.inspire.xml.DocumentType) MultiLingualCapabilities(org.geotoolkit.inspire.xml.MultiLingualCapabilities) TranslatedCapabilitiesType(org.geotoolkit.inspire.xml.TranslatedCapabilitiesType) Test(org.junit.Test)

Example 2 with DocumentType

use of org.geotoolkit.inspire.xml.DocumentType 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);
}
Also used : OperationsMetadata(org.geotoolkit.ows.xml.v100.OperationsMetadata) LanguagesType(org.geotoolkit.inspire.xml.LanguagesType) MultiLingualCapabilities(org.geotoolkit.inspire.xml.MultiLingualCapabilities) Capabilities(org.geotoolkit.csw.xml.v202.Capabilities) StringReader(java.io.StringReader) InspireCapabilitiesType(org.geotoolkit.inspire.xml.InspireCapabilitiesType) DocumentType(org.geotoolkit.inspire.xml.DocumentType) MultiLingualCapabilities(org.geotoolkit.inspire.xml.MultiLingualCapabilities) Unmarshaller(javax.xml.bind.Unmarshaller) TranslatedCapabilitiesType(org.geotoolkit.inspire.xml.TranslatedCapabilitiesType) Test(org.junit.Test)

Aggregations

Capabilities (org.geotoolkit.csw.xml.v202.Capabilities)2 DocumentType (org.geotoolkit.inspire.xml.DocumentType)2 InspireCapabilitiesType (org.geotoolkit.inspire.xml.InspireCapabilitiesType)2 LanguagesType (org.geotoolkit.inspire.xml.LanguagesType)2 MultiLingualCapabilities (org.geotoolkit.inspire.xml.MultiLingualCapabilities)2 TranslatedCapabilitiesType (org.geotoolkit.inspire.xml.TranslatedCapabilitiesType)2 OperationsMetadata (org.geotoolkit.ows.xml.v100.OperationsMetadata)2 Test (org.junit.Test)2 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 Marshaller (javax.xml.bind.Marshaller)1 Unmarshaller (javax.xml.bind.Unmarshaller)1