TwilioAccess { public boolean send(final String to, final String body) { final List<NameValuePair> params = new ArrayList<>(); params.add(new BasicNameValuePair("Body", body)); params.add(new BasicNameValuePair("To", to)); params.add(new BasicNameValuePair("From", twilioFrom)); try { final MessageFactory messageFactory = getTwilioRestClient().getAccount().getMessageFactory(); final Message message = messageFactory.create(params); System.out.println(message.getSid()); return true; } catch (final Exception e) { e.printStackTrace(); logger.log(Level.SEVERE, "Cannot send SMS using the configured account", e); } return false; } TwilioAccess(final String sid, final String token, final String from); boolean send(final String to, final String body);  }
@Test public void testFailCall() { System.out.println("testFailCall"); TwilioAccess t = new TwilioAccess("1234567890", "1234567890", "1234567890"); assertFalse(t.send("1234567890", "This is the body")); }