Example usage for org.apache.http.client ClientProtocolException printStackTrace

List of usage examples for org.apache.http.client ClientProtocolException printStackTrace

Introduction

In this page you can find the example usage for org.apache.http.client ClientProtocolException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.da.img.BoradHipList.java

public static void main(String[] args) {
    BoradHipList cfl = new BoradHipList();
    try {/*from  w w w.jav  a 2s  .  com*/
        String nPage = "1";
        if (args.length > 0) {
            nPage = args[0];
        }
        cfl.executeURL(nPage);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.thed.zapi.cloud.sample.CreateTestWithTestSteps.java

public static void main(String[] args) throws JSONException, URISyntaxException, ParseException, IOException {
    final String createTestUri = API_CREATE_TEST.replace("{SERVER}", jiraBaseURL);
    final String createTestStepUri = API_CREATE_TEST_STEP.replace("{SERVER}", zephyrBaseUrl);

    /**/*from   ww w  .  ja v a  2  s  .co m*/
     * Create Test Parameters, declare Create Test Issue fields Declare more
     * field objects if required
     */

    JSONObject projectObj = new JSONObject();
    projectObj.put("id", projectId); // Project ID where the Test to be
    // Created

    JSONObject issueTypeObj = new JSONObject();
    issueTypeObj.put("id", issueTypeId); // IssueType ID which is Test isse
    // type

    JSONObject assigneeObj = new JSONObject();
    assigneeObj.put("name", userName); // Username of the assignee

    JSONObject reporterObj = new JSONObject();
    reporterObj.put("name", userName); // Username of the Reporter

    String testSummary = "Sample Test case With Steps created through ZAPI Cloud"; // Test
    // Case
    // Summary/Name

    /**
     * Create JSON payload to POST Add more field objects if required
     * 
     * ***DONOT EDIT BELOW ***
     */

    JSONObject fieldsObj = new JSONObject();
    fieldsObj.put("project", projectObj);
    fieldsObj.put("summary", testSummary);
    fieldsObj.put("issuetype", issueTypeObj);
    fieldsObj.put("assignee", assigneeObj);
    fieldsObj.put("reporter", reporterObj);

    JSONObject createTestObj = new JSONObject();
    createTestObj.put("fields", fieldsObj);
    System.out.println(createTestObj.toString());
    byte[] bytesEncoded = Base64.encodeBase64((userName + ":" + password).getBytes());
    String authorizationHeader = "Basic " + new String(bytesEncoded);
    Header header = new BasicHeader(HttpHeaders.AUTHORIZATION, authorizationHeader);

    StringEntity createTestJSON = null;
    try {
        createTestJSON = new StringEntity(createTestObj.toString());
    } catch (UnsupportedEncodingException e1) {
        e1.printStackTrace();
    }

    HttpResponse response = null;
    HttpClient restClient = new DefaultHttpClient();
    try {
        // System.out.println(issueSearchURL);
        HttpPost createTestReq = new HttpPost(createTestUri);
        createTestReq.addHeader(header);
        createTestReq.addHeader("Content-Type", "application/json");
        createTestReq.setEntity(createTestJSON);

        response = restClient.execute(createTestReq);
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    String testId = null;
    int statusCode = response.getStatusLine().getStatusCode();
    // System.out.println(statusCode);
    HttpEntity entity1 = response.getEntity();
    if (statusCode >= 200 && statusCode < 300) {

        String string1 = null;
        try {
            string1 = EntityUtils.toString(entity1);
            System.out.println(string1);
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        JSONObject createTestResp = new JSONObject(string1);
        testId = createTestResp.getString("id");
        System.out.println("testId :" + testId);
    } else {

        try {
            String string = null;
            string = EntityUtils.toString(entity1);
            JSONObject executionResponseObj = new JSONObject(string);
            System.out.println(executionResponseObj.toString());
            throw new ClientProtocolException("Unexpected response status: " + statusCode);

        } catch (ClientProtocolException e) {
            e.printStackTrace();
        }
    }

    /** Create test Steps ***/

    /**
     * Create Steps Replace the step,data,result values as required
     */

    JSONObject testStepJsonObj = new JSONObject();
    testStepJsonObj.put("step", "Sample Test Step");
    testStepJsonObj.put("data", "Sample Test Data");
    testStepJsonObj.put("result", "Sample Expected Result");

    /** DONOT EDIT FROM HERE ***/

    StringEntity createTestStepJSON = null;
    try {
        createTestStepJSON = new StringEntity(testStepJsonObj.toString());
    } catch (UnsupportedEncodingException e1) {
        e1.printStackTrace();
    }
    String finalURL = createTestStepUri + testId + "?projectId=" + projectId;
    URI uri = new URI(finalURL);
    int expirationInSec = 360;
    JwtGenerator jwtGenerator = client.getJwtGenerator();
    String jwt = jwtGenerator.generateJWT("POST", uri, expirationInSec);
    System.out.println(uri.toString());
    System.out.println(jwt);

    HttpResponse responseTestStep = null;

    HttpPost addTestStepReq = new HttpPost(uri);
    addTestStepReq.addHeader("Content-Type", "application/json");
    addTestStepReq.addHeader("Authorization", jwt);
    addTestStepReq.addHeader("zapiAccessKey", accessKey);
    addTestStepReq.setEntity(createTestStepJSON);

    try {
        responseTestStep = restClient.execute(addTestStepReq);
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    int testStepStatusCode = responseTestStep.getStatusLine().getStatusCode();
    System.out.println(testStepStatusCode);
    System.out.println(response.toString());

    if (statusCode >= 200 && statusCode < 300) {
        HttpEntity entity = responseTestStep.getEntity();
        String string = null;
        String stepId = null;
        try {
            string = EntityUtils.toString(entity);
            JSONObject testStepObj = new JSONObject(string);
            stepId = testStepObj.getString("id");
            System.out.println("stepId :" + stepId);
            System.out.println(testStepObj.toString());
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    } else {
        try {
            throw new ClientProtocolException("Unexpected response status: " + statusCode);
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        }
    }

}

From source file:com.da.img.SoStroyInfoList.java

/**
 * http://story.soraven.info/honor/honor_list_rec.php
 * @param args/*from  w  ww.  j  ava  2 s.  co m*/
 */
public static void main(String[] args) {
    SoStroyInfoList cfl = new SoStroyInfoList();
    try {
        //   BoardAllList 1 174, 354, c:/temp
        // ba 1 174 354 c:\tmp

        String nPage = "1";
        //String p_author_id = "queen201"; jangma;durguf;kentia;nadoohagop
        String p_author_id = "bagpester";

        String p_gnum = ""; // ga
        String p_host_url = ""; // ga
        if (args.length > 0) {
            nPage = args[0];
        }
        if (args.length > 1) {
            p_author_id = args[1];
        }
        if (args.length > 2) {
            STORY_DIR = args[2];
        }

        if (args.length > 3) {
            p_host_url = args[3];
            SO_URL = p_host_url;
            host_url = "http://www." + SO_URL;
            photo_url = "http://photo." + SO_URL + "/album/theme/";
            story_url = "http://story." + SO_URL + "/honor/";
        }
        cfl.executeURL(nPage, p_author_id, p_gnum);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.da.img.SoStroyAllList0405.java

public static void main(String[] args) {
    SoStroyAllList0405 cfl = new SoStroyAllList0405();
    try {/*from www .j a  v  a2 s  .c  om*/
        //   BoardAllList 1 174, 354, c:/temp
        // ba 1 174 354 c:\tmp

        String nPage = "1";
        String p_author_id = "queen201";
        String p_gnum = ""; // ga
        String p_host_url = ""; // ga
        if (args.length > 0) {
            nPage = args[0];
        }
        if (args.length > 1) {
            p_author_id = args[1];
        }
        if (args.length > 2) {
            STORY_DIR = args[2];
        }

        if (args.length > 3) {
            p_host_url = args[3];
            SO_URL = p_host_url;
            host_url = "http://www." + SO_URL;
            photo_url = "http://photo." + SO_URL + "/album/theme/";
            story_url = "http://story." + SO_URL + "/honor/";
        }
        cfl.executeURL(nPage, p_author_id, p_gnum);
        //cfl.executeAuthorList(nPage, p_author_id, p_gnum);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.da.img.SoStroyAllList.java

public static void main(String[] args) {
    SoStroyAllList cfl = new SoStroyAllList();
    try {//from w w  w  .jav  a2  s  .co  m
        //   BoardAllList 1 174, 354, c:/temp
        // ba 1 174 354 c:\tmp

        String nPage = "1";
        String p_author_id = "queen201";
        String p_gnum = ""; // ga
        String p_host_url = ""; // ga
        if (args.length > 0) {
            nPage = args[0];
        }
        if (args.length > 1) {
            p_author_id = args[1];
        }
        if (args.length > 2) {
            STORY_DIR = args[2];
        }

        if (args.length > 3) {
            p_host_url = args[3];
            SO_URL = p_host_url;
            host_url = "http://www." + SO_URL;
            photo_url = "http://photo." + SO_URL + "/album/theme/";
            story_url = "http://story." + SO_URL + "/honor/";
        }
        cfl.executeURL(nPage, p_author_id, p_gnum);
        //cfl.executeAuthorList(nPage, p_author_id, p_gnum);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.da.daum.DaumCafeList.java

public static void main(String[] args) {
    DaumCafeList cfl = new DaumCafeList();

    log.warn("Logging Works");
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");

    System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
    System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");

    try {//ww w.  ja  va 2  s. c  o m
        // https://msp.f-secure.com/web-test/common/test.html
        // String body =
        // CHttpUtil.DownloadHtml("https://logins.daum.net/accounts/loginform.do?mobilefull=1&t__nil_footer=login&url=http%3a%2f%2fm%2edaum%2enet%2f");
        /*
         * String body = CHttpUtil.DownloadHtml(
         * "https://logins.daum.net/accounts/mobile.do?url=http%3A%2F%2Fm.daum.net%2F&relative=&mobilefull=1&weblogin=1&id=changwng&pw=cw89040310&stln=on&saved_id=on"
         * ); System.out.println(body);
         */
        String nPage = "1";
        String p_author_id = "bluesman";
        String p_gnum = ""; // ga
        String p_host_url = ""; // ga
        if (args.length > 0) {
            nPage = args[0];
        }
        if (args.length > 1) {
            p_author_id = args[1];
        }
        if (args.length > 2) {
            STORY_DIR = args[2];
        }

        if (args.length > 3) {
            p_host_url = args[3];
            SO_URL = p_host_url;
            /*
             * host_url = "http://www."+SO_URL; photo_url =
             * "http://photo."+SO_URL+"/album/theme/"; story_url =
             * "http://story."+SO_URL+"/honor/";
             */
        }
        cfl.executeURL(nPage, p_author_id, p_gnum);
        // cfl.executeAuthorList(nPage, p_author_id, p_gnum);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.da.daum.DaumCafeBungImgList.java

public static void main(String[] args) {
    DaumCafeBungImgList cfl = new DaumCafeBungImgList();

    log.warn("Logging Works");
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");

    System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
    System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");

    try {/*from  w w w.  j a  va2s  .c  o  m*/
        // https://msp.f-secure.com/web-test/common/test.html
        // String body =
        // CHttpUtil.DownloadHtml("https://logins.daum.net/accounts/loginform.do?mobilefull=1&t__nil_footer=login&url=http%3a%2f%2fm%2edaum%2enet%2f");
        /*
         * String body = CHttpUtil.DownloadHtml(
         * "https://logins.daum.net/accounts/mobile.do?url=http%3A%2F%2Fm.daum.net%2F&relative=&mobilefull=1&weblogin=1&id=changwng&pw=cw89040310&stln=on&saved_id=on"
         * ); System.out.println(body);
         */
        String nPage = "1";
        String p_author_id = "bluesman";
        String p_gnum = ""; // ga
        String p_host_url = ""; // ga
        if (args.length > 0) {
            nPage = args[0];
        }
        if (args.length > 1) {
            p_author_id = args[1];
        }
        if (args.length > 2) {
            STORY_DIR = args[2];
        }

        if (args.length > 3) {
            p_host_url = args[3];
            SO_URL = p_host_url;
            /*
             * host_url = "http://www."+SO_URL; photo_url =
             * "http://photo."+SO_URL+"/album/theme/"; story_url =
             * "http://story."+SO_URL+"/honor/";
             */
        }
        cfl.executeURL(nPage, p_author_id, p_gnum);
        // cfl.executeAuthorList(nPage, p_author_id, p_gnum);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.da.daum.DaumCafeImgAllList.java

public static void main(String[] args) {
    DaumCafeImgAllList cfl = new DaumCafeImgAllList();

    log.warn("Logging Works");
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");

    System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
    System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");

    try {/*from w w  w  .j  av a2s .co  m*/
        // https://msp.f-secure.com/web-test/common/test.html
        // String body =
        // CHttpUtil.DownloadHtml("https://logins.daum.net/accounts/loginform.do?mobilefull=1&t__nil_footer=login&url=http%3a%2f%2fm%2edaum%2enet%2f");
        /*
         * String body = CHttpUtil.DownloadHtml(
         * "https://logins.daum.net/accounts/mobile.do?url=http%3A%2F%2Fm.daum.net%2F&relative=&mobilefull=1&weblogin=1&id=changwng&pw=cw89040310&stln=on&saved_id=on"
         * ); System.out.println(body);
         */
        String nPage = "1";
        String p_author_id = "bluesman";
        String p_gnum = ""; // ga
        String p_host_url = ""; // ga
        if (args.length > 0) {
            nPage = args[0];
        }
        if (args.length > 1) {
            p_author_id = args[1];
        }
        if (args.length > 2) {
            STORY_DIR = args[2];
        }

        if (args.length > 3) {
            p_host_url = args[3];
            SO_URL = p_host_url;
            /*
             * host_url = "http://www."+SO_URL; photo_url =
             * "http://photo."+SO_URL+"/album/theme/"; story_url =
             * "http://story."+SO_URL+"/honor/";
             */
        }
        cfl.executeURL(nPage, p_author_id, p_gnum);
        // cfl.executeAuthorList(nPage, p_author_id, p_gnum);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.da.daum.DaumCafeJw0List.java

public static void main(String[] args) {
    DaumCafeJw0List cfl = new DaumCafeJw0List();

    log.warn("Logging Works");
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");

    System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
    System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");

    try {//from   w  w w.  j a  v a2s .  c  o m
        // https://msp.f-secure.com/web-test/common/test.html
        // String body =
        // CHttpUtil.DownloadHtml("https://logins.daum.net/accounts/loginform.do?mobilefull=1&t__nil_footer=login&url=http%3a%2f%2fm%2edaum%2enet%2f");
        /*
         * String body = CHttpUtil.DownloadHtml(
         * "https://logins.daum.net/accounts/mobile.do?url=http%3A%2F%2Fm.daum.net%2F&relative=&mobilefull=1&weblogin=1&id=changwng&pw=cw89040310&stln=on&saved_id=on"
         * ); System.out.println(body);
         */
        String nPage = "1";
        String p_author_id = "bluesman";
        String p_gnum = ""; // ga
        String p_host_url = ""; // ga
        if (args.length > 0) {
            nPage = args[0];
        }
        if (args.length > 1) {
            p_author_id = args[1];
        }
        if (args.length > 2) {
            STORY_DIR = args[2];
        }

        if (args.length > 3) {
            p_host_url = args[3];
            SO_URL = p_host_url;
            /*
             * host_url = "http://www."+SO_URL; photo_url =
             * "http://photo."+SO_URL+"/album/theme/"; story_url =
             * "http://story."+SO_URL+"/honor/";
             */
        }
        cfl.executeURL(nPage, p_author_id, p_gnum);
        // cfl.executeAuthorList(nPage, p_author_id, p_gnum);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.da.daum.DaumOk211List.java

public static void main(String[] args) {
    DaumOk211List cfl = new DaumOk211List();

    log.warn("Logging Works");
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");

    System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
    System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");

    try {//from   w  ww  . j av  a2 s .com
        // https://msp.f-secure.com/web-test/common/test.html
        // String body =
        // CHttpUtil.DownloadHtml("https://logins.daum.net/accounts/loginform.do?mobilefull=1&t__nil_footer=login&url=http%3a%2f%2fm%2edaum%2enet%2f");
        /*
         * String body = CHttpUtil.DownloadHtml(
         * "https://logins.daum.net/accounts/mobile.do?url=http%3A%2F%2Fm.daum.net%2F&relative=&mobilefull=1&weblogin=1&id=changwng&pw=cw89040310&stln=on&saved_id=on"
         * ); System.out.println(body);
         */
        String nPage = "1";
        String p_author_id = "bluesman";
        String p_gnum = ""; // ga
        String p_host_url = ""; // ga
        if (args.length > 0) {
            nPage = args[0];
        }
        if (args.length > 1) {
            STORY_DIR = args[1];
        }
        if (args.length > 2) {
            CAFE_TYPE = args[2];
        }
        if (args.length > 3) {
            BOARD_TYPE = args[3];
        }
        cfl.executeURL(nPage, p_author_id, p_gnum);
        // cfl.executeAuthorList(nPage, p_author_id, p_gnum);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}