Skip to content

Commit

Permalink
Make test to reproduce issue #102
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 3000dfc commit efa9f7d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.github.fge.jackson.JacksonUtils;
import com.github.fge.jackson.JsonLoader;
import com.github.fge.jackson.NodeType;
import com.github.fge.jsonschema.cfg.ValidationConfiguration;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
Expand All @@ -39,15 +40,18 @@
import com.github.fge.jsonschema.library.Keyword;
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.processors.data.FullData;
import com.github.fge.msgsimple.bundle.MessageBundle;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;

import static org.mockito.Mockito.*;
import static org.testng.Assert.*;
import static org.mockito.Mockito.mock;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;

public final class ValidationProcessorTest
{
Expand Down Expand Up @@ -111,6 +115,19 @@ public void childrenAreExploredOnDemandEvenIfContainerFails()
assertEquals(COUNT.get(), 1);
}

@Test(timeOut = 1000)
public void circularReferencingDuringValidationIsDetected()
throws IOException, ProcessingException
{
final JsonNode schemaNode
= JsonLoader.fromResource("/other/issue102.json");
final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
final JsonValidator validator = factory.getValidator();

validator.validate(schemaNode, JacksonUtils.nodeFactory().nullNode());
assertTrue(true);
}

public static final class K1Validator
extends AbstractKeywordValidator
{
Expand Down
30 changes: 30 additions & 0 deletions src/test/resources/other/issue102.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"S": {
"allOf": [
{
"type": "string",
"enum": ["a"]
},
{
"oneOf": [
{
"$ref": "#/definitions/S"
},
{
"type": "string",
"enum": [""]
}
]
},
{
"type": "string",
"enum": ["b"]
}
],
"additionalItems": false
}
},
"$ref": "#/definitions/S"
}

0 comments on commit efa9f7d

Please sign in to comment.