From 6e598589bff974f5fa43696a6e59c2f326a2c449 Mon Sep 17 00:00:00 2001 From: Ivan Garcia Sainz-Aja Date: Sun, 3 Mar 2024 19:58:15 +0100 Subject: [PATCH] upgrade to karate 1.4.1 --- pom.xml | 20 ++++++++-------- .../com/intuit/karate/core/MockHandler.java | 24 ++++++++++++++++++- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 2c094c1..44e6bb3 100644 --- a/pom.xml +++ b/pom.xml @@ -15,9 +15,9 @@ UTF-8 UTF-8 - 1.8 - 1.8 - 1.4.0 + 11 + 11 + 1.4.1 1.13.4 1.0.7 2.14.2 @@ -255,12 +255,12 @@ openapi-operation-validator ${openapi4j.version} - - com.linecorp.armeria - armeria - ${armeria.version} - provided - + + + + + + junit @@ -318,7 +318,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.2.4 + 3.5.2 package diff --git a/src/main/java/com/intuit/karate/core/MockHandler.java b/src/main/java/com/intuit/karate/core/MockHandler.java index 28b01c7..92a8e30 100644 --- a/src/main/java/com/intuit/karate/core/MockHandler.java +++ b/src/main/java/com/intuit/karate/core/MockHandler.java @@ -39,6 +39,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; @@ -188,7 +189,7 @@ private void initRuntime(ScenarioRuntime runtime) { runtime.engine.init(); } - private static final Result PASSED = Result.passed(0); + private static final Result PASSED = passed(); private static final String ALLOWED_METHODS = "GET, HEAD, POST, PUT, DELETE, PATCH"; @Override @@ -441,4 +442,25 @@ public Object bodyPath(String path) { } } + private static Result passed() { + try { + Method method = Result.class.getMethod("passed", long.class, long.class); + return (Result) method.invoke(null, 0L, 0L); + } catch (NoSuchMethodException ignored) { + // ignored + } + catch(InvocationTargetException|IllegalAccessException e) { + System.err.println("Error invoking method: Result.passed(0, 0). Please upgrade to karate +1.4.1"); // karate 1.4.1 + } + try { + Method method = Result.class.getMethod("passed", long.class); + return (Result) method.invoke(null, 0L); + } catch (NoSuchMethodException ignored) { + // ignored + } + catch(InvocationTargetException|IllegalAccessException e) { + System.err.println("Error invoking method: Result.passed(0)"); // karate 1.4.0 + } + return Result.passed(0, 0); + } }