You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2019/11/16 08:41:37 UTC
[wicket] branch master updated: WICKET-6713 start via class or
instance
This is an automated email from the ASF dual-hosted git repository.
svenmeier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git
The following commit(s) were added to refs/heads/master by this push:
new ef1fe3d WICKET-6713 start via class or instance
ef1fe3d is described below
commit ef1fe3da672b868dc134b6d16346fea94d46832b
Author: Sven Meier <sv...@apache.org>
AuthorDate: Sat Nov 16 08:49:06 2019 +0100
WICKET-6713 start via class or instance
on same tester
---
.../wicket/util/tester/BaseWicketTester.java | 25 +++++++---------------
.../wicket/util/tester/WicketTesterTest.java | 20 ++++++++++++++++-
2 files changed, 27 insertions(+), 18 deletions(-)
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 c643baa..01b1e29 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
@@ -1367,9 +1367,6 @@ public class BaseWicketTester
{
Constructor<C> c = componentClass.getConstructor(String.class);
comp = c.newInstance(ComponentInPage.ID);
- componentInPage = new ComponentInPage();
- componentInPage.component = comp;
- componentInPage.isInstantiated = true;
}
catch (Exception e)
{
@@ -1379,7 +1376,11 @@ public class BaseWicketTester
}
// process the component
- return startComponentInPage(comp, pageMarkup);
+ C started = startComponentInPage(comp, pageMarkup);
+
+ componentInPage.isInstantiated = true;
+
+ return started;
}
/**
@@ -1478,22 +1479,12 @@ public class BaseWicketTester
// Add the child component
page.add(component);
- // Preserve 'componentInPage' because #startPage() needs to null-fy it
- ComponentInPage oldComponentInPage = componentInPage;
-
// Process the page
startPage(page);
- // Remember the "root" component processes and return it
- if (oldComponentInPage != null)
- {
- componentInPage = oldComponentInPage;
- }
- else
- {
- componentInPage = new ComponentInPage();
- componentInPage.component = component;
- }
+ componentInPage = new ComponentInPage();
+ componentInPage.component = component;
+
return component;
}
diff --git a/wicket-core/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java b/wicket-core/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java
index 1d967f1..3799b7c 100644
--- a/wicket-core/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java
@@ -1353,6 +1353,24 @@ class WicketTesterTest extends WicketTestCase
}
+ /**
+ * WICKET-6713 component can be started via class or instance on same tester
+ */
+ @Test
+ void componentInPage() {
+ tester.startComponentInPage(Label.class);
+
+ tester.assertVisible("");
+
+ tester.startComponentInPage(new Label("otherLabel"));
+
+ tester.assertVisible("otherLabel");
+
+ tester.startComponentInPage(Label.class);
+
+ tester.assertVisible("");
+ }
+
public static class AlwaysRedirectPage extends WebPage
{
public AlwaysRedirectPage()
@@ -1360,5 +1378,5 @@ class WicketTesterTest extends WicketTestCase
// redirects to another web server on the same computer
throw new RedirectToUrlException("http://localhost:4333/");
}
- }
+ }
}