From 568bd01de186eafb3a41f191c2693e2156df56fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Petrovick=C3=BD?= Date: Thu, 23 Sep 2021 19:47:28 +0200 Subject: [PATCH] KOGITO-5941 Introduce changes to successfully run tests with JDK 17 (#1607) --- .../mongodb/MongoDBProcessInstancesIT.java | 4 +-- .../org/acme/travels/ManagementAddOnTest.java | 4 +-- .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../integrationtests/quarkus/BasicRestIT.java | 2 +- .../integrationtests/quarkus/EnumsIT.java | 2 +- .../quarkus/ManagementAddOnIT.java | 4 +-- .../quarkus/ParentSubProcessIT.java | 2 +- .../quarkus/PingPongMessageIT.java | 4 +-- .../springboot/BasicRestTest.java | 2 +- .../springboot/EnumsTest.java | 2 +- .../springboot/ManagementAddOnTest.java | 4 +-- .../springboot/ParentSubProcessTest.java | 2 +- .../springboot/PingPongMessageTest.java | 4 +-- jbpm/jbpm-flow-builder/pom.xml | 16 ++++++++++++ jbpm/jbpm-flow/pom.xml | 13 ++++++++++ .../instance/impl/JavaScriptAction.java | 13 ++++++++-- .../impl/JavaScriptReturnValueEvaluator.java | 4 +-- kogito-build/kogito-build-parent/pom.xml | 2 +- kogito-build/kogito-dependencies-bom/pom.xml | 26 ++++++++++++++----- .../kogito/codegen/tests/PublishEventIT.java | 4 +-- kogito-test-utils/pom.xml | 5 ++++ .../src/test/resources/logback-test.xml | 16 ++++++++++++ .../kafka/KafkaProcessInstancesIT.java | 4 +-- ...dDependencyToPomWithTextReplaceTest.groovy | 5 ++-- 24 files changed, 108 insertions(+), 38 deletions(-) create mode 100644 kogito-test-utils/src/test/resources/logback-test.xml diff --git a/addons/common/persistence/mongodb/src/test/java/org/kie/kogito/mongodb/MongoDBProcessInstancesIT.java b/addons/common/persistence/mongodb/src/test/java/org/kie/kogito/mongodb/MongoDBProcessInstancesIT.java index ab4430987ef..3cbf11e405d 100644 --- a/addons/common/persistence/mongodb/src/test/java/org/kie/kogito/mongodb/MongoDBProcessInstancesIT.java +++ b/addons/common/persistence/mongodb/src/test/java/org/kie/kogito/mongodb/MongoDBProcessInstancesIT.java @@ -217,7 +217,7 @@ void testFindByIdReadMode(MongoDBTransactionManager transactionManager) { mutablePi.start(); assertThat(mutablePi.status()).isEqualTo(STATE_ERROR); assertThat(mutablePi.error()).hasValueSatisfying(error -> { - assertThat(error.errorMessage()).endsWith("java.lang.NullPointerException - null"); + assertThat(error.errorMessage()).contains("java.lang.NullPointerException"); assertThat(error.failedNodeId()).isEqualTo("ScriptTask_1"); }); assertThat(mutablePi.variables().toMap()).containsExactly(entry("var", "value")); @@ -230,7 +230,7 @@ void testFindByIdReadMode(MongoDBTransactionManager transactionManager) { ProcessInstance readOnlyPi = instances.findById(mutablePi.id(), ProcessInstanceReadMode.READ_ONLY).get(); assertThat(readOnlyPi.status()).isEqualTo(STATE_ERROR); assertThat(readOnlyPi.error()).hasValueSatisfying(error -> { - assertThat(error.errorMessage()).endsWith("java.lang.NullPointerException - null"); + assertThat(error.errorMessage()).contains("java.lang.NullPointerException"); assertThat(error.failedNodeId()).isEqualTo("ScriptTask_1"); }); assertThat(readOnlyPi.variables().toMap()).containsExactly(entry("var", "value")); diff --git a/integration-tests/integration-tests-kogito-plugin/src/it/integration-tests-kogito-plugin-it/src/test/java/org/acme/travels/ManagementAddOnTest.java b/integration-tests/integration-tests-kogito-plugin/src/it/integration-tests-kogito-plugin-it/src/test/java/org/acme/travels/ManagementAddOnTest.java index d5a81405a4b..460a9328fa0 100644 --- a/integration-tests/integration-tests-kogito-plugin/src/it/integration-tests-kogito-plugin-it/src/test/java/org/acme/travels/ManagementAddOnTest.java +++ b/integration-tests/integration-tests-kogito-plugin/src/it/integration-tests-kogito-plugin-it/src/test/java/org/acme/travels/ManagementAddOnTest.java @@ -85,7 +85,7 @@ void testGetNodeInstances() { .get("/management/processes/{processId}/instances/{processInstanceId}/nodeInstances", "greetings", pid) .then() .statusCode(200) - .body("$.size", is(2)) + .body("$.size()", is(2)) .body("[0].name", is("Task")) .body("[0].state", is(0)) .body("[1].name", is("Task")) @@ -100,7 +100,7 @@ void testGetProcessNodes() { .get("/management/processes/{processId}/nodes", "greetings") .then() .statusCode(200) - .body("$.size", is(10)) + .body("$.size()", is(10)) .body("[0].id", is(1)) .body("[0].name", is("End")) .body("[0].type", is("EndNode")) diff --git a/integration-tests/integration-tests-quarkus-gradle/integration-tests-quarkus-gradle-project/gradle/wrapper/gradle-wrapper.properties b/integration-tests/integration-tests-quarkus-gradle/integration-tests-quarkus-gradle-project/gradle/wrapper/gradle-wrapper.properties index 549d84424d0..ffed3a254e9 100644 --- a/integration-tests/integration-tests-quarkus-gradle/integration-tests-quarkus-gradle-project/gradle/wrapper/gradle-wrapper.properties +++ b/integration-tests/integration-tests-quarkus-gradle/integration-tests-quarkus-gradle-project/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/BasicRestIT.java b/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/BasicRestIT.java index 58e72c00817..f0d51961c84 100644 --- a/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/BasicRestIT.java +++ b/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/BasicRestIT.java @@ -268,7 +268,7 @@ void testGetTasks() { .get("/AdHocFragments/{id}/tasks", id) .then() .statusCode(200) - .body("$.size", is(1)) + .body("$.size()", is(1)) .body("[0].name", is("Task")); assertExpectedUnitOfWorkEvents(1); diff --git a/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/EnumsIT.java b/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/EnumsIT.java index 8bdb9cf97d1..9c214b2f855 100644 --- a/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/EnumsIT.java +++ b/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/EnumsIT.java @@ -69,7 +69,7 @@ void testSubmitMovie() { .get("/cinema/{pid}/tasks", pid) .then() .statusCode(200) - .body("$.size", is(1)) + .body("$.size()", is(1)) .body("[0].name", is("ReviewRatingTask")) .extract() .path("[0].id"); diff --git a/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/ManagementAddOnIT.java b/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/ManagementAddOnIT.java index ef78c79397e..b8d9ab0ea5f 100644 --- a/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/ManagementAddOnIT.java +++ b/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/ManagementAddOnIT.java @@ -74,7 +74,7 @@ void testGetNodeInstances() { .get("/management/processes/{processId}/instances/{processInstanceId}/nodeInstances", GREETINGS, pid) .then() .statusCode(200) - .body("$.size", is(2)) + .body("$.size()", is(2)) .body("$", hasItems(hasEntry("name", "Hello1"), hasEntry("name", "Hello2"))) .body("[0].state", is(0)) .body("[1].state", is(0)); @@ -87,7 +87,7 @@ void testGetProcessNodes() { .get("/management/processes/{processId}/nodes", GREETINGS) .then() .statusCode(200) - .body("$.size", is(10)) + .body("$.size()", is(10)) .body("[0].id", is(1)) .body("[0].name", is("End")) .body("[0].type", is("EndNode")) diff --git a/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/ParentSubProcessIT.java b/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/ParentSubProcessIT.java index e5609f6df8d..4a352dfd2a9 100644 --- a/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/ParentSubProcessIT.java +++ b/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/ParentSubProcessIT.java @@ -69,7 +69,7 @@ public void testParentSubProcessRest() { String taskId = given().accept(ContentType.JSON) .when().get("/subprocess/{uuid}/tasks?user=john", subProcessId) .then().statusCode(200) - .body("$.size", is(1)) + .body("$.size()", is(1)) .body("[0].parameters.param_name", is(name)) .extract().path("[0].id"); diff --git a/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/PingPongMessageIT.java b/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/PingPongMessageIT.java index 9594d727fc6..de396cfe262 100644 --- a/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/PingPongMessageIT.java +++ b/integration-tests/integration-tests-quarkus-processes/src/test/java/org/kie/kogito/integrationtests/quarkus/PingPongMessageIT.java @@ -82,7 +82,7 @@ private void validateSubProcess() { .get("/pong_message/") .then() .statusCode(200) - .body("$.size", equalTo(1))); + .body("$.size()", equalTo(1))); String pId = given() .contentType(ContentType.JSON) @@ -90,7 +90,7 @@ private void validateSubProcess() { .get("/pong_message/") .then() .statusCode(200) - .body("$.size", equalTo(1)) + .body("$.size()", equalTo(1)) .extract().body().path("[0].id"); given() diff --git a/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicRestTest.java b/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicRestTest.java index 286ff60a49a..5f7fde6df4e 100644 --- a/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicRestTest.java +++ b/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-it/src/test/java/org/kie/kogito/integrationtests/springboot/BasicRestTest.java @@ -260,7 +260,7 @@ void testGetTasks() { .get("/AdHocFragments/{id}/tasks", id) .then() .statusCode(200) - .body("$.size", is(1)) + .body("$.size()", is(1)) .body("[0].name", is("Task")); assertExpectedUnitOfWorkEvents(1); diff --git a/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-it/src/test/java/org/kie/kogito/integrationtests/springboot/EnumsTest.java b/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-it/src/test/java/org/kie/kogito/integrationtests/springboot/EnumsTest.java index d59d1695e4c..accc8afbb72 100644 --- a/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-it/src/test/java/org/kie/kogito/integrationtests/springboot/EnumsTest.java +++ b/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-it/src/test/java/org/kie/kogito/integrationtests/springboot/EnumsTest.java @@ -69,7 +69,7 @@ void testSubmitMovie() { .get("/cinema/{pid}/tasks", pid) .then() .statusCode(200) - .body("$.size", is(1)) + .body("$.size()", is(1)) .extract() .as(TestWorkItem[].class)[0]; diff --git a/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-it/src/test/java/org/kie/kogito/integrationtests/springboot/ManagementAddOnTest.java b/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-it/src/test/java/org/kie/kogito/integrationtests/springboot/ManagementAddOnTest.java index 0e65a931519..e299d22708e 100644 --- a/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-it/src/test/java/org/kie/kogito/integrationtests/springboot/ManagementAddOnTest.java +++ b/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-it/src/test/java/org/kie/kogito/integrationtests/springboot/ManagementAddOnTest.java @@ -75,7 +75,7 @@ void testGetNodeInstances() { .get("/management/processes/{processId}/instances/{processInstanceId}/nodeInstances", GREETINGS, pid) .then() .statusCode(200) - .body("$.size", is(2)) + .body("$.size()", is(2)) .body("$", hasItems(hasEntry("name", "Hello1"),hasEntry("name", "Hello2"))) .body("[0].state", is(0)) .body("[1].state", is(0)); @@ -88,7 +88,7 @@ void testGetProcessNodes() { .get("/management/processes/{processId}/nodes", GREETINGS) .then() .statusCode(200) - .body("$.size", is(10)) + .body("$.size()", is(10)) .body("[0].id", is(1)) .body("[0].name", is("End")) .body("[0].type", is("EndNode")) diff --git a/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-it/src/test/java/org/kie/kogito/integrationtests/springboot/ParentSubProcessTest.java b/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-it/src/test/java/org/kie/kogito/integrationtests/springboot/ParentSubProcessTest.java index e67536936c5..3aae23b6465 100644 --- a/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-it/src/test/java/org/kie/kogito/integrationtests/springboot/ParentSubProcessTest.java +++ b/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-it/src/test/java/org/kie/kogito/integrationtests/springboot/ParentSubProcessTest.java @@ -67,7 +67,7 @@ public void testParentSubProcessRest() { String taskId = given().accept(ContentType.JSON) .when().get("/subprocess/{uuid}/tasks?user=john", subProcessId) .then().statusCode(200) - .body("$.size", is(1)) + .body("$.size()", is(1)) .body("[0].parameters.param_name", is(name)) .extract().path("[0].id"); diff --git a/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/PingPongMessageTest.java b/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/PingPongMessageTest.java index d99d213693c..96c36601001 100644 --- a/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/PingPongMessageTest.java +++ b/integration-tests/integration-tests-springboot/src/it/integration-tests-springboot-kafka-it/src/test/java/org/kie/kogito/integrationtests/springboot/PingPongMessageTest.java @@ -88,7 +88,7 @@ private void validateSubProcess(){ .get("/pong_message/") .then() .statusCode(200) - .body("$.size", equalTo(1))); + .body("$.size()", equalTo(1))); String pId = given() .contentType(ContentType.JSON) @@ -96,7 +96,7 @@ private void validateSubProcess(){ .get("/pong_message/") .then() .statusCode(200) - .body("$.size", equalTo(1)) + .body("$.size()", equalTo(1)) .extract().body().path("[0].id"); given() diff --git a/jbpm/jbpm-flow-builder/pom.xml b/jbpm/jbpm-flow-builder/pom.xml index 7d1e89f8879..e9cec0811ab 100755 --- a/jbpm/jbpm-flow-builder/pom.xml +++ b/jbpm/jbpm-flow-builder/pom.xml @@ -83,4 +83,20 @@ test + + + + java15-javascript + + [15,) + + + + org.mozilla + rhino-engine + test + + + + diff --git a/jbpm/jbpm-flow/pom.xml b/jbpm/jbpm-flow/pom.xml index 1f7f6f97429..a571cf18c32 100755 --- a/jbpm/jbpm-flow/pom.xml +++ b/jbpm/jbpm-flow/pom.xml @@ -87,6 +87,7 @@ com.fasterxml.jackson.datatype jackson-datatype-jsr310 + org.kie.kogito @@ -122,5 +123,17 @@ **/JBPMMessages.java + + java15-javascript + + [15,) + + + + org.mozilla + rhino-engine + + + diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/JavaScriptAction.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/JavaScriptAction.java index f0d920ece63..25a76ed2296 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/JavaScriptAction.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/JavaScriptAction.java @@ -33,6 +33,16 @@ public class JavaScriptAction implements Action, Externalizable { + static ScriptEngine loadJavaScriptEngine() { + ScriptEngineManager factory = new ScriptEngineManager(); + ScriptEngine engine = factory.getEngineByName("JavaScript"); + if (engine != null) { + return engine; + } + throw new IllegalStateException("JavaScript implementation not found on the classpath." + + "If you're running JDK 15 or later, please include org.mozilla:rhino-engine in your project."); + } + private static final long serialVersionUID = 630l; private String expr; @@ -54,8 +64,7 @@ public void writeExternal(ObjectOutput out) throws IOException { @Override public void execute(KogitoProcessContext context) throws Exception { - ScriptEngineManager factory = new ScriptEngineManager(); - ScriptEngine engine = factory.getEngineByName("JavaScript"); + ScriptEngine engine = loadJavaScriptEngine(); engine.put("kcontext", context); // insert globals into context diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/JavaScriptReturnValueEvaluator.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/JavaScriptReturnValueEvaluator.java index 1beda30f010..e9bc4cda460 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/JavaScriptReturnValueEvaluator.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/JavaScriptReturnValueEvaluator.java @@ -23,7 +23,6 @@ import java.util.Map.Entry; import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.process.instance.context.variable.VariableScopeInstance; @@ -53,8 +52,7 @@ public void writeExternal(ObjectOutput out) throws IOException { } public Object evaluate(KogitoProcessContext context) throws Exception { - ScriptEngineManager factory = new ScriptEngineManager(); - ScriptEngine engine = factory.getEngineByName("JavaScript"); + ScriptEngine engine = JavaScriptAction.loadJavaScriptEngine(); // insert globals into context Globals globals = context.getKieRuntime().getGlobals(); diff --git a/kogito-build/kogito-build-parent/pom.xml b/kogito-build/kogito-build-parent/pom.xml index de0c0d5a338..624579ba5d8 100644 --- a/kogito-build/kogito-build-parent/pom.xml +++ b/kogito-build/kogito-build-parent/pom.xml @@ -76,7 +76,7 @@ 1.8.2 1.8 - 3.0.1 + 3.2.0 1.5.2.1 3.0.0 3.1.0 diff --git a/kogito-build/kogito-dependencies-bom/pom.xml b/kogito-build/kogito-dependencies-bom/pom.xml index 77985541084..7dacbc72eca 100644 --- a/kogito-build/kogito-dependencies-bom/pom.xml +++ b/kogito-build/kogito-dependencies-bom/pom.xml @@ -33,7 +33,8 @@ 5.0.1 0.2.0 - 2.3.0 + 2.3.0.1 + 2.3.5 1.2.0 1.4.17 1.3.2 @@ -68,17 +69,18 @@ 4.3.1 4.2.3 4.1.0 + 1.7.13 3.20.2 2.9.0 1.3 - 7.2 + 8.0 5.${version.org.junit.minor} ${version.org.junit} ${version.org.junit} 1.${version.org.junit.minor} - 1.0.0 - 3.11.2 + 1.4.2 + 3.12.4 1.15.3 2.4.12.Final @@ -145,6 +147,18 @@ ${version.ch.qos.logback} + + + org.mozilla + rhino + ${version.org.mozilla.rhino} + + + org.mozilla + rhino-engine + ${version.org.mozilla.rhino} + + com.github.javaparser @@ -406,12 +420,12 @@ com.sun.xml.bind jaxb-core - ${version.com.sun.xml.bind} + ${version.com.sun.xml.bind.core} com.sun.xml.bind jaxb-impl - ${version.com.sun.xml.bind} + ${version.com.sun.xml.bind.impl} com.sun.activation diff --git a/kogito-codegen-modules/kogito-codegen-integration-tests/src/test/java/org/kie/kogito/codegen/tests/PublishEventIT.java b/kogito-codegen-modules/kogito-codegen-integration-tests/src/test/java/org/kie/kogito/codegen/tests/PublishEventIT.java index 5f07e388202..185304d0ea1 100644 --- a/kogito-codegen-modules/kogito-codegen-integration-tests/src/test/java/org/kie/kogito/codegen/tests/PublishEventIT.java +++ b/kogito-codegen-modules/kogito-codegen-integration-tests/src/test/java/org/kie/kogito/codegen/tests/PublishEventIT.java @@ -531,7 +531,7 @@ public void testServiceTaskProcessWithError() throws Exception { assertThat(body.getNodeInstances()).extractingResultOf("getLeaveTime").containsNull();// human task is active thus null for leave time assertThat(body.getError()).isNotNull(); - assertThat(body.getError().getErrorMessage()).contains("java.lang.NullPointerException - null"); + assertThat(body.getError().getErrorMessage()).contains("java.lang.NullPointerException"); assertThat(body.getError().getNodeDefinitionId()).isEqualTo("_38E04E27-3CCA-47F9-927B-E37DC4B8CE25"); parameters.put("s", "john"); @@ -545,7 +545,7 @@ public void testServiceTaskProcessWithError() throws Exception { assertThat(events).isNotNull().hasSize(1); body = assertProcessInstanceEvent(events.get(0), "ServiceProcessDifferentOperations", "Service Process", 5); assertThat(body.getError()).isNotNull(); - assertThat(body.getError().getErrorMessage()).contains("java.lang.NullPointerException - null"); + assertThat(body.getError().getErrorMessage()).contains("java.lang.NullPointerException"); assertThat(body.getError().getNodeDefinitionId()).isEqualTo("_38E04E27-3CCA-47F9-927B-E37DC4B8CE25"); uow = app.unitOfWorkManager().newUnitOfWork(); diff --git a/kogito-test-utils/pom.xml b/kogito-test-utils/pom.xml index ebb10b3bf1f..1566a0a36f4 100644 --- a/kogito-test-utils/pom.xml +++ b/kogito-test-utils/pom.xml @@ -86,6 +86,11 @@ mockito-core test + + ch.qos.logback + logback-classic + test + diff --git a/kogito-test-utils/src/test/resources/logback-test.xml b/kogito-test-utils/src/test/resources/logback-test.xml new file mode 100644 index 00000000000..2fe8072965e --- /dev/null +++ b/kogito-test-utils/src/test/resources/logback-test.xml @@ -0,0 +1,16 @@ + + + + + + + %d{HH:mm:ss.SSS} [%-12.12t] %-5p %m%n + + + + + + + + + diff --git a/quarkus/addons/persistence/kafka/runtime/src/test/java/org/kie/kogito/persistence/kafka/KafkaProcessInstancesIT.java b/quarkus/addons/persistence/kafka/runtime/src/test/java/org/kie/kogito/persistence/kafka/KafkaProcessInstancesIT.java index b857f4f2c2b..2cd8dbf62f6 100644 --- a/quarkus/addons/persistence/kafka/runtime/src/test/java/org/kie/kogito/persistence/kafka/KafkaProcessInstancesIT.java +++ b/quarkus/addons/persistence/kafka/runtime/src/test/java/org/kie/kogito/persistence/kafka/KafkaProcessInstancesIT.java @@ -101,7 +101,7 @@ void testFindByIdReadMode() { mutablePi.start(); assertThat(mutablePi.status()).isEqualTo(STATE_ERROR); assertThat(mutablePi.error()).hasValueSatisfying(error -> { - assertThat(error.errorMessage()).endsWith("java.lang.NullPointerException - null"); + assertThat(error.errorMessage()).contains("java.lang.NullPointerException"); assertThat(error.failedNodeId()).isEqualTo("ScriptTask_1"); }); assertThat(mutablePi.variables().toMap()).containsExactly(entry("var", "value")); @@ -114,7 +114,7 @@ void testFindByIdReadMode() { ProcessInstance readOnlyPi = instances.findById(mutablePi.id(), ProcessInstanceReadMode.READ_ONLY).get(); assertThat(readOnlyPi.status()).isEqualTo(STATE_ERROR); assertThat(readOnlyPi.error()).hasValueSatisfying(error -> { - assertThat(error.errorMessage()).endsWith("java.lang.NullPointerException - null"); + assertThat(error.errorMessage()).contains("java.lang.NullPointerException"); assertThat(error.failedNodeId()).isEqualTo("ScriptTask_1"); }); assertThat(readOnlyPi.variables().toMap()).containsExactly(entry("var", "value")); diff --git a/springboot/archetype/src/test/groovy/org/kie/kogito/springboot/archetypes/AddDependencyToPomWithTextReplaceTest.groovy b/springboot/archetype/src/test/groovy/org/kie/kogito/springboot/archetypes/AddDependencyToPomWithTextReplaceTest.groovy index 2f33e54ed0f..6d5be79dc1f 100644 --- a/springboot/archetype/src/test/groovy/org/kie/kogito/springboot/archetypes/AddDependencyToPomWithTextReplaceTest.groovy +++ b/springboot/archetype/src/test/groovy/org/kie/kogito/springboot/archetypes/AddDependencyToPomWithTextReplaceTest.groovy @@ -18,8 +18,7 @@ package org.kie.kogito.springboot.archetypes import spock.lang.Specification -import java.nio.file.Files -import java.nio.file.Path +import java.nio.charset.StandardCharsets // we can't use XML with the current Archetype plugin see: https://github.com/apache/maven-archetype/pull/58 @@ -40,7 +39,7 @@ class AddDependencyToPomWithTextReplaceTest extends Specification { } when: - String pomFile = Files.readString(Path.of(this.getClass().getResource(pomFile).toURI())) + String pomFile = new String(this.getClass().getResourceAsStream(pomFile).readAllBytes(), StandardCharsets.UTF_8) .replace(" ", dependencies) then: