Package com.mockrunner.mock.web

Examples of com.mockrunner.mock.web.MockHttpServletResponse


     authenticationManager.setProviders(
         Arrays.asList(new AuthenticationProvider[]{new OpenPlansAuthenticationProvider()})
         );
    
     MockHttpServletRequest request = new MockHttpServletRequest();
     MockHttpServletResponse response = new MockHttpServletResponse();
     request.addCookie(new Cookie("__ac", "this is an invalid cookie"));
    
     SecurityContextHolder.setContext(new SecurityContextImpl());
     testFilter.doFilter(request, response, new MockFilterChain());
    
View Full Code Here


        assertNotNull(image);
    }
   
    public void testSLDBody() throws Exception {
      String request = "wms?FORMAT=image/png&TRANSPARENT=TRUE&HEIGHT=406&WIDTH=810&REQUEST=GetMap&SRS=EPSG:4326&VERSION=1.1.1&BBOX=-120,-120,120,120&SLD_BODY=%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%3CStyledLayerDescriptor%20version%3D%221.0.0%22%20xmlns%3Agml%3D%22http%3A%2F%2Fwww.opengis.net%2Fgml%22%20xmlns%3Aogc%3D%22http%3A%2F%2Fwww.opengis.net%2Fogc%22%20xmlns%3D%22http%3A%2F%2Fwww.opengis.net%2Fsld%22%3E%3CUserLayer%3E%3CName%3Ejunk%3C%2FName%3E%3CInlineFeature%3E%3CFeatureCollection%3E%3CfeatureMember%3E%3CBodyPart%3E%3CType%3EFace%3C%2FType%3E%3CpolygonProperty%3E%3Cgml%3APolygon%3E%3Cgml%3AouterBoundaryIs%3E%3Cgml%3ALinearRing%3E%3Cgml%3Acoordinates%3E-10%2C10%2010%2C10%2010%2C-10%20-10%2C-10%20-10%2C10%3C%2Fgml%3Acoordinates%3E%3C%2Fgml%3ALinearRing%3E%3C%2Fgml%3AouterBoundaryIs%3E%3C%2Fgml%3APolygon%3E%3C%2FpolygonProperty%3E%3C%2FBodyPart%3E%3C%2FfeatureMember%3E%3C%2FFeatureCollection%3E%3C%2FInlineFeature%3E%3CLayerFeatureConstraints%3E%3CFeatureTypeConstraint%3E%3C%2FFeatureTypeConstraint%3E%3C%2FLayerFeatureConstraints%3E%3CUserStyle%3E%3CFeatureTypeStyle%3E%3CRule%3E%3CPolygonSymbolizer%3E%3CFill%3E%3CCssParameter%20name%3D%22fill%22%3E%3Cogc%3ALiteral%3E%23F00620%3C%2Fogc%3ALiteral%3E%3C%2FCssParameter%3E%3CCssParameter%20name%3D%22fill-opacity%22%3E%3Cogc%3ALiteral%3E1.0%3C%2Fogc%3ALiteral%3E%3C%2FCssParameter%3E%3C%2FFill%3E%3CStroke%3E%3CCssParameter%20name%3D%22stroke%22%3E%3Cogc%3ALiteral%3E%23FF0000%3C%2Fogc%3ALiteral%3E%3C%2FCssParameter%3E%3C%2FStroke%3E%3C%2FPolygonSymbolizer%3E%3C%2FRule%3E%3C%2FFeatureTypeStyle%3E%3C%2FUserStyle%3E%3C%2FUserLayer%3E%3C%2FStyledLayerDescriptor%3E";
      MockHttpServletResponse response = getAsServletResponse(request);
     
      assertEquals("image/png", response.getContentType());
     
      // this is the test; an exception will be thrown if no image was rendered
        BufferedImage image = ImageIO.read(
                getBinaryInputStream(
                    getAsServletResponse(request)
View Full Code Here

            "</sld:StyledLayerDescriptor>";
    }
    public void testPostAsSLD() throws Exception {
        String xml = newSLDXML();

        MockHttpServletResponse response =
            postAsServletResponse( "/rest/styles", xml, StyleResource.MEDIATYPE_SLD.toString());
        assertEquals( 201, response.getStatusCode() );
        assertNotNull( response.getHeader( "Location") );
        assertTrue( response.getHeader("Location").endsWith( "/styles/foo" ) );
       
        assertNotNull( catalog.getStyleByName( "foo" ) );
    }
View Full Code Here

    }
   
    public void testPostAsSLDWithName() throws Exception {
        String xml = newSLDXML();

        MockHttpServletResponse response =
            postAsServletResponse( "/rest/styles?name=bar", xml, StyleResource.MEDIATYPE_SLD.toString());
        assertEquals( 201, response.getStatusCode() );
        assertNotNull( response.getHeader( "Location") );
        assertTrue( response.getHeader("Location").endsWith( "/styles/bar" ) );
       
        assertNotNull( catalog.getStyleByName( "bar" ) );
    }
View Full Code Here

            "<style>" +
              "<name>Ponds</name>" +
              "<filename>Forests.sld</filename>" +
            "</style>";
       
        MockHttpServletResponse response =
            putAsServletResponse("/rest/styles/Ponds", xml.getBytes(), "text/xml");
        assertEquals( 200, response.getStatusCode() );
       
        style = catalog.getStyleByName( "Ponds");
        assertEquals( "Forests.sld", style.getFilename() );
    }
