Skip to content

Commit

Permalink
Modify tests; add a message for validation loops
Browse files Browse the repository at this point in the history
Signed-off-by: Francis Galiegue <[email protected]>
  • Loading branch information
fge committed May 25, 2014
1 parent 2d38847 commit 5d8a29d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,8 @@ err.format.jsonpointer.invalid = input string "%s" is not a valid JSON Pointer
err.format.macAddr.invalid = input string "%s" is not a valid MAC address
err.format.uriTemplate.invalid = input string "%s" is not a valid URI template
err.format.UUID.invalid = input string "%s" is not a valid UUID

#
# Other messages
#
err.common.validationLoop = validation loop detected
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
import com.github.fge.jsonschema.library.Library;
import com.github.fge.jsonschema.main.JsonSchemaFactory;
import com.github.fge.jsonschema.main.JsonValidator;
import com.github.fge.jsonschema.messages.JsonSchemaValidationBundle;
import com.github.fge.jsonschema.processors.data.FullData;
import com.github.fge.msgsimple.bundle.MessageBundle;
import com.github.fge.msgsimple.load.MessageBundles;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

Expand All @@ -52,6 +54,7 @@
import static org.mockito.Mockito.mock;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;

public final class ValidationProcessorTest
{
Expand Down Expand Up @@ -123,8 +126,18 @@ public void circularReferencingDuringValidationIsDetected()
= JsonLoader.fromResource("/other/issue102.json");
final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
final JsonValidator validator = factory.getValidator();

validator.validate(schemaNode, JacksonUtils.nodeFactory().nullNode());
final MessageBundle bundle
= MessageBundles.getBundle(JsonSchemaValidationBundle.class);
final String expectedMsg
= bundle.getMessage("err.common.validationLoop");

try {
validator.validate(schemaNode,
JacksonUtils.nodeFactory().nullNode());
fail("No exception thrown!");
} catch (ProcessingException e) {
assertEquals(e.getMessage(), expectedMsg);
}
assertTrue(true);
}

Expand Down

0 comments on commit 5d8a29d

Please sign in to comment.