Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more detailed error messages #129

Merged
merged 2 commits into from
Jun 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import com.jcabi.log.Logger;

import org.apache.http.HttpEntity;
import org.apache.http.client.HttpResponseException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.fluent.Request;
import org.apache.http.client.fluent.Response;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;

Expand Down Expand Up @@ -109,7 +111,7 @@ public void runTestSuite(final File testSuite) throws AETException {
}
}

private SuiteExecutionResult startSuiteExecution(File testSuite) throws IOException {
private SuiteExecutionResult startSuiteExecution(File testSuite) {
MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create()
.addBinaryBody("suite", testSuite, ContentType.APPLICATION_XML, testSuite.getName());
if (domain != null) {
Expand All @@ -119,12 +121,30 @@ private SuiteExecutionResult startSuiteExecution(File testSuite) throws IOExcept
entityBuilder.addTextBody("pattern", patternCorrelationId);
}
HttpEntity entity = entityBuilder.build();
return Request.Post(getSuiteUrl())
.body(entity)
.connectTimeout(timeout)
.socketTimeout(timeout)
.execute()
.handleResponse(suiteExecutionResponseHandler);

return retrieveSuiteExecutionResult(entity, timeout);
}

private SuiteExecutionResult retrieveSuiteExecutionResult(HttpEntity entity, int httpTimeout) {
SuiteExecutionResult result;
try {
Response response = Request.Post(getSuiteUrl())
.body(entity)
.connectTimeout(httpTimeout)
.socketTimeout(httpTimeout)
.execute();
result = response.handleResponse(suiteExecutionResponseHandler);
} catch (HttpResponseException re) {
String msg = String.format("Unexpected response for suite status. Status: %s, message: %s.",
re.getStatusCode(),
re.getMessage()
);
result = SuiteExecutionResult.createErrorResult(msg);
} catch (IOException ioe) {
String msg = "Error while checking suite execution status: " + ioe.getMessage();
result = SuiteExecutionResult.createErrorResult(msg);
}
return result;
}

private String getSuiteUrl() {
Expand Down