Last active
December 26, 2015 16:09
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
activiti explorer rest integration test
prj url: https://github.com/izerui/activiti-explorer