You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2014/04/18 01:20:24 UTC
git commit: TAP5-1672: Provide more info when PropertyDisplay
component hits an NPE
Repository: tapestry-5
Updated Branches:
refs/heads/master bc5c3a913 -> 639c57df2
TAP5-1672: Provide more info when PropertyDisplay component hits an NPE
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/639c57df
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/639c57df
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/639c57df
Branch: refs/heads/master
Commit: 639c57df2363181a8eb78d1a1653b7b73e9e614a
Parents: bc5c3a9
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu Apr 17 16:20:15 2014 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu Apr 17 16:20:15 2014 -0700
----------------------------------------------------------------------
.../corelib/base/AbstractPropertyOutput.java | 21 ++++++++++----------
.../base/AbstractPropertyOutputTest.java | 14 +++++++++----
2 files changed, 21 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/639c57df/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractPropertyOutput.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractPropertyOutput.java b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractPropertyOutput.java
index 610c77d..a3a29de 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractPropertyOutput.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractPropertyOutput.java
@@ -1,5 +1,3 @@
-// Copyright 2007, 2008, 2009, 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.
// You may obtain a copy of the License at
@@ -14,15 +12,13 @@
package org.apache.tapestry5.corelib.base;
-import org.apache.tapestry5.Block;
-import org.apache.tapestry5.MarkupWriter;
-import org.apache.tapestry5.PropertyConduit;
-import org.apache.tapestry5.PropertyOverrides;
+import org.apache.tapestry5.*;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.beaneditor.PropertyModel;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.ioc.internal.util.InternalUtils;
+import org.apache.tapestry5.ioc.internal.util.TapestryException;
import org.apache.tapestry5.services.BeanBlockSource;
import org.apache.tapestry5.services.Core;
import org.apache.tapestry5.services.Environment;
@@ -76,6 +72,9 @@ public abstract class AbstractPropertyOutput
private boolean mustPopEnvironment;
+ @Inject
+ private ComponentResources resources;
+
BeanBlockSource defaultBeanBlockSource()
{
return defaultBeanBlockSource;
@@ -150,10 +149,11 @@ public abstract class AbstractPropertyOutput
try
{
return conduit == null ? null : conduit.get(object);
- }
- catch (NullPointerException ex)
+ } catch (NullPointerException ex)
{
- throw new NullPointerException(String.format("Property '%s' contains a null value in the path.", model.getPropertyName()));
+ throw new TapestryException(String.format("Property '%s' contains a null value in the path.", model.getPropertyName()),
+ resources.getLocation(),
+ ex);
}
}
@@ -175,9 +175,10 @@ public abstract class AbstractPropertyOutput
}
// Used for testing.
- void inject(final PropertyModel model, final Object object)
+ void inject(final PropertyModel model, final Object object, final ComponentResources resources)
{
this.model = model;
this.object = object;
+ this.resources = resources;
}
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/639c57df/tapestry-core/src/test/java/org/apache/tapestry5/corelib/base/AbstractPropertyOutputTest.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/corelib/base/AbstractPropertyOutputTest.java b/tapestry-core/src/test/java/org/apache/tapestry5/corelib/base/AbstractPropertyOutputTest.java
index d599511..80c4a1e 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/corelib/base/AbstractPropertyOutputTest.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/corelib/base/AbstractPropertyOutputTest.java
@@ -1,5 +1,3 @@
-// Copyright 2008 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
@@ -14,9 +12,12 @@
package org.apache.tapestry5.corelib.base;
+import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.PropertyConduit;
import org.apache.tapestry5.beaneditor.PropertyModel;
import org.apache.tapestry5.internal.test.InternalBaseTestCase;
+import org.apache.tapestry5.ioc.Location;
+import org.apache.tapestry5.ioc.internal.util.TapestryException;
import org.testng.annotations.Test;
public class AbstractPropertyOutputTest extends InternalBaseTestCase
@@ -32,12 +33,15 @@ public class AbstractPropertyOutputTest extends InternalBaseTestCase
final PropertyConduit conduit = mockPropertyConduit();
final PropertyModel model = mockPropertyModel();
final Object object = new Object();
+ ComponentResources resources = mockComponentResources();
+ Location location = mockLocation();
- propertyOutputFixture.inject(model, object);
+ propertyOutputFixture.inject(model, object, resources);
expect(model.getConduit()).andReturn(conduit);
expect(conduit.get(object)).andThrow(new NullPointerException());
expect(model.getPropertyName()).andReturn("wilma.occupation.address");
+ expect(resources.getLocation()).andReturn(location);
replay();
@@ -47,9 +51,11 @@ public class AbstractPropertyOutputTest extends InternalBaseTestCase
fail("Expected a NullPointerException to be thrown.");
}
- catch (final NullPointerException ex)
+ catch (final TapestryException ex)
{
assertEquals(ex.getMessage(), "Property 'wilma.occupation.address' contains a null value in the path.");
+ assertSame(ex.getLocation(), location);
+ assertTrue(ex.getCause() instanceof NullPointerException);
}
verify();