List of usage examples for org.apache.commons.httpclient URIException getMessage
public String getMessage()
From source file:org.apache.wink.itest.DefaultValueParamTest.java
/** * Test that if no parameters are passed, the default values are used. *//*from w w w .j a v a 2 s .c o m*/ public void testDefaultValue() { try { GetMethod httpMethod = new GetMethod(); httpMethod.setURI(new URI(BASE_URI, false)); System.out.println(Arrays.asList(httpMethod.getRequestHeaders())); 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( "getRow:" + "offset=" + "0" + ";version=" + "1.0" + ";limit=" + "100" + ";sort=" + "normal", 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.DefaultValueParamTest.java
/** * Test using some default values.// w w w . j a va2 s .co m */ public void testUseSomeDefaultValue() { try { GetMethod httpMethod = new GetMethod(); httpMethod.setURI(new URI(BASE_URI + "?sort=backward&offset=314", false)); System.out.println(Arrays.asList(httpMethod.getRequestHeaders())); 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("getRow:" + "offset=" + "314" + ";version=" + "1.0" + ";limit=" + "100" + ";sort=" + "backward", 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 testSingleDecodedQueryParam() { try {/*from ww w .ja v a 2 s . c o m*/ GetMethod httpMethod = new GetMethod(); // httpMethod.setURI(new URI(BASE_URI_DECODE // + // "/city;appversion=1.1?location=! * ' ( ) ; : @ & = + $ , / ? % # [ ]" // , false)); httpMethod.setURI(new URI(BASE_URI_DECODE + "/city;appversion=1.1?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", 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("getShopInCityDecoded:location=! * ' ( ) ; : @ & = + $ , / ? % # [ ];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 testSingleEncodedQueryParam() { try {// w w w . jav a 2 s.com GetMethod httpMethod = new GetMethod(); httpMethod .setURI(new URI(BASE_URI_ENCODE + "/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); assertEquals("getShopInCity: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 testSingleEncodedQueryParamMethod() { try {/*from w w w. jav a 2s . co m*/ 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 ava 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 w w w .j a va2 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 {/*from www.j av a 2s . 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 {/*www . j ava2 s.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 {//w w w . j a v a2s. com 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()); } }