WICKET-5679 RenderStrategy REDIRECT_TO_RENDER lets fail test with BaseWicketTester#startComponentInPage
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/c3795bd0 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/c3795bd0 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/c3795bd0 Branch: refs/heads/WICKET-5677 Commit: c3795bd0ed0df1a9e73fcba37cf911192307dbe1 Parents: dfd4cc2 Author: Martin Tzvetanov Grigorov <[email protected]> Authored: Wed Aug 20 13:05:01 2014 +0300 Committer: Martin Tzvetanov Grigorov <[email protected]> Committed: Wed Aug 20 13:05:01 2014 +0300 ---------------------------------------------------------------------- .../wicket/util/tester/BaseWicketTester.java | 15 +++++- ...tartComponentInPageRedirectToRenderTest.java | 51 ++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/c3795bd0/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java b/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java index 15f0785..83c0c4a 100644 --- a/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java +++ b/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java @@ -1383,7 +1383,15 @@ public class BaseWicketTester fail("Error while parsing the markup for the autogenerated page: " + e.getMessage()); } } - page.setMarkup(pageMarkup); + + if (page instanceof StartComponentInPage) + { + ((StartComponentInPage)page).setPageMarkup(pageMarkup); + } + else + { + page.setMarkup(pageMarkup); + } // Add the child component page.add(component); @@ -1473,6 +1481,11 @@ public class BaseWicketTester return calculatedMarkup; } + public void setPageMarkup(IMarkupFragment markup) + { + setMarkup(markup); + pageMarkup = markup; + } } /** http://git-wip-us.apache.org/repos/asf/wicket/blob/c3795bd0/wicket-core/src/test/java/org/apache/wicket/util/tester/StartComponentInPageRedirectToRenderTest.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/tester/StartComponentInPageRedirectToRenderTest.java b/wicket-core/src/test/java/org/apache/wicket/util/tester/StartComponentInPageRedirectToRenderTest.java new file mode 100644 index 0000000..686f850 --- /dev/null +++ b/wicket-core/src/test/java/org/apache/wicket/util/tester/StartComponentInPageRedirectToRenderTest.java @@ -0,0 +1,51 @@ +/* + * 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.util.tester; + + +import org.apache.wicket.WicketTestCase; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.mock.MockApplication; +import org.apache.wicket.protocol.http.WebApplication; +import org.apache.wicket.settings.IRequestCycleSettings; +import org.junit.Test; + +/** + * https://issues.apache.org/jira/browse/WICKET-5679 + */ +public class StartComponentInPageRedirectToRenderTest extends WicketTestCase +{ + @Override + protected WebApplication newApplication() + { + return new MockApplication() + { + @Override + protected void init() + { + super.init(); + getRequestCycleSettings().setRenderStrategy(IRequestCycleSettings.RenderStrategy.REDIRECT_TO_RENDER); + } + }; + } + + @Test + public void startComponentInPageRedirectToRender() + { + tester.startComponentInPage(new Label("foo")); + } +}
