List of usage examples for org.springframework.mock.web MockHttpServletResponse getContentType
@Override
@Nullable
public String getContentType()
From source file:org.geoserver.opensearch.eo.OSEOTestSupport.java
/** * Returns the DOM after checking the status code is 200 and the returned mime type is the expected one * //from ww w .j av a 2s . c o m * @param path * @param expectedMimeType * @return * @throws Exception */ protected Document getAsDOM(String path, int expectedStatusCode, String expectedMimeType) throws Exception { MockHttpServletResponse response = getAsServletResponse(path); assertEquals(expectedMimeType, response.getContentType()); assertEquals(expectedStatusCode, response.getStatus()); Document dom = dom(new ByteArrayInputStream(response.getContentAsByteArray())); return dom; }
From source file:org.geoserver.opensearch.rest.CollectionsControllerTest.java
@Test public void testGetCollectionMetadata() throws Exception { MockHttpServletResponse response = getAsServletResponse("/rest/oseo/collections/SENTINEL2/metadata"); assertEquals(200, response.getStatus()); assertEquals("text/xml", response.getContentType()); assertThat(response.getContentAsString(), both(containsString("gmi:MI_Metadata")).and(containsString("Sentinel-2"))); }
From source file:org.geoserver.opensearch.rest.CollectionsControllerTest.java
private void assertTest123Metadata() throws Exception, UnsupportedEncodingException { MockHttpServletResponse response; response = getAsServletResponse("rest/oseo/collections/TEST123/metadata"); assertEquals(200, response.getStatus()); assertEquals("text/xml", response.getContentType()); assertThat(response.getContentAsString(), both(containsString("gmi:MI_Metadata")).and(containsString("TEST123"))); }
From source file:org.geoserver.opensearch.rest.CollectionsControllerTest.java
@Test public void testGetCollectionDescription() throws Exception { MockHttpServletResponse response = getAsServletResponse("/rest/oseo/collections/SENTINEL2/description"); assertEquals(200, response.getStatus()); assertEquals("text/html", response.getContentType()); assertThat(response.getContentAsString(), both(containsString("<table>")).and(containsString("Sentinel-2"))); }
From source file:org.geoserver.opensearch.rest.CollectionsControllerTest.java
private void assertTest123Description() throws Exception, UnsupportedEncodingException { MockHttpServletResponse response; response = getAsServletResponse("rest/oseo/collections/TEST123/description"); assertEquals(200, response.getStatus()); assertEquals("text/html", response.getContentType()); assertThat(response.getContentAsString(), both(containsString("<table")).and(containsString("TEST123"))); }
From source file:org.geoserver.opensearch.rest.OSEORestTestSupport.java
protected DocumentContext getAsJSONPath(String path, int expectedHttpCode) throws Exception { MockHttpServletResponse response = getAsServletResponse(path); if (!isQuietTests()) { System.out.println(response.getContentAsString()); }/* www . j av a 2 s . co m*/ assertEquals(expectedHttpCode, response.getStatus()); assertThat(response.getContentType(), startsWith("application/json")); return JsonPath.parse(response.getContentAsString()); }
From source file:org.geoserver.opensearch.rest.ProductsControllerTest.java
@Test public void testGetProductMetadata() throws Exception { MockHttpServletResponse response = getAsServletResponse( "/rest/oseo/collections/SENTINEL2/products/S2A_OPER_MSI_L1C_TL_SGS__20160117T141030_A002979_T32TPL_N02.01/metadata"); assertEquals(200, response.getStatus()); assertEquals("text/xml", response.getContentType()); assertThat(response.getContentAsString(), both(containsString("opt:EarthObservation")) .and(containsString("S2A_OPER_MSI_L1C_TL_SGS__20160117T141030_A002979_T32TPL_N02.01"))); }
From source file:org.geoserver.opensearch.rest.ProductsControllerTest.java
private void assertProductMetadata() throws Exception, UnsupportedEncodingException { MockHttpServletResponse response; response = getAsServletResponse(// www.j a v a 2 s .c om "rest/oseo/collections/SENTINEL2/products/S2A_OPER_MSI_L1C_TL_SGS__20180101T000000_A006640_T32TPP_N02.04/metadata"); assertEquals(200, response.getStatus()); assertEquals("text/xml", response.getContentType()); assertThat(response.getContentAsString(), both(containsString("opt:EarthObservation")) .and(containsString("S2A_OPER_MSI_L1C_TL_SGS__20180101T000000_A006640_T32TPP_N02.04"))); }
From source file:org.geoserver.opensearch.rest.ProductsControllerTest.java
@Test public void testGetProductDescription() throws Exception { MockHttpServletResponse response = getAsServletResponse( "/rest/oseo/collections/SENTINEL2/products/S2A_OPER_MSI_L1C_TL_SGS__20160117T141030_A002979_T32TPL_N02.01/description"); assertEquals(200, response.getStatus()); assertEquals("text/html", response.getContentType()); assertThat(response.getContentAsString(), both(containsString("<table>")) .and(containsString("2016-01-17T10:10:30.743Z / 2016-01-17T10:10:30.743Z"))); }
From source file:org.geoserver.opensearch.rest.ProductsControllerTest.java
private void assertProductDescription() throws Exception, UnsupportedEncodingException { MockHttpServletResponse response; response = getAsServletResponse(/*from w w w. j a v a2s . c o m*/ "rest/oseo/collections/SENTINEL2/products/S2A_OPER_MSI_L1C_TL_SGS__20180101T000000_A006640_T32TPP_N02.04/description"); assertEquals(200, response.getStatus()); assertEquals("text/html", response.getContentType()); assertThat(response.getContentAsString(), both(containsString("<table")) .and(containsString("S2A_OPER_MSI_L1C_TL_SGS__20180101T000000_A006640_T32TPP_N02.04"))); }