Search in sources :

Example 11 with SchemaComponentType

use of net.opengis.cat.csw.v_2_0_2.SchemaComponentType in project ddf by codice.

the class CswEndpointTest method testMarshallDescribeRecord.

/**
 * Tests to see that JAXB configuration is working
 */
@Test
public void testMarshallDescribeRecord() {
    DescribeRecordResponseType response = new DescribeRecordResponseType();
    List<SchemaComponentType> schemas = new ArrayList<>();
    SchemaComponentType schemaComponentType = new SchemaComponentType();
    schemas.add(schemaComponentType);
    response.setSchemaComponent(schemas);
    JAXBContext context;
    try {
        context = JAXBContext.newInstance("net.opengis.cat.csw.v_2_0_2:net.opengis.filter.v_1_1_0:net.opengis.gml.v_3_1_1");
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
        StringWriter sw = new StringWriter();
        JAXBElement<DescribeRecordResponseType> wrappedResponse = new JAXBElement<>(cswQnameOutPutSchema, DescribeRecordResponseType.class, response);
        marshaller.marshal(wrappedResponse, sw);
        LOGGER.info("Response: {}", sw.toString());
    } catch (JAXBException e) {
        fail("Could not marshall message, Error: " + e.getMessage());
    }
}
Also used : Marshaller(javax.xml.bind.Marshaller) SchemaComponentType(net.opengis.cat.csw.v_2_0_2.SchemaComponentType) StringWriter(java.io.StringWriter) DescribeRecordResponseType(net.opengis.cat.csw.v_2_0_2.DescribeRecordResponseType) JAXBException(javax.xml.bind.JAXBException) ArrayList(java.util.ArrayList) JAXBContext(javax.xml.bind.JAXBContext) JAXBElement(javax.xml.bind.JAXBElement) Test(org.junit.Test)

Example 12 with SchemaComponentType

use of net.opengis.cat.csw.v_2_0_2.SchemaComponentType in project ddf by codice.

the class CswEndpointTest method testDescribeRecordValidSchemaLanguage.

@Test
public void testDescribeRecordValidSchemaLanguage() {
    DescribeRecordRequest drr = createDefaultDescribeRecordRequest();
    drr.setTypeName(VALID_PREFIX_LOCAL_TYPE);
    drr.setSchemaLanguage(CswConstants.SCHEMA_LANGUAGE_X_SCHEMA);
    when(mockSchemaManager.getTransformerSchemaForId(VALID_PREFIX_LOCAL_TYPE)).thenReturn(CswConstants.CSW_OUTPUT_SCHEMA);
    when(mockSchemaManager.getTransformerSchemaLocationForId(VALID_PREFIX_LOCAL_TYPE)).thenReturn(CSW_SCHEMA_LOCATION);
    DescribeRecordResponseType drrt = null;
    try {
        drrt = csw.describeRecord(drr);
    } catch (CswException e) {
        fail("DescribeRecord failed with message '" + e.getMessage() + "'");
    }
    assertThat(drrt, notNullValue());
    assertThat(drrt.getSchemaComponent(), notNullValue());
    List<SchemaComponentType> schemaComponents = drrt.getSchemaComponent();
    assertThat(schemaComponents.size(), is(1));
}
Also used : SchemaComponentType(net.opengis.cat.csw.v_2_0_2.SchemaComponentType) DescribeRecordRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.DescribeRecordRequest) DescribeRecordResponseType(net.opengis.cat.csw.v_2_0_2.DescribeRecordResponseType) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) Test(org.junit.Test)

Example 13 with SchemaComponentType

use of net.opengis.cat.csw.v_2_0_2.SchemaComponentType in project ddf by codice.

the class CswEndpointTest method testPostDescribeRecordRequestMultipleTypes.

@Test
public void testPostDescribeRecordRequestMultipleTypes() {
    DescribeRecordType drt = createDefaultDescribeRecordType();
    List<QName> typeNames = new ArrayList<>();
    typeNames.add(new QName(CswConstants.CSW_OUTPUT_SCHEMA, VALID_TYPE, VALID_PREFIX));
    typeNames.add(new QName(CswConstants.CSW_OUTPUT_SCHEMA, "test", VALID_PREFIX));
    drt.setTypeName(typeNames);
    DescribeRecordResponseType drrt = null;
    try {
        drrt = csw.describeRecord(drt);
    } catch (CswException e) {
        fail("CswException caught during describeRecord GET request: " + e.getMessage());
    }
    assertThat(drrt, notNullValue());
    assertThat(drrt.getSchemaComponent(), notNullValue());
    List<SchemaComponentType> schemaComponents = drrt.getSchemaComponent();
    assertThat(schemaComponents.size(), is(1));
}
Also used : DescribeRecordType(net.opengis.cat.csw.v_2_0_2.DescribeRecordType) SchemaComponentType(net.opengis.cat.csw.v_2_0_2.SchemaComponentType) QName(javax.xml.namespace.QName) DescribeRecordResponseType(net.opengis.cat.csw.v_2_0_2.DescribeRecordResponseType) ArrayList(java.util.ArrayList) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) Test(org.junit.Test)

