Repository: james-project Updated Branches: refs/heads/master 7db81d51f -> e6a71cb50
JAMES-1972 Retry continuation token requests Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/e6a71cb5 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/e6a71cb5 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/e6a71cb5 Branch: refs/heads/master Commit: e6a71cb50ff7da6a8382dbbd58891f73c6d8a4ae Parents: 7db81d5 Author: benwa <[email protected]> Authored: Mon Mar 20 16:31:01 2017 +0700 Committer: benwa <[email protected]> Committed: Mon Mar 20 18:29:43 2017 +0700 ---------------------------------------------------------------------- .../james/jmap/HttpJmapAuthentication.java | 25 ++++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/e6a71cb5/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/HttpJmapAuthentication.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/HttpJmapAuthentication.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/HttpJmapAuthentication.java index 06bc960..e24034b 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/HttpJmapAuthentication.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/HttpJmapAuthentication.java @@ -42,19 +42,23 @@ public class HttpJmapAuthentication { .pollInterval(Duration.FIVE_HUNDRED_MILLISECONDS) .and().with() .pollDelay(Duration.ONE_HUNDRED_MILLISECONDS) - .await(); + .await() + .atMost(30, TimeUnit.SECONDS) + .ignoreExceptions(); - public static AccessToken authenticateJamesUser(URIBuilder uriBuilder, String username, String password) throws ClientProtocolException, IOException, URISyntaxException { + public static AccessToken authenticateJamesUser(URIBuilder uriBuilder, String username, String password) { + return CALMLY_AWAIT.until( + () -> doAuthenticate(uriBuilder, username, password), IsAnything.anything()); + } + + public static AccessToken doAuthenticate(URIBuilder uriBuilder, String username, String password) throws ClientProtocolException, IOException, URISyntaxException { String continuationToken = getContinuationToken(uriBuilder, username); - Response response = CALMLY_AWAIT - .atMost(30, TimeUnit.SECONDS) - .ignoreExceptions() - .until(() -> postAuthenticate(uriBuilder, password, continuationToken), IsAnything.anything()); + Response response = postAuthenticate(uriBuilder, password, continuationToken); return AccessToken.fromString( - JsonPath.parse(response.returnContent().asString()) - .read("accessToken")); + JsonPath.parse(response.returnContent().asString()) + .read("accessToken")); } private static Response postAuthenticate(URIBuilder uriBuilder, String password, String continuationToken) throws ClientProtocolException, IOException, URISyntaxException { @@ -67,10 +71,11 @@ public class HttpJmapAuthentication { private static String getContinuationToken(URIBuilder uriBuilder, String username) throws ClientProtocolException, IOException, URISyntaxException { Response response = Request.Post(uriBuilder.setPath("/authentication").build()) - .bodyString("{\"username\": \"" + username + "\", \"clientName\": \"Mozilla Thunderbird\", \"clientVersion\": \"42.0\", \"deviceName\": \"Joe Bloggâs iPhone\"}", - ContentType.APPLICATION_JSON) + .bodyString("{\"username\": \"" + username + "\", \"clientName\": \"Mozilla Thunderbird\", \"clientVersion\": \"42.0\", \"deviceName\": \"Joe Bloggâs iPhone\"}", + ContentType.APPLICATION_JSON) .setHeader("Accept", ContentType.APPLICATION_JSON.getMimeType()) .execute(); + return JsonPath.parse(response.returnContent().asString()) .read("continuationToken"); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
