Commit 56d81d21 authored by Ralph Soika's avatar Ralph Soika

issue #3

parent 012ea3a9
......@@ -20,7 +20,7 @@ COPY src/docker/imixsrealm.properties /opt/jboss/wildfly/standalone/configuratio
COPY src/docker/postgresql-9.3-1102.jdbc41.jar /opt/jboss/wildfly/standalone/deployments/
# deploy imixs-microservice.war
COPY target/imixs-microservice-1.0.0.war /opt/jboss/wildfly/standalone/deployments/
COPY target/imixs-microservice-*.war /opt/jboss/wildfly/standalone/deployments/
# use to start bash
#CMD ["bash"]
......
......@@ -10,8 +10,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.imixs.workflow.version>3.1.9</org.imixs.workflow.version>
<org.imixs.marty.version>2.1.1</org.imixs.marty.version>
<org.imixs.workflow.version>3.5.0</org.imixs.workflow.version>
<org.imixs.marty.version>2.5.0</org.imixs.marty.version>
<custom.webResources>src/main/webapp</custom.webResources>
</properties>
......@@ -91,8 +91,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
......
This diff is collapsed.
......@@ -92,11 +92,11 @@ public class SetupServlet extends HttpServlet {
}
private void setup() {
logger.info("Imixs-Office-Workflow - setup...");
logger.info("Imixs-Microservice - setup...");
// init userIDs for user db
try {
logger.info("Imixs-Office-Workflow - check default user...");
logger.info("Imixs-Microservice - checking default user...");
if (userGroupService != null) {
userGroupService.initUserIDs();
}
......@@ -108,7 +108,7 @@ public class SetupServlet extends HttpServlet {
// try to init system indizies and load default models
try {
logger.info("Imixs-Office-Workflow - check default model...");
logger.info("Imixs-Microservice - checking default model...");
setupService.init();
} catch (AccessDeniedException e1) {
logger.severe("SetupServlet - unable to init system "
......
......@@ -3,7 +3,7 @@
##############################
setup.mode=auto
setup.defaultModel=ticket.ixm
#setup.defaultModel=ticket.ixm
# Mail Plugin configuration
mail.defaultSender=info@mydomain.com
......
This diff is collapsed.
package org.imixs.microservice.test;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.logging.Level;
import junit.framework.Assert;
import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.exceptions.ModelException;
import org.imixs.workflow.services.rest.RestClient;
import org.imixs.workflow.test.WorkflowTestSuite;
import org.imixs.workflow.util.Base64;
import org.junit.Before;
import org.junit.Test;
import junit.framework.Assert;
/**
* This test shows an example how to post a workitem and how to get the worklist
* from the RestService API.
......@@ -21,50 +33,59 @@ import org.junit.Test;
*
*/
public class WorkflowTest {
static String BASE_URL = "http://localhost:8080/imixs-microservice/";
static String USERID = "admin";
static String PASSWORD = "adminadmin";
RestClient restClient = null;
WorkflowTestSuite testSuite = null;
/**
* create new Ticket based on a Imxis ItemCollection object using the Imixs
* The setup method deploys the ticket workflow into the running workflow
* instance.
*
* @throws Exception
*/
@Before
public void setup() throws Exception {
try {
deployBPMNModel("/ticket.bpmn");
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
/**
* create new Ticket based on a Imixs ItemCollection object using the Imixs
* WorkflowTestSuite.
*
*/
@Test
public void createNewWorkitemTest() {
testSuite = WorkflowTestSuite.getInstance();
testSuite.setHost(BASE_URL);
testSuite.joinParty(USERID, PASSWORD);
testSuite.joinParty("Anonymous", null);
ItemCollection registration = new ItemCollection();
registration.replaceItemValue("type", "workitem");
registration.replaceItemValue("$ModelVersion", "1.0.0");
registration.replaceItemValue("$processid", 10);
registration.replaceItemValue("$activityid", 10);
registration.replaceItemValue("txtName", "Test");
registration = testSuite.processWorkitem(registration, "admin");
Assert.assertNotNull(registration);
String uid = registration.getItemValueString("$UniqueID");
ItemCollection ticket = new ItemCollection();
ticket.replaceItemValue("type", "workitem");
ticket.replaceItemValue("$ModelVersion", "1.2.0");
ticket.replaceItemValue("$processid", 1000);
ticket.replaceItemValue("$activityid", 10);
ticket.replaceItemValue("txtName", "Test");
ticket = testSuite.processWorkitem(ticket, "admin");
Assert.assertNotNull(ticket);
String uid = ticket.getItemValueString("$UniqueID");
WorkflowTestSuite.log(Level.INFO, "UID=" + uid);
Assert.assertFalse(uid.isEmpty());
}
/**
* create new Ticket based on a JSON String
*
......@@ -72,21 +93,18 @@ public class WorkflowTest {
*/
@Test
public void createNewWorkitemJSONTest() {
RestClient restClient = new RestClient();
restClient.setCredentials(USERID, PASSWORD);
String uri = BASE_URL + "workflow/workitem.json";
// create a json test string
String json = "{\"item\":["
+ " {\"name\":\"type\",\"value\":{\"@type\":\"xs:string\",\"$\":\"workitem\"}},"
+ " {\"name\":\"$modelversion\",\"value\":{\"@type\":\"xs:string\",\"$\":\"1.0.0\"}},"
+ " {\"name\":\"$processid\",\"value\":{\"@type\":\"xs:int\",\"$\":\"10\"}},"
String json = "{\"item\":[" + " {\"name\":\"type\",\"value\":{\"@type\":\"xs:string\",\"$\":\"workitem\"}},"
+ " {\"name\":\"$modelversion\",\"value\":{\"@type\":\"xs:string\",\"$\":\"1.2.0\"}},"
+ " {\"name\":\"$processid\",\"value\":{\"@type\":\"xs:int\",\"$\":\"1000\"}},"
+ " {\"name\":\"$activityid\",\"value\":{\"@type\":\"xs:int\",\"$\":\"10\"}},"
+ " {\"name\":\"txtname\",\"value\":{\"@type\":\"xs:string\",\"$\":\"test-json\"}}"
+ "]}";
+ " {\"name\":\"txtname\",\"value\":{\"@type\":\"xs:string\",\"$\":\"test-json\"}}" + "]}";
try {
int httpResult = restClient.postJsonEntity(uri, json);
......@@ -102,7 +120,78 @@ public class WorkflowTest {
}
}
/**
* This method deploys a BPMN model into the running workflow instance via
* the Imixs-Rest API
*
* @throws Exception
*/
public void deployBPMNModel(String modelFilePath) throws Exception {
PrintWriter printWriter = null;
HttpURLConnection urlConnection = null;
try {
String serviceEndpoint = BASE_URL + "model/bpmn";
urlConnection = (HttpURLConnection) new URL(serviceEndpoint).openConnection();
urlConnection.setRequestMethod("POST");
urlConnection.setDoOutput(true);
urlConnection.setDoInput(true);
urlConnection.setAllowUserInteraction(false);
// set Authorization HEADER
urlConnection.setRequestProperty("Authorization", "Basic " + this.getAccessByUser());
// set Content_Type
urlConnection.setRequestProperty("Content-Type", "application/xml; charset=" + "UTF-8");
StringWriter writer = new StringWriter();
// read model as a resource stream
InputStream inputStream = getClass().getResourceAsStream(modelFilePath);
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
String read;
while ((read = br.readLine()) != null) {
writer.write(read);
}
br.close();
// compute length
urlConnection.setRequestProperty("Content-Length",
"" + Integer.valueOf(writer.toString().getBytes().length));
printWriter = new PrintWriter(
new BufferedWriter(new OutputStreamWriter(urlConnection.getOutputStream(), "UTF-8")));
printWriter.write(writer.toString());
printWriter.close();
String sHTTPResponse = urlConnection.getHeaderField(0);
int iLastHTTPResult = Integer.parseInt(sHTTPResponse.substring(9, 12));
if (iLastHTTPResult < 200 || iLastHTTPResult >= 300) {
throw new ModelException(ModelException.INVALID_MODEL,
"Deployment of Model '" + modelFilePath + "' failed");
}
} catch (Exception ioe) {
throw ioe;
} finally {
// Release current connection
if (printWriter != null)
printWriter.close();
}
}
/**
* This method decodes the user id and password used for basic
* authentication
*
*/
private String getAccessByUser() {
String sURLAccess = "";
String sUserCode = USERID + ":" + PASSWORD;
char[] authcode = Base64.encode(sUserCode.getBytes());
sURLAccess = String.valueOf(authcode);
return sURLAccess;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment