Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update-unit-tests #114

Merged
merged 11 commits into from
Aug 31, 2022
19 changes: 8 additions & 11 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: CWS CI

# Triggers the workflow on push or pull request
#on: [push, pull_request]
# Triggers the workflow on push
on:
push:
schedule:
Expand Down Expand Up @@ -42,15 +41,11 @@ jobs:
cd install/docker/es-only
docker-compose up -d
- name: Set up CWS database using Docker
run: docker run -d -p 3306:3306 -e MYSQL_DATABASE=cws_dev -e MYSQL_ROOT_PASSWORD=rootpw --name mdb103 mariadb:10.3
run: docker run -d -p 3306:3306 -e MYSQL_DATABASE=cws_dev -e MYSQL_ROOT_PASSWORD=adminpw --name mdb103 mariadb:10.3
- name: Show Docker containers
run: |
sleep 5s
docker ps -a
- name: Stop CWS
run: |
chmod +x stop_dev.sh
./stop_dev.sh
- name: Run CWS
run: |
cd ci
Expand All @@ -63,10 +58,11 @@ jobs:
ls -al
- uses: browser-actions/setup-chrome@latest
- run: chrome --version
- name: Run Unit and Integration Tests
run: |
chmod +x test.sh
./test.sh
- name: Run Unit Tests
run: mvn -Dmaven.compiler.debug=true -Dmaven.compiler.debuglevel=lines,vars,source clean test jacoco:report-aggregate
shell: bash
- name: Run Integration Tests
run: mvn -Dmaven.compiler.debug=true -Dmaven.compiler.debuglevel=lines,vars,source integration-test verify -DskipTests
shell: bash
- name: Upload Jacoco report
uses: actions/upload-artifact@v3
Expand All @@ -79,6 +75,7 @@ jobs:
name: test-screenshots
path: test-screenshots/
- name: Send custom JSON data to Slack workflow
if: ${{ always() }}
id: slack
uses: slackapi/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion ci/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ DB_TYPE=mariadb
DB_HOST=127.0.0.1
DB_NAME=cws_dev # needs to match the db you set up beforehand
DB_USER=root # needs to match the user you set up beforehand
DB_PASS=rootpw # could also be specified with environment vars
DB_PASS=adminpw # could also be specified with environment vars
DB_PORT=3306 # mariadb default

