added a eventlog test client
This commit is contained in:
parent
87ef39ece4
commit
2cbd5d66bc
3 changed files with 245 additions and 0 deletions
143
office-alexander-logistics-testclient/pom.xml
Normal file
143
office-alexander-logistics-testclient/pom.xml
Normal file
|
|
@ -0,0 +1,143 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<artifactId>office-alexander-logistics</artifactId>
|
||||||
|
<groupId>com.alexander-logistics</groupId>
|
||||||
|
<version>1.3.4</version>
|
||||||
|
</parent>
|
||||||
|
<artifactId>office-alexander-logistics-testclient</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>Imixs Office Workflow Remote Test Client</name>
|
||||||
|
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<resources>
|
||||||
|
<!-- enable resource filtering for multi language version -->
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
<plugins>
|
||||||
|
<!-- use JDK settings for compiling -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.11.0</version>
|
||||||
|
<configuration>
|
||||||
|
<source>11</source>
|
||||||
|
<target>11</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
|
<configuration>
|
||||||
|
<encoding>${project.build.sourceEncoding}</encoding>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Testing JUnit 5 -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>3.1.2</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
|
||||||
|
<finalName>imixs-process-manager</finalName>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- JEE Dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.platform</groupId>
|
||||||
|
<artifactId>jakarta.jakartaee-api</artifactId>
|
||||||
|
<version>10.0.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Imixs Workflow -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.imixs.workflow</groupId>
|
||||||
|
<artifactId>imixs-workflow-core</artifactId>
|
||||||
|
<version>${org.imixs.workflow.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Testing -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.imixs.workflow</groupId>
|
||||||
|
<artifactId>imixs-melman</artifactId>
|
||||||
|
<version>${org.imixs.melman.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- JUnit 5 Dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
|
<version>${junit.jupiter.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
|
<version>${junit.jupiter.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Mockito Dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mockito</groupId>
|
||||||
|
<artifactId>mockito-core</artifactId>
|
||||||
|
<version>${mockito.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mockito</groupId>
|
||||||
|
<artifactId>mockito-junit-jupiter</artifactId>
|
||||||
|
<version>${mockito.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Test dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.xml.bind</groupId>
|
||||||
|
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.parsson</groupId>
|
||||||
|
<artifactId>jakarta.json</artifactId>
|
||||||
|
<version>1.1.1</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.glassfish.jaxb</groupId>
|
||||||
|
<artifactId>jaxb-runtime</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.glassfish.jersey.media</groupId>
|
||||||
|
<artifactId>jersey-media-jaxb</artifactId>
|
||||||
|
<version>3.1.5</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.glassfish.jersey.core</groupId>
|
||||||
|
<artifactId>jersey-client</artifactId>
|
||||||
|
<version>3.1.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,101 @@
|
||||||
|
package com.alexanderlogistics.rest;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.imixs.melman.EventLogClient;
|
||||||
|
import org.imixs.melman.FormAuthenticator;
|
||||||
|
import org.imixs.melman.RestAPIException;
|
||||||
|
import org.imixs.workflow.ItemCollection;
|
||||||
|
import org.imixs.workflow.WorkflowKernel;
|
||||||
|
import org.imixs.workflow.exceptions.PluginException;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple example how to create a new event log entry remote.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Disabled
|
||||||
|
public class TestEventLog {
|
||||||
|
|
||||||
|
private static Logger logger = Logger.getLogger(TestEventLog.class.getName());
|
||||||
|
|
||||||
|
EventLogClient client = null;
|
||||||
|
|
||||||
|
// String restAPI = "https://test.alexander-logistics.office-workflow.de/api";
|
||||||
|
String restAPI = "http://localhost:8080/api";
|
||||||
|
String userID = "kutzner-service";
|
||||||
|
String password = "imixs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup a new Rest Client
|
||||||
|
*
|
||||||
|
* @throws PluginException
|
||||||
|
*/
|
||||||
|
@BeforeEach
|
||||||
|
public void setup() throws PluginException {
|
||||||
|
|
||||||
|
client = new EventLogClient(restAPI);
|
||||||
|
FormAuthenticator aut;
|
||||||
|
try {
|
||||||
|
aut = new FormAuthenticator(restAPI, userID, password);
|
||||||
|
client.registerClientRequestFilter(aut);
|
||||||
|
} catch (RestAPIException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an event log entry....
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void sendXMLData() {
|
||||||
|
|
||||||
|
logger.info("start...");
|
||||||
|
ItemCollection payLoad = new ItemCollection();
|
||||||
|
String uid = WorkflowKernel.generateUniqueID();
|
||||||
|
try {
|
||||||
|
// set data....
|
||||||
|
payLoad.setItemValue("some-data", "abc");
|
||||||
|
String xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||||
|
+ "<Invoices>"
|
||||||
|
+ " <InvoiceHeader>"
|
||||||
|
+ " <InvoiceNumber>224225</InvoiceNumber>"
|
||||||
|
+ " </InvoiceHeader>"
|
||||||
|
+ " </Invoices>";
|
||||||
|
payLoad.setItemValue("xml-data", xmlString);
|
||||||
|
|
||||||
|
client.createEventLogEntry("TOPIC_CARGOSOFT_INVOICE", uid, payLoad);
|
||||||
|
logger.info("completed");
|
||||||
|
} catch (RestAPIException e) {
|
||||||
|
logger.severe("Failed to send event log entry: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getXMLData() {
|
||||||
|
logger.info("start...");
|
||||||
|
try {
|
||||||
|
List<ItemCollection> list = client.searchEventLog("TOPIC_CARGOSOFT_INVOICE");
|
||||||
|
logger.info("found " + list.size() + " log entries");
|
||||||
|
for (ItemCollection entry : list) {
|
||||||
|
List<?> dataList = entry.getItemValue("data");
|
||||||
|
if (dataList != null && dataList.size() > 0) {
|
||||||
|
ItemCollection data = new ItemCollection((Map<String, List<Object>>) dataList.get(0));
|
||||||
|
logger.info("Data=" + data.getItemValueString("some-data"));
|
||||||
|
logger.info("XML Data=" + data.getItemValueString("xml-data"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (RestAPIException e) {
|
||||||
|
logger.severe("Failed to read event log entry: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
1
pom.xml
1
pom.xml
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>office-alexander-logistics-app</module>
|
<module>office-alexander-logistics-app</module>
|
||||||
|
<module>office-alexander-logistics-testclient</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue