Search in sources :

Example 56 with ObjectFactory

use of biblemulticonverter.schema.usx3.ObjectFactory in project cxf by apache.

the class AbstractTypeTestClient2 method testStructWithSubstitutionGroupNil.

@Test
public void testStructWithSubstitutionGroupNil() throws Exception {
    if (!shouldRunTest("StructWithSubstitutionGroupNil")) {
        return;
    }
    StructWithSubstitutionGroupNil x = new StructWithSubstitutionGroupNil();
    ObjectFactory objectFactory = new ObjectFactory();
    JAXBElement<? extends SgBaseTypeA> element = objectFactory.createSg04NillableBaseElementA(null);
    x.setSg04NillableBaseElementA(element);
    StructWithSubstitutionGroupNil yOrig = new StructWithSubstitutionGroupNil();
    element = objectFactory.createSg04NillableBaseElementA(null);
    yOrig.setSg04NillableBaseElementA(element);
    Holder<StructWithSubstitutionGroupNil> y = new Holder<>(yOrig);
    Holder<StructWithSubstitutionGroupNil> z = new Holder<>();
    StructWithSubstitutionGroupNil ret;
    if (testDocLiteral) {
        ret = docClient.testStructWithSubstitutionGroupNil(x, y, z);
    } else if (testXMLBinding) {
        ret = xmlClient.testStructWithSubstitutionGroupNil(x, y, z);
    } else {
        ret = rpcClient.testStructWithSubstitutionGroupNil(x, y, z);
    }
    if (!perfTestOnly) {
        assertTrue("testStructWithSubstitutionGroupNil(): Incorrect value for inout param", equals(x, y.value));
        assertTrue("testStructWithSubstitutionGroupNil(): Incorrect value for out param", equals(yOrig, z.value));
        assertTrue("testStructWithSubstitutionGroupNil(): Incorrect return value", equals(x, ret));
    }
}
Also used : ObjectFactory(org.apache.type_test.types3.ObjectFactory) Holder(javax.xml.ws.Holder) StructWithSubstitutionGroupNil(org.apache.type_test.types3.StructWithSubstitutionGroupNil) Test(org.junit.Test)

Example 57 with ObjectFactory

use of biblemulticonverter.schema.usx3.ObjectFactory in project ddf by codice.

the class GetRecordsResponseConverterTest method testMarshalRecordCollectionGetFull.

