Package org.springframework.mock.web

Examples of org.springframework.mock.web.MockHttpServletResponse$ResponsePrintWriter


    @Before
    public void setUp() throws Exception {
        request = new MockHttpServletRequest("GET", "http://localhost/myService");
        request.setQueryString("wsdl");
        response = new MockHttpServletResponse();
        servlet = new WsServletDelegate();
        service = mock(Service.class);
        mapper = mock(ServiceMapper.class);
        when(mapper.getServiceInstance(request)).thenReturn(service);
        doNothing().when(service).releaseInstance();
View Full Code Here


            {
                return "wsdl";
            }
        };

        MockHttpServletResponse response = new MockHttpServletResponse();
        exporter.handleRequest(request, response);
        InputSource source = new InputSource(new ByteArrayInputStream(response.getContentAsByteArray()));
        WSDLFactory factory = WSDLFactory.newInstance();
        WSDLReader reader = factory.newWSDLReader();
        reader.readWSDL("", source);
    }
View Full Code Here

            public String getQueryString()
            {
                return "wsdl";
            }
        };
        MockHttpServletResponse response = new MockHttpServletResponse();
        exporter.handleRequest(request, response);
        InputSource source = new InputSource(new ByteArrayInputStream(response.getContentAsByteArray()));
        WSDLFactory factory = WSDLFactory.newInstance();
        WSDLReader reader = factory.newWSDLReader();
        Definition definition = reader.readWSDL("", source);
        Service service = definition.getService(new QName(namespace, name));
        assertNotNull(service);
View Full Code Here

            throws Exception
    {
        exporter.afterPropertiesSet();

        HttpServletRequest request = getRequest();
        HttpServletResponse response = new MockHttpServletResponse();
        exporter.handleRequest(request, response);
    }
View Full Code Here

        uri = crypto.encrypt(doc.getUri());
    }

    @Test
    public void serve() throws Exception {
        MockHttpServletResponse response = new MockHttpServletResponse();
        response.setOutputStreamAccessAllowed(true);
        controller.serve(crypto.encrypt("no"), null, null, response);
        assertEquals("File could not be found", MockHttpServletResponse.SC_NOT_FOUND, response.getStatus());
        controller.serve(uri, null, null, response);
        assertTrue("Content streamed" ,  response.getContentAsByteArray().length > 1000);
    }
View Full Code Here

  }

  public void testNormalOperation() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/demo/any-path");
    request.addParameter("ticket", "ST-0-ER94xMJmn6pha35CQRoZ");
    Authentication result = filter.getPreauthAuthentication(request, new MockHttpServletResponse());
    assertTrue(result != null);
  }
View Full Code Here

      public Authentication authenticate(Authentication a) {
        throw new BadCredentialsException("Rejected");
      }
    });
    filter.setContinueOnFail(false);
    filter.doFilter(request, new MockHttpServletResponse(), mock(FilterChain.class));
  }
View Full Code Here

  public void testAuthenticateProxyUrl() throws IOException, ServletException {
    config.setProxyReceptor("/proxy/receptor");
    filter.setConfig(config);
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    request.setRequestURI("/demo/proxy/receptor");
    FilterChain chain = mock(FilterChain.class);
    filter.setProxyGrantingTicketStorage(mock(ProxyGrantingTicketStorage.class));
    filter.doFilterHttp(request, response, chain);
    verifyZeroInteractions(chain);
View Full Code Here

  public void testNormalOperationWithRenewFalse() throws Exception {
    CasConfig config = new CasConfig("https://cas", "https://mycompany.com/bigWebApp");
    config.setRenew(false);
    CasEntryPoint ep = new CasEntryPoint(config);
    MockHttpServletRequest request = new MockHttpServletRequest(null, "/some_path");
    MockHttpServletResponse response = new MockHttpServletResponse();
    ep.afterPropertiesSet();
    ep.commence(request, response, null);
    assertEquals(
        response.getRedirectedUrl(),
        "https://cas/login?service="
            + URLEncoder.encode("https://mycompany.com/bigWebApp/some_path", "UTF-8"));
  }
View Full Code Here

  public void testNormalOperationWithRenewTrue() throws Exception {
    CasConfig config = new CasConfig("https://cas", "https://mycompany.com/bigWebApp");
    config.setRenew(true);
    CasEntryPoint ep = new CasEntryPoint(config);
    MockHttpServletRequest request = new MockHttpServletRequest(null, "/some_path");
    MockHttpServletResponse response = new MockHttpServletResponse();
    ep.afterPropertiesSet();
    ep.commence(request, response, null);
    assertEquals(
        "https://cas/login?service="
            + URLEncoder.encode("https://mycompany.com/bigWebApp/some_path", "UTF-8")
            + "&renew=true", response.getRedirectedUrl());
  }
View Full Code Here

TOP

Related Classes of org.springframework.mock.web.MockHttpServletResponse$ResponsePrintWriter

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.