Author: hlship
Date: Wed Apr 13 22:24:17 2011
New Revision: 1091963
URL: http://svn.apache.org/viewvc?rev=1091963&view=rev
Log:
TAP5-853: Minor cleanups to get last few failing tests to pass
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/bindings/PropBindingFactoryTest.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java?rev=1091963&r1=1091962&r2=1091963&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java
Wed Apr 13 22:24:17 2011
@@ -307,11 +307,18 @@ public class PropertyConduitSourceImpl i
builder.loadConstant(conduitPropertyName).returnResult();
}
});
+
+ if (conduitPropertyType == null)
+ throw new RuntimeException("Conduit property type is null for
" + rootType + " " + expression);
+
+ final PlasticField propertyTypeField =
plasticClass.introduceField(Class.class, "propertyType").inject(
+ conduitPropertyType);
+
plasticClass.introduceMethod(ConduitMethods.GET_PROPERTY_TYPE, new
InstructionBuilderCallback()
{
public void doBuild(InstructionBuilder builder)
{
-
builder.loadTypeConstant(conduitPropertyType).returnResult();
+
builder.loadThis().getField(propertyTypeField).returnResult();
}
});
@@ -492,11 +499,12 @@ public class PropertyConduitSourceImpl i
PropertyAdapter adapter = findPropertyAdapter(activeType,
propertyName);
- implementGetter(activeType, adapter);
- implementSetter(activeType, adapter);
-
+ conduitPropertyType = adapter.getType();
conduitPropertyName = propertyName;
annotationProvider = adapter;
+
+ implementGetter(activeType, adapter);
+ implementSetter(activeType, adapter);
}
private void implementSetter(Type activeType, PropertyAdapter adapter)
@@ -513,7 +521,7 @@ public class PropertyConduitSourceImpl i
return;
}
- implementNoOpMethod(ConduitMethods.SET, "Expression %s for class
%s is read-only.", expression,
+ implementNoOpMethod(ConduitMethods.SET, "Expression '%s' for class
%s is read-only.", expression,
rootType.getName());
}
@@ -568,7 +576,7 @@ public class PropertyConduitSourceImpl i
return;
}
- implementNoOpMethod(ConduitMethods.GET, "Expression %d for class
%s is write-only.", expression,
+ implementNoOpMethod(ConduitMethods.GET, "Expression '%s' for class
%s is write-only.", expression,
rootType.getName());
}
@@ -580,9 +588,6 @@ public class PropertyConduitSourceImpl i
{
invokeNavigateMethod(builder);
- Type actualType =
GenericsUtils.extractActualType(activeType, field);
- conduitPropertyType = GenericsUtils.asClass(actualType);
-
builder.getField(field.getDeclaringClass().getName(),
field.getName(), field.getType());
// Cast not necessary here since the return type of get()
is Object
@@ -606,8 +611,6 @@ public class PropertyConduitSourceImpl i
invokeMethod(builder, readMethod, null, 0);
- conduitPropertyType = GenericsUtils.asClass(actualType);
-
boxIfPrimitive(builder, conduitPropertyType);
builder.returnResult();
@@ -1126,20 +1129,29 @@ public class PropertyConduitSourceImpl i
private Method findMethod(Class activeType, String methodName, int
parameterCount)
{
- for (Method method : activeType.getMethods())
- {
+ Class searchType = activeType;
- if (method.getParameterTypes().length == parameterCount
- && method.getName().equalsIgnoreCase(methodName))
- return method;
- }
+ while (true)
+ {
- // TAP5-330
- if (activeType != Object.class)
- return findMethod(Object.class, methodName, parameterCount);
+ for (Method method : searchType.getMethods())
+ {
+ if (method.getParameterTypes().length == parameterCount
+ && method.getName().equalsIgnoreCase(methodName))
+ return method;
+ }
- throw new RuntimeException(String.format("Class %s does not
contain a method named '%s()'.", activeType,
- methodName));
+ // TAP5-330
+ if (searchType != Object.class)
+ {
+ searchType = Object.class;
+ }
+ else
+ {
+ throw new RuntimeException(String.format("Class %s does
not contain a public method named '%s()'.",
+ activeType.getName(), methodName));
+ }
+ }
}
public void boxIfPrimitive(InstructionBuilder builder, Type termType)
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/bindings/PropBindingFactoryTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/bindings/PropBindingFactoryTest.java?rev=1091963&r1=1091962&r2=1091963&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/bindings/PropBindingFactoryTest.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/bindings/PropBindingFactoryTest.java
Wed Apr 13 22:24:17 2011
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008, 2009, 2010 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009, 2010, 2011 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.
@@ -266,7 +266,7 @@ public class PropBindingFactoryTest exte
catch (RuntimeException ex)
{
assertMessageContains(ex,
- "No public method \'isThatRealBlood()\' in class
org.apache.tapestry5.internal.bindings.TargetBean");
+ "Class org.apache.tapestry5.internal.bindings.TargetBean
does not contain a public method named 'isThatRealBlood()'");
}
verify();
@@ -290,8 +290,7 @@ public class PropBindingFactoryTest exte
}
catch (RuntimeException ex)
{
- assertMessageContains(ex,
- "No public method \'isThatRealBlood()\' in class
org.apache.tapestry5.internal.bindings.StringHolder");
+ assertMessageContains(ex, "StringHolder", "does not contain a
public method", "isThatRealBlood()");
}
verify();
@@ -478,7 +477,7 @@ public class PropBindingFactoryTest exte
catch (TapestryException ex)
{
assertEquals(ex.getMessage(),
- "Expression writeOnly for class
org.apache.tapestry5.internal.bindings.TargetBean is write-only.");
+ "Expression 'writeOnly' for class
org.apache.tapestry5.internal.bindings.TargetBean is write-only.");
assertEquals(ex.getLocation(), l);
}