List of usage examples for org.apache.http.client ClientProtocolException getMessage
public String getMessage()
From source file:gov.nih.nci.caxchange.messaging.RegistrationIntegrationTest.java
/** * Testcase for Participant Registration */// www. ja v a 2s . c o m @Test public void sendRegistrationMessage() { try { final HttpPost httppost = new HttpPost(transcendCaxchangeServiceUrl); final StringEntity reqentity = new StringEntity(getCreateMsg()); httppost.setEntity(reqentity); httppost.setHeader(HttpHeaders.CONTENT_TYPE, XMLTEXT); final HttpResponse response = httpclient.execute(httppost); final HttpEntity entity = response.getEntity(); if (entity != null) { final String output = EntityUtils.toString(entity); Assert.assertNotNull(output); Assert.assertEquals(getSuccessCreateMsg(), removeCaXchangeIdentifier(output)); } } catch (ClientProtocolException e) { Assert.fail(e.getMessage()); } catch (IllegalStateException e) { Assert.fail(e.getMessage()); } catch (IOException e) { Assert.fail(e.getMessage()); } }
From source file:gov.nih.nci.caxchange.messaging.RegistrationIntegrationTest.java
/** * Testcase for Update Participant/*from www . j ava 2 s .c o m*/ */ @Test public void sendUpdateRegistrationMessage() { try { final HttpPost httppost = new HttpPost(transcendCaxchangeServiceUrl); final StringEntity reqentity = new StringEntity(getUpdateMsg()); httppost.setEntity(reqentity); httppost.setHeader(HttpHeaders.CONTENT_TYPE, XMLTEXT); final HttpResponse response = httpclient.execute(httppost); final HttpEntity entity = response.getEntity(); if (entity != null) { final String output = EntityUtils.toString(entity); Assert.assertNotNull(output); Assert.assertEquals(getSuccessUpdateMsg(), removeCaXchangeIdentifier(output)); } } catch (ClientProtocolException e) { Assert.fail(e.getMessage()); } catch (IllegalStateException e) { Assert.fail(e.getMessage()); } catch (IOException e) { Assert.fail(e.getMessage()); } }
From source file:com.liato.bankdroid.banking.banks.AkeliusSpar.java
@Override public void update() throws BankException, LoginException, BankChoiceException { super.update(); if (username == null || password == null || username.length() == 0 || password.length() == 0) { throw new LoginException(res.getText(R.string.invalid_username_password).toString()); }/*w w w. j a v a 2 s .c om*/ urlopen = login(); String response = null; Matcher matcher; try { response = urlopen.open("https://www.online.akeliusspar.se/AccountPortfolio.mws"); matcher = reAccounts.matcher(response); int accId = 0; while (matcher.find()) { /* * Capture groups: * GROUP ICA AKELIUSINVEST * 1: ID 0000000000 Kontonamn * 2: Name ICA KONTO KontoID * 3: Disponibelt 00.000,00 Kontonummer * 4: Saldo 1.655,71 Valuta * 5: Tillgngligt belopp * 6: Saldo */ // Frsk att lsa problemet med fr lnga, icke radbrytande kontonamn: // if (matcher.group(1).length() > 24) { // matcher.group(1).replaceFirst("(", "(\n"); // } mIdMappings.put(Integer.toString(accId), matcher.group(2).trim()); accounts.add( new Account(Html.fromHtml(matcher.group(1)).toString().trim() + " (Tillgngligt belopp)", Helpers.parseBalance(matcher.group(5).trim()), Integer.toString(accId))); Account account = new Account(Html.fromHtml(matcher.group(1)).toString().trim() + " (Saldo)", Helpers.parseBalance(matcher.group(6).trim()), "a:" + accId); account.setAliasfor(matcher.group(1).trim()); accounts.add(account); balance = balance.add(Helpers.parseBalance(matcher.group(5))); accId++; } if (accounts.isEmpty()) { throw new BankException(res.getText(R.string.no_accounts_found).toString()); } } catch (ClientProtocolException e) { throw new BankException(e.getMessage()); } catch (IOException e) { throw new BankException(e.getMessage()); } finally { super.updateComplete(); } }
From source file:com.liato.bankdroid.banking.banks.AkeliusInvest.java
@Override public void update() throws BankException, LoginException, BankChoiceException { super.update(); if (username == null || password == null || username.length() == 0 || password.length() == 0) { throw new LoginException(res.getText(R.string.invalid_username_password).toString()); }/* ww w. j a va 2 s . c o m*/ urlopen = login(); String response = null; Matcher matcher; try { response = urlopen.open("https://online.akeliusinvest.com/AccountPortfolio.mws"); matcher = reAccounts.matcher(response); int accId = 0; while (matcher.find()) { /* * Capture groups: * GROUP ICA AKELIUSINVEST * 1: ID 0000000000 Kontonamn * 2: Name ICA KONTO KontoID * 3: Disponibelt 00.000,00 Kontonummer * 4: Saldo 1.655,71 Valuta * 5: Tillgngligt belopp * 6: Saldo */ // Frsk att lsa problemet med fr lnga, icke radbrytande kontonamn: // if (matcher.group(1).length() > 24) { // matcher.group(1).replaceFirst("(", "(\n"); // } mIdMappings.put(Integer.toString(accId), matcher.group(2).trim()); accounts.add( new Account(Html.fromHtml(matcher.group(1)).toString().trim() + " (Tillgngligt belopp)", Helpers.parseBalance(matcher.group(5).trim()), Integer.toString(accId))); Account account = new Account(Html.fromHtml(matcher.group(1)).toString().trim() + " (Saldo)", Helpers.parseBalance(matcher.group(6).trim()), "a:" + accId); account.setAliasfor(matcher.group(1).trim()); accounts.add(account); balance = balance.add(Helpers.parseBalance(matcher.group(5))); accId++; } if (accounts.isEmpty()) { throw new BankException(res.getText(R.string.no_accounts_found).toString()); } } catch (ClientProtocolException e) { throw new BankException(e.getMessage()); } catch (IOException e) { throw new BankException(e.getMessage()); } finally { super.updateComplete(); } }
From source file:com.tomdignan.android.opencnam.library.teststub.test.OpenCNAMRequestTestCase.java
public void testNumberWithLeadingCountryCode() { String response = null;/*from ww w . j ava2 s . com*/ mOpenCNAMRequest.setPhoneNumber("1" + NUMBER); try { response = (String) mOpenCNAMRequest.execute(); } catch (ClientProtocolException e) { Log.e(TAG, "ClientProtocolException: " + e.getMessage()); } catch (IOException e) { Log.e(TAG, "ClientProtocolException: " + e.getMessage()); } assertNotNull(response); assertEquals(CNAM, response.trim()); }
From source file:com.tomdignan.android.opencnam.library.teststub.test.OpenCNAMRequestTestCase.java
public void testNumberWithLeadingCountryCodeAndNonNumericChars() { String response = null;//from ww w .j a v a 2 s.c o m mOpenCNAMRequest.setPhoneNumber("--1--*((*&(*&(&&*&basdjasjcjasca" + NUMBER); try { response = (String) mOpenCNAMRequest.execute(); } catch (ClientProtocolException e) { Log.e(TAG, "ClientProtocolException: " + e.getMessage()); } catch (IOException e) { Log.e(TAG, "ClientProtocolException: " + e.getMessage()); } assertNotNull(response); assertEquals(CNAM, response.trim()); }
From source file:gov.nih.nci.caxchange.messaging.RegistrationIntegrationTest.java
/** * Testcase for Update Participant// w ww.j a v a 2s .c o m */ @Test public void sendUpdateRegistrationToDifferentStudyMessage() { try { final HttpPost httppost = new HttpPost(transcendCaxchangeServiceUrl); String messageStr = getUpdateMsg(); messageStr = messageStr.replace("6482", "7216"); final StringEntity reqentity = new StringEntity(getUpdateMsg()); httppost.setEntity(reqentity); httppost.setHeader(HttpHeaders.CONTENT_TYPE, XMLTEXT); final HttpResponse response = httpclient.execute(httppost); final HttpEntity entity = response.getEntity(); if (entity != null) { final String output = EntityUtils.toString(entity); Assert.assertNotNull(output); Assert.assertEquals(getSuccessUpdateMsg(), removeCaXchangeIdentifier(output)); } } catch (ClientProtocolException e) { Assert.fail(e.getMessage()); } catch (IllegalStateException e) { Assert.fail(e.getMessage()); } catch (IOException e) { Assert.fail(e.getMessage()); } }
From source file:com.tomdignan.android.opencnam.library.teststub.test.OpenCNAMRequestTestCase.java
public void testTextRequest() { // TEXT is default. String response = null;//from ww w.ja va 2 s . co m try { response = (String) mOpenCNAMRequest.execute(); } catch (ClientProtocolException e) { Log.e(TAG, "ClientProtocolException: " + e.getMessage()); } catch (IOException e) { Log.e(TAG, "ClientProtocolException: " + e.getMessage()); } assertNotNull(response); assertEquals(CNAM, response.trim()); }
From source file:gov.nih.nci.caxchange.messaging.RegistrationIntegrationTest.java
/** * Testcase for sending invalid credential message *//*from ww w . j a v a 2 s. co m*/ @Test public void sendInvalidIHubCredentialsMessage() { try { final HttpPost httppost = new HttpPost(transcendCaxchangeServiceUrl); String msg = getCreateMsg(); msg = msg.replaceAll("<mes:userName>tolvenuser</mes:userName>", "<mes:userName>tolvenuser-invalid</mes:userName>"); final StringEntity reqentity = new StringEntity(msg); httppost.setEntity(reqentity); httppost.setHeader(HttpHeaders.CONTENT_TYPE, XMLTEXT); final HttpResponse response = httpclient.execute(httppost); final HttpEntity entity = response.getEntity(); if (entity != null) { final String output = EntityUtils.toString(entity); Assert.assertNotNull(output); Assert.assertEquals(getInvalidCredentialsCreateMsg(), removeCaXchangeIdentifier(output)); } } catch (ClientProtocolException e) { Assert.fail(e.getMessage()); } catch (IllegalStateException e) { Assert.fail(e.getMessage()); } catch (IOException e) { Assert.fail(e.getMessage()); } }
From source file:com.sparkred.mdex.metrics.publish.EndecaMDEXAgent.java
/** * Implementation of the pollCycle as per the required API This impl makes * the call to the server, grabs and parses the stats page and runs thorugh * the list of reported metrics as per the REPORTED_METRICS array and * returns all of the relevant data//from ww w . j ava2s .c o m * */ @Override public void pollCycle() { try { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(new URL(mStatsUrl).openStream()); for (int i = 0; i < REPORTED_METRICS.length; i++) { List<MdexStatsEntry> statsList = fetchMDEXStatsByType(doc, REPORTED_METRICS[i]); reportMetrics(statsList); } // throughput stats have a different format reportThroughputMetrics(doc); } catch (ClientProtocolException e) { LOGGER.error(e, e.getMessage()); } catch (ConnectException ce) { LOGGER.error(ce, "Cannot connect to the provided URL, please validate your configs and make sure the host/port is accesible"); } catch (IOException e) { LOGGER.error(e, e.getMessage()); } catch (ParserConfigurationException e) { LOGGER.error(e, e.getMessage()); } catch (SAXException e) { LOGGER.error(e, e.getMessage()); } }