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());
}
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);
}
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;
}
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));
}
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());
}
Aggregations