View Full Code Here

    }
   
    public void testPutAsSLD() throws Exception {
        String xml = newSLDXML();

        MockHttpServletResponse response =
            putAsServletResponse( "/rest/styles/Ponds", xml, StyleResource.MEDIATYPE_SLD.toString());
        assertEquals( 200, response.getStatusCode() );
       
        Style s = catalog.getStyleByName( "Ponds" ).getStyle();
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        new SLDFormat().write(s, out);
       
View Full Code Here

              "<filename>dummy.sld</filename>" +
            "</style>";
        post( "/rest/styles", xml, "text/xml");
        assertNotNull( catalog.getStyleByName( "dummy" ) );
       
        MockHttpServletResponse response =
            deleteAsServletResponse("/rest/styles/dummy");
        assertEquals( 200, response.getStatusCode() );
       
        assertNull( catalog.getStyleByName( "dummy" ) );
    }
View Full Code Here

    }
   
    public void testDeleteWithLayerReference() throws Exception {
        assertNotNull( catalog.getStyleByName( "Ponds" ) );
       
        MockHttpServletResponse response =
            deleteAsServletResponse("/rest/styles/Ponds");
        assertEquals( 403, response.getStatusCode() );
        
        assertNotNull( catalog.getStyleByName( "Ponds" ) );
    }
View Full Code Here

    }

    public void testDeleteWithoutPurge() throws Exception {
        String xml = newSLDXML();

        MockHttpServletResponse response =
            postAsServletResponse( "/rest/styles", xml, StyleResource.MEDIATYPE_SLD.toString());
        assertNotNull( catalog.getStyleByName( "foo" ) );
       
        //ensure the style not deleted on disk
        assertTrue(new File(getDataDirectory().findStyleDir(), "foo.sld").exists());
       
        response = deleteAsServletResponse("/rest/styles/foo");
        assertEquals( 200, response.getStatusCode() );
       
        //ensure the style not deleted on disk
        assertTrue(new File(getDataDirectory().findStyleDir(), "foo.sld").exists());
    }
View Full Code Here

    }
   
    public void testDeleteWithPurge() throws Exception {
        String xml = newSLDXML();

        MockHttpServletResponse response =
            postAsServletResponse( "/rest/styles", xml, StyleResource.MEDIATYPE_SLD.toString());
        assertNotNull( catalog.getStyleByName( "foo" ) );
       
        //ensure the style not deleted on disk
        assertTrue(new File(getDataDirectory().findStyleDir(), "foo.sld").exists());
       
        response = deleteAsServletResponse("/rest/styles/foo?purge=true");
        assertEquals( 200, response.getStatusCode() );
       
        //ensure the style not deleted on disk
        assertFalse(new File(getDataDirectory().findStyleDir(), "foo.sld").exists());
    }
View Full Code Here

TOP

Related Classes of com.mockrunner.mock.web.MockHttpServletResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.