use of org.apache.http.HttpResponse in project Activiti by Activiti.
the class JpaRestTest method testGetJpaVariableViaHistoricProcessCollection.
@Deployment(resources = { "org/activiti/rest/api/jpa/jpa-process.bpmn20.xml" })
public void testGetJpaVariableViaHistoricProcessCollection() throws Exception {
// Get JPA managed entity through the repository
Message message = messageRepository.findOne(1L);
assertNotNull(message);
assertEquals("Hello World", message.getText());
// add the entity to the process variables and start the process
Map<String, Object> processVariables = new HashMap<String, Object>();
processVariables.put("message", message);
ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceByKey("jpa-process", processVariables);
assertNotNull(processInstance);
Task task = processEngine.getTaskService().createTaskQuery().singleResult();
assertEquals("Activiti is awesome!", task.getName());
// Request all variables (no scope provides) which include global and local
HttpResponse response = executeHttpRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCES) + "?processInstanceId=" + processInstance.getId() + "&includeProcessVariables=true"), HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
// check for message variable of type serializable
assertNotNull(responseNode);
JsonNode variablesArrayNode = responseNode.get("data").get(0).get("variables");
assertEquals(1, variablesArrayNode.size());
JsonNode variableNode = variablesArrayNode.get(0);
assertEquals("message", variableNode.get("name").asText());
assertEquals("serializable", variableNode.get("type").asText());
assertNotNull(variableNode.get("valueUrl"));
}
use of org.apache.http.HttpResponse in project android_frameworks_base by DirtyUnicorns.
the class TestHttpClient method execute.
public HttpResponse execute(final HttpRequest request, final HttpHost targetHost, final HttpClientConnection conn) throws HttpException, IOException {
this.context.setAttribute(ExecutionContext.HTTP_REQUEST, request);
this.context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, targetHost);
this.context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
request.setParams(new DefaultedHttpParams(request.getParams(), this.params));
this.httpexecutor.preProcess(request, this.httpproc, this.context);
HttpResponse response = this.httpexecutor.execute(request, conn, this.context);
response.setParams(new DefaultedHttpParams(response.getParams(), this.params));
this.httpexecutor.postProcess(response, this.httpproc, this.context);
return response;
}
use of org.apache.http.HttpResponse in project nhin-d by DirectProject.
the class SecuredServiceRequestBase method call.
/**
* {@inheritDoc}}
*/
@Override
public T call() throws E, IOException, ServiceException {
HttpUriRequest request = createRequest();
assert request != null;
request = securityManager.createAuthenticatedRequest(request);
final HttpResponse response = httpClient.execute(request);
try {
final int statusCode = response.getStatusLine().getStatusCode();
return interpretResponse(statusCode, response);
} finally {
closeConnection(response);
}
}
use of org.apache.http.HttpResponse in project nhin-d by DirectProject.
the class UnsecuredServiceRequestBase_interpretResponseTest method testInterpretResponseTest_404Status_assertServiceMethodException.
@Test
public void testInterpretResponseTest_404Status_assertServiceMethodException() throws Exception {
MockServiceRequest req = new MockServiceRequest(null, "http://service/svc", "Test");
HttpResponse resp = mock(HttpResponse.class);
boolean exceptionOccured = false;
try {
req.interpretResponse(404, resp);
} catch (ServiceMethodException e) {
assertEquals(404, e.getResponseCode());
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.apache.http.HttpResponse in project nhin-d by DirectProject.
the class UnsecureServiceRequestBase_callTest method testCall_callWithNoReturnValue.
@Test
public void testCall_callWithNoReturnValue() throws Exception {
HttpClient mockClient = mock(HttpClient.class);
StatusLine statLine = mock(StatusLine.class);
when(statLine.getStatusCode()).thenReturn(204);
HttpResponse resp = mock(HttpResponse.class);
when(resp.getStatusLine()).thenReturn(statLine);
when(mockClient.execute((HttpUriRequest) any())).thenReturn(resp);
MockServiceRequest req = new MockServiceRequest(mockClient, "http://service/svc", "Test");
assertNull(req.call());
}
Aggregations