TAP5-1213 - Refactor public API changes to be backwards compatible
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/737ebd64 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/737ebd64 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/737ebd64 Branch: refs/heads/master Commit: 737ebd64cf8f1607b5c755c7967260e1e755633d Parents: daa2790 Author: uklance <[email protected]> Authored: Mon May 19 21:33:03 2014 +0100 Committer: uklance <[email protected]> Committed: Mon May 19 21:34:52 2014 +0100 ---------------------------------------------------------------------- .../main/java/org/apache/tapestry5/Binding.java | 9 ----- .../java/org/apache/tapestry5/Binding2.java | 38 +++++++++++++++++++ .../org/apache/tapestry5/PropertyConduit.java | 13 ------- .../org/apache/tapestry5/PropertyConduit2.java | 40 ++++++++++++++++++++ .../internal/InternalPropertyConduit.java | 6 +-- .../internal/TapestryInternalUtils.java | 6 ++- .../internal/bindings/AbstractBinding.java | 3 +- .../internal/bindings/InternalPropBinding.java | 4 +- .../internal/bindings/PropBinding.java | 17 ++++++--- .../CoercingPropertyConduitWrapper.java | 14 ++++--- .../services/PropertyConduitSourceImpl.java | 3 +- .../InternalComponentResourcesImpl.java | 9 ++++- .../integration/app1/CoreBehaviorsTests.java | 18 ++++----- .../app1/components/GenericTypeDisplay.java | 8 ++-- .../integration/app1/pages/GenericTypeDemo.java | 14 +------ .../services/PropertyConduitSourceImplTest.java | 19 +++++----- .../integration/app1/pages/GenericTypeDemo.tml | 18 ++++----- 17 files changed, 153 insertions(+), 86 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/737ebd64/tapestry-core/src/main/java/org/apache/tapestry5/Binding.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/Binding.java b/tapestry-core/src/main/java/org/apache/tapestry5/Binding.java index 711c748..8a99914 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/Binding.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/Binding.java @@ -14,8 +14,6 @@ package org.apache.tapestry5; -import java.lang.reflect.Type; - import org.apache.tapestry5.ioc.AnnotationProvider; /** @@ -55,11 +53,4 @@ public interface Binding extends AnnotationProvider * bound. */ Class getBindingType(); - - /** - * Returns the generic type of the binding, either the generic type of resource exposed by the binding, or the - * generic type of the property bound. - * @since 5.4 - */ - Type getBindingGenericType(); } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/737ebd64/tapestry-core/src/main/java/org/apache/tapestry5/Binding2.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/Binding2.java b/tapestry-core/src/main/java/org/apache/tapestry5/Binding2.java new file mode 100644 index 0000000..7569a8c --- /dev/null +++ b/tapestry-core/src/main/java/org/apache/tapestry5/Binding2.java @@ -0,0 +1,38 @@ +// Copyright 2006-2013 The Apache Software Foundation +// +// 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 org.apache.tapestry5; + +import java.lang.reflect.Method; +import java.lang.reflect.Type; + +import org.apache.tapestry5.services.BindingFactory; + +/** + * Extension to {@link Binding} that adds a method to access the generic property type. + * {@link BindingFactory} instances should ideally return Binding2 objects, not Binding. + * This is only primarily of interest to {@link ComponentResources}. + * + * @since 5.4 + */ +public interface Binding2 extends Binding +{ + /** + * Returns the generic type of the binding + * + * @see Method#getGenericReturnType() + * @see java.lang.reflect.Field#getGenericType() + */ + Type getBindingGenericType(); +} http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/737ebd64/tapestry-core/src/main/java/org/apache/tapestry5/PropertyConduit.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/PropertyConduit.java b/tapestry-core/src/main/java/org/apache/tapestry5/PropertyConduit.java index b28293a..3dbb0c0 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/PropertyConduit.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/PropertyConduit.java @@ -14,8 +14,6 @@ package org.apache.tapestry5; -import java.lang.reflect.Type; - import org.apache.tapestry5.ioc.AnnotationProvider; /** @@ -44,15 +42,4 @@ public interface PropertyConduit extends AnnotationProvider * Returns the type of the property read or updated by the conduit. */ Class getPropertyType(); - - /** - * Returns a Type object that represents the declared type for the property. - * If the Type is a parameterized type, the Type object returned must accurately - * reflect the actual type parameters used in the source code. If the type of the - * underlying property is a type variable or a parameterized type, it is created. - * Otherwise, it is resolved. - * - * @since 5.4 - */ - Type getPropertyGenericType(); } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/737ebd64/tapestry-core/src/main/java/org/apache/tapestry5/PropertyConduit2.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/PropertyConduit2.java b/tapestry-core/src/main/java/org/apache/tapestry5/PropertyConduit2.java new file mode 100644 index 0000000..839d70f --- /dev/null +++ b/tapestry-core/src/main/java/org/apache/tapestry5/PropertyConduit2.java @@ -0,0 +1,40 @@ +// Copyright 2007 The Apache Software Foundation +// +// 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 org.apache.tapestry5; + +import java.lang.reflect.Method; +import java.lang.reflect.Type; + +import org.apache.tapestry5.services.PropertyConduitSource; + + +/** + * Extension to {@link PropertyConduit} that adds a method to access the generic property type. + * {@link PropertyConduitSource} instances should ideally return PropertyConduit2 objects, not PropertyConduit. + * This is only primarily of interest to {@link Binding2}. + * + * @since 5.4 + */ +public interface PropertyConduit2 extends PropertyConduit +{ + /** + * Returns the generic type of the property + * + * @see Method#getGenericReturnType() + * @see java.lang.reflect.Field#getGenericType() + * + */ + Type getPropertyGenericType(); +} http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/737ebd64/tapestry-core/src/main/java/org/apache/tapestry5/internal/InternalPropertyConduit.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/InternalPropertyConduit.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/InternalPropertyConduit.java index 5e19e5b..315b372 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/InternalPropertyConduit.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/InternalPropertyConduit.java @@ -14,16 +14,16 @@ package org.apache.tapestry5.internal; -import org.apache.tapestry5.PropertyConduit; +import org.apache.tapestry5.PropertyConduit2; /** - * Extension to {@link org.apache.tapestry5.PropertyConduit} that adds a method to determine the name of the property. + * Extension to {@link org.apache.tapestry5.PropertyConduit2} that adds a method to determine the name of the property. * * @since 5.2.0 * */ -public interface InternalPropertyConduit extends PropertyConduit +public interface InternalPropertyConduit extends PropertyConduit2 { /** * Returns the name of the property read or updated by the conduit or null. http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/737ebd64/tapestry-core/src/main/java/org/apache/tapestry5/internal/TapestryInternalUtils.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/TapestryInternalUtils.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/TapestryInternalUtils.java index 45da70b..6c6138b 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/TapestryInternalUtils.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/TapestryInternalUtils.java @@ -494,7 +494,11 @@ public class TapestryInternalUtils public Type getPropertyGenericType() { - return conduit.getPropertyGenericType(); + if (conduit instanceof PropertyConduit2) + { + return ((PropertyConduit2) conduit).getPropertyGenericType(); + } + return conduit.getPropertyType(); } public Object get(Object instance) http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/737ebd64/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AbstractBinding.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AbstractBinding.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AbstractBinding.java index 12885e1..8e731b7 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AbstractBinding.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/AbstractBinding.java @@ -15,6 +15,7 @@ package org.apache.tapestry5.internal.bindings; import org.apache.tapestry5.Binding; +import org.apache.tapestry5.Binding2; import org.apache.tapestry5.ioc.BaseLocatable; import org.apache.tapestry5.ioc.Location; import org.apache.tapestry5.ioc.internal.util.TapestryException; @@ -26,7 +27,7 @@ import java.lang.reflect.Type; * Abstract base class for bindings. Assumes that the binding is read only and invariant. Subclasses must provide an * implementation of {@link Binding#get()}. */ -public abstract class AbstractBinding extends BaseLocatable implements Binding +public abstract class AbstractBinding extends BaseLocatable implements Binding2 { public AbstractBinding() { http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/737ebd64/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/InternalPropBinding.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/InternalPropBinding.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/InternalPropBinding.java index 1d7fd60..8af0943 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/InternalPropBinding.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/InternalPropBinding.java @@ -13,13 +13,13 @@ // limitations under the License. package org.apache.tapestry5.internal.bindings; -import org.apache.tapestry5.Binding; +import org.apache.tapestry5.Binding2; /** * Internal marker interface for {@linkplain org.apache.tapestry5.internal.bindings.PropBinding} * */ -public interface InternalPropBinding extends Binding +public interface InternalPropBinding extends Binding2 { /** * Returns the name of the property, if exists. http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/737ebd64/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/PropBinding.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/PropBinding.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/PropBinding.java index 55ea9d8..afe63eb 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/PropBinding.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/bindings/PropBinding.java @@ -14,15 +14,16 @@ package org.apache.tapestry5.internal.bindings; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; + import org.apache.tapestry5.PropertyConduit; +import org.apache.tapestry5.PropertyConduit2; import org.apache.tapestry5.internal.TapestryInternalUtils; import org.apache.tapestry5.internal.services.Invariant; import org.apache.tapestry5.ioc.Location; import org.apache.tapestry5.ioc.internal.util.TapestryException; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; - /** * Base class for bindings created by the {@link org.apache.tapestry5.internal.bindings.PropBindingFactory}. A subclass * of this is created at runtime. @@ -103,13 +104,17 @@ public class PropBinding extends AbstractBinding implements InternalPropBinding } /** - * Get the generic type from the underlying field or getter. - * @see PropertyConduit#getPropertyGenericType() + * Get the generic type from the underlying property + * + * @see PropertyConduit2#getPropertyGenericType() */ @Override public Type getBindingGenericType() { - return conduit.getPropertyGenericType(); + if (conduit instanceof PropertyConduit2) { + return ((PropertyConduit2) conduit).getPropertyGenericType(); + } + return conduit.getPropertyType(); } @Override http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/737ebd64/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/CoercingPropertyConduitWrapper.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/CoercingPropertyConduitWrapper.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/CoercingPropertyConduitWrapper.java index 158d4a4..4dbfb2d 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/CoercingPropertyConduitWrapper.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/CoercingPropertyConduitWrapper.java @@ -14,13 +14,14 @@ package org.apache.tapestry5.internal.services; -import org.apache.tapestry5.PropertyConduit; -import org.apache.tapestry5.ioc.services.TypeCoercer; - import java.lang.annotation.Annotation; import java.lang.reflect.Type; -public class CoercingPropertyConduitWrapper implements PropertyConduit +import org.apache.tapestry5.PropertyConduit; +import org.apache.tapestry5.PropertyConduit2; +import org.apache.tapestry5.ioc.services.TypeCoercer; + +public class CoercingPropertyConduitWrapper implements PropertyConduit2 { private final PropertyConduit conduit; @@ -49,7 +50,10 @@ public class CoercingPropertyConduitWrapper implements PropertyConduit public Type getPropertyGenericType() { - return conduit.getPropertyGenericType(); + if (conduit instanceof PropertyConduit2) { + return ((PropertyConduit2) conduit).getPropertyGenericType(); + } + return conduit.getPropertyType(); } @SuppressWarnings("unchecked") http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/737ebd64/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java index 6dab120..701420f 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java @@ -18,6 +18,7 @@ import org.antlr.runtime.ANTLRInputStream; import org.antlr.runtime.CommonTokenStream; import org.antlr.runtime.tree.Tree; import org.apache.tapestry5.PropertyConduit; +import org.apache.tapestry5.PropertyConduit2; import org.apache.tapestry5.internal.InternalPropertyConduit; import org.apache.tapestry5.internal.antlr.PropertyExpressionLexer; import org.apache.tapestry5.internal.antlr.PropertyExpressionParser; @@ -63,7 +64,7 @@ public class PropertyConduitSourceImpl implements PropertyConduitSource private static final MethodDescription GET_PROPERTY_TYPE = getMethodDescription(PropertyConduit.class, "getPropertyType"); - private static final MethodDescription GET_PROPERTY_GENERIC_TYPE = getMethodDescription(PropertyConduit.class, + private static final MethodDescription GET_PROPERTY_GENERIC_TYPE = getMethodDescription(PropertyConduit2.class, "getPropertyGenericType"); private static final MethodDescription GET_PROPERTY_NAME = getMethodDescription(InternalPropertyConduit.class, http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/737ebd64/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java index 5e0e440..c51c086 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java @@ -349,8 +349,13 @@ public class InternalComponentResourcesImpl extends LockSupport implements Inter public Type getBoundGenericType(String parameterName) { Binding binding = getBinding(parameterName); - - return binding == null ? null : binding.getBindingGenericType(); + Type genericType; + if (binding instanceof Binding2) { + genericType = ((Binding2) binding).getBindingGenericType(); + } else { + genericType = binding.getBindingType(); + } + return genericType; } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/737ebd64/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/CoreBehaviorsTests.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/CoreBehaviorsTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/CoreBehaviorsTests.java index afdc002..d7ecc25 100644 --- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/CoreBehaviorsTests.java +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/CoreBehaviorsTests.java @@ -1726,14 +1726,14 @@ public class CoreBehaviorsTests extends App1TestCase { openLinks("Generic bound type demo"); - assertTextPresent("clientId=one,type=java.util.Map,genericType=java.util.Map<java.lang.String, java.lang.String>"); - assertTextPresent("clientId=two,type=java.lang.String,genericType=class java.lang.String"); - assertTextPresent("clientId=three,type=java.util.Set,genericType=java.util.Set<java.lang.Long>"); - assertTextPresent("clientId=four,type=java.util.List,genericType=java.util.List<java.util.List<java.util.Date>>"); - assertTextPresent("clientId=five,type=java.util.List,genericType=interface java.util.List"); - assertTextPresent("clientId=six,type=java.util.Date,genericType=class java.util.Date"); - assertTextPresent("clientId=seven,type=java.util.List,genericType=interface java.util.List"); - assertTextPresent("clientId=eight,type=java.util.Map,genericType=interface java.util.Map"); - assertTextPresent("clientId=nine,type=java.lang.String,genericType=class java.lang.String"); + assertTextPresent("description=mapOfStrings,type=java.util.Map,genericType=java.util.Map<java.lang.String, java.lang.String>"); + assertTextPresent("description=mapOfStrings.get('foo'),type=java.lang.String,genericType=class java.lang.String"); + assertTextPresent("description=setOfLongs,type=java.util.Set,genericType=java.util.Set<java.lang.Long>"); + assertTextPresent("description=listOfListOfDates,type=java.util.List,genericType=java.util.List<java.util.List<java.util.Date>>"); + assertTextPresent("description=listOfListOfDates.get(0),type=java.util.List,genericType=interface java.util.List"); + assertTextPresent("description=listOfListOfDates.get(0).get(0),type=java.util.Date,genericType=class java.util.Date"); + assertTextPresent("description=[1,2,3],type=java.util.List,genericType=interface java.util.List"); + assertTextPresent("description={'foo':'bar'},type=java.util.Map,genericType=interface java.util.Map"); + assertTextPresent("description=baz,type=java.lang.String,genericType=class java.lang.String"); } } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/737ebd64/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/GenericTypeDisplay.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/GenericTypeDisplay.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/GenericTypeDisplay.java index ab95807..f6d2aa7 100644 --- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/GenericTypeDisplay.java +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/GenericTypeDisplay.java @@ -22,23 +22,23 @@ import org.apache.tapestry5.annotations.Parameter; import org.apache.tapestry5.ioc.annotations.Inject; /** - * Outputs the type and genericType of the 'value' parameter in a div + * Outputs the type and genericType of the 'value' binding in a div */ public class GenericTypeDisplay { @Inject private ComponentResources resources; @Parameter(required=true, defaultPrefix=BindingConstants.LITERAL) - private String clientId; + private String description; @Parameter(required=true) private Object value; void afterRender(MarkupWriter writer) { - writer.element("div", "id", clientId); + writer.element("div"); Class<?> type = resources.getBoundType("value"); Type genericType = resources.getBoundGenericType("value"); - String text = String.format("clientId=%s,type=%s,genericType=%s", clientId, type.getName(), genericType.toString()); + String text = String.format("description=%s,type=%s,genericType=%s", description, type.getName(), genericType.toString()); writer.write(text); writer.end(); } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/737ebd64/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/GenericTypeDemo.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/GenericTypeDemo.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/GenericTypeDemo.java index 80bf40a..8e9fdd3 100644 --- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/GenericTypeDemo.java +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/GenericTypeDemo.java @@ -1,14 +1,11 @@ package org.apache.tapestry5.integration.app1.pages; -import java.util.Arrays; import java.util.Date; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.tapestry5.annotations.Property; -import org.apache.tapestry5.annotations.SetupRender; public class GenericTypeDemo { private Set<Long> setOfLongs; @@ -17,17 +14,10 @@ public class GenericTypeDemo { private Map<String, String> mapOfStrings; public List<List<Date>> getListOfListOfDates() { - List<Date> dates = Arrays.asList(new Date(Long.MIN_VALUE), new Date(0), new Date(Long.MAX_VALUE)); - return Arrays.asList(dates); + throw new UnsupportedOperationException(); } public void setSetOfLongs(Set<Long> setOfLongs) { - this.setOfLongs = setOfLongs; - } - - @SetupRender - void setupRender() { - mapOfStrings = new HashMap<String,String>(); - mapOfStrings.put("foo", "bar"); + throw new UnsupportedOperationException(); } } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/737ebd64/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImplTest.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImplTest.java b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImplTest.java index 5c9f88a..0e61220 100644 --- a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImplTest.java +++ b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImplTest.java @@ -14,8 +14,14 @@ package org.apache.tapestry5.internal.services; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Map; + import org.apache.tapestry5.Block; import org.apache.tapestry5.PropertyConduit; +import org.apache.tapestry5.PropertyConduit2; import org.apache.tapestry5.beaneditor.NonVisual; import org.apache.tapestry5.beaneditor.Validate; import org.apache.tapestry5.integration.app1.data.IntegerHolder; @@ -29,11 +35,6 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; - /** * Most of the testing occurs inside {@link PropBindingFactoryTest} (due to * historical reasons). @@ -178,10 +179,10 @@ public class PropertyConduitSourceImplTest extends InternalBaseTestCase @Test public void generic_types_are_determined() { - PropertyConduit datesConduit = source.create(GenericBean.class, "dates"); - PropertyConduit longsConduit = source.create(GenericBean.class, "longs"); - PropertyConduit nestedDatesConduit = source.create(GenericBean.class, "genericBeans.get(0).dates"); - PropertyConduit mapConduit = source.create(GenericBean.class, "map"); + PropertyConduit2 datesConduit = (PropertyConduit2) source.create(GenericBean.class, "dates"); + PropertyConduit2 longsConduit = (PropertyConduit2) source.create(GenericBean.class, "longs"); + PropertyConduit2 nestedDatesConduit = (PropertyConduit2) source.create(GenericBean.class, "genericBeans.get(0).dates"); + PropertyConduit2 mapConduit = (PropertyConduit2) source.create(GenericBean.class, "map"); assertEquals(datesConduit.getPropertyGenericType().toString(), "java.util.List<java.util.Date>"); assertEquals(longsConduit.getPropertyGenericType().toString(), "java.util.List<java.lang.Long>"); assertEquals(nestedDatesConduit.getPropertyGenericType().toString(), "java.util.List<java.util.Date>"); http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/737ebd64/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/GenericTypeDemo.tml ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/GenericTypeDemo.tml b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/GenericTypeDemo.tml index c9f4b78..12e347a 100644 --- a/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/GenericTypeDemo.tml +++ b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/GenericTypeDemo.tml @@ -1,12 +1,12 @@ <html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> <h1>Generic Type Tests</h1> - <t:genericTypeDisplay clientId="one" value="mapOfStrings" /> - <t:genericTypeDisplay clientId="two" value="mapOfStrings.get('foo')" /> - <t:genericTypeDisplay clientId="three" value="setOfLongs" /> - <t:genericTypeDisplay clientId="four" value="listOfListOfDates" /> - <t:genericTypeDisplay clientId="five" value="listOfListOfDates.get(0)" /> - <t:genericTypeDisplay clientId="six" value="listOfListOfDates.get(0).get(0)" /> - <t:genericTypeDisplay clientId="seven" value="[1,2,3]" /> - <t:genericTypeDisplay clientId="eight" value="{'foo':'bar'}" /> - <t:genericTypeDisplay clientId="nine" value="literal:aaa" /> + <t:genericTypeDisplay description="mapOfStrings" value="mapOfStrings" /> + <t:genericTypeDisplay description="mapOfStrings.get('foo')" value="mapOfStrings.get('foo')" /> + <t:genericTypeDisplay description="setOfLongs" value="setOfLongs" /> + <t:genericTypeDisplay description="listOfListOfDates" value="listOfListOfDates" /> + <t:genericTypeDisplay description="listOfListOfDates.get(0)" value="listOfListOfDates.get(0)" /> + <t:genericTypeDisplay description="listOfListOfDates.get(0).get(0)" value="listOfListOfDates.get(0).get(0)" /> + <t:genericTypeDisplay description="[1,2,3]" value="[1,2,3]" /> + <t:genericTypeDisplay description="{'foo':'bar'}" value="{'foo':'bar'}" /> + <t:genericTypeDisplay description="baz" value="literal:baz" /> </html>