@Ignore
@Test
public void testMarshalRecordCollectionGetFull() throws UnsupportedEncodingException, JAXBException {
    final int totalResults = 5;
    XStream xstream = createXStream(CswConstants.GET_RECORDS_RESPONSE);
    GetRecordsType getRecords = new GetRecordsType();
    QueryType query = new QueryType();
    ElementSetNameType set = new ElementSetNameType();
    set.setValue(ElementSetType.FULL);
    query.setElementSetName(set);
    ObjectFactory objectFactory = new ObjectFactory();
    getRecords.setAbstractQuery(objectFactory.createAbstractQuery(query));
    CswRecordCollection collection = createCswRecordCollection(getRecords, totalResults);
    collection.setElementSetType(ElementSetType.FULL);
    ArgumentCaptor<MarshallingContext> captor = ArgumentCaptor.forClass(MarshallingContext.class);
    String xml = xstream.toXML(collection);
    // Verify the context arguments were set correctly
    verify(mockProvider, times(totalResults)).marshal(any(Object.class), any(HierarchicalStreamWriter.class), captor.capture());
    MarshallingContext context = captor.getValue();
    assertThat(context, not(nullValue()));
    assertThat(context.get(CswConstants.OUTPUT_SCHEMA_PARAMETER), is(CswConstants.CSW_OUTPUT_SCHEMA));
    assertThat(context.get(CswConstants.ELEMENT_SET_TYPE), is(ElementSetType.FULL));
    JAXBElement<GetRecordsResponseType> jaxb = (JAXBElement<GetRecordsResponseType>) getJaxBContext().createUnmarshaller().unmarshal(new ByteArrayInputStream(xml.getBytes("UTF-8")));
    GetRecordsResponseType response = jaxb.getValue();
    // Assert the GetRecordsResponse elements and attributes
    assertThat(response, not(nullValue()));
    SearchResultsType resultsType = response.getSearchResults();
    assertThat(resultsType, not(nullValue()));
    assertThat(resultsType.getElementSet(), is(ElementSetType.FULL));
    assertThat(resultsType.getNumberOfRecordsMatched().intValue(), is(totalResults));
    assertThat(resultsType.getNumberOfRecordsReturned().intValue(), is(totalResults));
    assertThat(resultsType.getRecordSchema(), is(CswConstants.CSW_OUTPUT_SCHEMA));
}
Also used : HierarchicalStreamWriter(com.thoughtworks.xstream.io.HierarchicalStreamWriter) XStream(com.thoughtworks.xstream.XStream) SearchResultsType(net.opengis.cat.csw.v_2_0_2.SearchResultsType) GetRecordsType(net.opengis.cat.csw.v_2_0_2.GetRecordsType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) JAXBElement(javax.xml.bind.JAXBElement) ObjectFactory(net.opengis.cat.csw.v_2_0_2.ObjectFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) CswRecordCollection(org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection) ElementSetNameType(net.opengis.cat.csw.v_2_0_2.ElementSetNameType) GetRecordsResponseType(net.opengis.cat.csw.v_2_0_2.GetRecordsResponseType) MarshallingContext(com.thoughtworks.xstream.converters.MarshallingContext) QueryType(net.opengis.cat.csw.v_2_0_2.QueryType) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 58 with ObjectFactory

use of biblemulticonverter.schema.usx3.ObjectFactory in project ddf by codice.

the class GetRecordsResponseConverterTest method testMarshalRecordCollectionFullXml.

@Ignore
@Test
public void testMarshalRecordCollectionFullXml() throws UnsupportedEncodingException, JAXBException {
    final int totalResults = 5;
    TransformerManager mockMetacardManager = mock(TransformerManager.class);
    when(mockMetacardManager.getTransformerBySchema(anyString())).thenReturn(new CswRecordConverter(CswRecordConverterTest.getCswMetacardType()));
    GetRecordsResponseConverter rrConverter = new GetRecordsResponseConverter(new CswTransformProvider(mockMetacardManager, null));
    XStream xstream = createXstream(new StaxDriver(new NoNameCoder()));
    xstream.registerConverter(rrConverter);
    xstream.alias(CswConstants.CSW_NAMESPACE_PREFIX + CswConstants.NAMESPACE_DELIMITER + CswConstants.GET_RECORDS_RESPONSE, CswRecordCollection.class);
    GetRecordsType getRecords = new GetRecordsType();
    QueryType query = new QueryType();
    ElementSetNameType set = new ElementSetNameType();
    set.setValue(ElementSetType.FULL);
    query.setElementSetName(set);
    ObjectFactory objectFactory = new ObjectFactory();
    getRecords.setAbstractQuery(objectFactory.createAbstractQuery(query));
    CswRecordCollection collection = createCswRecordCollection(getRecords, totalResults);
    collection.setElementSetType(ElementSetType.FULL);
    String xml = xstream.toXML(collection);
    JAXBElement<GetRecordsResponseType> jaxb = (JAXBElement<GetRecordsResponseType>) getJaxBContext().createUnmarshaller().unmarshal(new ByteArrayInputStream(xml.getBytes("UTF-8")));
    GetRecordsResponseType response = jaxb.getValue();
    // Assert the GetRecordsResponse elements and attributes
    assertThat(response, not(nullValue()));
    SearchResultsType resultsType = response.getSearchResults();
    assertThat(resultsType, not(nullValue()));
    assertThat(resultsType.getElementSet(), is(ElementSetType.FULL));
    assertThat(resultsType.getNumberOfRecordsMatched().intValue(), is(totalResults));
    assertThat(resultsType.getNumberOfRecordsReturned().intValue(), is(totalResults));
    assertThat(resultsType.getRecordSchema(), is(CswConstants.CSW_OUTPUT_SCHEMA));
}
Also used : TransformerManager(org.codice.ddf.spatial.ogc.csw.catalog.common.transformer.TransformerManager) XStream(com.thoughtworks.xstream.XStream) SearchResultsType(net.opengis.cat.csw.v_2_0_2.SearchResultsType) GetRecordsType(net.opengis.cat.csw.v_2_0_2.GetRecordsType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) JAXBElement(javax.xml.bind.JAXBElement) NoNameCoder(com.thoughtworks.xstream.io.naming.NoNameCoder) StaxDriver(com.thoughtworks.xstream.io.xml.StaxDriver) ObjectFactory(net.opengis.cat.csw.v_2_0_2.ObjectFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) CswRecordCollection(org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection) ElementSetNameType(net.opengis.cat.csw.v_2_0_2.ElementSetNameType) GetRecordsResponseType(net.opengis.cat.csw.v_2_0_2.GetRecordsResponseType) QueryType(net.opengis.cat.csw.v_2_0_2.QueryType) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 59 with ObjectFactory

