Example usage for org.springframework.mock.web MockHttpServletResponse getStatus

List of usage examples for org.springframework.mock.web MockHttpServletResponse getStatus

Introduction

In this page you can find the example usage for org.springframework.mock.web MockHttpServletResponse getStatus.

Prototype

@Override
    public int getStatus() 

Source Link

Usage

From source file:org.geoserver.opensearch.rest.ProductsControllerTest.java

@Test
public void testPutProductMetadata() throws Exception {
    testCreateProduct();/*from  ww w .  j  a  v  a  2 s. c o  m*/

    // create the metadata
    MockHttpServletResponse response = putAsServletResponse(
            "rest/oseo/collections/SENTINEL2/products/S2A_OPER_MSI_L1C_TL_SGS__20180101T000000_A006640_T32TPP_N02.04/metadata",
            getTestData("/product-metadata.xml"), MediaType.TEXT_XML_VALUE);
    assertEquals(200, response.getStatus());

    // grab and check
    assertProductMetadata();
}

From source file:org.geoserver.opensearch.rest.ProductsControllerTest.java

private void assertProductMetadata() throws Exception, UnsupportedEncodingException {
    MockHttpServletResponse response;
    response = getAsServletResponse(/*w w w  . j  a  va 2s.c  o  m*/
            "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 testDeleteProductMetadata() throws Exception {
    // creates the product and adds the metadata
    testPutProductMetadata();/*from w ww  . j ava 2s  .  c om*/

    // now remove
    MockHttpServletResponse response = deleteAsServletResponse(
            "rest/oseo/collections/SENTINEL2/products/S2A_OPER_MSI_L1C_TL_SGS__20180101T000000_A006640_T32TPP_N02.04/metadata");
    assertEquals(200, response.getStatus());

    // check it's not there anymore
    response = getAsServletResponse(
            "rest/oseo/collections/SENTINEL2/products/S2A_OPER_MSI_L1C_TL_SGS__20180101T000000_A006640_T32TPP_N02.04/metadata");
    assertEquals(404, response.getStatus());
}

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

@Test
public void testPutProductDescription() throws Exception {
    testCreateProduct();//from   w  w  w .j  a  va2  s .com

    // create the description
    MockHttpServletResponse response = putAsServletResponse(
            "rest/oseo/collections/SENTINEL2/products/S2A_OPER_MSI_L1C_TL_SGS__20180101T000000_A006640_T32TPP_N02.04/description",
            getTestData("/product-description.html"), MediaType.TEXT_HTML_VALUE);
    assertEquals(200, response.getStatus());

    // grab and check
    assertProductDescription();
}

From source file:org.geoserver.opensearch.rest.ProductsControllerTest.java

private void assertProductDescription() throws Exception, UnsupportedEncodingException {
    MockHttpServletResponse response;
    response = getAsServletResponse(//w  w  w.j a  v  a 2s  . 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")));
}

From source file:org.geoserver.opensearch.rest.ProductsControllerTest.java

@Test
public void testDeleteCollectionDescription() throws Exception {
    // creates the collection and adds the metadata
    testPutProductDescription();//from ww w .java2 s.co  m

    // now remove
    MockHttpServletResponse response = deleteAsServletResponse(
            "rest/oseo/collections/SENTINEL2/products/S2A_OPER_MSI_L1C_TL_SGS__20180101T000000_A006640_T32TPP_N02.04/description");
    assertEquals(200, response.getStatus());

    // check it's not there anymore
    response = getAsServletResponse(
            "rest/oseo/collections/SENTINEL2/products/S2A_OPER_MSI_L1C_TL_SGS__20180101T000000_A006640_T32TPP_N02.04/description");
    assertEquals(404, response.getStatus());
}

From source file:org.geoserver.opensearch.rest.ProductsControllerTest.java

@Test
public void testGetProductMissingThumbnail() throws Exception {
    // this one does not have a thumbnail
    MockHttpServletResponse response = getAsServletResponse(
            "/rest/oseo/collections/SENTINEL2/products/S2A_OPER_MSI_L1C_TL_SGS__20160117T141030_A002979_T32TPL_N02.01/thumbnail");
    assertEquals(404, response.getStatus());
    assertThat(response.getContentAsString(),
            containsString("S2A_OPER_MSI_L1C_TL_SGS__20160117T141030_A002979_T32TPL_N02.01"));
}

From source file:org.geoserver.opensearch.rest.ProductsControllerTest.java

@Test
public void testPutProductThumbnail() throws Exception {
    testCreateProduct();// w  w  w.j av  a 2s  . c om

    // create the image
    MockHttpServletResponse response = putAsServletResponse(
            "rest/oseo/collections/SENTINEL2/products/S2A_OPER_MSI_L1C_TL_SGS__20180101T000000_A006640_T32TPP_N02.04/thumbnail",
            getTestData("/product-thumb.jpeg"), MediaType.IMAGE_JPEG_VALUE);
    assertEquals(200, response.getStatus());

    // grab and check
    assertProductThumbnail();
}

From source file:org.geoserver.opensearch.rest.ProductsControllerTest.java

@Test
public void testDeleteProductThumbnail() throws Exception {
    testPutProductThumbnail();/*from   w ww . j a v a  2 s  .  c o  m*/

    // now delete it
    MockHttpServletResponse response = deleteAsServletResponse(
            "rest/oseo/collections/SENTINEL2/products/S2A_OPER_MSI_L1C_TL_SGS__20180101T000000_A006640_T32TPP_N02.04/thumbnail");
    assertEquals(200, response.getStatus());

    // no more there now
    response = getAsServletResponse(
            "rest/oseo/collections/SENTINEL2/products/S2A_OPER_MSI_L1C_TL_SGS__20180101T000000_A006640_T32TPP_N02.04/thumbnail");
    assertEquals(404, response.getStatus());
}