Skip to content

Instantly share code, notes, and snippets.

@izerui
Last active December 26, 2015 16:09
Show Gist options
  • Save izerui/7177628 to your computer and use it in GitHub Desktop.
Save izerui/7177628 to your computer and use it in GitHub Desktop.
activiti explorer rest integration test prj url: https://github.com/izerui/activiti-explorer
package com.izerui.activiti;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* @author izerui.com
* @version createtime:2013年8月3日 下午10:22:52
*/
public class TestRest {
private DefaultHttpClient httpClient = new DefaultHttpClient();
@Before
public void login() throws Exception {
HttpPost postRequest = new HttpPost("http://localhost:8080/activiti-explorer/service/login");
StringEntity input = new StringEntity("{\"userId\":\"kermit\",\"password\":\"kermit\"}");
input.setContentType("application/json");
postRequest.setEntity(input);
HttpResponse response = httpClient.execute(postRequest);
writeMessage(response);
}
@Test
public void listDeployments() throws ClientProtocolException, IOException{
HttpPost postRequest = new HttpPost("http://localhost:8080/activiti-explorer/service/repository/process-definitions");
StringEntity input = new StringEntity("{\"userId\":\"kermit\",\"password\":\"kermit\"}");
input.setContentType("application/json");
postRequest.setEntity(input);
HttpResponse response = httpClient.execute(postRequest);
writeMessage(response);
}
@After
public void closeHttpClient(){
httpClient.getConnectionManager().shutdown();
}
public void writeMessage(HttpResponse response) throws IllegalStateException, IOException{
BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
String output;
while ((output = br.readLine()) != null) {
System.out.println(output);
}
}
}
@izerui
Copy link
Author

izerui commented Oct 27, 2013

activiti explorer rest integration test

prj url: https://github.com/izerui/activiti-explorer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment