From a31eaf73ec588df9de2240d57f02b581ccbc2a51 Mon Sep 17 00:00:00 2001 From: Ivan Paolillo Date: Fri, 8 Jul 2016 10:44:07 +0200 Subject: [PATCH] Add JSON Schema validation --- .../baeldung/json/schema/JSONSchemaTest.java | 25 ++----------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/json/src/test/java/org/baeldung/json/schema/JSONSchemaTest.java b/json/src/test/java/org/baeldung/json/schema/JSONSchemaTest.java index 16721d6700..273fd48bac 100644 --- a/json/src/test/java/org/baeldung/json/schema/JSONSchemaTest.java +++ b/json/src/test/java/org/baeldung/json/schema/JSONSchemaTest.java @@ -1,7 +1,6 @@ package org.baeldung.json.schema; import org.everit.json.schema.Schema; -import org.everit.json.schema.ValidationException; import org.everit.json.schema.loader.SchemaLoader; import org.json.JSONObject; @@ -17,17 +16,7 @@ public class JSONSchemaTest { JSONObject jsonSubject = new JSONObject(new JSONTokener(JSONSchemaTest.class.getResourceAsStream("/product_invalid.json"))); Schema schema = SchemaLoader.load(jsonSchema); - - try { - - schema.validate(jsonSubject); - } - - catch (ValidationException e) { - - System.out.println(e.getMessage()); - e.getCausingExceptions().stream().map(ValidationException::getMessage).forEach(System.out::println); - } + schema.validate(jsonSubject); } @Test @@ -37,16 +26,6 @@ public class JSONSchemaTest { JSONObject jsonSubject = new JSONObject(new JSONTokener(JSONSchemaTest.class.getResourceAsStream("/product_valid.json"))); Schema schema = SchemaLoader.load(jsonSchema); - - try { - - schema.validate(jsonSubject); - } - - catch (ValidationException e) { - - System.out.println(e.getMessage()); - e.getCausingExceptions().stream().map(ValidationException::getMessage).forEach(System.out::println); - } + schema.validate(jsonSubject); } }