use of biblemulticonverter.schema.usx3.ObjectFactory in project ddf by codice.

the class GetRecordsResponseConverterTest method testMarshalRecordCollectionGetSummary.

@Ignore
@Test
public void testMarshalRecordCollectionGetSummary() throws UnsupportedEncodingException, JAXBException {
    final int totalResults = 5;
    XStream xstream = createXStream(CswConstants.GET_RECORDS_RESPONSE);
    GetRecordsType getRecords = new GetRecordsType();
    QueryType query = new QueryType();
    ElementSetNameType set = new ElementSetNameType();
    set.setValue(ElementSetType.SUMMARY);
    query.setElementSetName(set);
    ObjectFactory objectFactory = new ObjectFactory();
    getRecords.setAbstractQuery(objectFactory.createAbstractQuery(query));
    CswRecordCollection collection = createCswRecordCollection(getRecords, totalResults);
    collection.setElementSetType(ElementSetType.SUMMARY);
    ArgumentCaptor<MarshallingContext> captor = ArgumentCaptor.forClass(MarshallingContext.class);
    String xml = xstream.toXML(collection);
    // Verify the context arguments were set correctly
    verify(mockProvider, times(totalResults)).marshal(any(Object.class), any(HierarchicalStreamWriter.class), captor.capture());
    MarshallingContext context = captor.getValue();
    assertThat(context, not(nullValue()));
    assertThat(context.get(CswConstants.OUTPUT_SCHEMA_PARAMETER), is(CswConstants.CSW_OUTPUT_SCHEMA));
    assertThat(context.get(CswConstants.ELEMENT_SET_TYPE), is(ElementSetType.SUMMARY));
    JAXBElement<GetRecordsResponseType> jaxb = (JAXBElement<GetRecordsResponseType>) getJaxBContext().createUnmarshaller().unmarshal(new ByteArrayInputStream(xml.getBytes("UTF-8")));
    GetRecordsResponseType response = jaxb.getValue();
    // Assert the GetRecordsResponse elements and attributes
    assertThat(response, not(nullValue()));
    SearchResultsType resultsType = response.getSearchResults();
    assertThat(resultsType, not(nullValue()));
    assertThat(resultsType.getElementSet(), is(ElementSetType.SUMMARY));
    assertThat(resultsType.getNumberOfRecordsMatched().intValue(), is(totalResults));
    assertThat(resultsType.getNumberOfRecordsReturned().intValue(), is(totalResults));
    assertThat(resultsType.getRecordSchema(), is(CswConstants.CSW_OUTPUT_SCHEMA));
}
Also used : HierarchicalStreamWriter(com.thoughtworks.xstream.io.HierarchicalStreamWriter) XStream(com.thoughtworks.xstream.XStream) SearchResultsType(net.opengis.cat.csw.v_2_0_2.SearchResultsType) GetRecordsType(net.opengis.cat.csw.v_2_0_2.GetRecordsType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) JAXBElement(javax.xml.bind.JAXBElement) ObjectFactory(net.opengis.cat.csw.v_2_0_2.ObjectFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) CswRecordCollection(org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection) ElementSetNameType(net.opengis.cat.csw.v_2_0_2.ElementSetNameType) GetRecordsResponseType(net.opengis.cat.csw.v_2_0_2.GetRecordsResponseType) MarshallingContext(com.thoughtworks.xstream.converters.MarshallingContext) QueryType(net.opengis.cat.csw.v_2_0_2.QueryType) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 60 with ObjectFactory

