Validate server JSON with org.json as well
This commit is contained in:
@@ -381,6 +381,7 @@ project(":tests"){
|
|||||||
testImplementation "org.junit.jupiter:junit-jupiter-params:5.7.1"
|
testImplementation "org.junit.jupiter:junit-jupiter-params:5.7.1"
|
||||||
testImplementation "org.junit.jupiter:junit-jupiter-api:5.7.1"
|
testImplementation "org.junit.jupiter:junit-jupiter-api:5.7.1"
|
||||||
testImplementation arcModule("backends:backend-headless")
|
testImplementation arcModule("backends:backend-headless")
|
||||||
|
testImplementation "org.json:json:20230618"
|
||||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.7.1"
|
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.7.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import mindustry.type.*;
|
|||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.payloads.*;
|
import mindustry.world.blocks.payloads.*;
|
||||||
import mindustry.world.blocks.storage.*;
|
import mindustry.world.blocks.storage.*;
|
||||||
|
import org.json.*;
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.*;
|
||||||
import org.junit.jupiter.params.*;
|
import org.junit.jupiter.params.*;
|
||||||
import org.junit.jupiter.params.provider.*;
|
import org.junit.jupiter.params.provider.*;
|
||||||
@@ -227,11 +228,14 @@ public class ApplicationTests{
|
|||||||
void serverListJson(){
|
void serverListJson(){
|
||||||
String[] files = {"servers_v6.json", "servers_v7.json", "servers_be.json"};
|
String[] files = {"servers_v6.json", "servers_v7.json", "servers_be.json"};
|
||||||
|
|
||||||
|
|
||||||
for(String file : files){
|
for(String file : files){
|
||||||
try{
|
try{
|
||||||
String str = Core.files.absolute("./../../" + file).readString();
|
String str = Core.files.absolute("./../../" + file).readString();
|
||||||
assertEquals(ValueType.array, new JsonReader().parse(str).type());
|
assertEquals(ValueType.array, new JsonReader().parse(str).type());
|
||||||
assertTrue(Jval.read(str).isArray());
|
assertTrue(Jval.read(str).isArray());
|
||||||
|
JSONArray array = new JSONArray(str);
|
||||||
|
assertTrue(array.length() > 0);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
fail("Failed to parse " + file, e);
|
fail("Failed to parse " + file, e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user