Skip to content

Commit b96065a

Browse files
committed
fixes #229 move the remotes to resource from draftv4 so that it can be shared by all tests
1 parent caf5259 commit b96065a

File tree

15 files changed

+370
-5
lines changed

15 files changed

+370
-5
lines changed

src/test/java/com/networknt/schema/V201909JsonSchemaTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static void setUp() {
3737
server = Undertow.builder()
3838
.addHttpListener(1234, "localhost")
3939
.setHandler(resource(new FileResourceManager(
40-
new File("./src/test/resources/draft2019-09"), 100)))
40+
new File("./src/test/resources/remotes"), 100)))
4141
.build();
4242
server.start();
4343
}

src/test/java/com/networknt/schema/V4JsonSchemaTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static void setUp() {
5252
server = Undertow.builder()
5353
.addHttpListener(1234, "localhost")
5454
.setHandler(resource(new FileResourceManager(
55-
new File("./src/test/resources/draft4"), 100)))
55+
new File("./src/test/resources/remotes"), 100)))
5656
.build();
5757
server.start();
5858
}
@@ -312,7 +312,7 @@ public void testEnumObject() throws Exception {
312312

313313
@Test
314314
public void testIdSchemaWithUrl() throws Exception {
315-
runTestFile("draft4/id_schema/property.json");
315+
runTestFile("draft4/property.json");
316316
}
317317

318318
@Test

src/test/java/com/networknt/schema/V6JsonSchemaTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static void setUp() {
3333
server = Undertow.builder()
3434
.addHttpListener(1234, "localhost")
3535
.setHandler(resource(new FileResourceManager(
36-
new File("./src/test/resources/draft6"), 100)))
36+
new File("./src/test/resources/remotes"), 100)))
3737
.build();
3838
server.start();
3939
}

src/test/java/com/networknt/schema/V7JsonSchemaTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static void setUp() {
3333
server = Undertow.builder()
3434
.addHttpListener(1234, "localhost")
3535
.setHandler(resource(new FileResourceManager(
36-
new File("./src/test/resources/draft7"), 100)))
36+
new File("./src/test/resources/remotes"), 100)))
3737
.build();
3838
server.start();
3939
}

