Skip to content

Commit

Permalink
upgrade to karate 1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ivangsa committed Mar 3, 2024
1 parent 267e784 commit 6e59858
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
20 changes: 10 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<karate.version>1.4.0</karate.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<karate.version>1.4.1</karate.version>
<armeria.version>1.13.4</armeria.version>
<openapi4j.version>1.0.7</openapi4j.version>
<jackson-dataformat-yaml.version>2.14.2</jackson-dataformat-yaml.version>
Expand Down Expand Up @@ -255,12 +255,12 @@
<artifactId>openapi-operation-validator</artifactId>
<version>${openapi4j.version}</version>
</dependency>
<dependency>
<groupId>com.linecorp.armeria</groupId>
<artifactId>armeria</artifactId>
<version>${armeria.version}</version>
<scope>provided</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.linecorp.armeria</groupId>-->
<!-- <artifactId>armeria</artifactId>-->
<!-- <version>${armeria.version}</version>-->
<!-- <scope>provided</scope>-->
<!-- </dependency>-->

<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -318,7 +318,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<version>3.5.2</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
24 changes: 23 additions & 1 deletion src/main/java/com/intuit/karate/core/MockHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 6e59858

Please sign in to comment.