Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/intuit/karate into featu…
Browse files Browse the repository at this point in the history
…res/logbackConfigMain
  • Loading branch information
ivangsa committed Feb 4, 2021
2 parents 72f3d8a + 343487a commit deaa44c
Show file tree
Hide file tree
Showing 64 changed files with 1,132 additions and 533 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ jobs:
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: build with maven
run: mvn -B clean install -P pre-release -Djavacpp.platform=linux-x86_64
run: mvn -B clean install -P pre-release -Djavacpp.platform=linux-x86_64
- name: build and test with docker
run: ./build-docker.sh
216 changes: 57 additions & 159 deletions README.md

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions examples/gatling/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ plugins {
}

ext {
karateVersion = '0.9.6'
karateVersion = '1.0.0'
}

dependencies {
testCompile "com.intuit.karate:karate-apache:${karateVersion}"
testCompile "com.intuit.karate:karate-gatling:${karateVersion}"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class CatsKarateSimulation extends Simulation {
protocol.nameResolver = (req, ctx) => req.getHeader("karate-name")

val create = scenario("create").feed(feeder).exec(karateFeature("classpath:mock/cats-create.feature"))
val delete = scenario("delete").exec(karateFeature("classpath:mock/cats-delete.feature@name=delete"))
val delete = scenario("delete").group("delete cats") {
exec(karateFeature("classpath:mock/cats-delete.feature@name=delete"))
}
val custom = scenario("custom").exec(karateFeature("classpath:mock/custom-rpc.feature"))

setUp(
Expand Down
5 changes: 2 additions & 3 deletions examples/jobserver/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ plugins {
}

ext {
karateVersion = '0.9.6'
karateVersion = '1.0.0'
}

dependencies {
testCompile "com.intuit.karate:karate-junit5:${karateVersion}"
testCompile "com.intuit.karate:karate-apache:${karateVersion}"
}

sourceSets {
Expand All @@ -34,5 +33,5 @@ repositories {

task karateDebug(type: JavaExec) {
classpath = sourceSets.test.runtimeClasspath
main = 'com.intuit.karate.cli.Main'
main = 'com.intuit.karate.Main'
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
function fn() {
function fn() {
var env = karate.env; // get system property 'karate.env'
karate.log('karate.env system property was:', env);
if (!env) {
env = 'dev';
}
var config = {
env: env,
myVarName: 'someValue'
myVarName: 'someValue'
}
if (env == 'dev') {
// customize
Expand Down
19 changes: 4 additions & 15 deletions karate-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<dependency>
<groupId>com.linecorp.armeria</groupId>
<artifactId>armeria</artifactId>
<version>1.3.0</version>
</dependency>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
Expand Down Expand Up @@ -202,7 +202,6 @@
<include>io.micrometer:*</include>
<include>org.reactivestreams:*</include>
<include>io.netty:*</include>
<include>io.netty.incubator:*</include>
<include>org.apache.httpcomponents:*</include>
<include>org.antlr:*</include>
<include>io.github.classgraph:*</include>
Expand Down Expand Up @@ -234,17 +233,11 @@
<shadedPattern>karate.nonapi.io.github.classgraph.</shadedPattern>
</relocation>
</relocations>
<filters>
<filter>
<artifact>io.netty.incubator:netty-incubator-transport-native-io_uring</artifact>
<excludes>
<exclude>META-INF/native/libnetty_transport_native_io_uring_x86_64.so</exclude>
</excludes>
</filter>
<filters>
<filter>
<artifact>io.netty:netty-transport-native-epoll</artifact>
<excludes>
<exclude>META-INF/native/libnetty_transport_native_epoll_x86_64.so</exclude>
<exclude>META-INF/native/libnetty_transport_native_epoll_x86_64.so</exclude>
</excludes>
</filter>
<filter>
Expand All @@ -260,10 +253,6 @@
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.intuit.karate.Main</mainClass>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
<resource>META-INF/native/libkarate_netty_transport_native_io_uring_x86_64.so</resource>
<file>target/shade/META-INF/native/libnetty_transport_native_io_uring_x86_64.so</file>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
<resource>META-INF/native/libkarate_netty_transport_native_epoll_x86_64.so</resource>
Expand Down
1 change: 1 addition & 0 deletions karate-core/src/main/java/com/intuit/karate/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ private Constants() {

public static final String KARATE_ENV = "karate.env";
public static final String KARATE_CONFIG_DIR = "karate.config.dir";
public static final String KARATE_CONFIG_INCL_RESULT_METHOD = "karate.config.result.result-method.include";
public static final String KARATE_OUTPUT_DIR = "karate.output.dir";
public static final String KARATE_OPTIONS = "karate.options";
public static final String KARATE_REPORTS = "karate-reports";
Expand Down
32 changes: 16 additions & 16 deletions karate-core/src/main/java/com/intuit/karate/Json.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ public static Json array() {
return Json.of("[]");
}

public static Json of(Object o) {
if (o instanceof String) {
return new Json(JsonPath.parse((String) o));
} else if (o instanceof List) {
return new Json(JsonPath.parse((List) o));
} else if (o instanceof Map) {
return new Json(JsonPath.parse((Map) o));
public static Json of(Object any) {
if (any instanceof String) {
return new Json(JsonPath.parse((String) any));
} else if (any instanceof List) {
return new Json(JsonPath.parse((List) any));
} else if (any instanceof Map) {
return new Json(JsonPath.parse((Map) any));
} else {
String json = JsonUtils.toJson(o);
String json = JsonUtils.toJson(any);
return new Json(JsonPath.parse(json));
}
}
Expand Down Expand Up @@ -138,14 +138,14 @@ public Map<String, Object> asMap() {
return value();
}

public Json set(String path, String s) {
if (JsonUtils.isJson(s)) {
setInternal(path, Json.of(s).value());
public Json set(String path, String value) {
if (JsonUtils.isJson(value)) {
setInternal(path, Json.of(value).value());
} else {
if (s != null && s.charAt(0) == '\\') {
s = s.substring(1);
if (value != null && value.charAt(0) == '\\') {
value = value.substring(1);
}
setInternal(path, s);
setInternal(path, value);
}
return this;
}
Expand All @@ -155,8 +155,8 @@ public Json remove(String path) {
return this;
}

public Json set(String path, Object o) {
setInternal(path, o);
public Json set(String path, Object value) {
setInternal(path, value);
return this;
}

Expand Down
4 changes: 2 additions & 2 deletions karate-core/src/main/java/com/intuit/karate/JsonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,11 @@ private static void recurseJsonString(Object o, boolean pretty, StringBuilder sb
Iterator<Map.Entry<String, Object>> iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, Object> entry = iterator.next();
String key = entry.getKey();
Object key = entry.getKey(); // found a rare case where this was a boolean
if (pretty) {
pad(sb, depth + 1);
}
sb.append('"').append(escapeValue(key)).append('"').append(':');
sb.append('"').append(escapeValue(key == null ? null : key.toString())).append('"').append(':');
if (pretty) {
sb.append(' ');
}
Expand Down
68 changes: 34 additions & 34 deletions karate-core/src/main/java/com/intuit/karate/Match.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ public String toString() {
return sb.toString();
}

public Result is(Type mt, Object o) {
MatchOperation mo = new MatchOperation(mt, this, new Value(parseIfJsonOrXmlString(o), exceptionOnMatchFailure));
public Result is(Type matchType, Object expected) {
MatchOperation mo = new MatchOperation(matchType, this, new Value(parseIfJsonOrXmlString(expected), exceptionOnMatchFailure));
mo.execute();
if (mo.pass) {
return Match.PASS;
Expand All @@ -352,60 +352,60 @@ public Result is(Type mt, Object o) {

//======================================================================
//
public Result isEqualTo(Object o) {
return is(Type.EQUALS, o);
public Result isEqualTo(Object expected) {
return is(Type.EQUALS, expected);
}

public Result contains(Object o) {
return is(Type.CONTAINS, o);
public Result contains(Object expected) {
return is(Type.CONTAINS, expected);
}

public Result containsDeep(Object o) {
return is(Type.CONTAINS_DEEP, o);
public Result containsDeep(Object expected) {
return is(Type.CONTAINS_DEEP, expected);
}

public Result containsOnly(Object o) {
return is(Type.CONTAINS_ONLY, o);
public Result containsOnly(Object expected) {
return is(Type.CONTAINS_ONLY, expected);
}

public Result containsAny(Object o) {
return is(Type.CONTAINS_ANY, o);
public Result containsAny(Object expected) {
return is(Type.CONTAINS_ANY, expected);
}

public Result isNotEqualTo(Object o) {
return is(Type.NOT_EQUALS, o);
public Result isNotEqualTo(Object expected) {
return is(Type.NOT_EQUALS, expected);
}

public Result isNotContaining(Object o) {
return is(Type.NOT_CONTAINS, o);
public Result isNotContaining(Object expected) {
return is(Type.NOT_CONTAINS, expected);
}

public Result isEachEqualTo(Object o) {
return is(Type.EACH_EQUALS, o);
public Result isEachEqualTo(Object expected) {
return is(Type.EACH_EQUALS, expected);
}

public Result isEachNotEqualTo(Object o) {
return is(Type.EACH_NOT_EQUALS, o);
public Result isEachNotEqualTo(Object expected) {
return is(Type.EACH_NOT_EQUALS, expected);
}

public Result isEachContaining(Object o) {
return is(Type.EACH_CONTAINS, o);
public Result isEachContaining(Object expected) {
return is(Type.EACH_CONTAINS, expected);
}

public Result isEachNotContaining(Object o) {
return is(Type.EACH_NOT_CONTAINS, o);
public Result isEachNotContaining(Object expected) {
return is(Type.EACH_NOT_CONTAINS, expected);
}

public Result isEachContainingDeep(Object o) {
return is(Type.EACH_CONTAINS_DEEP, o);
public Result isEachContainingDeep(Object expected) {
return is(Type.EACH_CONTAINS_DEEP, expected);
}

public Result isEachContainingOnly(Object o) {
return is(Type.EACH_CONTAINS_ONLY, o);
public Result isEachContainingOnly(Object expected) {
return is(Type.EACH_CONTAINS_ONLY, expected);
}

public Result isEachContainingAny(Object o) {
return is(Type.EACH_CONTAINS_ANY, o);
public Result isEachContainingAny(Object expected) {
return is(Type.EACH_CONTAINS_ANY, expected);
}

}
Expand Down Expand Up @@ -438,12 +438,12 @@ public static Object parseIfJsonOrXmlString(Object o) {
return o;
}

public static Value evaluate(Object o) {
return new Value(parseIfJsonOrXmlString(o), false);
public static Value evaluate(Object actual) {
return new Value(parseIfJsonOrXmlString(actual), false);
}

public static Value that(Object o) {
return new Value(parseIfJsonOrXmlString(o), true);
public static Value that(Object actual) {
return new Value(parseIfJsonOrXmlString(actual), true);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ private boolean macroEqualsExpected(String expStr) {
if (validator != null) {
if (optional && actual.isNotPresent()) {
// pass
} else if (!optional && actual.isNotPresent()) {
// if the element is not present the expected result can only be
// the notpresent keyword, ignored or an optional comparison
return expected.isNotPresent() || "#ignore".contentEquals(expected.getAsString());
} else {
Match.Result mr = validator.apply(actual);
if (!mr.pass) {
Expand Down
Loading

0 comments on commit deaa44c

Please sign in to comment.