src/test/resources/draft4/allOf.json

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,78 @@
108108
"valid": false
109109
}
110110
]
111+
},
112+
{
113+
"description": "allOf with one empty schema",
114+
"schema": {
115+
"allOf": [
116+
{}
117+
]
118+
},
119+
"tests": [
120+
{
121+
"description": "any data is valid",
122+
"data": 1,
123+
"valid": true
124+
}
125+
]
126+
},
127+
{
128+
"description": "allOf with two empty schemas",
129+
"schema": {
130+
"allOf": [
131+
{},
132+
{}
133+
]
134+
},
135+
"tests": [
136+
{
137+
"description": "any data is valid",
138+
"data": 1,
139+
"valid": true
140+
}
141+
]
142+
},
143+
{
144+
"description": "allOf with the first empty schema",
145+
"schema": {
146+
"allOf": [
147+
{},
148+
{ "type": "number" }
149+
]
150+
},
151+
"tests": [
152+
{
153+
"description": "number is valid",
154+
"data": 1,
155+
"valid": true
156+
},
157+
{
158+
"description": "string is invalid",
159+
"data": "foo",
160+
"valid": false
161+
}
162+
]
163+
},
164+
{
165+
"description": "allOf with the last empty schema",
166+
"schema": {
167+
"allOf": [
168+
{ "type": "number" },
169+
{}
170+
]
171+
},
172+
"tests": [
173+
{
174+
"description": "number is valid",
175+
"data": 1,
176+
"valid": true
177+
},
178+
{
179+
"description": "string is invalid",
180+
"data": "foo",
181+
"valid": false
182+
}
183+
]
111184
}
112185
]
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
[
2+
{
3+
"description": "ECMA 262 regex non-compliance",
4+
"schema": { "format": "regex" },
5+
"tests": [
6+
{
7+
"description": "ECMA 262 has no support for \\Z anchor from .NET",
8+
"data": "^\\S(|(.|\\n)*\\S)\\Z",
9+
"valid": false
10+
}
11+
]
12+
},
13+
{
14+
"description": "ECMA 262 regex $ does not match trailing newline",
15+
"schema": {
16+
"type": "string",
17+
"pattern": "^abc$"
18+
},
19+
"tests": [
20+
{
21+
"description": "matches in Python, but should not in jsonschema",
22+
"data": "abc\n",
23+
"valid": false
24+
},
25+
{
26+
"description": "should match",
27+
"data": "abc",
28+
"valid": true
29+
}
30+
]
31+
},
32+
{
33+
"description": "ECMA 262 regex converts \\t to horizontal tab",
34+
"schema": {
35+
"type": "string",
36+
"pattern": "^\\t$"
37+
},
38+
"tests": [
39+
{
40+
"description": "does not match",
41+
"data": "\\t",
42+
"valid": false
43+
},
44+
{
45+
"description": "matches",
46+
"data": "\u0009",
47+
"valid": true
48+
}
49+
]
50+
},
51+
{
52+
"description": "ECMA 262 regex escapes control codes with \\c and upper letter",
53+
"schema": {
54+
"type": "string",
55+
"pattern": "^\\cC$"
56+
},
57+
"tests": [
58+
{
59+
"description": "does not match",
60+
"data": "\\cC",
61+
"valid": false
62+
},
63+
{
64+
"description": "matches",
65+
"data": "\u0003",
66+
"valid": true
67+
}
68+
]
69+
},
70+
{
71+
"description": "ECMA 262 regex escapes control codes with \\c and lower letter",
72+
"schema": {
73+
"type": "string",
74+
"pattern": "^\\cc$"
75+
},
76+
"tests": [
77+
{
78+
"description": "does not match",
79+
"data": "\\cc",
80+
"valid": false
81+
},
82+
{
83+
"description": "matches",
84+
"data": "\u0003",
85+
"valid": true
86+
}
87+
]
88+
},
89+
{
90+
"description": "ECMA 262 \\d matches ascii digits only",
91+
"schema": {
92+
"type": "string",
93+
"pattern": "^\\d$"
94+
},
95+
"tests": [
96+
{
97+
"description": "ASCII zero matches",
98+
"data": "0",
99+
"valid": true
100+
},
101+
{
102+
"description": "NKO DIGIT ZERO does not match (unlike e.g. Python)",
103+
"data": "߀",
104+
"valid": false
105+
},
106+
{
107+
"description": "NKO DIGIT ZERO (as \\u escape) does not match",
108+
"data": "\u07c0",
109+
"valid": false
110+
}
111+
]
112+
},
113+
{
114+
"description": "ECMA 262 \\D matches everything but ascii digits",
115+
"schema": {
116+
"type": "string",
117+
"pattern": "^\\D$"
118+
},
119+
"tests": [
120+
{
121+
"description": "ASCII zero does not match",
122+
"data": "0",
123+
"valid": false
124+
},
125+
{
126+
"description": "NKO DIGIT ZERO matches (unlike e.g. Python)",
127+
"data": "߀",
128+
"valid": true
129+
},
130+
{
131+
"description": "NKO DIGIT ZERO (as \\u escape) matches",
132+
"data": "\u07c0",
133+
"valid": true
134+
}
135+
]
136+
},
137+
{
138+
"description": "ECMA 262 \\w matches ascii letters only",
139+
"schema": {
140+
"type": "string",
141+
"pattern": "^\\w$"
142+
},
143+
"tests": [
144+
{
145+
"description": "ASCII 'a' matches",
146+
"data": "a",
147+
"valid": true
148+
},
149+
{
150+
"description": "latin-1 e-acute does not match (unlike e.g. Python)",
151+
"data": "é",
152+
"valid": false
153+
}
154+
]
155+
},
156+
{
157+
"description": "ECMA 262 \\w matches everything but ascii letters",
158+
"schema": {
159+
"type": "string",
160+
"pattern": "^\\W$"
161+
},
162+
"tests": [
163+
{
164+
"description": "ASCII 'a' does not match",
165+
"data": "a",
166+
"valid": false
167+
},
168+
{
169+
"description": "latin-1 e-acute matches (unlike e.g. Python)",
170+
"data": "é",
171+
"valid": true
172+
}
173+
]
174+
},
175+
{
176+
"description": "ECMA 262 \\s matches ascii whitespace only",
177+
"schema": {
178+
"type": "string",
179+
"pattern": "^\\s$"
180+
},
181+
"tests": [
182+
{
183+
"description": "ASCII space matches",
184+
"data": " ",
185+
"valid": true
186+
},
187+
{
188+
"description": "latin-1 non-breaking-space does not match (unlike e.g. Python)",
189+
"data": "\u00a0",
190+
"valid": false
191+
}
192+
]
193+
},
194+
{
195+
"description": "ECMA 262 \\S matches everything but ascii whitespace",
196+
"schema": {
197+
"type": "string",
198+
"pattern": "^\\S$"
199+
},
200+
"tests": [
201+
{
202+
"description": "ASCII space does not match",
203+
"data": " ",
204+
"valid": false
205+
},
206+
{
207+
"description": "latin-1 non-breaking-space matches (unlike e.g. Python)",
208+
"data": "\u00a0",
209+
"valid": true
210+
}
211+
]
212+
}
213+
]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "integer"
3+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[
2+
{
3+
"description": "id as schema",
4+
"schema": {
5+
"id": "http://localhost:1234/id_schema/schema/features.json",
6+
"title": "property object",
7+
"type": "object",
8+
"properties": {
9+
"featuresInteger": {
10+
"$ref": "#/featuresInteger"
11+
},
12+
"featuresBoolean": {
13+
"$ref": "#/featuresBoolean"
14+
}
15+
},
16+
"additionalProperties": false
17+
},
18+
"tests": [
19+
{
20+
"data": {
21+
"featuresInteger": 4,
22+
"featuresBoolean": true
23+
},
24+
"valid": true
25+
},
26+
{
27+
"data": {
28+
"featuresInteger": 4.0,
29+
"featuresBoolean": true
30+
},
31+
"valid": false
32+
}
33+
]
34+
}
35+
]

0 commit comments

Comments
 (0)