Package com.meterware.httpunit

Examples of com.meterware.httpunit.WebResponse


    }

    public @Test void testCookiesTool() throws Exception {
        WebConversation conv = new WebConversation();
        WebRequest req = new GetMethodWebRequest(ROOT_URL+"cookies.vm");
        WebResponse resp = conv.getResponse(req);

        /* check all */
        checkTextStart(resp,"all","[Ljavax.servlet.http.Cookie;");

        /* check get('JSESSIONID') */
        resp = submitWithParam(resp,"get","get","JSESSIONID");
        checkTextStart(resp,"get","javax.servlet.http.Cookie");

        /* check add('foo','bar') */
        WebForm form = resp.getFormWithName("add2");
        form.setParameter("add1","foo");
        form.setParameter("add2","bar");
        resp = form.submit();
        resp = submitWithParam(resp,"get","get","foo");
        checkTextStart(resp,"get","javax.servlet.http.Cookie");
View Full Code Here


    }

    public @Test void testLinkTool() throws Exception {
        WebConversation conv = new WebConversation();
        WebRequest req = new GetMethodWebRequest(ROOT_URL+"link.vm");
        WebResponse resp = conv.getResponse(req);

        /* check anchor(foo) and anchor */
        resp = submitWithParam(resp,"anchor","anchor","foo");
        checkText(resp,"anchor","#foo");
        checkText(resp,"altanchor","#foo");
View Full Code Here

    }

    public @Test void testParameterParserTool() throws Exception {
        WebConversation conv = new WebConversation();
        WebRequest req = new GetMethodWebRequest(ROOT_URL+"params.vm?foo=bar&b=false&n=55&d=1.2");
        WebResponse resp = conv.getResponse(req);

        /* check exists(foo) */
        resp = submitWithParam(resp,"exists","exists","foo");
        checkText(resp,"exists","true");

        /* check get(foo) */
        resp = submitWithParam(resp,"get","get","foo");
        checkText(resp,"get","bar");

        /* check getString(foo) */
        resp = submitWithParam(resp,"getString","getString","foo");
        checkText(resp,"getString","bar");

        /* check getBoolean(b) */
        resp = submitWithParam(resp,"getBoolean","getBoolean","b");
        checkText(resp,"getBoolean","false");

        /* check getNumber(n) */
        resp = submitWithParam(resp,"getNumber","getNumber","n");
        checkText(resp,"getNumber","55");

        /* check getDouble(d) */
        resp = submitWithParam(resp,"getDouble","getDouble","d");
        checkText(resp,"getDouble","1.2");

        /* check getInteger(n) */
        resp = submitWithParam(resp,"getInteger","getInteger","n");
        checkText(resp,"getInteger","55");

        /* check getStrings(foo) */
        resp = submitWithParam(resp,"getStrings","getStrings","foo");
        checkTextStart(resp,"getStrings","[Ljava.lang.String;@");

        /* check getBooleans(b) */
        resp = submitWithParam(resp,"getBooleans","getBooleans","b");
        checkTextStart(resp,"getBooleans","[Ljava.lang.Boolean;@");

        /* check getNumbers(n) */
        resp = submitWithParam(resp,"getNumbers","getNumbers","n");
        checkTextStart(resp,"getNumbers","[Ljava.lang.Number;@");

        /* check getDoubles(d) */
        resp = submitWithParam(resp,"getDoubles","getDoubles","d");
        checkTextStart(resp,"getDoubles","[D@");

        /* check getInts(n) */
        resp = submitWithParam(resp,"getInts","getInts","n");
        checkTextStart(resp,"getInts","[I@");

        /* check getString(bar,foo) */
        WebForm form = resp.getFormWithName("getString2");
        form.setParameter("getString1","'bar'");
        form.setParameter("getString2","'foo'");
        resp = form.submit();
        checkText(resp,"getString2","foo");

View Full Code Here

        SlingConversation con = app.createConversation();
       
        HashMap<String, String> post = new HashMap<String, String>();
        post.put("path", source.getName());
        post.put("cmd", "Activate");
        WebResponse response = con.request("/bin/replicate.json",post);
        if (response.getResponseCode() == 200) {
          System.out.println( response.getText() );
        }
      } catch (Throwable e) {
        monitor.log().i(e);
      }
      monitor.nextFinished();
View Full Code Here

     return getResponse( req );
  }

  public IConfig requestConfig(CaoElement element, String suffix) throws Exception {
     WebRequest req = new GetMethodWebRequest( app.getUri(element) + suffix );
     WebResponse res = getResponse( req );
     if ( res.getResponseCode() != 200 )
       return null;
     String content = res.getText();
     IConfig config = MConfigFactory.getInstance().toConfig(content);
     return config;
  }
View Full Code Here

     WebRequest req = new PostMethodWebRequest( app.getUri(element) + suffix );
     if (post != null) {
       for (Map.Entry<String, String> entry : post.entrySet())
         req.setParameter(entry.getKey(), entry.getValue());
     }
     WebResponse res = getResponse( req );
     if ( res.getResponseCode() != 200 )
       return null;
     String content = res.getText();
     IConfig config = MConfigFactory.getInstance().toConfig(content);
     return config;
  }
View Full Code Here

     if (post != null) {
       for (Map.Entry<String, String> entry : post.entrySet())
         req.setParameter(entry.getKey(), entry.getValue());
     }

     WebResponse res = getResponse( req );
     if ( res.getResponseCode() != 200 )
       return null;
     String content = res.getText();
     IConfig config = MConfigFactory.getInstance().toConfig(content);
     return config;
  }
View Full Code Here

     return config;
  }
 
  public IConfig requestConfig(String path) throws Exception {
     WebRequest req = new GetMethodWebRequest( app.getUri() + path );
     WebResponse res = getResponse( req );
     if ( res.getResponseCode() != 200 )
       return null;
     String content = res.getText();
     IConfig config = MConfigFactory.getInstance().toConfig(content);
     return config;
  }
View Full Code Here

        // 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();
        OAuth2Servlet.handleException(ic.getRequest(),hsr,problem,null,true,false);
       
        WebResponse response   = ic.getServletResponse();
   
        assertEquals("ErrorJSONResponse Body chcek", "{"+toStringWithQuotation("error")+":"+toStringWithQuotation("unsupported_response_type")+"}", response.getText());
        assertEquals("ErrorJSONResponse ContentType check", "application/json", response.getContentType());

           
       
    }
View Full Code Here

        problem.setParameter(OAuth2.REDIRECT_URI,"https://client.example.com/cb");
        HttpServletResponse hsr = ic.getResponse();
        OAuth2Servlet.handleException(ic.getRequest(),hsr,problem,null,false,false);
       
     
        WebResponse response   = ic.getServletResponse();
           
        assertEquals("ErroeRedirectResponse Location chceck", "https://client.example.com/cb?error=unsupported_response_type", response.getHeaderField(OAuth2ProblemException.HTTP_LOCATION));  
        assertEquals("ErrorRedirectResponse Code check", "302", new Integer(response.getResponseCode()).toString());
           
       
    }
View Full Code Here

TOP

Related Classes of com.meterware.httpunit.WebResponse

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.