List of usage examples for org.apache.commons.httpclient URI URI
public URI(URI base, URI relative) throws URIException
From source file:org.apache.wink.itest.EncodingParamTest.java
public void testSingleEncodedQueryParamMethod() { try {/* www .j a va 2 s.c om*/ GetMethod httpMethod = new GetMethod(); httpMethod.setURI( new URI(BASE_URI_ENCODE + "/method/city;appversion=1.1%2B?location=Austin%2B%20Texas", true)); httpclient = new HttpClient(); try { int result = httpclient.executeMethod(httpMethod); System.out.println("Response status code: " + result); System.out.println("Response body: "); String responseBody = httpMethod.getResponseBodyAsString(); System.out.println(responseBody); assertEquals(200, result); System.out.println(responseBody); assertEquals("getShopInCityMethod:location=Austin%2B%20Texas;appversion=1.1%2B", responseBody); } catch (IOException ioe) { ioe.printStackTrace(); fail(ioe.getMessage()); } finally { httpMethod.releaseConnection(); } } catch (URIException e) { e.printStackTrace(); fail(e.getMessage()); } }
From source file:org.apache.wink.itest.EncodingParamTest.java
public void testSingleDecodedPathParm() { try {/* w w w .j a va 2 s . c o m*/ GetMethod httpMethod = new GetMethod(); httpMethod.setURI( new URI(BASE_URI_DECODE + "/country/United%20States%20of%20America;appversion=1.1%2C2", true)); httpclient = new HttpClient(); try { int result = httpclient.executeMethod(httpMethod); System.out.println("Response status code: " + result); System.out.println("Response body: "); String responseBody = httpMethod.getResponseBodyAsString(); System.out.println(responseBody); assertEquals(200, result); assertEquals("getShopInCountryDecoded:location=United States of America;appversion=1.1,2", responseBody); } catch (IOException ioe) { ioe.printStackTrace(); fail(ioe.getMessage()); } finally { httpMethod.releaseConnection(); } } catch (URIException e) { e.printStackTrace(); fail(e.getMessage()); } }
From source file:org.apache.wink.itest.EncodingParamTest.java
public void testSingleEncodedPathParam() { try {//from ww w. ja v a2 s .co m GetMethod httpMethod = new GetMethod(); httpMethod.setURI( new URI(BASE_URI_ENCODE + "/country/United%20States%20of%20America;appversion=1.1%2B", true)); httpclient = new HttpClient(); try { int result = httpclient.executeMethod(httpMethod); System.out.println("Response status code: " + result); System.out.println("Response body: "); String responseBody = httpMethod.getResponseBodyAsString(); System.out.println(responseBody); assertEquals(200, result); assertEquals("getShopInCountry:location=United%20States%20of%20America;appversion=1.1%2B", responseBody); } catch (IOException ioe) { ioe.printStackTrace(); fail(ioe.getMessage()); } finally { httpMethod.releaseConnection(); } } catch (URIException e) { e.printStackTrace(); fail(e.getMessage()); } }
From source file:org.apache.wink.itest.EncodingParamTest.java
public void testSingleEncodedPathParamMethod() { try {//ww w . j a v a 2 s . com GetMethod httpMethod = new GetMethod(); httpMethod.setURI(new URI( BASE_URI_ENCODE + "/method/country/United%20States%20of%20America;appversion=1.1%2B", true)); httpclient = new HttpClient(); try { int result = httpclient.executeMethod(httpMethod); System.out.println("Response status code: " + result); System.out.println("Response body: "); String responseBody = httpMethod.getResponseBodyAsString(); System.out.println(responseBody); assertEquals(200, result); assertEquals("getShopInCountryMethod:location=United%20States%20of%20America;appversion=1.1%2B", responseBody); } catch (IOException ioe) { ioe.printStackTrace(); fail(ioe.getMessage()); } finally { httpMethod.releaseConnection(); } } catch (URIException e) { e.printStackTrace(); fail(e.getMessage()); } }
From source file:org.apache.wink.itest.EncodingParamTest.java
public void testSingleDecodedMatrixParam() { try {/* w w w .ja v a 2s . c o m*/ GetMethod httpMethod = new GetMethod(); httpMethod.setURI(new URI(BASE_URI_DECODE + "/street;location=Burnet%20Road;appversion=1.1%2B", true)); httpclient = new HttpClient(); try { int result = httpclient.executeMethod(httpMethod); System.out.println("Response status code: " + result); System.out.println("Response body: "); String responseBody = httpMethod.getResponseBodyAsString(); System.out.println(responseBody); assertEquals(200, result); assertEquals("getShopOnStreetDecoded:location=Burnet Road;appversion=1.1+", responseBody); } catch (IOException ioe) { ioe.printStackTrace(); fail(ioe.getMessage()); } finally { httpMethod.releaseConnection(); } } catch (URIException e) { e.printStackTrace(); fail(e.getMessage()); } }
From source file:org.apache.wink.itest.EncodingParamTest.java
public void testSingleEncodedMatrixParam() { try {//from w w w . j a va 2s . co m GetMethod httpMethod = new GetMethod(); httpMethod.setURI(new URI(BASE_URI_ENCODE + "/street;location=Burnet%20Road;appversion=1.1%2B", true)); httpclient = new HttpClient(); try { int result = httpclient.executeMethod(httpMethod); System.out.println("Response status code: " + result); System.out.println("Response body: "); String responseBody = httpMethod.getResponseBodyAsString(); System.out.println(responseBody); assertEquals(200, result); assertEquals("getShopOnStreet:location=Burnet%20Road;appversion=1.1%2B", responseBody); } catch (IOException ioe) { ioe.printStackTrace(); fail(ioe.getMessage()); } finally { httpMethod.releaseConnection(); } } catch (URIException e) { e.printStackTrace(); fail(e.getMessage()); } }
From source file:org.apache.wink.itest.EncodingParamTest.java
public void testSingleEncodedMatrixParamMethod() { try {/*from w w w. j a va 2s. c o m*/ GetMethod httpMethod = new GetMethod(); httpMethod.setURI( new URI(BASE_URI_ENCODE + "/method/street;location=Burnet%2B%20Road;appversion=1.1%2B", true)); httpclient = new HttpClient(); try { int result = httpclient.executeMethod(httpMethod); System.out.println("Response status code: " + result); System.out.println("Response body: "); String responseBody = httpMethod.getResponseBodyAsString(); System.out.println(responseBody); assertEquals(200, result); assertEquals("getShopOnStreetMethod:location=Burnet%2B%20Road;appversion=1.1%2B", responseBody); } catch (IOException ioe) { ioe.printStackTrace(); fail(ioe.getMessage()); } finally { httpMethod.releaseConnection(); } } catch (URIException e) { e.printStackTrace(); fail(e.getMessage()); } }
From source file:org.apache.wink.itest.EncodingParamTest.java
public void testSingleDecodedFormParam() throws Exception { try {/*from ww w .jav a 2 s .com*/ PostMethod httpMethod = new PostMethod(); httpMethod.setURI(new URI(BASE_URI_DECODE + "/region;appversion=", true)); // httpMethod.setParameter("location", "The%20Southwest"); httpMethod.setRequestEntity(new StringRequestEntity( "location=%21%20%2A%20%27%20%28%20%29%20%3B%20%3A%20%40%20%26%20%3D%20%2B%20%24%20%2C%20%2F%20%3F%20%25%20%23%20%5B%20%5D", "application/x-www-form-urlencoded", "UTF-8")); httpclient = new HttpClient(); try { int result = httpclient.executeMethod(httpMethod); System.out.println("Response status code: " + result); System.out.println("Response body: "); String responseBody = httpMethod.getResponseBodyAsString(); System.out.println(responseBody); assertEquals(200, result); assertEquals("getShopInRegionDecoded:location=! * ' ( ) ; : @ & = + $ , / ? % # [ ];appversion=", responseBody); } catch (IOException ioe) { ioe.printStackTrace(); fail(ioe.getMessage()); } finally { httpMethod.releaseConnection(); } } catch (URIException e) { e.printStackTrace(); fail(e.getMessage()); } }
From source file:org.apache.wink.itest.EncodingParamTest.java
public void testSingleEncodedFormParam() throws Exception { try {//from w w w.j a va 2 s . c o m PostMethod httpMethod = new PostMethod(); httpMethod.setURI(new URI(BASE_URI_ENCODE + "/region;appversion=1.1%2B", true)); // httpMethod.setParameter("location", "The%20Southwest"); httpMethod.setRequestEntity(new StringRequestEntity("location=The%20Southwest", "application/x-www-form-urlencoded", "UTF-8")); httpclient = new HttpClient(); try { int result = httpclient.executeMethod(httpMethod); System.out.println("Response status code: " + result); System.out.println("Response body: "); String responseBody = httpMethod.getResponseBodyAsString(); System.out.println(responseBody); assertEquals(200, result); assertEquals("getShopInRegion:location=The%20Southwest;appversion=1.1%2B", responseBody); } catch (IOException ioe) { ioe.printStackTrace(); fail(ioe.getMessage()); } finally { httpMethod.releaseConnection(); } } catch (URIException e) { e.printStackTrace(); fail(e.getMessage()); } }
From source file:org.apache.wink.itest.EncodingParamTest.java
public void testSingleEncodedFormParamMethod() throws Exception { try {/*from w w w . j a va2 s .c o m*/ PostMethod httpMethod = new PostMethod(); httpMethod.setURI(new URI(BASE_URI_ENCODE + "/method/region;appversion=1.1%2B", true)); httpMethod.setRequestEntity(new StringRequestEntity("location=The%20Southwest", "application/x-www-form-urlencoded", "UTF-8")); httpclient = new HttpClient(); try { int result = httpclient.executeMethod(httpMethod); System.out.println("Response status code: " + result); System.out.println("Response body: "); String responseBody = httpMethod.getResponseBodyAsString(); System.out.println(responseBody); assertEquals(200, result); assertEquals("getShopInRegionMethod:location=The%20Southwest;appversion=1.1%2B", responseBody); } catch (IOException ioe) { ioe.printStackTrace(); fail(ioe.getMessage()); } finally { httpMethod.releaseConnection(); } } catch (URIException e) { e.printStackTrace(); fail(e.getMessage()); } }