Package com.meterware.servletunit

Examples of com.meterware.servletunit.ServletUnitClient.newInvocation()


   
     
        ServletRunner sr = new ServletRunner();
    ServletUnitClient sc = sr.newClient();
    WebRequest request   = new PostMethodWebRequest( "https://test.meterware.com/myServlet" );
    InvocationContext ic = sc.newInvocation( request );
   
        OAuth2ProblemException problem = new OAuth2ProblemException(OAuth2.ErrorCode.UNSUPPORTED_RESPONSE_TYPE);
        // if you do not specify status code 200 here response does not inluce anything
        problem.setParameter(OAuth2ProblemException.HTTP_STATUS_CODE,new Integer(200));
        HttpServletResponse hsr = ic.getResponse();
View Full Code Here


   
     
        ServletRunner sr = new ServletRunner();
    ServletUnitClient sc = sr.newClient();
    WebRequest request   = new PostMethodWebRequest( "https://test.meterware.com/myServlet" );
    InvocationContext ic = sc.newInvocation( request );
   
        OAuth2ProblemException problem = new OAuth2ProblemException(OAuth2.ErrorCode.UNSUPPORTED_RESPONSE_TYPE);
        problem.setParameter(OAuth2ProblemException.HTTP_STATUS_CODE,new Integer(302));
        //problem.getParameters().put(OAuth2.REDIRECT_URI,"https://client.example.com/cb");
        problem.setParameter(OAuth2.REDIRECT_URI,"https://client.example.com/cb");
View Full Code Here

    {

        ServletRunner sr = new ServletRunner();
        ServletUnitClient sc = sr.newClient();
        WebRequest request   = new PostMethodWebRequest( "https://test.meterware.com/myServlet" );
        InvocationContext ic = sc.newInvocation( request );

        OAuth2ProblemException problem = new OAuth2ProblemException(OAuth2.ErrorCode.UNSUPPORTED_RESPONSE_TYPE);
        problem.setParameter(OAuth2ProblemException.HTTP_STATUS_CODE,new Integer(302));
        //problem.getParameters().put(OAuth2.REDIRECT_URI,"https://client.example.com/cb");
        problem.setParameter(OAuth2.REDIRECT_URI,"https://client.example.com/cb");
View Full Code Here

     
      for (String[] testCase : OAUTH_PARAMETERS) {
        ServletRunner sr = new ServletRunner();
        ServletUnitClient sc = sr.newClient();
        WebRequest request   = new PostMethodWebRequest( "https://test.meterware.com/myServlet" );      
        InvocationContext ic = sc.newInvocation( request );     
      
            String label = testCase[0];
            //String realm = testCase[1];
            List<OAuth2.Parameter> parameters = decodeForm(testCase[1]);
            OAuth2Servlet.sendFormInJson(ic.getResponse(),parameters);
View Full Code Here

        request.setParameter( "grant_type", testCase[2] );
        request.setParameter( "client_id", testCase[3] );
        //request.setParameter( "client_secret", testCase[5] );
        request.setParameter( "code", testCase[4] );
        request.setParameter( "redirect_uri", testCase[5] );       
        InvocationContext ic = sc.newInvocation( request );
        OAuth2Message message = OAuth2Servlet.getMessage(ic.getRequest(),"https://test.meterware.com/myServlet");
       
            String label = testCase[0];
            //String realm = testCase[1];
            String expectedGrantType = testCase[2];
View Full Code Here

   
      ServletRunner sr = new ServletRunner();
      ServletUnitClient sc = sr.newClient();
        WebRequest request   = new GetMethodWebRequest( "http://test.meterware.com/myServlet" );
        request.setParameter( "color", "red" );
        InvocationContext ic = sc.newInvocation( request );
        String url = OAuth2Servlet.getRequestURL(ic.getRequest());
        assertEquals("URL check", "http://test.meterware.com/myServlet?color=red", url);       
    }
   
   
View Full Code Here

            factory.setRepositorySession( session );

            ServletRunner sr = new ServletRunner();
            ServletUnitClient sc = sr.newClient();

            action.setServletRequest( sc.newInvocation( "http://localhost/admin/repositories.action" ).getRequest() );

            action.prepare();
            String result = action.execute();
            assertEquals( Action.SUCCESS, result );
View Full Code Here

        archivaConfiguration.getConfiguration();
        archivaConfigurationControl.setReturnValue( configuration, 6 );
        archivaConfigurationControl.replay();

        action.setServletRequest( sc.newInvocation( "http://localhost/admin/repositoryGroups.action" ).getRequest() );
        action.prepare();
        String result = action.execute();
        assertEquals( Action.SUCCESS, result );

        assertEquals( "http://localhost:0/repository", action.getBaseUrl() );
View Full Code Here

        throws Exception
    {
        ServletRunner sr = new ServletRunner();
        ServletUnitClient sc = sr.newClient();

        action.setServletRequest( sc.newInvocation( "http://localhost/admin/repositories.action" ).getRequest() );
        action.prepare();
        String result = action.execute();
        assertEquals( Action.SUCCESS, result );

        // TODO: for some reason servletunit is not populating the port of the servlet request
View Full Code Here

        action.setRepositoryId( INTERNAL );
        ServletRunner sr = new ServletRunner();
        ServletUnitClient sc = sr.newClient();

        action.setServletRequest( sc.newInvocation( URL ).getRequest() );
        prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );

        String result = action.execute();
        assertSuccessResult( result );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.