You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by da...@apache.org on 2015/05/12 14:56:00 UTC
wicket git commit: WICKET-5898: Added two more failing tests
Repository: wicket
Updated Branches:
refs/heads/master 541d5b395 -> c5a445504
WICKET-5898: Added two more failing tests
These tests fail with a StackOverflowError with auto-added TWMCs
or manually added TWMCs. Both situations could occur in a Wicket
application.
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/c5a44550
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/c5a44550
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/c5a44550
Branch: refs/heads/master
Commit: c5a445504d1ba07bf8cb8f782187f6f003b64521
Parents: 541d5b3
Author: Martijn Dashorst <ma...@gmail.com>
Authored: Tue May 12 14:54:45 2015 +0200
Committer: Martijn Dashorst <ma...@gmail.com>
Committed: Tue May 12 14:55:14 2015 +0200
----------------------------------------------------------------------
...ntainerWithAutoTransparentContainerPage.html | 14 +++
...ntainerWithAutoTransparentContainerPage.java | 82 ++++++++++++++++++
...ainerWithManualTransparentContainerPage.html | 14 +++
...ainerWithManualTransparentContainerPage.java | 89 ++++++++++++++++++++
.../html/TransparentWebMarkupContainerTest.java | 42 +++++++++
5 files changed, 241 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/c5a44550/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentContainerWithAutoTransparentContainerPage.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentContainerWithAutoTransparentContainerPage.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentContainerWithAutoTransparentContainerPage.html
new file mode 100644
index 0000000..3287346
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentContainerWithAutoTransparentContainerPage.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html xmlns:wicket="http://wicket.apache.org">
+<body>
+ <h3 wicket:id="twmc">
+ <span wicket:id="label"></span>
+ <span>
+ <a wicket:id="group1"><img alt="group1" src="group1.gif"></a>
+ <a wicket:id="group2"><img alt="group2" src="group2.gif"></a>
+ </span>
+ <span></span>
+ </h3>
+ <a href="#" wicket:id="link"></a>
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/c5a44550/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentContainerWithAutoTransparentContainerPage.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentContainerWithAutoTransparentContainerPage.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentContainerWithAutoTransparentContainerPage.java
new file mode 100644
index 0000000..287adb4
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentContainerWithAutoTransparentContainerPage.java
@@ -0,0 +1,82 @@
+/*
+ * 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.ajax.markup.html.AjaxLink;
+import org.apache.wicket.markup.html.basic.Label;
+
+/**
+ * A test page for triggering a StackOverflowError when updating a component inside a
+ * {@link TransparentWebMarkupContainer}, with Wicket auto-adding TWMC's.
+ */
+public class TransparentContainerWithAutoTransparentContainerPage extends WebPage
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor.
+ */
+ public TransparentContainerWithAutoTransparentContainerPage()
+ {
+ final Label label = new Label("label", "Label");
+ label.setOutputMarkupId(true);
+ add(label);
+
+ // Letting Wicket auto-add a TransparentWebMarkupContainer to the AJAX link (due to relative
+ // URL rewriting) causes a StackOverflowException
+ add(new AjaxLink<Void>("group1")
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onClick(AjaxRequestTarget t)
+ {
+ }
+ });
+
+ // But you need two auto-added TWMCs to trigger the StackOverflowError
+ add(new AjaxLink<Void>("group2")
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onClick(AjaxRequestTarget t)
+ {
+ }
+ });
+
+ // 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);
+ }
+ });
+
+ // if you add this TransparentWebMarkupContainer as first component in
+ // the page, the test passes
+ add(new TransparentWebMarkupContainer("twmc"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/c5a44550/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentContainerWithManualTransparentContainerPage.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentContainerWithManualTransparentContainerPage.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentContainerWithManualTransparentContainerPage.html
new file mode 100644
index 0000000..382dbec
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentContainerWithManualTransparentContainerPage.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html xmlns:wicket="http://wicket.apache.org">
+<body>
+ <h3 wicket:id="twmc">
+ <span wicket:id="label"></span>
+ <span>
+ <a wicket:id="group1"><span wicket:id="twmc_group_1"></span></a>
+ <a wicket:id="group2"><span wicket:id="twmc_group_2"></span></a>
+ </span>
+ <span></span>
+ </h3>
+ <a href="#" wicket:id="link"></a>
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/c5a44550/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentContainerWithManualTransparentContainerPage.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentContainerWithManualTransparentContainerPage.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentContainerWithManualTransparentContainerPage.java
new file mode 100644
index 0000000..f2c2303
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/TransparentContainerWithManualTransparentContainerPage.java
@@ -0,0 +1,89 @@
+/*
+ * 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.ajax.markup.html.AjaxLink;
+import org.apache.wicket.markup.html.basic.Label;
+
+/**
+ * A test page for triggering a StackOverflowError when updating a component inside a
+ * {@link TransparentWebMarkupContainer}, with manually added TWMCs to ensure we don't only check
+ * for auto-added components, but manually added TWMCs as well while fixing the StackOverflowError
+ * bug.
+ */
+public class TransparentContainerWithManualTransparentContainerPage extends WebPage
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor.
+ */
+ public TransparentContainerWithManualTransparentContainerPage()
+ {
+ final Label label = new Label("label", "Label");
+ label.setOutputMarkupId(true);
+ add(label);
+
+ // adding a TWMC to this link in itself is harmless, but when you have two of these
+ // constructions on your page, it causes a StackOverflowError.
+ AjaxLink<Void> group1 = new AjaxLink<Void>("group1")
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onClick(AjaxRequestTarget t)
+ {
+ }
+ };
+ add(group1);
+ group1.add(new TransparentWebMarkupContainer("twmc_group_1"));
+
+ // This is the second TWMC inside a container construct that triggers the
+ // StackOverflowError.
+ AjaxLink<Void> group2 = new AjaxLink<Void>("group2")
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onClick(AjaxRequestTarget t)
+ {
+ }
+ };
+ add(group2);
+ group2.add(new TransparentWebMarkupContainer("twmc_group_2"));
+
+ // 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);
+ }
+ });
+
+ // if you add this TransparentWebMarkupContainer as first component in
+ // the page, the test passes
+ add(new TransparentWebMarkupContainer("twmc"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/c5a44550/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 ef3607e..19db265 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
@@ -31,6 +31,7 @@ import org.apache.wicket.page.IPageManagerContext;
import org.apache.wicket.util.resource.IResourceStream;
import org.apache.wicket.util.resource.StringResourceStream;
import org.apache.wicket.util.tester.WicketTester;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -188,6 +189,47 @@ public class TransparentWebMarkupContainerTest extends WicketTestCase
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
+ * introduce automatic transparent containers inside some link components due to a
+ * {@code <img src="">} tag inside the link tags, and trying to update a label that was added to
+ * the outer TWMC.
+ */
+ @Test
+ @Ignore("Fails due to WICKET-5898")
+ public void ajaxRequestForComponentInTransparentWebMarkupContainerShouldntCauseStackOverflow4()
+ {
+ tester.startPage(TransparentContainerWithAutoTransparentContainerPage.class);
+
+ // the page renders normally using normal web requests
+ tester.assertRenderedPage(TransparentContainerWithAutoTransparentContainerPage.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
+ * manually added transparent containers inside some link components, and trying to update a
+ * label that was added to the outer TWMC.
+ */
+ @Test
+ @Ignore("Fails due to WICKET-5898")
+ public void ajaxRequestForComponentInTransparentWebMarkupContainerShouldntCauseStackOverflow5()
+ {
+ tester.startPage(TransparentContainerWithManualTransparentContainerPage.class);
+
+ // the page renders normally using normal web requests
+ tester.assertRenderedPage(TransparentContainerWithManualTransparentContainerPage.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
{