List of usage examples for org.apache.commons.httpclient HttpMethodBase releaseConnection
@Override public void releaseConnection()
From source file:org.apache.geronimo.javaee6.jpa20.tests.JPATest.java
/** * Test 1//from w ww .j ava2 s.c o m * Test * Criteria Query feature. * @throws Exception */ @Test public void addCourseTest() throws Exception { String contextroot = System.getProperty("appContext"); root = "http://localhost:8080/" + contextroot; HttpClient nclient = new HttpClient(); String url = root + "/CourseAdd?cid=1&cname=course1&classroom=course1&teacher=course1&assistTeacher=course1"; HttpMethodBase httpMethod; httpMethod = new PostMethod(url); nclient.executeMethod(httpMethod); httpMethod.releaseConnection(); url = root + "/ListQuery?cname=course1"; HttpMethodBase httpMethod2; httpMethod2 = new PostMethod(url); int status = nclient.executeMethod(httpMethod2); Assert.assertEquals(status, 200); // System.out.println("status:" + status); String response = null; if (status == 200) { response = new String(httpMethod2.getResponseBodyAsString().getBytes("8859_1")); } Assert.assertTrue(response.contains("course name is :course1 from listQuery.")); httpMethod2.releaseConnection(); }
From source file:org.apache.geronimo.javaee6.jpa20.tests.JPATest.java
/** * Test 2/* w ww .j av a 2 s .c o m*/ * Test * @ElementCollection annotation * */ @Test(dependsOnMethods = { "addCourseTest" }) public void addCommentTest() throws HttpException, Exception { HttpClient nclient = new HttpClient(); String url = root + "/CommentAdd?cid=1"; HttpMethodBase httpMethod; httpMethod = new PostMethod(url); nclient.executeMethod(httpMethod); httpMethod.releaseConnection(); url = root + "/viewAllComments?cid=1"; HttpMethodBase httpMethod2; httpMethod2 = new PostMethod(url); int status = nclient.executeMethod(httpMethod2); System.out.println("status:" + status); String response = null; if (status == 200) { response = new String(httpMethod2.getResponseBodyAsString().getBytes("8859_1")); } Assert.assertTrue(response.contains("Comment:comment0 from viewAllComments")); httpMethod2.releaseConnection(); }
From source file:org.apache.geronimo.javaee6.jpa20.tests.JPATest.java
/** * Test 3/* w w w. j av a 2 s . c om*/ * Test * @Embedded annotation * @Embeddable annotation * @throws Exception * @throws HttpException */ @Test(dependsOnMethods = { "addCourseTest" }) public void AddStudentTest() throws HttpException, Exception { HttpClient nclient = new HttpClient(); String url = root + "/StudentAdd?sid=1&sname=s1&country=country1&city=city1&street=street1&telephone=111111&age=11&score=0"; HttpMethodBase httpMethod; httpMethod = new PostMethod(url); nclient.executeMethod(httpMethod); httpMethod.releaseConnection(); url = root + "/viewStudents"; HttpMethodBase httpMethod2; httpMethod2 = new PostMethod(url); nclient.executeMethod(httpMethod2); int status = nclient.executeMethod(httpMethod2); Assert.assertEquals(status, 200); // System.out.println("status:" + status); String response = null; if (status == 200) { response = new String(httpMethod2.getResponseBodyAsString().getBytes("8859_1")); } Assert.assertTrue(response.contains("Country:country1")); Assert.assertTrue(response.contains("City:city1")); Assert.assertTrue(response.contains("Street:street1")); httpMethod2.releaseConnection(); }
From source file:org.apache.geronimo.javaee6.jpa20.tests.JPATest.java
/** * Test 4// ww w . j ava2s. c om * Test * Foreign key function--add one ONE-TO-MANY record * @throws HttpException * @throws Exception */ @Test(dependsOnMethods = { "AddStudentTest" }) public void SelectCourseTest() throws HttpException, Exception { HttpClient nclient = new HttpClient(); String url = root + "/viewSelect_CourseRelation?sid=1"; HttpMethodBase httpMethod; httpMethod = new PostMethod(url); int status = nclient.executeMethod(httpMethod); // System.out.println("status:" + status); String response = null; Assert.assertEquals(status, 200); if (status == 200) { response = new String(httpMethod.getResponseBodyAsString().getBytes("8859_1")); } Assert.assertTrue(response.contains("Click Here to Select course1 from selectCourse")); httpMethod.releaseConnection(); url = root + "/CourseSelect?cid=1&sid=1"; httpMethod = new PostMethod(url); status = nclient.executeMethod(httpMethod); Assert.assertEquals(status, 200); // System.out.println("status:" + status); response = null; if (status == 200) { response = new String(httpMethod.getResponseBodyAsString().getBytes("8859_1")); } Assert.assertTrue(response.contains("Click Here to Unselect course1 from selectCourse")); httpMethod.releaseConnection(); }
From source file:org.apache.geronimo.javaee6.jpa20.tests.JPATest.java
/** * Test 5//w w w.j av a 2s . c o m * Test * Foreign key function--delete one ONE-TO-MANY record * @throws HttpException * @throws Exception */ @Test(dependsOnMethods = { "SelectCourseTest" }) public void UnselectCourseTest() throws HttpException, Exception { String result = null; String response = null; HttpClient nclient = new HttpClient(); String url = root + "/CourseUnselect?cid=1&sid=1"; HttpMethodBase httpMethod; httpMethod = new PostMethod(url); int status = nclient.executeMethod(httpMethod); // System.out.println("status:" + status); Assert.assertEquals(status, 200); if (status == 200) { response = new String(httpMethod.getResponseBodyAsString().getBytes("8859_1")); } Assert.assertTrue(response.contains("Click Here to Select course1 from selectCourse")); httpMethod.releaseConnection(); }
From source file:org.apache.geronimo.javaee6.jpa20.tests.JPATest.java
/** * Test 6/* w w w. j a v a 2s . c o m*/ * Test * Insert and delete Student Record. * @throws HttpException * @throws Exception */ @Test 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(); }
From source file:org.apache.geronimo.javaee6.jpa20.tests.JPATest.java
/** * Test 7/* w w w. j a va 2s . com*/ * Test * NULLIF in JPQL * @throws HttpException * @throws Exception */ @Test public void NullIf_JPQL_Test() throws HttpException, Exception { String response = null; HttpClient nclient = new HttpClient(); String url = root + "/StudentAdd?sid=3&sname=student3&country=country3&city=city3&street=street3&telephone=333333&age=33&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 + "/nullIfJPQL?sid=3"; 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("Nullif is sucess.")); httpMethod2.releaseConnection(); }
From source file:org.apache.geronimo.testsuite.deployment.test.urlBindingTest.java
@Test public void test() throws Exception { String contextRoot = System.getProperty("appContext"); HttpClient nclient = new HttpClient(); System.out.println("~~~~~~~~~~~~~~~~" + contextRoot); String url = "http://localhost:8080/" + contextRoot + "/testServlet"; HttpMethodBase httpMethod; httpMethod = new PostMethod(url); int status = nclient.executeMethod(httpMethod); Assert.assertEquals(200, status);// w w w. j a v a 2 s .c om String result = null; if (status == 200) { String response = new String(httpMethod.getResponseBodyAsString().getBytes("8859_1")); Assert.assertTrue(response.contains("http://geronimo.apache.org")); } httpMethod.releaseConnection(); }
From source file:org.apache.geronimo.testsuite.requirebundle.resolution.tests.ResolutionOptionalServletTest.java
/** * Test 1/* ww w .ja v a 2s . co m*/ * Test * Require-Bundle: Resolution=optional in OSGi core spec. * @throws Exception */ @Test public void RequireBundleTest() throws Exception { String contextroot = System.getProperty("webAppName"); String root = "http://localhost:8080/" + contextroot; int status = 0; HttpClient nclient = new HttpClient(); String url = root + "/checkResolution"; 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("Succeed to resolve Attr \"resolution=optional\"")); httpMethod.releaseConnection(); }
From source file:org.apache.geronimo.testsuite.requirebundle.tests.RequireBundleCalculatorServletTest.java
/** * Test 1//from w w w . j a v a 2 s .c o m * Test * Require-Bundle in OSGi core spec. * @throws Exception */ @Test public void RequireBundleTest() throws Exception { 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(); }