use of biblemulticonverter.schema.usx3.ObjectFactory in project ddf by codice.

the class WfsSource method buildSortBy.

private SortByType buildSortBy(QName featureType, SortBy incomingSortBy) {
    net.opengis.filter.v_1_1_0.ObjectFactory filterObjectFactory = new net.opengis.filter.v_1_1_0.ObjectFactory();
    String propertyName = mapSortByPropertyName(featureType, incomingSortBy.getPropertyName().getPropertyName(), metacardMappers);
    if (propertyName != null) {
        SortOrder sortOrder = incomingSortBy.getSortOrder();
        SortPropertyType sortPropertyType = filterObjectFactory.createSortPropertyType();
        PropertyNameType propertyNameType = filterObjectFactory.createPropertyNameType();
        List<Serializable> props = Arrays.asList(propertyName);
        propertyNameType.setContent(props);
        sortPropertyType.setPropertyName(propertyNameType);
        if (SortOrder.ASCENDING.equals(sortOrder)) {
            sortPropertyType.setSortOrder(SortOrderType.ASC);
        } else if (SortOrder.DESCENDING.equals(sortOrder)) {
            sortPropertyType.setSortOrder(SortOrderType.DESC);
        } else {
            LOGGER.debug("Unable to build query. Unknown sort order of [{}].", sortOrder == null ? null : sortOrder.identifier());
            return null;
        }
        SortByType sortByType = filterObjectFactory.createSortByType();
        sortByType.getSortProperty().add(sortPropertyType);
        return sortByType;
    }
    return null;
}
Also used : Serializable(java.io.Serializable) SortOrder(org.opengis.filter.sort.SortOrder) SortByType(net.opengis.filter.v_1_1_0.SortByType) ObjectFactory(net.opengis.wfs.v_1_1_0.ObjectFactory) SortPropertyType(net.opengis.filter.v_1_1_0.SortPropertyType) PropertyNameType(net.opengis.filter.v_1_1_0.PropertyNameType)

Aggregations

Test (org.junit.Test)23 JAXBElement (javax.xml.bind.JAXBElement)22 ObjectFactory (net.opengis.cat.csw.v_2_0_2.ObjectFactory)20 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)18 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)17 QName (javax.xml.namespace.QName)13 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)13 XStream (com.thoughtworks.xstream.XStream)12 ByteArrayInputStream (java.io.ByteArrayInputStream)12 Marshaller (javax.xml.bind.Marshaller)12 GetRecordsResponseType (net.opengis.cat.csw.v_2_0_2.GetRecordsResponseType)12 SearchResultsType (net.opengis.cat.csw.v_2_0_2.SearchResultsType)12 ArrayList (java.util.ArrayList)11 JAXBContext (javax.xml.bind.JAXBContext)11 ElementSetNameType (net.opengis.cat.csw.v_2_0_2.ElementSetNameType)11 MarshallingContext (com.thoughtworks.xstream.converters.MarshallingContext)10 HierarchicalStreamWriter (com.thoughtworks.xstream.io.HierarchicalStreamWriter)10 StringWriter (java.io.StringWriter)10 BigInteger (java.math.BigInteger)10 ObjectFactory (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectFactory)8