Repository: wicket Updated Branches: refs/heads/master 7ac9ccdee -> 3c0678877
WICKET-5898 test methods moved to TransparentWebMarkupContainerTest Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/3c067887 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/3c067887 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/3c067887 Branch: refs/heads/master Commit: 3c06788776b6b2d4881b206d3c1566342cc8b880 Parents: 7ac9ccd Author: Andrea Del Bene <[email protected]> Authored: Sun May 3 14:49:29 2015 +0200 Committer: Andrea Del Bene <[email protected]> Committed: Sun May 3 14:51:44 2015 +0200 ---------------------------------------------------------------------- .../DoubleNestedTransparentContainerPage.html | 10 +++ .../DoubleNestedTransparentContainerPage.java | 64 ++++++++++++++ .../SingleNestedTransparentContainerPage.html | 10 +++ .../SingleNestedTransparentContainerPage.java | 66 +++++++++++++++ .../html/TransparentWebMarkupContainerTest.java | 41 ++++++++- .../transparentresolvers/Wicket5898Page.html | 10 --- .../transparentresolvers/Wicket5898Page.java | 66 --------------- .../transparentresolvers/Wicket5898Page2.html | 10 --- .../transparentresolvers/Wicket5898Page2.java | 64 -------------- .../transparentresolvers/Wicket5898Test.java | 89 -------------------- 10 files changed, 190 insertions(+), 240 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/3c067887/wicket-core/src/test/java/org/apache/wicket/markup/html/DoubleNestedTransparentContainerPage.html ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/DoubleNestedTransparentContainerPage.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/DoubleNestedTransparentContainerPage.html new file mode 100644 index 0000000..9c60648 --- /dev/null +++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/DoubleNestedTransparentContainerPage.html @@ -0,0 +1,10 @@ +<!DOCTYPE html> +<html xmlns:wicket="http://wicket.apache.org"> +<body> + <div wicket:id="twmc"> + <span wicket:id="label"></span> + <span wicket:id="group"></span> + </div> + <a href="#" wicket:id="link"></a> +</body> +</html> http://git-wip-us.apache.org/repos/asf/wicket/blob/3c067887/wicket-core/src/test/java/org/apache/wicket/markup/html/DoubleNestedTransparentContainerPage.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/DoubleNestedTransparentContainerPage.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/DoubleNestedTransparentContainerPage.java new file mode 100644 index 0000000..651d85a --- /dev/null +++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/DoubleNestedTransparentContainerPage.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.wicket.markup.html; + +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.markup.html.AjaxFallbackLink; +import org.apache.wicket.markup.html.TransparentWebMarkupContainer; +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.markup.html.basic.Label; + +/** + * A test page for triggering a StackOverflowError when updating a component inside a + * {@link TransparentWebMarkupContainer} using AJAX. + */ +public class DoubleNestedTransparentContainerPage extends WebPage +{ + private static final long serialVersionUID = 1L; + + /** + * Constructor. + */ + public DoubleNestedTransparentContainerPage() + { + final Label label = new Label("label", "Label"); + label.setOutputMarkupId(true); + add(label); + + // Adding a TransparentWebMarkupContainer to the outer TransparentWebMarkupContainer causes + // a StackOverflowException + add(new TransparentWebMarkupContainer("group")); + + // if you add this TransparentWebMarkupContainer as first component in + // the page (i.e. move line 48 to line 38), the test passes + add(new TransparentWebMarkupContainer("twmc")); + + // a non-AJAX click on this link passes the test case, an AJAX request + // fails with a StackOverflowError + add(new AjaxFallbackLink<Void>("link") + { + private static final long serialVersionUID = 1L; + + @Override + public void onClick(AjaxRequestTarget target) + { + if (target != null) + target.add(label); + } + }); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/3c067887/wicket-core/src/test/java/org/apache/wicket/markup/html/SingleNestedTransparentContainerPage.html ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/SingleNestedTransparentContainerPage.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/SingleNestedTransparentContainerPage.html new file mode 100644 index 0000000..f3a861c --- /dev/null +++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/SingleNestedTransparentContainerPage.html @@ -0,0 +1,10 @@ +<!DOCTYPE html> +<html xmlns:wicket="http://wicket.apache.org"> +<body> + <div wicket:id="twmc"> + <span wicket:id="label"></span> + <span wicket:id="group"><img src="foo.gif"></span> + </div> + <a href="#" wicket:id="link"></a> +</body> +</html> http://git-wip-us.apache.org/repos/asf/wicket/blob/3c067887/wicket-core/src/test/java/org/apache/wicket/markup/html/SingleNestedTransparentContainerPage.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/SingleNestedTransparentContainerPage.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/SingleNestedTransparentContainerPage.java new file mode 100644 index 0000000..877e9b6 --- /dev/null +++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/SingleNestedTransparentContainerPage.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.wicket.markup.html; + +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.markup.html.AjaxFallbackLink; +import org.apache.wicket.markup.html.TransparentWebMarkupContainer; +import org.apache.wicket.markup.html.WebMarkupContainer; +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.markup.html.basic.Label; + +/** + * A test page for triggering a StackOverflowError when updating a component inside a + * {@link TransparentWebMarkupContainer} using AJAX. + */ +public class SingleNestedTransparentContainerPage extends WebPage +{ + private static final long serialVersionUID = 1L; + + /** + * Constructor + */ + public SingleNestedTransparentContainerPage() + { + final Label label = new Label("label", "Label"); + label.setOutputMarkupId(true); + add(label); + + // The src attribute of the image tag inside this WebMarkupContainer is + // essential in triggering this bug. This causes Wicket to insert an + // autocomponent (also a TransparentWebMarkupContainer) + add(new WebMarkupContainer("group")); + + // if you add this TransparentWebMarkupContainer as first component in + // the page (i.e. move line 50 to line 39), the test passes + add(new TransparentWebMarkupContainer("twmc")); + + // a non-AJAX click on this link passes the test case, an AJAX request + // fails with a StackOverflowError + add(new AjaxFallbackLink<Void>("link") + { + private static final long serialVersionUID = 1L; + + @Override + public void onClick(AjaxRequestTarget target) + { + if (target != null) + target.add(label); + } + }); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/3c067887/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentWebMarkupContainerTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentWebMarkupContainerTest.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentWebMarkupContainerTest.java index f1ac3b2..0350126 100644 --- a/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentWebMarkupContainerTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentWebMarkupContainerTest.java @@ -19,6 +19,7 @@ package org.apache.wicket.markup.html; import org.apache.wicket.IPageManagerProvider; import org.apache.wicket.MarkupContainer; import org.apache.wicket.WicketTestCase; +import org.apache.wicket.core.util.lang.WicketObjects; import org.apache.wicket.markup.IMarkupResourceStreamProvider; import org.apache.wicket.markup.MarkupException; import org.apache.wicket.markup.html.basic.Label; @@ -27,7 +28,6 @@ import org.apache.wicket.mock.MockPageManager; import org.apache.wicket.page.IManageablePage; import org.apache.wicket.page.IPageManager; import org.apache.wicket.page.IPageManagerContext; -import org.apache.wicket.core.util.lang.WicketObjects; import org.apache.wicket.util.resource.IResourceStream; import org.apache.wicket.util.resource.StringResourceStream; import org.apache.wicket.util.tester.WicketTester; @@ -129,7 +129,46 @@ public class TransparentWebMarkupContainerTest extends WicketTestCase wicketTester.clickLink("link", true); wicketTester.destroy(); } + + + /** + * Tests the WICKET-5898 issue of triggering a StackOverflowError when a component inside nested + * TransparentWebMarkupContainers is updated. This particular test case is caused by Wicket's + * insertion of a TransparentWebMarkupContainer automatically due to a {@code src} attribute + * that might need rewriting. + */ + @Test + public void ajaxRequestForComponentInTransparentWebMarkupContainerShouldntCauseStackOverflow() + { + tester.startPage(SingleNestedTransparentContainerPage.class); + + // the page renders normally using normal web requests + tester.assertRenderedPage(SingleNestedTransparentContainerPage.class); + + // without WICKET-5898 fixed the statement below causes a StackOverflowError + tester.clickLink("link", true); + tester.assertComponentOnAjaxResponse("label"); + } + + /** + * Tests the WICKET-5898 issue of triggering a StackOverflowError when a component inside nested + * TransparentWebMarkupContainers is updated. This particular test case is caused by having two + * TransparentWebMarkupContainers nested and trying to update a label that was added to the + * outer TWMC. + */ + @Test + public void ajaxRequestForComponentInTransparentWebMarkupContainerShouldntCauseStackOverflow2() + { + tester.startPage(DoubleNestedTransparentContainerPage.class); + // the page renders normally using normal web requests + tester.assertRenderedPage(DoubleNestedTransparentContainerPage.class); + + // without WICKET-5898 fixed the statement below causes a StackOverflowError + tester.clickLink("link", true); + tester.assertComponentOnAjaxResponse("label"); + } + /** */ public static class TestPage extends WebPage implements IMarkupResourceStreamProvider { http://git-wip-us.apache.org/repos/asf/wicket/blob/3c067887/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page.html ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page.html b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page.html deleted file mode 100644 index f3a861c..0000000 --- a/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page.html +++ /dev/null @@ -1,10 +0,0 @@ -<!DOCTYPE html> -<html xmlns:wicket="http://wicket.apache.org"> -<body> - <div wicket:id="twmc"> - <span wicket:id="label"></span> - <span wicket:id="group"><img src="foo.gif"></span> - </div> - <a href="#" wicket:id="link"></a> -</body> -</html> http://git-wip-us.apache.org/repos/asf/wicket/blob/3c067887/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page.java b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page.java deleted file mode 100644 index 58dd9f9..0000000 --- a/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.wicket.queueing.transparentresolvers; - -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.markup.html.AjaxFallbackLink; -import org.apache.wicket.markup.html.TransparentWebMarkupContainer; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.WebPage; -import org.apache.wicket.markup.html.basic.Label; - -/** - * A test page for triggering a StackOverflowError when updating a component inside a - * {@link TransparentWebMarkupContainer} using AJAX. - */ -public class Wicket5898Page extends WebPage -{ - private static final long serialVersionUID = 1L; - - /** - * Constructor - */ - public Wicket5898Page() - { - final Label label = new Label("label", "Label"); - label.setOutputMarkupId(true); - add(label); - - // The src attribute of the image tag inside this WebMarkupContainer is - // essential in triggering this bug. This causes Wicket to insert an - // autocomponent (also a TransparentWebMarkupContainer) - add(new WebMarkupContainer("group")); - - // if you add this TransparentWebMarkupContainer as first component in - // the page (i.e. move line 50 to line 39), the test passes - add(new TransparentWebMarkupContainer("twmc")); - - // a non-AJAX click on this link passes the test case, an AJAX request - // fails with a StackOverflowError - add(new AjaxFallbackLink<Void>("link") - { - private static final long serialVersionUID = 1L; - - @Override - public void onClick(AjaxRequestTarget target) - { - if (target != null) - target.add(label); - } - }); - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/3c067887/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page2.html ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page2.html b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page2.html deleted file mode 100644 index 9c60648..0000000 --- a/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page2.html +++ /dev/null @@ -1,10 +0,0 @@ -<!DOCTYPE html> -<html xmlns:wicket="http://wicket.apache.org"> -<body> - <div wicket:id="twmc"> - <span wicket:id="label"></span> - <span wicket:id="group"></span> - </div> - <a href="#" wicket:id="link"></a> -</body> -</html> http://git-wip-us.apache.org/repos/asf/wicket/blob/3c067887/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page2.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page2.java b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page2.java deleted file mode 100644 index 1a85c72..0000000 --- a/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page2.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.wicket.queueing.transparentresolvers; - -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.markup.html.AjaxFallbackLink; -import org.apache.wicket.markup.html.TransparentWebMarkupContainer; -import org.apache.wicket.markup.html.WebPage; -import org.apache.wicket.markup.html.basic.Label; - -/** - * A test page for triggering a StackOverflowError when updating a component inside a - * {@link TransparentWebMarkupContainer} using AJAX. - */ -public class Wicket5898Page2 extends WebPage -{ - private static final long serialVersionUID = 1L; - - /** - * Constructor. - */ - public Wicket5898Page2() - { - final Label label = new Label("label", "Label"); - label.setOutputMarkupId(true); - add(label); - - // Adding a TransparentWebMarkupContainer to the outer TransparentWebMarkupContainer causes - // a StackOverflowException - add(new TransparentWebMarkupContainer("group")); - - // if you add this TransparentWebMarkupContainer as first component in - // the page (i.e. move line 48 to line 38), the test passes - add(new TransparentWebMarkupContainer("twmc")); - - // a non-AJAX click on this link passes the test case, an AJAX request - // fails with a StackOverflowError - add(new AjaxFallbackLink<Void>("link") - { - private static final long serialVersionUID = 1L; - - @Override - public void onClick(AjaxRequestTarget target) - { - if (target != null) - target.add(label); - } - }); - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/3c067887/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Test.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Test.java b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Test.java deleted file mode 100644 index 47f27d5..0000000 --- a/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Test.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.wicket.queueing.transparentresolvers; - -import org.apache.wicket.WicketTestCase; -import org.junit.Test; - -/** - * This page causes a {@code StackOverflowError} when trying to update the component {@code label} - * from an Ajax request. The page renders normally in normal page requests or fallback requests. - * - * Things of note: the test passes when you add the {@code TransparentWebMarkupContainer} as the - * first component to the page, instead of it being the last component to be added. - * - * It appears that the {@code src} attribute of the {@code <img>} tag inside the {@code group} - * {@code WebMarkupContainer} is significant in triggering this bug. Removing the {@code group} or - * the {@code src} attribute lets the test pass. - */ -public class Wicket5898Test extends WicketTestCase -{ - /** - * This test should pass, it is just here to validate that the page renders initially, and using - * a normal, non-AJAX request cycle. - */ - @Test - public void normalRequestDoesntCauseStackOverflow() - { - tester.startPage(Wicket5898Page.class); - - // the page renders normally using normal web requests - tester.assertRenderedPage(Wicket5898Page.class); - - // the page renders normally when clicking on a link without using AJAX - tester.clickLink("link", false); - tester.assertRenderedPage(Wicket5898Page.class); - } - - /** - * Tests the WICKET-5898 issue of triggering a StackOverflowError when a component inside nested - * TransparentWebMarkupContainers is updated. This particular test case is caused by Wicket's - * insertion of a TransparentWebMarkupContainer automatically due to a {@code src} attribute - * that might need rewriting. - */ - @Test - public void ajaxRequestForComponentInTransparentWebMarkupContainerShouldntCauseStackOverflow() - { - tester.startPage(Wicket5898Page.class); - - // the page renders normally using normal web requests - tester.assertRenderedPage(Wicket5898Page.class); - - // without WICKET-5898 fixed the statement below causes a StackOverflowError - tester.clickLink("link", true); - tester.assertComponentOnAjaxResponse("label"); - } - - /** - * Tests the WICKET-5898 issue of triggering a StackOverflowError when a component inside nested - * TransparentWebMarkupContainers is updated. This particular test case is caused by having two - * TransparentWebMarkupContainers nested and trying to update a label that was added to the - * outer TWMC. - */ - @Test - public void ajaxRequestForComponentInTransparentWebMarkupContainerShouldntCauseStackOverflow2() - { - tester.startPage(Wicket5898Page2.class); - - // the page renders normally using normal web requests - tester.assertRenderedPage(Wicket5898Page2.class); - - // without WICKET-5898 fixed the statement below causes a StackOverflowError - tester.clickLink("link", true); - tester.assertComponentOnAjaxResponse("label"); - } -}
