use of net.opengis.ows._1.ExceptionReport in project ddf by codice.
the class CswExceptionMapper method createServiceException.
private ExceptionReport createServiceException(CswException cswException) {
ExceptionReport exceptionReport = new ExceptionReport();
exceptionReport.setVersion(SERVICE_EXCEPTION_REPORT_VERSION);
ExceptionType exception = new ExceptionType();
exception.setExceptionCode(cswException.getExceptionCode());
exception.setLocator(cswException.getLocator());
exception.getExceptionText().add(cswException.getMessage());
exceptionReport.getException().add(exception);
return exceptionReport;
}
use of net.opengis.ows._1.ExceptionReport in project ddf by codice.
the class TestCswExceptionMapper method testCswExceptionToServiceExceptionReportWithLocatorAndCode.
@Test
public void testCswExceptionToServiceExceptionReportWithLocatorAndCode() {
CswException exception = new CswException(SERVICE_EXCEPTION_MSG, Status.BAD_REQUEST.getStatusCode(), EXCEPTION_CODE, LOCATOR);
ExceptionMapper<Throwable> exceptionMapper = new CswExceptionMapper();
Response response = exceptionMapper.toResponse(exception);
assertThat(response.getEntity(), is(instanceOf(ExceptionReport.class)));
ExceptionReport exceptionReport = (ExceptionReport) response.getEntity();
assertThat(Status.BAD_REQUEST.getStatusCode(), is(response.getStatus()));
assertThat(SERVICE_EXCEPTION_MSG, is(exceptionReport.getException().get(0).getExceptionText().get(0)));
assertThat(EXCEPTION_CODE, is(exceptionReport.getException().get(0).getExceptionCode()));
assertThat(LOCATOR, is(exceptionReport.getException().get(0).getLocator()));
}
use of net.opengis.ows._1.ExceptionReport in project ddf by codice.
the class TestCswExceptionMapper method testCswExceptionToServiceExceptionReport.
@Test
public void testCswExceptionToServiceExceptionReport() {
CswException exception = new CswException(SERVICE_EXCEPTION_MSG, Status.BAD_REQUEST.getStatusCode());
ExceptionMapper<Throwable> exceptionMapper = new CswExceptionMapper();
Response response = exceptionMapper.toResponse(exception);
assertThat(response.getEntity(), is(instanceOf(ExceptionReport.class)));
ExceptionReport exceptionReport = (ExceptionReport) response.getEntity();
assertThat(Status.BAD_REQUEST.getStatusCode(), is(response.getStatus()));
assertThat(SERVICE_EXCEPTION_MSG, is(exceptionReport.getException().get(0).getExceptionText().get(0)));
assertThat(exceptionReport.getException().get(0).getExceptionCode(), nullValue());
assertThat(exceptionReport.getException().get(0).getLocator(), nullValue());
}
use of net.opengis.ows._1.ExceptionReport in project ddf by codice.
the class TestCswExceptionMapper method testThrowableExceptionToServiceExceptionReport.
@Test
public void testThrowableExceptionToServiceExceptionReport() {
NullPointerException npe = new NullPointerException();
ExceptionMapper<Throwable> exceptionMapper = new CswExceptionMapper();
Response response = exceptionMapper.toResponse(npe);
assertThat(response.getEntity(), is(instanceOf(ExceptionReport.class)));
ExceptionReport exceptionReport = (ExceptionReport) response.getEntity();
assertThat(Status.BAD_REQUEST.getStatusCode(), is(response.getStatus()));
assertThat(XML_PARSE_FAIL_MSG, is(exceptionReport.getException().get(0).getExceptionText().get(0)));
assertThat(CswConstants.MISSING_PARAMETER_VALUE, is(exceptionReport.getException().get(0).getExceptionCode()));
assertThat(exceptionReport.getException().get(0).getLocator(), nullValue());
IllegalArgumentException iae = new IllegalArgumentException();
exceptionMapper = new CswExceptionMapper();
response = exceptionMapper.toResponse(iae);
assertThat(response.getEntity(), is(instanceOf(ExceptionReport.class)));
exceptionReport = (ExceptionReport) response.getEntity();
assertThat(Status.BAD_REQUEST.getStatusCode(), is(response.getStatus()));
assertThat(XML_PARSE_FAIL_MSG, is(exceptionReport.getException().get(0).getExceptionText().get(0)));
assertThat(CswConstants.MISSING_PARAMETER_VALUE, is(exceptionReport.getException().get(0).getExceptionCode()));
assertThat(exceptionReport.getException().get(0).getLocator(), nullValue());
}
use of net.opengis.ows._1.ExceptionReport in project geotoolkit by Geomatys.
the class OWSXmlBindingTest method exceptionMarshalingTest.
/**
* Test simple Record Marshalling.
*
* @throws JAXBException
*/
@Test
public void exceptionMarshalingTest() throws JAXBException, IOException, ParserConfigurationException, SAXException {
/*
* Test marshalling exception report 110
*/
ExceptionReport report = new ExceptionReport("some error", OWSExceptionCode.INVALID_CRS.name(), "parameter1", "1.1.0");
StringWriter sw = new StringWriter();
marshaller.marshal(report, sw);
String result = sw.toString();
String expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<ns2:ExceptionReport version=\"1.1.0\" xmlns:ns2=\"http://www.opengis.net/ows/1.1\">" + '\n' + " <ns2:Exception locator=\"parameter1\" exceptionCode=\"InvalidCRS\">" + '\n' + " <ns2:ExceptionText>some error</ns2:ExceptionText>" + '\n' + " </ns2:Exception>" + '\n' + "</ns2:ExceptionReport>" + '\n';
assertXmlEquals(expResult, result, "xmlns:*");
}
Aggregations