TwitterWrapper { public void send(String token, String secret, String message, AsyncCompletionHandler<Response> handler) { asyncHttpClient .preparePost(TWITTER_UPDATE_STATUS_URL) .addQueryParam("status", message) .setSignatureCalculator(new OAuthSignatureCalculator(consumerKey, new RequestToken(token, secret))) .execute(handler); } TwitterWrapper(TwitterProperties twitterProperties, AsyncHttpClient asyncHttpClient); void send(String token, String secret, String message,
                     AsyncCompletionHandler<Response> handler);  }
@Test @Ignore("requires real credentials") public void testSend() throws Exception { TwitterProperties twitterProperties = new TwitterProperties(Collections.emptyMap()); TwitterWrapper twitterWrapper = new TwitterWrapper(twitterProperties, client); String userToken = ""; String userSecret = ""; String message = "Hello!!!"; twitterWrapper.send(userToken, userSecret, message, new AsyncCompletionHandler<>() { @Override public Response onCompleted(Response response) { if (response.getStatusCode() != HttpResponseStatus.OK.code()) { System.out.println("Error sending twit. Reason : " + response.getResponseBody()); } assertEquals(200, response.getStatusCode()); return response; } @Override public void onThrowable(Throwable t) { t.printStackTrace(); System.out.println("Error sending twit."); } }); Thread.sleep(5000); }