use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswException in project ddf by codice.
the class TestCswResponseExceptionMapper method testCswExceptionWithMultipleExceptionTexts.
@Test
public void testCswExceptionWithMultipleExceptionTexts() {
String exceptionReportXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n" + "<ows:ExceptionReport version=\"1.2.0\" xmlns:ns16=\"http://www.opengis.net/ows/1.1\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cat=\"http://www.opengis.net/cat/csw\" xmlns:gco=\"http://www.isotc211.org/2005/gco\" xmlns:gmd=\"http://www.isotc211.org/2005/gmd\" xmlns:fra=\"http://www.cnig.gouv.fr/2005/fra\" xmlns:ins=\"http://www.inspire.org\" xmlns:gmx=\"http://www.isotc211.org/2005/gmx\" xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:dct=\"http://purl.org/dc/terms/\" xmlns:ows=\"http://www.opengis.net/ows\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:gml=\"http://www.opengis.net/gml\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:gmi=\"http://www.isotc211.org/2005/gmi\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n" + " <ows:Exception exceptionCode=\"INVALID_PARAMETER_VALUE\" locator=\"QueryConstraint\">\r\n" + " <ows:ExceptionText>Only dc:title,dct:modified,dc:subject,dct:dateSubmitted,dct:alternative,dc:format,dct:created,dc:type,dct:abstract,dc:identifier,dc:creator are currently supported</ows:ExceptionText>\r\n" + " <ows:ExceptionText>Second exception text</ows:ExceptionText>\r\n" + " </ows:Exception>\r\n" + "</ows:ExceptionReport>";
CswException cswException = createCswException(exceptionReportXml);
assertThat(cswException.getMessage(), containsString("exceptionCode = INVALID_PARAMETER_VALUE"));
assertThat(cswException.getMessage(), containsString("locator = QueryConstraint"));
assertThat(cswException.getMessage(), containsString("Only dc:title,dct:modified,dc:subject,dct:dateSubmitted,dct:alternative,dc:format,dct:created,dc:type,dct:abstract,dc:identifier,dc:creator are currently supported"));
assertThat(cswException.getMessage(), containsString("Second exception text"));
}
use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswException in project ddf by codice.
the class TestCswEndpoint method testGetCapabilitiesTypeNoVersion.
@Test
public void testGetCapabilitiesTypeNoVersion() {
// Should return all sections
GetCapabilitiesType gct = createDefaultGetCapabilitiesType();
gct.setAcceptVersions(null);
CapabilitiesType ct = null;
try {
ct = csw.getCapabilities(gct);
} catch (CswException e) {
fail("CswException caught during getCapabilities GET request: " + e.getMessage());
}
assertThat(ct, notNullValue());
verifyOperationsMetadata(ct);
verifyServiceIdentification(ct);
verifyServiceProvider(ct);
verifyFilterCapabilities(ct);
}
use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswException 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 org.codice.ddf.spatial.ogc.csw.catalog.common.CswException 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 org.codice.ddf.spatial.ogc.csw.catalog.common.CswException in project ddf by codice.
the class TestCswEndpoint method testGetCapabilitiesTypeServiceProvider.
@Test
public void testGetCapabilitiesTypeServiceProvider() {
// Should only return the ServiceProvider section
GetCapabilitiesType gct = createDefaultGetCapabilitiesType();
SectionsType stv = new SectionsType();
stv.setSection(Arrays.asList(CswEndpoint.SERVICE_PROVIDER));
gct.setSections(stv);
CapabilitiesType ct = null;
try {
ct = csw.getCapabilities(gct);
} catch (CswException e) {
fail("CswException caught during getCapabilities GET request: " + e.getMessage());
}
assertThat(ct, notNullValue());
verifyServiceProvider(ct);
verifyFilterCapabilities(ct);
assertThat(ct.getServiceIdentification(), nullValue());
assertThat(ct.getOperationsMetadata(), nullValue());
}
Aggregations