Example usage for org.apache.commons.httpclient URIException printStackTrace

List of usage examples for org.apache.commons.httpclient URIException printStackTrace

Introduction

In this page you can find the example usage for org.apache.commons.httpclient URIException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Print this HttpException and its stack trace to the standard error stream.

Usage

From source file:org.apache.wink.itest.DefaultValueParamTest.java

/**
 * Test using some default values.//from   w  w w  .  j  a v a  2s  .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 {/*w  w  w  . j av a 2 s .com*/
        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 {/*from   w  w  w  .  ja va 2 s.  c om*/
        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 {//www.j  a  v  a  2s. c  o 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  ww.  jav  a2  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  v a 2s .com*/
        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  va 2s. co  m
        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 {/*from   w w w  .j  a  v  a  2  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 {/*from   ww w .j  ava 2s.  c om*/
        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 {/* ww w. j  a  va  2 s. com*/
        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());
    }
}