Example 14 with SchemaComponentType

use of net.opengis.cat.csw.v_2_0_2.SchemaComponentType in project ddf by codice.

the class CswEndpointTest method testDescribeRecordSingleTypeSingleNamespaceNoPrefixes.

@Test
public void testDescribeRecordSingleTypeSingleNamespaceNoPrefixes() {
    DescribeRecordRequest drr = createDefaultDescribeRecordRequest();
    drr.setTypeName(VALID_TYPE);
    drr.setNamespace("xmlns(" + CswConstants.CSW_OUTPUT_SCHEMA + ")");
    when(mockSchemaManager.getTransformerSchemaForId(VALID_TYPE)).thenReturn(CswConstants.CSW_OUTPUT_SCHEMA);
    when(mockSchemaManager.getTransformerSchemaLocationForId(VALID_TYPE)).thenReturn(CSW_SCHEMA_LOCATION);
    DescribeRecordResponseType drrt = null;
    try {
        drrt = csw.describeRecord(drr);
    } catch (CswException e) {
        fail("DescribeRecord failed with message '" + e.getMessage() + "'");
    }
    assertThat(drrt, notNullValue());
    assertThat(drrt.getSchemaComponent(), notNullValue());
    List<SchemaComponentType> schemaComponents = drrt.getSchemaComponent();
    assertThat(schemaComponents.size(), is(1));
}
Also used : SchemaComponentType(net.opengis.cat.csw.v_2_0_2.SchemaComponentType) DescribeRecordRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.DescribeRecordRequest) DescribeRecordResponseType(net.opengis.cat.csw.v_2_0_2.DescribeRecordResponseType) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) Test(org.junit.Test)

Example 15 with SchemaComponentType

use of net.opengis.cat.csw.v_2_0_2.SchemaComponentType in project ddf by codice.

the class CswEndpointTest method testDescribeRecordValidOutputFormat.

@Test
public void testDescribeRecordValidOutputFormat() {
    DescribeRecordRequest drr = createDefaultDescribeRecordRequest();
    drr.setTypeName(VALID_PREFIX_LOCAL_TYPE);
    drr.setOutputFormat(CswConstants.OUTPUT_FORMAT_XML);
    DescribeRecordResponseType drrt = null;
    try {
        drrt = csw.describeRecord(drr);
    } catch (CswException e) {
        fail("DescribeRecord failed with message '" + e.getMessage() + "'");
    }
    assertThat(drrt, notNullValue());
    assertThat(drrt.getSchemaComponent(), notNullValue());
    List<SchemaComponentType> schemaComponents = drrt.getSchemaComponent();
    assertThat(schemaComponents.size(), is(1));
}
Also used : SchemaComponentType(net.opengis.cat.csw.v_2_0_2.SchemaComponentType) DescribeRecordRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.DescribeRecordRequest) DescribeRecordResponseType(net.opengis.cat.csw.v_2_0_2.DescribeRecordResponseType) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) Test(org.junit.Test)

Aggregations

SchemaComponentType (net.opengis.cat.csw.v_2_0_2.SchemaComponentType)25 DescribeRecordResponseType (net.opengis.cat.csw.v_2_0_2.DescribeRecordResponseType)24 Test (org.junit.Test)22 CswException (org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)20 ArrayList (java.util.ArrayList)13 DescribeRecordRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.DescribeRecordRequest)12 QName (javax.xml.namespace.QName)10 DescribeRecordType (net.opengis.cat.csw.v_2_0_2.DescribeRecordType)8 StringWriter (java.io.StringWriter)2 JAXBContext (javax.xml.bind.JAXBContext)2 JAXBElement (javax.xml.bind.JAXBElement)2 JAXBException (javax.xml.bind.JAXBException)2 Marshaller (javax.xml.bind.Marshaller)2