http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ab15d45b/juneau-core-test/src/test/java/org/apache/juneau/dto/html5/Html5TemplateComboTest.java ---------------------------------------------------------------------- diff --git a/juneau-core-test/src/test/java/org/apache/juneau/dto/html5/Html5TemplateComboTest.java b/juneau-core-test/src/test/java/org/apache/juneau/dto/html5/Html5TemplateComboTest.java deleted file mode 100644 index e3a3267..0000000 --- a/juneau-core-test/src/test/java/org/apache/juneau/dto/html5/Html5TemplateComboTest.java +++ /dev/null @@ -1,104 +0,0 @@ -// *************************************************************************************************************************** -// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * -// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * -// * to you 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 org.apache.juneau.dto.html5; - -import static org.apache.juneau.TestUtils.*; - -import static org.apache.juneau.dto.html5.HtmlBuilder.*; - -import java.util.*; - -import org.apache.juneau.*; -import org.apache.juneau.annotation.*; -import org.junit.runner.*; -import org.junit.runners.*; - -/** - * Tests serialization of HTML5 templates. - */ -@RunWith(Parameterized.class) -@SuppressWarnings({"javadoc"}) -public class Html5TemplateComboTest extends ComboRoundTripTest { - - @Parameterized.Parameters - public static Collection<Object[]> getParameters() { - return Arrays.asList(new Object[][] { - { - new ComboInput<FormTemplate>( - "FormTemplate-1", - FormTemplate.class, - new FormTemplate("http://myaction", 123, true), - /* Json */ "{a:{action:'http://myaction'},c:[{_type:'input',a:{type:'text',name:'v1',value:123}},{_type:'input',a:{type:'text',name:'v2',value:true}}]}", - /* JsonT */ "{a:{action:'http://myaction'},c:[{t:'input',a:{type:'text',name:'v1',value:123}},{t:'input',a:{type:'text',name:'v2',value:true}}]}", - /* JsonR */ "{\n\ta: {\n\t\taction: 'http://myaction'\n\t},\n\tc: [\n\t\t{\n\t\t\t_type: 'input',\n\t\t\ta: {\n\t\t\t\ttype: 'text',\n\t\t\t\tname: 'v1',\n\t\t\t\tvalue: 123\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t_type: 'input',\n\t\t\ta: {\n\t\t\t\ttype: 'text',\n\t\t\t\tname: 'v2',\n\t\t\t\tvalue: true\n\t\t\t}\n\t\t}\n\t]\n}", - /* Xml */ "<form action='http://myaction'><input type='text' name='v1' value='123'/><input type='text' name='v2' value='true'/></form>", - /* XmlT */ "<form action='http://myaction'><input type='text' name='v1' value='123'/><input type='text' name='v2' value='true'/></form>", - /* XmlR */ "<form action='http://myaction'><input type='text' name='v1' value='123'/><input type='text' name='v2' value='true'/></form>\n", - /* XmlNs */ "<form action='http://myaction'><input type='text' name='v1' value='123'/><input type='text' name='v2' value='true'/></form>", - /* Html */ "<form action='http://myaction'><input type='text' name='v1' value='123'/><input type='text' name='v2' value='true'/></form>", - /* HtmlT */ "<form action='http://myaction'><input type='text' name='v1' value='123'/><input type='text' name='v2' value='true'/></form>", - /* HtmlR */ "<form action='http://myaction'><input type='text' name='v1' value='123'/><input type='text' name='v2' value='true'/></form>\n", - /* Uon */ "(a=(action=http://myaction),c=@((_type=input,a=(type=text,name=v1,value=123)),(_type=input,a=(type=text,name=v2,value=true))))", - /* UonT */ "(a=(action=http://myaction),c=@((t=input,a=(type=text,name=v1,value=123)),(t=input,a=(type=text,name=v2,value=true))))", - /* UonR */ "(\n\ta=(\n\t\taction=http://myaction\n\t),\n\tc=@(\n\t\t(\n\t\t\t_type=input,\n\t\t\ta=(\n\t\t\t\ttype=text,\n\t\t\t\tname=v1,\n\t\t\t\tvalue=123\n\t\t\t)\n\t\t),\n\t\t(\n\t\t\t_type=input,\n\t\t\ta=(\n\t\t\t\ttype=text,\n\t\t\t\tname=v2,\n\t\t\t\tvalue=true\n\t\t\t)\n\t\t)\n\t)\n)", - /* UrlEnc */ "a=(action=http://myaction)&c=@((_type=input,a=(type=text,name=v1,value=123)),(_type=input,a=(type=text,name=v2,value=true)))", - /* UrlEncT */ "a=(action=http://myaction)&c=@((t=input,a=(type=text,name=v1,value=123)),(t=input,a=(type=text,name=v2,value=true)))", - /* UrlEncR */ "a=(\n\taction=http://myaction\n)\n&c=@(\n\t(\n\t\t_type=input,\n\t\ta=(\n\t\t\ttype=text,\n\t\t\tname=v1,\n\t\t\tvalue=123\n\t\t)\n\t),\n\t(\n\t\t_type=input,\n\t\ta=(\n\t\t\ttype=text,\n\t\t\tname=v2,\n\t\t\tvalue=true\n\t\t)\n\t)\n)", - /* MsgPack */ "82A16181A6616374696F6EAF687474703A2F2F6D79616374696F6EA1639282A55F74797065A5696E707574A16183A474797065A474657874A46E616D65A27631A576616C75657B82A55F74797065A5696E707574A16183A474797065A474657874A46E616D65A27632A576616C7565C3", - /* MsgPackT */ "82A16181A6616374696F6EAF687474703A2F2F6D79616374696F6EA1639282A174A5696E707574A16183A474797065A474657874A46E616D65A27631A576616C75657B82A174A5696E707574A16183A474797065A474657874A46E616D65A27632A576616C7565C3", - /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:a rdf:parseType='Resource'>\n<jp:action rdf:resource='http://myaction'/>\n</jp:a>\n<jp:c>\n<rdf:Seq>\n<rdf:li rdf:parseType='Resource'>\n<jp:_type>input</jp:_type>\n<jp:a rdf:parseType='Resource'>\n<jp:type>text</jp:type>\n<jp:name>v1</jp:name>\n<jp:value>123</jp:value>\n</jp:a>\n</rdf:li>\n<rdf:li rdf:parseType='Resource'>\n<jp:_type>input</jp:_type>\n<jp:a rdf:parseType='Resource'>\n<jp:type>text</jp:type>\n<jp:name>v2</jp:name>\n<jp:value>true</jp:value>\n</jp:a>\n</rdf:li>\n</rdf:Seq>\n</jp:c>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<jp:a rdf:parseType='Resource'>\n<jp:action rdf:resource='http://myaction'/>\n</jp:a>\n<jp:c>\n<rdf:Seq>\n<rdf:li rdf:parseType='Resource'>\n<jp:t>input</jp:t>\n<jp:a rdf:parseType='Resource'>\n<jp:type>text</jp:type>\n<jp:name>v1</jp:name>\n<jp:value>123</jp:value>\n</jp:a>\n</rdf:li>\n<rdf:li rdf:parseType='Resource'>\n<jp:t>input</jp:t>\n<jp:a rdf:parseType='Resource'>\n<jp:type>text</jp:type>\n<jp:name>v2</jp:name>\n<jp:value>true</jp:value>\n</jp:a>\n</rdf:li>\n</rdf:Seq>\n</jp:c>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <jp:a rdf:parseType='Resource'>\n <jp:action rdf:resource='http://myaction'/>\n </jp:a>\n <jp:c>\n <rdf:Seq>\n <rdf:li rdf:parseType='Resource'>\n <jp:_type>input</jp:_type>\n <jp:a rdf:parseType='Resource'>\n <jp:type>text</jp:type>\n <jp:name>v1</jp:name>\n <jp:value>123</jp:value>\n </jp:a>\n </rdf:li>\n <rdf:li rdf:parseType='Resource'>\n <jp:_type>input</jp:_type>\n <jp:a rdf:parseType='Resource'>\n <jp:type>text</jp:type>\n <jp:name>v2</jp:name>\n <jp:value>true</jp:value>\n </jp:a>\n </rdf:li>\n </rdf:Seq>\n </jp:c>\n </rdf:Description>\n</rdf:RDF>\n" - ) - { - @Override - public void verify(FormTemplate o) { - assertType(FormTemplate.class, o); - } - } - }, - }); - } - - - @Bean(beanDictionary=HtmlBeanDictionary.class) - public static class FormTemplate { - - private String action; - private int value1; - private boolean value2; - - public FormTemplate(Form f) { - this.action = f.getAttr("action"); - this.value1 = f.getChild(Input.class, 0).getAttr(int.class, "value"); - this.value2 = f.getChild(Input.class, 1).getAttr(boolean.class, "value"); - } - - public FormTemplate(String action, int value1, boolean value2) { - this.action = action; - this.value1 = value1; - this.value2 = value2; - } - - public Form swap(BeanSession session) { - return form(action, - input("text").name("v1").value(value1), - input("text").name("v2").value(value2) - ); - } - } - - public Html5TemplateComboTest(ComboInput<?> comboInput) { - super(comboInput); - } -}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ab15d45b/juneau-core-test/src/test/java/org/apache/juneau/dto/jsonschema/JsonSchemaTest.java ---------------------------------------------------------------------- diff --git a/juneau-core-test/src/test/java/org/apache/juneau/dto/jsonschema/JsonSchemaTest.java b/juneau-core-test/src/test/java/org/apache/juneau/dto/jsonschema/JsonSchemaTest.java deleted file mode 100755 index 19d95e9..0000000 --- a/juneau-core-test/src/test/java/org/apache/juneau/dto/jsonschema/JsonSchemaTest.java +++ /dev/null @@ -1,204 +0,0 @@ -// *************************************************************************************************************************** -// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * -// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * -// * to you 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 org.apache.juneau.dto.jsonschema; - -import static org.junit.Assert.*; - -import java.net.*; - -import org.apache.juneau.json.*; -import org.junit.*; - -@SuppressWarnings("javadoc") -public class JsonSchemaTest { - - @Test - public void testSchema1() throws Exception { - JsonSerializer s = new JsonSerializerBuilder().simple().ws().addBeanTypeProperties(false).build(); - JsonParser p = JsonParser.DEFAULT; - String r; - Schema t, t2; - - String expected = - "{\n" - +" id: 'http://id',\n" - +" '$schema': 'http://schemaVersionUri',\n" - +" title: 'title',\n" - +" description: 'description',\n" - +" type: 'number',\n" - +" definitions: {\n" - +" definition: {\n" - +" '$ref': 'http://definition'\n" - +" }\n" - +" },\n" - +" properties: {\n" - +" property: {\n" - +" type: 'number'\n" - +" }\n" - +" },\n" - +" patternProperties: {\n" - +" '/pattern/': {\n" - +" type: 'number'\n" - +" }\n" - +" },\n" - +" dependencies: {\n" - +" dependency: {\n" - +" '$ref': 'http://dependency'\n" - +" }\n" - +" },\n" - +" items: [\n" - +" {\n" - +" type: 'number'\n" - +" }\n" - +" ],\n" - +" multipleOf: 1,\n" - +" maximum: 2,\n" - +" exclusiveMaximum: true,\n" - +" minimum: 3,\n" - +" exclusiveMinimum: true,\n" - +" maxLength: 4,\n" - +" minLength: 5,\n" - +" pattern: '/pattern/',\n" - +" additionalItems: [\n" - +" {\n" - +" type: 'number'\n" - +" }\n" - +" ],\n" - +" maxItems: 6,\n" - +" minItems: 7,\n" - +" uniqueItems: true,\n" - +" maxProperties: 8,\n" - +" minProperties: 9,\n" - +" required: [\n" - +" 'required'\n" - +" ],\n" - +" additionalProperties: {\n" - +" '$ref': 'http://additionalProperty'\n" - +" },\n" - +" 'enum': [\n" - +" 'enum'\n" - +" ],\n" - +" allOf: [\n" - +" {\n" - +" '$ref': 'http://allOf'\n" - +" }\n" - +" ],\n" - +" anyOf: [\n" - +" {\n" - +" '$ref': 'http://anyOf'\n" - +" }\n" - +" ],\n" - +" oneOf: [\n" - +" {\n" - +" '$ref': 'http://oneOf'\n" - +" }\n" - +" ],\n" - +" not: {\n" - +" '$ref': 'http://not'\n" - +" }\n" - +"}"; - - t = getTest1(); - r = s.serialize(t); - assertEquals(expected, r); - t2 = p.parse(r, Schema.class); - r = s.serialize(t2); - assertEquals(expected, r); - } - - @Test - public void testSchema2() throws Exception { - JsonSerializer s = new JsonSerializerBuilder().simple().ws().addBeanTypeProperties(false).build(); - JsonParser p = JsonParser.DEFAULT; - String r; - Schema t, t2; - - String expected = - "{\n" - +" id: 'http://id',\n" - +" '$schema': 'http://schemaVersionUri',\n" - +" type: [\n" - +" 'string',\n" - +" 'number'\n" - +" ],\n" - +" definitions: {\n" - +" definition: {\n" - +" id: 'http://definition'\n" - +" }\n" - +" },\n" - +" items: [\n" - +" {\n" - +" '$ref': 'http://items'\n" - +" }\n" - +" ],\n" - +" additionalItems: true,\n" - +" additionalProperties: true\n" - +"}"; - - t = getTest2(); - r = s.serialize(t); - assertEquals(expected, r); - t2 = p.parse(r, Schema.class); - r = s.serialize(t2); - assertEquals(expected, r); - } - - /** Bean with simple values for each property */ - public static Schema getTest1() { - return new Schema() - .setId("http://id") - .setSchemaVersionUri("http://schemaVersionUri") - .setTitle("title") - .setDescription("description") - .setType(JsonType.NUMBER) - .addDefinition("definition", new SchemaRef("http://definition")) - .addProperties(new SchemaProperty("property", JsonType.NUMBER)) - .addPatternProperties(new SchemaProperty("/pattern/", JsonType.NUMBER)) - .addDependency("dependency", new SchemaRef("http://dependency")) - .addItems(new Schema().setType(JsonType.NUMBER)) - .setMultipleOf(1) - .setMaximum(2) - .setExclusiveMaximum(true) - .setMinimum(3) - .setExclusiveMinimum(true) - .setMaxLength(4) - .setMinLength(5) - .setPattern("/pattern/") - .addAdditionalItems(new SchemaProperty("additionalItem", JsonType.NUMBER)) - .setMaxItems(6) - .setMinItems(7) - .setUniqueItems(true) - .setMaxProperties(8) - .setMinProperties(9) - .addRequired("required") - .setAdditionalProperties(new SchemaRef("http://additionalProperty")) - .addEnum("enum") - .addAllOf(new SchemaRef("http://allOf")) - .addAnyOf(new SchemaRef("http://anyOf")) - .addOneOf(new SchemaRef("http://oneOf")) - .setNot(new SchemaRef("http://not")) - ; - } - - /** Bean with other possible property value types not covered in test1 */ - public static Schema getTest2() { - return new Schema() - .setId(URI.create("http://id")) - .setSchemaVersionUri(URI.create("http://schemaVersionUri")) - .setType(new JsonTypeArray(JsonType.STRING, JsonType.NUMBER)) - .addDefinition("definition", new Schema().setId("http://definition")) - .setItems(new SchemaArray(new SchemaRef("http://items"))) - .setAdditionalItems(Boolean.TRUE) - .setAdditionalProperties(Boolean.TRUE); - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ab15d45b/juneau-core-test/src/test/java/org/apache/juneau/encoders/EncoderGroupTest.java ---------------------------------------------------------------------- diff --git a/juneau-core-test/src/test/java/org/apache/juneau/encoders/EncoderGroupTest.java b/juneau-core-test/src/test/java/org/apache/juneau/encoders/EncoderGroupTest.java deleted file mode 100755 index 3a0e026..0000000 --- a/juneau-core-test/src/test/java/org/apache/juneau/encoders/EncoderGroupTest.java +++ /dev/null @@ -1,116 +0,0 @@ -// *************************************************************************************************************************** -// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * -// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * -// * to you 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 org.apache.juneau.encoders; - -import static org.apache.juneau.TestUtils.*; - -import org.junit.*; - -@SuppressWarnings({"javadoc"}) -public class EncoderGroupTest { - - //==================================================================================================== - // Test matching - //==================================================================================================== - @Test - public void testEncoderGroupMatching() throws Exception { - - EncoderGroup g = new EncoderGroupBuilder().append(Encoder1.class, Encoder2.class, Encoder3.class).build(); - assertType(Encoder1.class, g.getEncoder("gzip1")); - assertType(Encoder2.class, g.getEncoder("gzip2")); - assertType(Encoder2.class, g.getEncoder("gzip2a")); - assertType(Encoder3.class, g.getEncoder("gzip3")); - assertType(Encoder3.class, g.getEncoder("gzip3a")); - assertType(Encoder3.class, g.getEncoder("gzip3,gzip2,gzip1")); - assertType(Encoder1.class, g.getEncoder("gzip3;q=0.9,gzip2;q=0.1,gzip1")); - assertType(Encoder3.class, g.getEncoder("gzip2;q=0.9,gzip1;q=0.1,gzip3")); - assertType(Encoder2.class, g.getEncoder("gzip1;q=0.9,gzip3;q=0.1,gzip2")); - } - - public static class Encoder1 extends GzipEncoder { - @Override /* Encoder */ - public String[] getCodings() { - return new String[]{"gzip1"}; - } - } - - public static class Encoder2 extends GzipEncoder { - @Override /* Encoder */ - public String[] getCodings() { - return new String[]{"gzip2","gzip2a"}; - } - } - - public static class Encoder3 extends GzipEncoder { - @Override /* Encoder */ - public String[] getCodings() { - return new String[]{"gzip3","gzip3a"}; - } - } - - //==================================================================================================== - // Test inheritence - //==================================================================================================== - @Test - public void testInheritence() throws Exception { - EncoderGroupBuilder gb = null; - EncoderGroup g = null; - - gb = new EncoderGroupBuilder().append(E1.class, E2.class); - g = gb.build(); - assertObjectEquals("['E1','E2','E2a']", g.getSupportedEncodings()); - - gb = new EncoderGroupBuilder(g).append(E3.class, E4.class); - g = gb.build(); - assertObjectEquals("['E3','E4','E4a','E1','E2','E2a']", g.getSupportedEncodings()); - - gb = new EncoderGroupBuilder(g).append(E5.class); - g = gb.build(); - assertObjectEquals("['E5','E3','E4','E4a','E1','E2','E2a']", g.getSupportedEncodings()); - } - - public static class E1 extends GzipEncoder { - @Override /* Encoder */ - public String[] getCodings() { - return new String[]{"E1"}; - } - } - - public static class E2 extends GzipEncoder { - @Override /* Encoder */ - public String[] getCodings() { - return new String[]{"E2","E2a"}; - } - } - - public static class E3 extends GzipEncoder { - @Override /* Encoder */ - public String[] getCodings() { - return new String[]{"E3"}; - } - } - - public static class E4 extends GzipEncoder { - @Override /* Encoder */ - public String[] getCodings() { - return new String[]{"E4","E4a"}; - } - } - - public static class E5 extends GzipEncoder { - @Override /* Encoder */ - public String[] getCodings() { - return new String[]{"E5"}; - } - } -}
