Examples of HttpMethodBase


Examples of org.apache.commons.httpclient.HttpMethodBase

  public void Insert_Del_Stu_Test() throws HttpException, Exception
  {
    String response = null;
    HttpClient nclient = new HttpClient();
    String url = root+"/StudentAdd?sid=2&sname=student2&country=country2&city=city2&street=street2&telephone=222222&age=22&score=0";
    HttpMethodBase httpMethod;
    httpMethod = new PostMethod(url);
    int status = nclient.executeMethod(httpMethod);
//    System.out.println("status:" + status);
    Assert.assertEquals(status, 200);
    httpMethod.releaseConnection();
   
    url = root +"/viewAllStudents";
    HttpMethodBase httpMethod2;
    httpMethod2 = new PostMethod(url);
    status = nclient.executeMethod(httpMethod2);
    Assert.assertEquals(status, 200);
    if(status==200)
    {
      response = new String(httpMethod2.getResponseBodyAsString().getBytes("8859_1"));
    }
    Assert.assertTrue(response.contains("student2"));
    httpMethod2.releaseConnection();
 
 
    url = root +"/StudentDelete?sid=2";
    httpMethod = new PostMethod(url);
    status = nclient.executeMethod(httpMethod);
    Assert.assertEquals(status, 200);
    httpMethod.releaseConnection();
   
    url = root +"/viewAllStudents";
    httpMethod2 = new PostMethod(url);
    status = nclient.executeMethod(httpMethod2);
    Assert.assertEquals(status, 200);
    if(status==200)
    {
      response = new String(httpMethod2.getResponseBodyAsString().getBytes("8859_1"));
    }
    Assert.assertTrue(!response.contains("student2"));
    httpMethod2.releaseConnection();
  }
View Full Code Here

Examples of org.apache.commons.httpclient.HttpMethodBase

    String contextroot = System.getProperty("webAppName");
    String root = "http://localhost:8080/"+contextroot;
    int status = 0;
    HttpClient nclient = new HttpClient();
    String url = root+"/CalculatorServlet";
    HttpMethodBase httpMethod;
    httpMethod = new PostMethod(url);
    status = nclient.executeMethod(httpMethod)
    Assert.assertEquals(status, 200);
    String response = null;
    if(status==200)
    {
      response = new String(httpMethod.getResponseBodyAsString().getBytes("8859_1"));
    }
    Assert.assertTrue(response.contains("Hello! Reexport in Require-bundle attribute is effective since this INFO displays."));
    Assert.assertTrue(response.contains("result of ADD operation [\"10.0 + 8.0 = ?\"] is: 18"));
    Assert.assertTrue(response.contains("result of SUB operation [\"10.0 - 8.0 = ?\"] is: 2"));   
    httpMethod.releaseConnection();
  }
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.