Author: ivaynberg Date: Sat Jul 2 17:34:00 2011 New Revision: 1142252 URL: http://svn.apache.org/viewvc?rev=1142252&view=rev Log:
Issue: WICKET-3843 Modified: wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/internal/InlineEnclosure.java wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java Modified: wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/internal/InlineEnclosure.java URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/internal/InlineEnclosure.java?rev=1142252&r1=1142251&r2=1142252&view=diff ============================================================================== --- wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/internal/InlineEnclosure.java (original) +++ wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/internal/InlineEnclosure.java Sat Jul 2 17:34:00 2011 @@ -21,6 +21,7 @@ import java.util.List; import org.apache.wicket.Component; import org.apache.wicket.MarkupContainer; +import org.apache.wicket.WicketRuntimeException; import org.apache.wicket.markup.ComponentTag; import org.apache.wicket.markup.MarkupStream; import org.apache.wicket.markup.parser.filter.InlineEnclosureHandler; @@ -150,6 +151,11 @@ public class InlineEnclosure extends Enc } }.execute(); child = container.get(tag.getId()); + if (child == null) + { + throw new WicketRuntimeException("Could not find child with id: " + + tag.getId() + " in the wicket:enclosure"); + } } children.add(child); } Modified: wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java?rev=1142252&r1=1142251&r2=1142252&view=diff ============================================================================== --- wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java (original) +++ wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/internal/EnclosureTest.java Sat Jul 2 17:34:00 2011 @@ -18,13 +18,21 @@ package org.apache.wicket.markup.html.in import java.io.IOException; +import org.apache.wicket.MarkupContainer; import org.apache.wicket.Page; import org.apache.wicket.PageParameters; +import org.apache.wicket.WicketRuntimeException; import org.apache.wicket.WicketTestCase; +import org.apache.wicket.markup.IMarkupResourceStreamProvider; +import org.apache.wicket.markup.html.WebMarkupContainer; +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.CheckBox; import org.apache.wicket.protocol.http.WebApplication; import org.apache.wicket.resource.DummyApplication; import org.apache.wicket.util.diff.DiffUtil; +import org.apache.wicket.util.resource.IResourceStream; +import org.apache.wicket.util.resource.StringResourceStream; import org.apache.wicket.util.tester.FormTester; import org.apache.wicket.util.tester.WicketTester; @@ -331,5 +339,31 @@ public class EnclosureTest extends Wicke executeTest(EnclosurePage_11.class, "EnclosurePageExpectedResult_11.html"); } - + public void testBadEnclosure1() + { + class TestPage extends WebPage implements IMarkupResourceStreamProvider + { + public TestPage() + { + add(new WebMarkupContainer("d")); + add(new Label("msg", "hi")); + } + + public IResourceStream getMarkupResourceStream(MarkupContainer container, + Class<?> containerClass) + { + return new StringResourceStream( + "<html><body><div wicket:id='d'><div wicket:enclosure='msg'><span wicket:id='msg'></span></div></div></body></html>"); + } + } + + try + { + tester.startPage(new TestPage()); + } + catch (WicketRuntimeException e) + { + assertTrue(e.getMessage().startsWith("Could not find child")); + } + } }