Reputation: 99
I've stumbled uppon a JSON matching behaviour that doesn't make sense for me at all, because if I execute my feature via parallel runner, the matching fails (which shouldn't). But if I run the feature standalone (in IntelliJ, run feature), the matching succeeds as expected. I am almost losing my mind over this. :)
This is the actual response I get from an REST call:
[
{
"servicePointInfo": {
"cplID": "CPL123",
"klsID": 26035132,
"type": "Gebaeudeteil",
"state": "FREI",
"stateText": "Freier Service Point",
"plannedDisconnectDate": null,
"recentInfo": {
"firstName": null,
"surname": null,
"MSN0": null
}
},
"buildingInfo": {
"type": null,
"typeText": null,
"part": "FeH",
"partText": "Fernsprechh�uschen",
"partNumber": null,
"partInfo": "vor Telekom",
"partAlignment": null,
"level": null,
"levelText": null,
"levelNumber": null,
"floor": null,
"floorText": null,
"flatNumber": null,
"flatInfo": null
}
},
{
"servicePointInfo": {
"cplID": "CPL456",
"klsID": 26035132,
"type": "Wohnung",
"state": "FREI",
"stateText": "Freier Service Point",
"plannedDisconnectDate": null,
"recentInfo": {
"firstName": "Karl",
"surname": "Schaefer",
"MSN0": null
}
},
"buildingInfo": {
"type": "M",
"typeText": "Mehrfamilienhaus",
"part": null,
"partText": null,
"partNumber": null,
"partInfo": null,
"partAlignment": null,
"level": "EG",
"levelText": "Erdgescho�",
"levelNumber": null,
"floor": "R",
"floorText": "rechts",
"flatNumber": "12",
"flatInfo": null
}
},
{
"servicePointInfo": {
"cplID": "CPL789",
"klsID": 26035132,
"type": "Gebaeudeteil",
"state": "FREI",
"stateText": "Freier Service Point",
"plannedDisconnectDate": null,
"recentInfo": {
"firstName": null,
"surname": null,
"MSN0": null
}
},
"buildingInfo": {
"type": null,
"typeText": null,
"part": "VH",
"partText": "Vorderhaus",
"partNumber": null,
"partInfo": "gelbe Haus mit dem h�sslichen Dach",
"partAlignment": null,
"level": null,
"levelText": null,
"levelNumber": null,
"floor": null,
"floorText": null,
"flatNumber": null,
"flatInfo": null
}
}
]
And this is the JSON I use for matching. It's actually the copied actual response with some fuzzy matching expressions I used because I thought the special chars (ä, ß) could be the problem):
[
{
"servicePointInfo": {
"cplID": "CPL123",
"klsID": 26035132,
"type": "Gebaeudeteil",
"state": "FREI",
"stateText": "Freier Service Point",
"plannedDisconnectDate": null,
"recentInfo": {
"firstName": null,
"surname": null,
"MSN0": null
}
},
"buildingInfo": {
"type": null,
"typeText": null,
"part": "FeH",
"partText": "#notnull",
"partNumber": null,
"partInfo": "vor Telekom",
"partAlignment": null,
"level": null,
"levelText": null,
"levelNumber": null,
"floor": null,
"floorText": null,
"flatNumber": null,
"flatInfo": null
}
},
{
"servicePointInfo": {
"cplID": "CPL456",
"klsID": 26035132,
"type": "Wohnung",
"state": "FREI",
"stateText": "Freier Service Point",
"plannedDisconnectDate": null,
"recentInfo": {
"firstName": "Karl",
"surname": "Schaefer",
"MSN0": null
}
},
"buildingInfo": {
"type": "M",
"typeText": "Mehrfamilienhaus",
"part": null,
"partText": null,
"partNumber": null,
"partInfo": null,
"partAlignment": null,
"level": "EG",
"levelText": "#notnull",
"levelNumber": null,
"floor": "R",
"floorText": "rechts",
"flatNumber": "12",
"flatInfo": null
}
},
{
"servicePointInfo": {
"cplID": "CPL789",
"klsID": 26035132,
"type": "Gebaeudeteil",
"state": "FREI",
"stateText": "Freier Service Point",
"plannedDisconnectDate": null,
"recentInfo": {
"firstName": null,
"surname": null,
"MSN0": null
}
},
"buildingInfo": {
"type": null,
"typeText": null,
"part": "VH",
"partText": "Vorderhaus",
"partNumber": null,
"partInfo": "#notnull",
"partAlignment": null,
"level": null,
"levelText": null,
"levelNumber": null,
"floor": null,
"floorText": null,
"flatNumber": null,
"flatInfo": null
}
}
]
This is the matching result:
com.intuit.karate.exception.KarateException: path: $, actual: '[{"servicePointInfo":{"cplID":"CPL123","klsID":26035132,"type":"Gebaeudeteil","state":"FREI","stateText":"Freier Service Point","plannedDisconnectDate":null,"recentInfo":{"firstName":null,"surname":null,"MSN0":null}},"buildingInfo":{"type":null,"typeText":null,"part":"FeH","partText":"Fernsprechh�uschen","partNumber":null,"partInfo":"vor Telekom","partAlignment":null,"level":null,"levelText":null,"levelNumber":null,"floor":null,"floorText":null,"flatNumber":null,"flatInfo":null}},{"servicePointInfo":{"cplID":"CPL456","klsID":26035132,"type":"Wohnung","state":"FREI","stateText":"Freier Service Point","plannedDisconnectDate":null,"recentInfo":{"firstName":"Karl","surname":"Schaefer","MSN0":null}},"buildingInfo":{"type":"M","typeText":"Mehrfamilienhaus","part":null,"partText":null,"partNumber":null,"partInfo":null,"partAlignment":null,"level":"EG","levelText":"Erdgescho�","levelNumber":null,"floor":"R","floorText":"rechts","flatNumber":"12","flatInfo":null}},{"servicePointInfo":{"cplID":"CPL789","klsID":26035132,"type":"Gebaeudeteil","state":"FREI","stateText":"Freier Service Point","plannedDisconnectDate":null,"recentInfo":{"firstName":null,"surname":null,"MSN0":null}},"buildingInfo":{"type":null,"typeText":null,"part":"VH","partText":"Vorderhaus","partNumber":null,"partInfo":"gelbe Haus mit dem h�sslichen Dach","partAlignment":null,"level":null,"levelText":null,"levelNumber":null,"floor":null,"floorText":null,"flatNumber":null,"flatInfo":null}}]', expected: '[{"servicePointInfo":{"cplID":"CPL123","klsID":26035132,"type":"Gebaeudeteil","state":"FREI","stateText":"Freier Service Point","plannedDisconnectDate":null,"recentInfo":{"firstName":null,"surname":null,"MSN0":null}},"buildingInfo":{"type":null,"typeText":null,"part":"FeH","partText":"#notnull","partNumber":null,"partInfo":"vor Telekom","partAlignment":null,"level":null,"levelText":null,"levelNumber":null,"floor":null,"floorText":null,"flatNumber":null,"flatInfo":null}},{"servicePointInfo":{"cplID":"CPL456","klsID":26035132,"type":"Wohnung","state":"FREI","stateText":"Freier Service Point","plannedDisconnectDate":null,"recentInfo":{"firstName":"Karl","surname":"Schaefer","MSN0":null}},"buildingInfo":{"type":"M","typeText":"Mehrfamilienhaus","part":null,"partText":null,"partNumber":null,"partInfo":null,"partAlignment":null,"level":"EG","levelText":"#notnull","levelNumber":null,"floor":"R","floorText":"rechts","flatNumber":"12","flatInfo":null}},{"servicePointInfo":{"cplID":"CPL789","klsID":26035132,"type":"Gebaeudeteil","state":"FREI","stateText":"Freier Service Point","plannedDisconnectDate":null,"recentInfo":{"firstName":null,"surname":null,"MSN0":null}},"buildingInfo":{"type":null,"typeText":null,"part":"VH","partText":"Vorderhaus","partNumber":null,"partInfo":"#notnull","partAlignment":null,"level":null,"levelText":null,"levelNumber":null,"floor":null,"floorText":null,"flatNumber":null,"flatInfo":null}}]', reason: not equal
Someone experience such a behaviour as well? cheers
--Edit due to the answer of @Peter--
This is my current build.gradle:
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
sourceSets {
test {
resources {
srcDir file('src/test/java')
exclude '**/*.java'
}
}
}
dependencies {
testCompile('com.intuit.karate:karate-apache:0.8.0.RC3')
testCompile('com.intuit.karate:karate-junit4:0.8.0.RC3')
testCompile('net.masterthought:cucumber-reporting:3.8.0')
testCompile('org.apache.commons:commons-text:1.3')
testCompile('com.googlecode.json-simple:json-simple:1.1.1')
}
test.dependsOn clean
Upvotes: 1
Views: 120
Reputation: 58058
No worries, forcing the maven surefire plugin to UTF-8 should fix this problem, documented here: https://github.com/intuit/karate#fileencoding
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<configuration>
<argLine>-Dfile.encoding=UTF-8</argLine>
</configuration>
</plugin>
Upvotes: 1