http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/svl/vars/IfVarTest.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/svl/vars/IfVarTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/svl/vars/IfVarTest.java new file mode 100755 index 0000000..41f67b7 --- /dev/null +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/svl/vars/IfVarTest.java @@ -0,0 +1,46 @@ +// *************************************************************************************************************************** +// * 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.svl.vars; + +import static org.junit.Assert.*; + +import org.apache.juneau.svl.*; +import org.junit.*; + +@SuppressWarnings("javadoc") +public class IfVarTest { + + //==================================================================================================== + // test - Basic tests + //==================================================================================================== + @Test + public void test() throws Exception { + VarResolver vr = new VarResolverBuilder().vars(IfVar.class, SystemPropertiesVar.class).build(); + + for (String test : new String[]{"","0","false","FALSE","f","F","foobar"}) { + System.setProperty("IfVarTest.test", test); + assertEquals("NO", vr.resolve("$IF{$S{IfVarTest.test},YES,NO}")); + assertEquals("x NO x", vr.resolve("x $IF{ $S{ IfVarTest.test } , YES , NO } x")); + assertEquals("", vr.resolve("$IF{$S{IfVarTest.test},YES}")); + assertEquals("x x", vr.resolve("x $IF{ $S{ IfVarTest.test } , YES } x")); + } + + for (String test : new String[]{"1","true","TRUE","t","T"}) { + System.setProperty("IfVarTest.test", test); + assertEquals("YES", vr.resolve("$IF{$S{IfVarTest.test},YES,NO}")); + assertEquals("YES", vr.resolve("$IF{$S{IfVarTest.test},YES}")); + assertEquals("x YES x", vr.resolve("x $IF{ $S{ IfVarTest.test } , YES , NO } x")); + assertEquals("x YES x", vr.resolve("x $IF{ $S{ IfVarTest.test } , YES } x")); + } + } +}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/svl/vars/SwitchVarTest.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/svl/vars/SwitchVarTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/svl/vars/SwitchVarTest.java new file mode 100644 index 0000000..62167dc --- /dev/null +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/svl/vars/SwitchVarTest.java @@ -0,0 +1,53 @@ +// *************************************************************************************************************************** +// * 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.svl.vars; + +import static org.junit.Assert.*; + +import org.apache.juneau.svl.*; +import org.junit.*; + +@SuppressWarnings("javadoc") +public class SwitchVarTest { + + //==================================================================================================== + // test - Basic tests + //==================================================================================================== + @Test + public void test() throws Exception { + VarResolver vr = new VarResolverBuilder().vars(SwitchVar.class, SystemPropertiesVar.class).build(); + + System.setProperty("SwitchVarTest.test", "foobar"); + + assertEquals("YES", vr.resolve("$SW{$S{SwitchVarTest.test},foobar,YES}")); + assertEquals("YES", vr.resolve("$SW{ $S{ SwitchVarTest.test } , foobar , YES }")); + assertEquals("", vr.resolve("$SW{$S{SwitchVarTest.test},foobar2,YES}")); + assertEquals("NO", vr.resolve("$SW{$S{SwitchVarTest.test},foobar2,YES,NO}")); + assertEquals("NO", vr.resolve("$SW{ $S{ SwitchVarTest.test } , foobar2 , YES , NO }")); + + assertEquals("YES", vr.resolve("$SW{$S{SwitchVarTest.test},foo*,YES,NO}")); + assertEquals("YES", vr.resolve("$SW{$S{SwitchVarTest.test},*bar,YES,NO}")); + assertEquals("YES", vr.resolve("$SW{$S{SwitchVarTest.test},*,YES,NO}")); + assertEquals("YES", vr.resolve("$SW{$S{SwitchVarTest.test},??????,YES,NO}")); + + assertEquals("NO", vr.resolve("$SW{$S{SwitchVarTest.test},foox*,YES,NO}")); + assertEquals("NO", vr.resolve("$SW{$S{SwitchVarTest.test},*xbar,YES,NO}")); + assertEquals("NO", vr.resolve("$SW{$S{SwitchVarTest.test},?????,YES,NO}")); + assertEquals("NO", vr.resolve("$SW{$S{SwitchVarTest.test},???????,YES,NO}")); + + assertEquals("YES2", vr.resolve("$SW{$S{SwitchVarTest.test},foox*,YES1,foo*,YES2}")); + assertEquals("YES2", vr.resolve("$SW{$S{SwitchVarTest.test},foox*,YES1,foo*,YES2,NO}")); + + assertEquals("NO", vr.resolve("$SW{$S{SwitchVarTest.test},foox*,YES1,fooy*,YES2,NO}")); + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/ABean.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/ABean.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/ABean.java new file mode 100644 index 0000000..aa6a724 --- /dev/null +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/ABean.java @@ -0,0 +1,24 @@ +// *************************************************************************************************************************** +// * 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.test.pojos; + +public class ABean { + public int a; + public String b; + + public ABean init() { + this.a = 1; + this.b = "foo"; + return this; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/Constants.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/Constants.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/Constants.java new file mode 100644 index 0000000..ccfef31 --- /dev/null +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/Constants.java @@ -0,0 +1,25 @@ +// *************************************************************************************************************************** +// * 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.test.pojos; + +/** + * Description. + * <p> + * + * @author James Bognar ([email protected]) + */ +public class Constants { + + public static final String SWAP = "swap-~!@#$%^&*()_+`-={}[]|:;\"<,>.?/"; + +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/ImplicitSwappedPojo.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/ImplicitSwappedPojo.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/ImplicitSwappedPojo.java new file mode 100644 index 0000000..cd1bc0d --- /dev/null +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/ImplicitSwappedPojo.java @@ -0,0 +1,35 @@ +// *************************************************************************************************************************** +// * 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.test.pojos; + +import static org.apache.juneau.test.pojos.Constants.*; + +import org.apache.juneau.annotation.*; + +@BeanIgnore +public class ImplicitSwappedPojo { + public boolean wasUnswapped; + + @Override + public String toString() { + return SWAP; + } + + public ImplicitSwappedPojo() {} + + + public ImplicitSwappedPojo(String fromString) { + if (fromString.equals(SWAP)) + wasUnswapped = true; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/SwappedPojo.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/SwappedPojo.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/SwappedPojo.java new file mode 100644 index 0000000..605fd25 --- /dev/null +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/SwappedPojo.java @@ -0,0 +1,20 @@ +// *************************************************************************************************************************** +// * 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.test.pojos; + +import org.apache.juneau.annotation.*; + +@Pojo(swap=SwappedPojoSwap.class) +public class SwappedPojo { + public boolean wasUnswapped; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/SwappedPojoSwap.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/SwappedPojoSwap.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/SwappedPojoSwap.java new file mode 100644 index 0000000..950b754 --- /dev/null +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/SwappedPojoSwap.java @@ -0,0 +1,35 @@ +// *************************************************************************************************************************** +// * 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.test.pojos; + +import static org.apache.juneau.test.pojos.Constants.*; + +import org.apache.juneau.*; +import org.apache.juneau.parser.*; +import org.apache.juneau.serializer.*; +import org.apache.juneau.transform.*; + +public class SwappedPojoSwap extends PojoSwap<SwappedPojo,String> { + @Override + public String swap(BeanSession session, SwappedPojo c) throws SerializeException { + return SWAP; + } + + @Override + public SwappedPojo unswap(BeanSession session, String f, ClassMeta<?> hint) throws ParseException { + SwappedPojo c = new SwappedPojo(); + if (f.equals(SWAP)) + c.wasUnswapped = true; + return c; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/TestEnum.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/TestEnum.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/TestEnum.java new file mode 100644 index 0000000..63368a4 --- /dev/null +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/TestEnum.java @@ -0,0 +1,17 @@ +// *************************************************************************************************************************** +// * 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.test.pojos; + +public enum TestEnum { + ONE,TWO,THREE +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/TypedBean.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/TypedBean.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/TypedBean.java new file mode 100644 index 0000000..2a50d98 --- /dev/null +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/TypedBean.java @@ -0,0 +1,17 @@ +// *************************************************************************************************************************** +// * 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.test.pojos; + [email protected](beanDictionary={TypedBeanImpl.class}) +public interface TypedBean { +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/TypedBeanImpl.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/TypedBeanImpl.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/TypedBeanImpl.java new file mode 100644 index 0000000..7b00644 --- /dev/null +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/test/pojos/TypedBeanImpl.java @@ -0,0 +1,25 @@ +// *************************************************************************************************************************** +// * 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.test.pojos; + [email protected](typeName="TypedBeanImpl", sort=true) +public class TypedBeanImpl implements TypedBean { + public int a; + public String b; + + public TypedBeanImpl init() { + this.a = 1; + this.b = "foo"; + return this; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/testbeans/PrimitiveAtomicObjectsBean.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/testbeans/PrimitiveAtomicObjectsBean.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/testbeans/PrimitiveAtomicObjectsBean.java new file mode 100755 index 0000000..324a44f --- /dev/null +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/testbeans/PrimitiveAtomicObjectsBean.java @@ -0,0 +1,74 @@ +// *************************************************************************************************************************** +// * 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.testbeans; + +import java.util.*; +import java.util.concurrent.atomic.*; + +import org.apache.juneau.utils.*; + +/** + * Test bean fields of type AtomicInteger and AtomicLong. + * Note that Jena parsers cannot handle these types, so we only test non-Jena parsers. + */ +@SuppressWarnings({"javadoc"}) +public class PrimitiveAtomicObjectsBean { + + // primitive objects + public AtomicInteger poAtomicInteger; + public AtomicLong poAtomicLong; + + // uninitialized primitive objects + public AtomicInteger pouAtomicInteger; + public AtomicLong pouAtomicLong; + + // primitive object arrays + public AtomicInteger[][] poaAtomicInteger; + public AtomicLong[][] poaAtomicLong; + + // primitive object arrays + public AtomicInteger[][] poauAtomicInteger; + public AtomicLong[][] poauAtomicLong; + + // Anonymous list of primitives (types not erased on objects + public List<AtomicInteger[]> poalAtomicInteger; + public List<AtomicLong[]> poalAtomicLong; + + // Regular list of primitives (types erased on objects) + public List<AtomicInteger[]> polAtomicInteger; + public List<AtomicLong[]> polAtomicLong; + + public PrimitiveAtomicObjectsBean init() { + // primitive objects + poAtomicInteger = new AtomicInteger(1); + poAtomicLong = new AtomicLong(2); + + // primitive object arrays + poaAtomicInteger = new AtomicInteger[][]{{new AtomicInteger(1)}, {new AtomicInteger(2)}, null}; + poaAtomicLong = new AtomicLong[][]{{new AtomicLong(1)}, {new AtomicLong(2)}, null}; + + // Anonymous list of primitives + poalAtomicInteger = new AList<AtomicInteger[]>().append(new AtomicInteger[]{new AtomicInteger(1)}).append(null); + poalAtomicLong = new AList<AtomicLong[]>().append(new AtomicLong[]{new AtomicLong(1)}).append(null); + + // Regular list of primitives + polAtomicInteger = new ArrayList<AtomicInteger[]>(); + polAtomicInteger.add(new AtomicInteger[]{new AtomicInteger(1)}); + polAtomicInteger.add(null); + polAtomicLong = new ArrayList<AtomicLong[]>(); + polAtomicLong.add(new AtomicLong[]{new AtomicLong(1)}); + polAtomicLong.add(null); + + return this; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/testbeans/PrimitiveObjectsBean.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/testbeans/PrimitiveObjectsBean.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/testbeans/PrimitiveObjectsBean.java new file mode 100755 index 0000000..9eacaa6 --- /dev/null +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/testbeans/PrimitiveObjectsBean.java @@ -0,0 +1,178 @@ +// *************************************************************************************************************************** +// * 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.testbeans; + +import java.math.*; +import java.util.*; + +import org.apache.juneau.utils.*; + +@SuppressWarnings({"javadoc"}) +public class PrimitiveObjectsBean { + + // primitive objects + public Boolean poBoolean; + public Byte poByte; + public Character poChar; + public Short poShort; + public Integer poInt; + public Long poLong; + public Float poFloat; + public Double poDouble; + public Number poNumber; + public BigInteger poBigInteger; + public BigDecimal poBigDecimal; + + // uninitialized primitive objects + public Boolean pouBoolean; + public Byte pouByte; + public Character pouChar; + public Short pouShort; + public Integer pouInt; + public Long pouLong; + public Float pouFloat; + public Double pouDouble; + public Number pouNumber; + public BigInteger pouBigInteger; + public BigDecimal pouBigDecimal; + + // primitive object arrays + public Boolean[][] poaBoolean; + public Byte[][] poaByte; + public Character[][] poaChar; + public Short[][] poaShort; + public Integer[][] poaInt; + public Long[][] poaLong; + public Float[][] poaFloat; + public Double[][] poaDouble; + public Number[][] poaNumber; + public BigInteger[][] poaBigInteger; + public BigDecimal[][] poaBigDecimal; + + // primitive object arrays + public Boolean[][] poauBoolean; + public Byte[][] poauByte; + public Character[][] poauChar; + public Short[][] poauShort; + public Integer[][] poauInt; + public Long[][] poauLong; + public Float[][] poauFloat; + public Double[][] poauDouble; + public Number[][] poauNumber; + public BigInteger[][] poauBigInteger; + public BigDecimal[][] poauBigDecimal; + + // Anonymous list of primitives (types not erased on objects + public List<Boolean[]> poalBoolean; + public List<Byte[]> poalByte; + public List<Character[]> poalChar; + public List<Short[]> poalShort; + public List<Integer[]> poalInt; + public List<Long[]> poalLong; + public List<Float[]> poalFloat; + public List<Double[]> poalDouble; + public List<Number[]> poalNumber; + public List<BigInteger[]> poalBigInteger; + public List<BigDecimal[]> poalBigDecimal; + + // Regular list of primitives (types erased on objects) + public List<Boolean[]> polBoolean; + public List<Byte[]> polByte; + public List<Character[]> polChar; + public List<Short[]> polShort; + public List<Integer[]> polInt; + public List<Long[]> polLong; + public List<Float[]> polFloat; + public List<Double[]> polDouble; + public List<Number[]> polNumber; + public List<BigInteger[]> polBigInteger; + public List<BigDecimal[]> polBigDecimal; + + public PrimitiveObjectsBean init() { + // primitive objects + poBoolean = true; + poByte = 1; + poChar = 'a'; + poShort = 2; + poInt = 3; + poLong = 4l; + poFloat = 5f; + poDouble = 6d; + poNumber = 7; + poBigInteger = new BigInteger("8"); + poBigDecimal = new BigDecimal("9"); + + // primitive object arrays + poaBoolean = new Boolean[][]{{true},{false},null}; + poaByte = new Byte[][]{{1},{2},null}; + poaChar = new Character[][]{{'a'},{'b'},null}; + poaShort = new Short[][]{{1},{2},null}; + poaInt = new Integer[][]{{1},{2},null}; + poaLong = new Long[][]{{1l},{2l},null}; + poaFloat = new Float[][]{{1f},{2f},null}; + poaDouble = new Double[][]{{1d},{2d},null}; + poaNumber = new Number[][]{{1},{2},null}; + poaBigInteger = new BigInteger[][]{{new BigInteger("1")}, {new BigInteger("2")}, null}; + poaBigDecimal = new BigDecimal[][]{{new BigDecimal("1")}, {new BigDecimal("2")}, null}; + + // Anonymous list of primitives + poalBoolean = new AList<Boolean[]>().append(new Boolean[]{Boolean.TRUE}).append(null); + poalByte = new AList<Byte[]>().append(new Byte[]{1}).append(null); + poalChar = new AList<Character[]>().append(new Character[]{'a'}).append(null); + poalShort = new AList<Short[]>().append(new Short[]{1}).append(null); + poalInt = new AList<Integer[]>().append(new Integer[]{1}).append(null); + poalLong = new AList<Long[]>().append(new Long[]{1l}).append(null); + poalFloat = new AList<Float[]>().append(new Float[]{1f}).append(null); + poalDouble = new AList<Double[]>().append(new Double[]{1d}).append(null); + poalNumber = new AList<Number[]>().append(new Integer[]{1}).append(null); + poalBigInteger = new AList<BigInteger[]>().append(new BigInteger[]{new BigInteger("1")}).append(null); + poalBigDecimal = new AList<BigDecimal[]>().append(new BigDecimal[]{new BigDecimal("1")}).append(null); + + // Regular list of primitives + polBoolean = new ArrayList<Boolean[]>(); + polBoolean.add(new Boolean[]{Boolean.TRUE}); + polBoolean.add(null); + polByte = new ArrayList<Byte[]>(); + polByte.add(new Byte[]{1}); + polByte.add(null); + polChar = new ArrayList<Character[]>(); + polChar.add(new Character[]{'a'}); + polChar.add(null); + polShort = new ArrayList<Short[]>(); + polShort.add(new Short[]{1}); + polShort.add(null); + polInt = new ArrayList<Integer[]>(); + polInt.add(new Integer[]{1}); + polInt.add(null); + polLong = new ArrayList<Long[]>(); + polLong.add(new Long[]{1l}); + polLong.add(null); + polFloat = new ArrayList<Float[]>(); + polFloat.add(new Float[]{1f}); + polFloat.add(null); + polDouble = new ArrayList<Double[]>(); + polDouble.add(new Double[]{1d}); + polDouble.add(null); + polNumber = new ArrayList<Number[]>(); + polNumber.add(new Number[]{1}); + polNumber.add(null); + polBigInteger = new ArrayList<BigInteger[]>(); + polBigInteger.add(new BigInteger[]{new BigInteger("1")}); + polBigInteger.add(null); + polBigDecimal = new ArrayList<BigDecimal[]>(); + polBigDecimal.add(new BigDecimal[]{new BigDecimal("1")}); + polBigDecimal.add(null); + + return this; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/testbeans/TestURI.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/testbeans/TestURI.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/testbeans/TestURI.java new file mode 100755 index 0000000..b257cb5 --- /dev/null +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/testbeans/TestURI.java @@ -0,0 +1,70 @@ +// *************************************************************************************************************************** +// * 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.testbeans; + +import java.net.*; +import java.net.URI; + +import org.apache.juneau.annotation.*; +import org.apache.juneau.jena.annotation.*; +import org.apache.juneau.xml.annotation.*; + +@SuppressWarnings("javadoc") +@Bean(sort=true) +public class TestURI { + @org.apache.juneau.annotation.URI + @Rdf(beanUri=true) + @Xml(format=XmlFormat.ATTR) + public String f0 = "f0/x0"; + + public URI f1, f2, f3; + + @org.apache.juneau.annotation.URI + public String f4, f5, f6; + + public URL f7; + + public TestURIb f8; + + public String fa, fb, fc, fd, fe; + + @org.apache.juneau.annotation.URI + public String getF9() { + return "f9/x9"; + } + + public TestURI() throws Exception { + f1 = new URI("f1/x1"); + f2 = new URI("/f2/x2"); + f3 = new URI("http://www.apache.org/f3/x3"); + f4 = "f4/x4"; + f5 = "/f5/x5"; + f6 = "http://www.apache.org/f6/x6"; + f7 = new URL("http://www.apache.org/f7/x7"); + f8 = new TestURIb(); + fa = "http://www.apache.org/fa/xa#MY_LABEL"; + fb = "http://www.apache.org/fb/xb?label=MY_LABEL&foo=bar"; + fc = "http://www.apache.org/fc/xc?foo=bar&label=MY_LABEL"; + fd = "http://www.apache.org/fd/xd?label2=MY_LABEL&foo=bar"; + fe = "http://www.apache.org/fe/xe?foo=bar&label2=MY_LABEL"; + } + + @org.apache.juneau.annotation.URI + public static class TestURIb { + @Override /* Object */ + public String toString() { + return "f8/x8"; + } + } +} +
