You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by jk...@apache.org on 2015/09/17 12:11:25 UTC
tapestry-5 git commit: TAP5-2506: Detect and report conflicting
BeanBlockOverrideSource configuration
Repository: tapestry-5
Updated Branches:
refs/heads/master 7277127b1 -> 919d4fc71
TAP5-2506: Detect and report conflicting BeanBlockOverrideSource configuration
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/919d4fc7
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/919d4fc7
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/919d4fc7
Branch: refs/heads/master
Commit: 919d4fc710d9a27ecc423ddfb84047473baecf76
Parents: 7277127
Author: Jochen Kemnade <jo...@eddyson.de>
Authored: Thu Sep 17 12:10:32 2015 +0200
Committer: Jochen Kemnade <jo...@eddyson.de>
Committed: Thu Sep 17 12:10:32 2015 +0200
----------------------------------------------------------------------
.../services/BeanBlockOverrideSourceImpl.java | 10 ++++++++--
.../services/BeanBlockSourceImplTest.java | 21 ++++++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/919d4fc7/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanBlockOverrideSourceImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanBlockOverrideSourceImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanBlockOverrideSourceImpl.java
index 0f79237..343597a 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanBlockOverrideSourceImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanBlockOverrideSourceImpl.java
@@ -39,8 +39,14 @@ public class BeanBlockOverrideSourceImpl implements BeanBlockOverrideSource
for (BeanBlockContribution contribution : configuration)
{
Map<String, BeanBlockContribution> map = contribution.isEdit() ? edit : display;
-
- map.put(contribution.getDataType(), contribution);
+ String dataType = contribution.getDataType();
+
+ BeanBlockContribution previousValue = map.put(dataType, contribution);
+ if (previousValue != null)
+ {
+ throw new IllegalArgumentException("The BeanBlockOverrideSource configuration contains multiple "
+ + (contribution.isEdit() ? "edit" : "display") + " block overrides for data type '" + dataType+ "'.");
+ }
}
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/919d4fc7/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanBlockSourceImplTest.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanBlockSourceImplTest.java b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanBlockSourceImplTest.java
index 3da8ea2..a70eab0 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanBlockSourceImplTest.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BeanBlockSourceImplTest.java
@@ -18,6 +18,7 @@ import org.apache.tapestry5.Block;
import org.apache.tapestry5.internal.structure.ComponentPageElement;
import org.apache.tapestry5.internal.structure.Page;
import org.apache.tapestry5.internal.test.InternalBaseTestCase;
+import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
import org.apache.tapestry5.services.*;
import org.testng.annotations.Test;
@@ -184,6 +185,26 @@ public class BeanBlockSourceImplTest extends InternalBaseTestCase
verify();
}
+
+ @Test
+ // TAP5-2506
+ public void conflicting_bean_block_overrides()
+ {
+ RequestPageCache cache = mockRequestPageCache();
+ Collection<BeanBlockContribution> configuration = CollectionFactory.newList();
+ configuration.add(new DisplayBlockContribution("foo", "page1", "bar"));
+ configuration.add(new DisplayBlockContribution("foo", "page2", "baz"));
+ try {
+ new BeanBlockOverrideSourceImpl(cache, configuration);
+ unreachable();
+ } catch(IllegalArgumentException ex)
+ {
+ assertEquals(
+ ex.getMessage(),
+ "The BeanBlockOverrideSource configuration contains multiple display block overrides for data type 'foo'.");
+
+ }
+ }
protected final void train_getBlock(Page page, String blockId, Block block)
{