USER=cwsci
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@ private void getHistoryVarDetails(List<HistoryDetail> history, String processIns

if (variable.getSerializerName().equals("json")) {

// TODO: Update this to display the actual JSON data in history (Collapsible table hopefully?)
message = "Setting (json) " + variable.getVariableName() + " = " + " <jsonData>";
// TODO: Update this to be a collapsible table
message = "Setting (json) " + variable.getVariableName() + " = " + variable.getValue();
}
else {
message = "Setting (" + variable.getTypeName() + ") " + variable.getVariableName() + " = " + variable.getValue();
Expand Down
2 changes: 0 additions & 2 deletions cws-test/src/test/java/jpl/cws/test/CmdLineExecTaskTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package jpl.cws.test;

//import static org.camunda.bpm.engine.test.assertions.ProcessEngineAssertions.assertThat;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.*;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.runtimeService;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.withVariables;
Expand All @@ -18,7 +17,6 @@
* Tests related to EmailTask
*
*/
@Ignore
public class CmdLineExecTaskTest extends CwsTestBase {

@Rule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package jpl.cws.test;

//import static org.camunda.bpm.engine.test.assertions.ProcessEngineAssertions.assertThat;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.*;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.runtimeService;
import static org.junit.Assert.fail;
Expand Down
1 change: 0 additions & 1 deletion cws-test/src/test/java/jpl/cws/test/Cws331Test.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package jpl.cws.test;

//import static org.camunda.bpm.engine.test.assertions.ProcessEngineAssertions.assertThat;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.*;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.execute;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.job;
Expand Down
1 change: 0 additions & 1 deletion cws-test/src/test/java/jpl/cws/test/CwsTestBase.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package jpl.cws.test;

//import static org.camunda.bpm.engine.test.assertions.ProcessEngineAssertions.assertThat;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.*;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.claim;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.complete;
Expand Down
1 change: 0 additions & 1 deletion cws-test/src/test/java/jpl/cws/test/CwsTestBase2.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package jpl.cws.test;

//import static org.camunda.bpm.engine.test.assertions.ProcessEngineAssertions.assertThat;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.*;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.claim;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.complete;
Expand Down
13 changes: 4 additions & 9 deletions cws-test/src/test/java/jpl/cws/test/EmailTaskTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package jpl.cws.test;

//import static org.camunda.bpm.engine.test.assertions.ProcessEngineAssertions.assertThat;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.*;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.runtimeService;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.withVariables;
Expand All @@ -13,10 +12,7 @@
import org.camunda.bpm.engine.test.Deployment;
import org.camunda.bpm.engine.test.ProcessEngineRule;
import org.camunda.bpm.engine.test.mock.Mocks;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.*;

import com.dumbster.smtp.SimpleSmtpServer;
import com.dumbster.smtp.SmtpMessage;
Expand Down Expand Up @@ -50,8 +46,7 @@ public void tearDown() {
* Tests BPMN process that sends an email using EmailTask.
*
*/
//@Test
@Ignore
@Test
@Deployment(resources = {"bpmn/test_email_task.bpmn"})
public void testCase1() {
try {
Expand Down Expand Up @@ -81,8 +76,8 @@ public void testCase1() {
assertTrue(email.getBody().contains("this<br/>has<br/>line<br/>breaks!"));

// verify to/from
assertTrue(email.getHeaderValue("From").equals("user@localhost"));
assertTrue(email.getHeaderValue("To").equals("user@localhost"));
assertTrue(email.getHeaderValue("From").equals("user@domain.com"));
assertTrue(email.getHeaderValue("To").equals("user@domain.org"));
}

}
57 changes: 52 additions & 5 deletions cws-test/src/test/java/jpl/cws/test/InstallerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.junit.Assert.assertTrue;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
Expand All @@ -20,19 +21,18 @@
* Tests related to Security
*
*/
@Ignore
public class InstallerTest {
private static Charset charset = StandardCharsets.UTF_8;
private static final String NL = System.getProperty("line.separator");

@Before
public void setup() {

public void setup() throws IOException {
shutdownConsole();
}

@After
public void tearDown() {

public void tearDown() throws IOException {
startConsole();
}

/**
Expand Down Expand Up @@ -109,4 +109,51 @@ public static void writeToFile(Path filePath, String content) throws IOException
Files.write(filePath, content.getBytes(charset));
}

public static void shutdownConsole() throws IOException {
try {
String cwsDir = new File(System.getProperty("user.dir")).getParent();
System.out.println(cwsDir);
String stopConsoleScript = cwsDir + "/dist/console-only/cws/stop_cws.sh";
String[] command = {"bash", "-c", "bash " + stopConsoleScript};

Process proc = Runtime.getRuntime().exec(command);
proc.waitFor();
StringBuffer output = new StringBuffer();
BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line = "";
while ((line = reader.readLine())!= null) {
output.append(line + "\n");
}
System.out.println("### " + output);

//Thread.sleep(75000); //wait for shutdown of console.
}
catch (Throwable e) {
System.out.println(e.toString());
}
}

public static void startConsole() throws IOException {
try {
String startConsoleScript = new File(System.getProperty("user.dir")).getParent() + "/dist/console-only/cws/start_cws.sh";
String commandStart = "bash " + startConsoleScript;

Process procStart = Runtime.getRuntime().exec(commandStart);
procStart.waitFor();
StringBuffer outputStart = new StringBuffer();
BufferedReader readerStart = new BufferedReader(new InputStreamReader(procStart.getInputStream()));
String lineStart = "";
while ((lineStart = readerStart.readLine())!= null) {
outputStart.append(lineStart + "\n");
}
System.out.println("### " + outputStart);

//wait for start up of console.
// Thread.sleep(75000);
}
catch (Throwable e) {
System.out.println(e.toString());
}
}

}
1 change: 0 additions & 1 deletion cws-test/src/test/java/jpl/cws/test/Issue16Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
/**
*
*/
@Ignore
public class Issue16Test extends CwsTestBase {
private static final Logger log = LoggerFactory.getLogger(Issue16Test.class);

Expand Down
1 change: 0 additions & 1 deletion cws-test/src/test/java/jpl/cws/test/SecurityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Tests related to Security
*
*/
@Ignore
public class SecurityTest {
private static Charset charset = StandardCharsets.UTF_8;
private static final String NL = System.getProperty("line.separator");
Expand Down
1 change: 0 additions & 1 deletion cws-test/src/test/java/jpl/cws/test/SleepTaskTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package jpl.cws.test;

//import static org.camunda.bpm.engine.test.assertions.ProcessEngineAssertions.assertThat;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.*;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.runtimeService;
import static org.junit.Assert.assertTrue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package jpl.cws.test;

//import static org.camunda.bpm.engine.test.assertions.ProcessEngineAssertions.assertThat;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.*;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.runtimeService;
import static org.junit.Assert.fail;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package jpl.cws.test;

//import static org.camunda.bpm.engine.test.assertions.ProcessEngineAssertions.assertThat;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.*;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.runtimeService;
import static org.junit.Assert.fail;
Expand Down
101 changes: 53 additions & 48 deletions cws-test/src/test/resources/bpmn/test_email_task.bpmn
Original file line number Diff line number Diff line change
@@ -1,56 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://activiti.org/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_Cz7uAKS7EeO8s9siEIxdog" targetNamespace="http://activiti.org/bpmn">
<bpmn2:process id="test_email_task" isExecutable="true">
<bpmn2:serviceTask id="ServiceTask_1" camunda:class="jpl.cws.task.EmailTask" name="send email">
<bpmn2:extensionElements>
<camunda:field name="smtpHost" expression="${execution.getVariable('smtpHost') == null ? 'localhost' : smtpHost}" />
<camunda:field name="smtpPort" expression="${execution.getVariable('smtpPort') == null ? '25' : smtpPort}" />
<camunda:field name="from" expression="[email protected]" />
<camunda:field name="to" expression="[email protected]" />
<camunda:field name="subject" expression="test from CWS" />
<camunda:field name="body" expression="${body}" />
<camunda:field expression="html" name="bodyType"/>
</bpmn2:extensionElements>
<bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>
</bpmn2:serviceTask>
<bpmn2:startEvent id="StartEvent_1">
<bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="ServiceTask_1"/>
<bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="ServiceTask_1" targetRef="EndEvent_1"/>
<bpmn2:endEvent id="EndEvent_1">
<bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
</bpmn2:endEvent>
</bpmn2:process>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_00yap56" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1">
<bpmn:process id="test_email_task" name="Test Email Task" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>SequenceFlow_1</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:serviceTask id="ServiceTask_1" name="send email" camunda:class="jpl.cws.task.EmailTask">
<bpmn:extensionElements>
<camunda:field name="smtpHost">
<camunda:expression>${execution.getVariable('smtpHost') == null ? 'localhost' : smtpHost}</camunda:expression>
</camunda:field>
<camunda:field name="smtpPort">
<camunda:expression>${execution.getVariable('smtpPort') == null ? '25' : smtpPort}</camunda:expression>
</camunda:field>
<camunda:field name="from">
<camunda:expression>[email protected]</camunda:expression>
</camunda:field>
<camunda:field name="to">
<camunda:expression>[email protected]</camunda:expression>
</camunda:field>
<camunda:field name="subject">
<camunda:expression>test from CWS</camunda:expression>
</camunda:field>
<camunda:field name="body">
<camunda:expression>${body}</camunda:expression>
</camunda:field>
<camunda:field name="bodyType">
<camunda:expression>html</camunda:expression>
</camunda:field>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_2</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:endEvent id="EndEvent_1">
<bpmn:incoming>SequenceFlow_2</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_1" sourceRef="StartEvent_1" targetRef="ServiceTask_1" />
<bpmn:sequenceFlow id="SequenceFlow_2" sourceRef="ServiceTask_1" targetRef="EndEvent_1" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="email_task_test">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="test_email_task">
<bpmndi:BPMNEdge id="Flow_1in0ucq_di" bpmnElement="SequenceFlow_1">
<di:waypoint x="215" y="117" />
<di:waypoint x="280" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1ym5xir_di" bpmnElement="SequenceFlow_2">
<di:waypoint x="380" y="117" />
<di:waypoint x="442" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds height="36.0" width="36.0" x="612.0" y="287.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="630.0" y="328.0"/>
</bpmndi:BPMNLabel>
<dc:Bounds x="179" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_ServiceTask_2" bpmnElement="ServiceTask_1">
<dc:Bounds height="80.0" width="100.0" x="691.0" y="265.0"/>
<bpmndi:BPMNShape id="Activity_0zgipi5_di" bpmnElement="ServiceTask_1">
<dc:Bounds x="280" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_EndEvent_2" bpmnElement="EndEvent_1">
<dc:Bounds height="36.0" width="36.0" x="840.0" y="287.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="858.0" y="328.0"/>
</bpmndi:BPMNLabel>
<bpmndi:BPMNShape id="Event_1dkf61l_di" bpmnElement="EndEvent_1">
<dc:Bounds x="442" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_2" targetElement="_BPMNShape_ServiceTask_2">
<di:waypoint xsi:type="dc:Point" x="648.0" y="305.0"/>
<di:waypoint xsi:type="dc:Point" x="691.0" y="305.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ServiceTask_2" targetElement="_BPMNShape_EndEvent_2">
<di:waypoint xsi:type="dc:Point" x="791.0" y="305.0"/>
<di:waypoint xsi:type="dc:Point" x="840.0" y="305.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="816.0" y="305.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
</bpmn:definitions>
7 changes: 7 additions & 0 deletions cws-test/src/test/resources/camunda.cfg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,12 @@
<bean class="org.camunda.bpm.engine.test.mock.MockExpressionManager" />
</property>

<property name="processEnginePlugins">
<list>
<bean id="procAppEventListenerPlugin" class="org.camunda.bpm.application.impl.event.ProcessApplicationEventListenerPlugin" />
<bean id="spinProcessEnginePlugin" class="org.camunda.spin.plugin.impl.SpinProcessEnginePlugin" />
</list>
</property>

</bean>
</beans>
Loading