Search in sources :

Example 31 with OwsExceptionReport

use of org.n52.shetland.ogc.ows.exception.OwsExceptionReport in project arctic-sea by 52North.

the class GmlV321EncoderTest method isMeasureTypeValidWithoutUnitTest.

@Test
public void isMeasureTypeValidWithoutUnitTest() throws OwsExceptionReport, EncodingException {
    QuantityValue quantity = new QuantityValue(2.2);
    XmlObject encode = encoder.encode(quantity);
    assertTrue("Encoded Object is NOT valid", encode.validate());
}
Also used : QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) XmlObject(org.apache.xmlbeans.XmlObject) Test(org.junit.Test)

Example 32 with OwsExceptionReport

use of org.n52.shetland.ogc.ows.exception.OwsExceptionReport in project arctic-sea by 52North.

the class SweCommonEncoderv20Test method shouldEncodeDataRecordWithSweTextField.

@Test
public void shouldEncodeDataRecordWithSweTextField() throws OwsExceptionReport, EncodingException {
    final SweDataRecord record = new SweDataRecord();
    record.addField(new SweField("text", new SweText().setValue("textValue").setDefinition("textDef")));
    record.addField(new SweField("count", new SweCount().setValue(2).setDefinition("countDef")));
    final XmlObject encoded = sweCommonEncoderv20.encode(record);
    // validateDocument throws exceptions if the document is invalid
    XmlHelper.validateDocument(encoded, EncodingException::new);
}
Also used : SweText(org.n52.shetland.ogc.swe.simpleType.SweText) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) EncodingException(org.n52.svalbard.encode.exception.EncodingException) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) XmlObject(org.apache.xmlbeans.XmlObject) Test(org.junit.Test)

Example 33 with OwsExceptionReport

use of org.n52.shetland.ogc.ows.exception.OwsExceptionReport in project arctic-sea by 52North.

the class Soap12Encoder method createSOAP12FaultFromExceptionResponse.

// see
// http://www.angelikalanger.com/GenericsFAQ/FAQSections/ProgrammingIdioms.html#FAQ300
// for more details
private XmlObject createSOAP12FaultFromExceptionResponse(final OwsExceptionReport owsExceptionReport) throws EncodingException {
    final FaultDocument faultDoc = FaultDocument.Factory.newInstance();
    final Fault fault = faultDoc.addNewFault();
    final Faultcode code = fault.addNewCode();
    code.setValue(SOAPConstants.SOAP_SENDER_FAULT);
    // 19.2.3 SOAP 1.2 Fault Binding
    if (!owsExceptionReport.getExceptions().isEmpty()) {
        final CodedException firstException = owsExceptionReport.getExceptions().get(0);
        final Subcode subcode = code.addNewSubcode();
        QName qName;
        if (firstException.getCode() != null) {
            qName = OwsHelper.getQNameForLocalName(firstException.getCode().toString());
        } else {
            qName = OwsHelper.getQNameForLocalName(OwsExceptionCode.NoApplicableCode.name());
        }
        subcode.setValue(qName);
        final Reasontext addNewText = fault.addNewReason().addNewText();
        addNewText.setLang(Locale.ENGLISH.getLanguage());
        addNewText.setStringValue(SoapHelper.getSoapFaultReasonText(firstException.getCode()));
        fault.addNewDetail().set(encodeObjectToXml(OWSConstants.NS_OWS, firstException, EncodingContext.of(XmlBeansEncodingFlags.ENCODE_OWS_EXCEPTION_ONLY)));
    }
    return faultDoc;
}
Also used : Faultcode(org.w3.x2003.x05.soapEnvelope.Faultcode) Subcode(org.w3.x2003.x05.soapEnvelope.Subcode) FaultDocument(org.w3.x2003.x05.soapEnvelope.FaultDocument) Reasontext(org.w3.x2003.x05.soapEnvelope.Reasontext) CodedException(org.n52.shetland.ogc.ows.exception.CodedException) QName(javax.xml.namespace.QName) SoapFault(org.n52.shetland.w3c.soap.SoapFault) Fault(org.w3.x2003.x05.soapEnvelope.Fault)

Example 34 with OwsExceptionReport

use of org.n52.shetland.ogc.ows.exception.OwsExceptionReport in project arctic-sea by 52North.

the class SosDecoderv20Test method should_decode_boolean_swesExtensions.

@Test
public void should_decode_boolean_swesExtensions() throws XmlException, OwsExceptionReport, DecodingException {
    final GetObservationDocument doc = GetObservationDocument.Factory.parse("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<sos:GetObservation service=\"SOS\" version=\"2.0.0\"\n" + "    xmlns:sos=\"http://www.opengis.net/sos/2.0\"\n" + "    xmlns:swe=\"http://www.opengis.net/swe/2.0\"\n" + "    xmlns:swes=\"http://www.opengis.net/swes/2.0\">\n" + "    <swes:extension>\n" + "        <swe:Boolean definition=\"MergeObservationsIntoDataArray\">\n" + "            <swe:value>true</swe:value>\n" + "        </swe:Boolean>\n" + "    </swes:extension>\n" + "</sos:GetObservation>");
    final OwsServiceCommunicationObject decodedObject = decoder.decode(doc);
    assertThat(decodedObject, instanceOf(GetObservationRequest.class));
    final GetObservationRequest request = (GetObservationRequest) decodedObject;
    assertThat(request.getBooleanExtension("MergeObservationsIntoDataArray"), is(TRUE));
}
Also used : OwsServiceCommunicationObject(org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject) GetObservationRequest(org.n52.shetland.ogc.sos.request.GetObservationRequest) GetObservationDocument(net.opengis.sos.x20.GetObservationDocument) Test(org.junit.Test)

Example 35 with OwsExceptionReport

use of org.n52.shetland.ogc.ows.exception.OwsExceptionReport in project arctic-sea by 52North.

the class DescribeSensorResponseEncoderTest method should_return_exception_if_received_null.

@Test(expected = UnsupportedEncoderInputException.class)
public void should_return_exception_if_received_null() throws OwsExceptionReport, EncodingException {
    new DescribeSensorResponseEncoder().encode(null);
    new DescribeSensorResponseEncoder().encode(null, new ByteArrayOutputStream());
    new DescribeSensorResponseEncoder().encode(null, EncodingContext.empty());
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) DescribeSensorResponseEncoder(org.n52.svalbard.encode.DescribeSensorResponseEncoder) Test(org.junit.Test)

Aggregations

OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)27 EncodingException (org.n52.svalbard.encode.exception.EncodingException)14 Test (org.junit.Test)12 OmObservation (org.n52.shetland.ogc.om.OmObservation)9 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)8 OwsServiceRequest (org.n52.shetland.ogc.ows.service.OwsServiceRequest)8 DecodingException (org.n52.svalbard.decode.exception.DecodingException)8 XmlObject (org.apache.xmlbeans.XmlObject)7 OwsServiceResponse (org.n52.shetland.ogc.ows.service.OwsServiceResponse)7 IOException (java.io.IOException)6 DateTime (org.joda.time.DateTime)6 ObservationStream (org.n52.shetland.ogc.om.ObservationStream)6 OwsDecodingException (org.n52.iceland.coding.decode.OwsDecodingException)5 EReportingHeader (org.n52.shetland.aqd.EReportingHeader)5 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)5 LinkedList (java.util.LinkedList)4 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)4 FeatureCollection (org.n52.shetland.ogc.om.features.FeatureCollection)4 CodedException (org.n52.shetland.ogc.ows.exception.CodedException)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3