diff options
Diffstat (limited to 'javatoscachecker/kwalify/src/test')
35 files changed, 1106 insertions, 0 deletions
diff --git a/javatoscachecker/kwalify/src/test/java/kwalify/test/ParserTest.java b/javatoscachecker/kwalify/src/test/java/kwalify/test/ParserTest.java new file mode 100644 index 0000000..1983619 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/java/kwalify/test/ParserTest.java @@ -0,0 +1,300 @@ +/* + * Copyright (c) 2017 <AT&T>. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for + * the specific language governing permissions and limitations under the License. + */ +package kwalify.test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.junit.FixMethodOrder; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import static org.assertj.core.api.Assertions.*; + +import java.util.Set; +import java.util.Map; +import java.util.List; +import java.util.Arrays; +import java.io.InputStream; +import java.io.IOException; + +import kwalify.PlainYamlParser; +import kwalify.SyntaxException; +import kwalify.Util; + + +/* + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class ParserTest { + + @BeforeClass + public static void initialize() throws Exception { + } + + private Object parse(String theResource) throws SyntaxException { + Object output = null; + InputStream source = getClass().getClassLoader().getResourceAsStream(theResource); + if (source == null) { + fail("Cannot find test resource " + theResource); + } + + try { + output = new PlainYamlParser( + Util.readInputStream(source)) + .parse(); + } + catch (IOException iox) { + fail("Failed to load test resource " + theResource + ": " + iox); + } + return output; + } + + @Test + public void testParserSuccess() { + try { + assertTrue( + parse("parserSuccess.yml") instanceof Map); + } + catch (SyntaxException sx) { + fail("Unexpected syntax error " + sx); + } + } + + + + @Test + public void testParserFailOnInvalidAnchor() { + try { + parse("parserFailInvalidAnchor.yml"); + } + catch (SyntaxException sx) { + assertTrue(sx.getMessage(), sx.getMessage().matches("anchor '.*' not found.")); + assertTrue("" + sx.getLineNumber(), sx.getLineNumber() == 25); + } + } + + @Test + public void testParserFailIndentation() { + try { + parse("parserFailIndentation.yml"); + } + catch (SyntaxException sx) { + assertTrue(sx.getMessage(), sx.getMessage().matches("invalid indent of mapping.")); + assertTrue("" + sx.getLineNumber(), sx.getLineNumber() == 28); + } + } + + @Test + public void testParserSeqOfScalar() { + try { + assertTrue( + parse("parserSuccessSeqOfScalar.yml") instanceof List); + } + catch (SyntaxException sx) { + fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber()); + } + } + + @Test + public void testParserSeqOfMap() { + Object res = null; + try { + res = parse("parserSuccessSeqOfMap.yml"); + } + catch (SyntaxException sx) { + fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber()); + } + assertTrue(res instanceof List); + for (Object entry: (List)res) + assertTrue(entry instanceof Map); + } + + //@Test + public void testParserSeqOfSeq() { + Object res = null; + try { + res = parse("parserSuccessSeqOfSeq.yml"); + } + catch (SyntaxException sx) { + fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber()); + } + assertTrue(res instanceof List); + for (Object entry: (List)res) + assertTrue(entry instanceof List); + } + + @Test + public void testParserMapScalarToScalar() { + Object res = null; + try { + res = parse("parserSuccessMapScalarToScalar.yml"); + } + catch (SyntaxException sx) { + fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber()); + } + assertTrue(res instanceof Map); + } + + @Test + public void testParserMapScalarToSeq() { + Object res = null; + try { + res = parse("parserSuccessMapScalarToSeq.yml"); + } + catch (SyntaxException sx) { + fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber()); + } + assertTrue(res instanceof Map); + for (Object value: ((Map)res).values()) + assertTrue(value instanceof List); + } + + @Test + public void testParserMapOfMap() { + Object res = null; + try { + res = parse("parserSuccessMapOfMap.yml"); + } + catch (SyntaxException sx) { + fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber()); + } + assertTrue("result not a map: " + res.getClass() + ", " + res, res instanceof Map); + for (Object value: ((Map)res).values()) + assertTrue("value not a map, " + value.getClass() + ", " + value, value instanceof Map); + } + + //@Test + //not supported + public void testParserMapOfSeqToSeq() { + Object res = null; + try { + res = parse("parserSuccessMapOfSeqToSeq.yml"); + } + catch (SyntaxException sx) { + fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber()); + } + assertTrue("result not a map: " + res.getClass() + ", " + res, res instanceof Map); + for (Map.Entry entry: (Set<Map.Entry>)((Map)res).entrySet()) { + assertTrue(entry.getKey() instanceof List); + assertTrue(entry.getValue() instanceof List); + } + } + + //@Test + //not supported + public void testParserUnorderedSet() { + Object res = null; + try { + res = parse("parserSuccessUnorderedSet.yml"); + } + catch (SyntaxException sx) { + fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber()); + } + assertTrue("result not a set: " + res.getClass() + ", " + res, res instanceof Set); + } + + @Test + public void testParserOrderedMap() { + Object res = null; + try { + res = parse("parserSuccessOrderedMap.yml"); + } + catch (SyntaxException sx) { + fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber()); + } + assertTrue("result not a list: " + res.getClass() + ", " + res, res instanceof List); + } + + @Test + public void testParserFloats() { + Object res = null; + try { + res = parse("parserSuccessFloats.yml"); + } + catch (SyntaxException sx) { + fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber()); + } + assertTrue("result not a map: " + res.getClass() + ", " + res, res instanceof Map); + + for (Object value: ((Map)res).values()) + assertTrue("value not encoded as a Double: " + value.getClass() + ", " + value, value instanceof Double); + } + + @Test + public void testParserInts() { + Object res = null; + try { + res = parse("parserSuccessInts.yml"); + } + catch (SyntaxException sx) { + fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber()); + } + assertTrue("result not a map: " + res.getClass() + ", " + res, res instanceof Map); + + for (Object value: ((Map)res).values()) + assertTrue("value not encoded as a Integer: " + value.getClass() + ", " + value, value instanceof Integer); + } + + @Test + public void testParserQuotedStrings() { + Object res = null; + try { + res = parse("parserSuccessQuotedStrings.yml"); + } + catch (SyntaxException sx) { + fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber()); + } + assertTrue("result not a map: " + res.getClass() + ", " + res, res instanceof Map); + + for (Object value: ((Map)res).values()) + assertTrue("value not encoded as a String: " + value.getClass() + ", " + value, value instanceof String); + } + + @Test + public void testParserTimestamps() { + Object res = null; + try { + res = parse("parserSuccessTimestamps.yml"); + } + catch (SyntaxException sx) { + fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber()); + } + assertTrue("result not a map: " + res.getClass() + ", " + res, res instanceof Map); + + for (Object value: ((Map)res).values()) + assertTrue("value not encoded as a Date: " + value.getClass() + ", " + value, value instanceof java.util.Date); + } + + @Test + public void testMultipleDocs() throws SyntaxException { + Object[] output = null; + InputStream source = getClass().getClassLoader().getResourceAsStream("parserSuccessMultipleDocs.yml"); + if (source == null) { + fail("Cannot find test resource parserSuccessMultipleDocs.yml"); + } + + try { + output = new PlainYamlParser( + Util.readInputStream(source)) + .parseAll(); + } + catch (IOException iox) { + fail("Failed to load test resource parserSuccessMultipleDocs.yml: " + iox); + } + assertTrue("Unexpected output " + output == null ? "null" : Arrays.toString(output), output != null && output.length == 2); + } +} diff --git a/javatoscachecker/kwalify/src/test/java/kwalify/test/ValidatorTest.java b/javatoscachecker/kwalify/src/test/java/kwalify/test/ValidatorTest.java new file mode 100644 index 0000000..e5c2735 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/java/kwalify/test/ValidatorTest.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2017 <AT&T>. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for + * the specific language governing permissions and limitations under the License. + */ +package kwalify.test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.junit.FixMethodOrder; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import static org.assertj.core.api.Assertions.*; + +import java.util.Map; +import java.util.List; +import java.io.InputStream; +import java.io.IOException; + +import kwalify.PlainYamlParser; +import kwalify.SyntaxException; +import kwalify.SchemaException; +import kwalify.Util; +import kwalify.Validator; + + +/* + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class ValidatorTest { + + @BeforeClass + public static void initialize() throws Exception { + } + + protected Object[] prepareValidateTest(String theName) { + Object[] res = new Object[3]; + InputStream source = null; + + source = getClass().getClassLoader().getResourceAsStream(theName + "Schema.yml"); + if (source == null) { + fail("Cannot find test resource " + theName + "Schema.yml"); + } + + try { + res[0] = new PlainYamlParser( + Util.readInputStream(source)) + .parse(); + } + catch (IOException iox) { + fail("Failed to load test resource " + iox); + } + catch (SyntaxException sx) { + fail("Unexpected syntax error " + sx); + } + + source = getClass().getClassLoader().getResourceAsStream(theName + ".yml"); + if (source == null) { + fail("Cannot find test resource " + theName + ".yml"); + } + try { + res[1] = new PlainYamlParser( + Util.readInputStream(source)) + .parse(); + } + catch (IOException iox) { + fail("Failed to load test resource " + iox); + } + catch (SyntaxException sx) { + fail("Unexpected syntax error " + sx); + } + + source = getClass().getClassLoader().getResourceAsStream("in" + theName + ".yml"); + if (source == null) { + fail("Cannot find test resource in" + theName + ".yml"); + } + try { + res[2] = new PlainYamlParser( + Util.readInputStream(source)) + .parse(); + } + catch (IOException iox) { + fail("Failed to load test resource " + iox); + } + catch (SyntaxException sx) { + fail("Unexpected syntax error " + sx); + } + + return res; + } + + protected void runValidateTest(String theTestName) { + Object[] docs = prepareValidateTest(theTestName); + List errors = null; + try { + errors = new Validator(docs[0]).validate(docs[1]); + } + catch (SchemaException sx) { + fail("Invalid schema " + sx); + } + + assertTrue(errors.toString(), errors != null && errors.size() == 0); + + try { + errors = new Validator(docs[0]).validate(docs[2]); + } + catch (SchemaException sx) { + fail("Invalid schema " + sx); + } + + assertTrue(errors.toString(), errors != null && errors.size() > 0); + } + + @Test + public void testMap() { + runValidateTest("validateMap"); + } + + @Test + public void testSeq() { + runValidateTest("validateSeq"); + } + + @Test + public void testMapOfSeq() { + runValidateTest("validateMapOfSeq"); + } + + @Test + public void testSeqOfMap() { + runValidateTest("validateSeqOfMap"); + } + + @Test + public void testRule() { + runValidateTest("validateRule"); + } +} diff --git a/javatoscachecker/kwalify/src/test/resources/invalidateMap.yml b/javatoscachecker/kwalify/src/test/resources/invalidateMap.yml new file mode 100644 index 0000000..4c26997 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/invalidateMap.yml @@ -0,0 +1,16 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +name: foo +email: foo(at)mail.com +age: twenty +birth: Jun 01, 1985 diff --git a/javatoscachecker/kwalify/src/test/resources/invalidateMapOfSeq.yml b/javatoscachecker/kwalify/src/test/resources/invalidateMapOfSeq.yml new file mode 100644 index 0000000..b6b4345 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/invalidateMapOfSeq.yml @@ -0,0 +1,21 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +company: Kuwata Lab. +email: webmaster@kuwata-lab.com +employees: + - code: A101 + name: foo + email: foo@kuwata-lab.com + - code: 102 + name: bar + mail: bar@kuwata-lab.com diff --git a/javatoscachecker/kwalify/src/test/resources/invalidateRule.yml b/javatoscachecker/kwalify/src/test/resources/invalidateRule.yml new file mode 100644 index 0000000..9b4ca17 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/invalidateRule.yml @@ -0,0 +1,24 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +- name: foo + email: foo(at)mail.com + password: xxx123 + age: twenty + blood: a + birth: 1985-01-01 +- given-name: bar + family-name: Bar + email: bar@mail.net + age: 15 + blood: AB + birth: 1980/01/01 diff --git a/javatoscachecker/kwalify/src/test/resources/invalidateSeq.yml b/javatoscachecker/kwalify/src/test/resources/invalidateSeq.yml new file mode 100644 index 0000000..f2dd1a5 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/invalidateSeq.yml @@ -0,0 +1,15 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +- foo +- 123 +- baz diff --git a/javatoscachecker/kwalify/src/test/resources/invalidateSeqOfMap.yml b/javatoscachecker/kwalify/src/test/resources/invalidateSeqOfMap.yml new file mode 100644 index 0000000..c3c828a --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/invalidateSeqOfMap.yml @@ -0,0 +1,18 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +- name: foo + email: foo@mail.com +- naem: bar + email: bar@mail.net +- name: baz + mail: baz@mail.org diff --git a/javatoscachecker/kwalify/src/test/resources/parserFailIndentation.yml b/javatoscachecker/kwalify/src/test/resources/parserFailIndentation.yml new file mode 100644 index 0000000..949ef56 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/parserFailIndentation.yml @@ -0,0 +1,40 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +invoice: 34843 +date : 2001-01-23 +bill-to: &id001 + given : Chris + family : Dumars + address: + lines: | + 458 Walkman Dr. + Suite #292 + city : Royal Oak + state : MI + postal : 48046 +ship-to: *id001 +product: + - sku : BL394D + quantity : 4 + description : Basketball + price : 450.00 + - sku : BL4438H + quantity : 1 + description : Super Hoop + price : 2392.00 +tax : 251.42 +total: 4443.52 +comments: > + Late afternoon is best. + Backup contact is Nancy + Billsmer @ 338-4338 diff --git a/javatoscachecker/kwalify/src/test/resources/parserFailInvalidAnchor.yml b/javatoscachecker/kwalify/src/test/resources/parserFailInvalidAnchor.yml new file mode 100644 index 0000000..702bc65 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/parserFailInvalidAnchor.yml @@ -0,0 +1,40 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +invoice: 34843 +date : 2001-01-23 +bill-to: &id001 + given : Chris + family : Dumars + address: + lines: | + 458 Walkman Dr. + Suite #292 + city : Royal Oak + state : MI + postal : 48046 +ship-to: *id002 +product: + - sku : BL394D + quantity : 4 + description : Basketball + price : 450.00 + - sku : BL4438H + quantity : 1 + description : Super Hoop + price : 2392.00 +tax : 251.42 +total: 4443.52 +comments: > + Late afternoon is best. + Backup contact is Nancy + Billsmer @ 338-4338 diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccess.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccess.yml new file mode 100644 index 0000000..35dbbb9 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/parserSuccess.yml @@ -0,0 +1,40 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +invoice: 34843 +date : 2001-01-23 +bill-to: &id001 + given : Chris + family : Dumars + address: + lines: | + 458 Walkman Dr. + Suite #292 + city : Royal Oak + state : MI + postal : 48046 +ship-to: *id001 +product: + - sku : BL394D + quantity : 4 + description : Basketball + price : 450.00 + - sku : BL4438H + quantity : 1 + description : Super Hoop + price : 2392.00 +tax : 251.42 +total: 4443.52 +comments: > + Late afternoon is best. + Backup contact is Nancy + Billsmer @ 338-4338 diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessFloats.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessFloats.yml new file mode 100644 index 0000000..b26e45b --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessFloats.yml @@ -0,0 +1,17 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +#canonical: 1.23015e+3 +#exponential: 12.3015e+02 +fixed: 1230.15 +#negative infinity: -.inf +#not a number: .NaN diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessInts.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessInts.yml new file mode 100644 index 0000000..18faa3c --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessInts.yml @@ -0,0 +1,16 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +canonical: 12345 +#decimal: +12345 +#octal: 0o14 +#hexadecimal: 0xC diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessMapOfMap.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessMapOfMap.yml new file mode 100644 index 0000000..4695f11 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessMapOfMap.yml @@ -0,0 +1,18 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +'Mark McGwire': + hr: 65 + avg: 0.278 +'Sammy Sosa': + hr: 63 + avg: 0.288 diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessMapOfSeqToSeq.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessMapOfSeqToSeq.yml new file mode 100644 index 0000000..d2d70a1 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessMapOfSeqToSeq.yml @@ -0,0 +1,21 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +? - Detroit Tigers + - Chicago cubs +: + - 2001-07-23 + +? [ New York Yankees, + Atlanta Braves ] +: [ 2001-07-02, 2001-08-12, + 2001-08-14 ] diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessMapScalarToScalar.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessMapScalarToScalar.yml new file mode 100644 index 0000000..b875202 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessMapScalarToScalar.yml @@ -0,0 +1,15 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +hr: 65 # Home runs +avg: 0.278 # Batting average +rbi: 147 # Runs Batted In diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessMapScalarToSeq.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessMapScalarToSeq.yml new file mode 100644 index 0000000..d1f85cb --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessMapScalarToSeq.yml @@ -0,0 +1,20 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +american: + - Boston Red Sox + - Detroit Tigers + - New York Yankees +national: + - New York Mets + - Chicago Cubs + - Atlanta Braves diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessMultipleDocs.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessMultipleDocs.yml new file mode 100644 index 0000000..357cbc6 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessMultipleDocs.yml @@ -0,0 +1,21 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +time: 20:03:20 +player: Sammy Sosa +action: strike (miss) + +--- + +time: 20:03:47 +player: Sammy Sosa +action: grand slam diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessOrderedMap.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessOrderedMap.yml new file mode 100644 index 0000000..5f9e127 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessOrderedMap.yml @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +# Ordered maps are represented as +# A sequence of mappings, with +# each mapping having one key +--- !!omap +- Mark McGwire: 65 +- Sammy Sosa: 63 +- Ken Griffy: 58 diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessQuotedStrings.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessQuotedStrings.yml new file mode 100644 index 0000000..dff2570 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessQuotedStrings.yml @@ -0,0 +1,18 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +unicode: "Sosa did fine.\u263A" +control: "\b1998\t1999\t2000\n" +#hex esc: "\x0d\x0a is \r\n" +single: '"Howdy!" he cried.' +quoted: ' # Not a ''comment''.' +tie-fighter: '|\-*-/|' diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfMap.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfMap.yml new file mode 100644 index 0000000..b1d59b3 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfMap.yml @@ -0,0 +1,20 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +- + name: Mark McGwire + hr: 65 + avg: 0.278 +- + name: Sammy Sosa + hr: 63 + avg: 0.288 diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfScalar.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfScalar.yml new file mode 100644 index 0000000..a9a025a --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfScalar.yml @@ -0,0 +1,15 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +- Mark McGwire +- Sammy Sosa +- Ken Griffey diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfSeq.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfSeq.yml new file mode 100644 index 0000000..7bfb6fe --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfSeq.yml @@ -0,0 +1,15 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +- [name , hr, avg ] +- [Mark McGwire, 65, 0.278] +- [Sammy Sosa , 63, 0.288] diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessTimestamps.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessTimestamps.yml new file mode 100644 index 0000000..3bea395 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessTimestamps.yml @@ -0,0 +1,16 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +canonical: 2001-12-15T02:59:43.1Z +iso8601: 2001-12-14t21:59:43.10-05:00 +spaced: 2001-12-14 21:59:43.10 -5 +date: 2002-12-14 diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessTypeTags.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessTypeTags.yml new file mode 100644 index 0000000..b7aac5d --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessTypeTags.yml @@ -0,0 +1,25 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +--- +not-date: !!str 2002-04-28 + +picture: !!binary | + R0lGODlhDAAMAIQAAP//9/X + 17unp5WZmZgAAAOfn515eXv + Pz7Y6OjuDg4J+fn5OTk6enp + 56enmleECcgggoBADs= + +application specific tag: !something | + The semantics of the tag + above may be different for + different documents. diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessUnorderedSet.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessUnorderedSet.yml new file mode 100644 index 0000000..fcd2d47 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessUnorderedSet.yml @@ -0,0 +1,19 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +# Sets are represented as a +# Mapping where each key is +# associated with a null value +--- !!set +? Mark McGwire +? Sammy Sosa +? Ken Griff diff --git a/javatoscachecker/kwalify/src/test/resources/validateMap.yml b/javatoscachecker/kwalify/src/test/resources/validateMap.yml new file mode 100644 index 0000000..34363a7 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/validateMap.yml @@ -0,0 +1,16 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +name: foo +email: foo@mail.com +age: 20 +birth: 1985-01-01 diff --git a/javatoscachecker/kwalify/src/test/resources/validateMapOfSeq.yml b/javatoscachecker/kwalify/src/test/resources/validateMapOfSeq.yml new file mode 100644 index 0000000..a3a7648 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/validateMapOfSeq.yml @@ -0,0 +1,21 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +company: Kuwata lab. +email: webmaster@kuwata-lab.com +employees: + - code: 101 + name: foo + email: foo@kuwata-lab.com + - code: 102 + name: bar + email: bar@kuwata-lab.com diff --git a/javatoscachecker/kwalify/src/test/resources/validateMapOfSeqSchema.yml b/javatoscachecker/kwalify/src/test/resources/validateMapOfSeqSchema.yml new file mode 100644 index 0000000..7868fc2 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/validateMapOfSeqSchema.yml @@ -0,0 +1,20 @@ +type: map +mapping: + company: + type: str + required: yes + email: + type: str + employees: + type: seq + sequence: + - type: map + mapping: + code: + type: int + required: yes + name: + type: str + required: yes + email: + type: str diff --git a/javatoscachecker/kwalify/src/test/resources/validateMapSchema.yml b/javatoscachecker/kwalify/src/test/resources/validateMapSchema.yml new file mode 100644 index 0000000..72361aa --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/validateMapSchema.yml @@ -0,0 +1,12 @@ +type: map +mapping: + name: + type: str + required: yes + email: + type: str + pattern: /@/ + age: + type: int + birth: + type: date diff --git a/javatoscachecker/kwalify/src/test/resources/validateRule.yml b/javatoscachecker/kwalify/src/test/resources/validateRule.yml new file mode 100644 index 0000000..0e6ee06 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/validateRule.yml @@ -0,0 +1,23 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +- name: foo + email: foo@mail.com + password: xxx123456 + age: 20 + blood: A + birth: 1985-01-01 +- name: bar + email: bar@mail.net + age: 25 + blood: AB + birth: 1980-01-01 diff --git a/javatoscachecker/kwalify/src/test/resources/validateRuleSchema.yml b/javatoscachecker/kwalify/src/test/resources/validateRuleSchema.yml new file mode 100644 index 0000000..7b1f1b6 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/validateRuleSchema.yml @@ -0,0 +1,30 @@ +type: seq +sequence: + - + type: map + mapping: + name: + type: str + required: yes + email: + type: str + required: yes + pattern: /@/ + password: + type: text + length: { max: 16, min: 8 } + age: + type: int + range: { max: 30, min: 18 } + # or assert: 18 <= val && val <= 30 + blood: + type: str + enum: + - A + - B + - O + - AB + birth: + type: date + memo: + type: any diff --git a/javatoscachecker/kwalify/src/test/resources/validateSeq.yml b/javatoscachecker/kwalify/src/test/resources/validateSeq.yml new file mode 100644 index 0000000..d75d58f --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/validateSeq.yml @@ -0,0 +1,15 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +- foo +- bar +- baz diff --git a/javatoscachecker/kwalify/src/test/resources/validateSeqOfMap.yml b/javatoscachecker/kwalify/src/test/resources/validateSeqOfMap.yml new file mode 100644 index 0000000..cd05584 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/validateSeqOfMap.yml @@ -0,0 +1,18 @@ +# +# Copyright (c) 2017 <AT&T>. All rights reserved. +# =================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for +# the specific language governing permissions and limitations under the License. +# +- name: foo + email: foo@mail.com +- name: bar + email: bar@mail.net +- name: baz + email: baz@mail.org diff --git a/javatoscachecker/kwalify/src/test/resources/validateSeqOfMapSchema.yml b/javatoscachecker/kwalify/src/test/resources/validateSeqOfMapSchema.yml new file mode 100644 index 0000000..73af17a --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/validateSeqOfMapSchema.yml @@ -0,0 +1,9 @@ +type: seq +sequence: + - type: map + mapping: + name: + type: str + required: true + email: + type: str diff --git a/javatoscachecker/kwalify/src/test/resources/validateSeqSchema.yml b/javatoscachecker/kwalify/src/test/resources/validateSeqSchema.yml new file mode 100644 index 0000000..4e02606 --- /dev/null +++ b/javatoscachecker/kwalify/src/test/resources/validateSeqSchema.yml @@ -0,0 +1,3 @@ +type: seq +sequence: + - type: str |