You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by cm...@apache.org on 2016/07/04 15:22:50 UTC

[1/2] wicket git commit: WICKET-6053 Allow to reuse the same application instance in several tests

Repository: wicket
Updated Branches:
  refs/heads/wicket-6.x 2678faa03 -> 1fccffb76


WICKET-6053 Allow to reuse the same application instance in several tests


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/8c3b6567
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/8c3b6567
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/8c3b6567

Branch: refs/heads/wicket-6.x
Commit: 8c3b6567852f60f68aa92cc77361f05d924af8b3
Parents: 2678faa
Author: Carl-Eric Menzel <cm...@wicketbuch.de>
Authored: Tue Jun 28 22:38:25 2016 +0200
Committer: Carl-Eric Menzel <cm...@wicketbuch.de>
Committed: Tue Jun 28 22:38:25 2016 +0200

----------------------------------------------------------------------
 .../wicket/util/tester/BaseWicketTester.java    | 35 +++++++++-----------
 1 file changed, 16 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/8c3b6567/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 67c85af..a9ec85f 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
@@ -318,18 +318,15 @@ public class BaseWicketTester
 
 		this.application = application;
 
-		// If it's provided from the container it's not necessary to set again.
-		if (init)
-		{
-			// FIXME some tests are leaking applications by not calling destroy on them or overriding
-			// teardown() without calling super, for now we work around by making each name unique
-			application.setName("WicketTesterApplication-" + UUID.randomUUID());
-		}
 		ThreadContext.setApplication(application);
 
-		// If it's provided from the container it's not necessary to set again and init.
 		if (init)
 		{
+			if (application.getName() == null)
+			{
+				application.setName("WicketTesterApplication-" + UUID.randomUUID());
+			}
+
 			application.setServletContext(servletContext);
 			// initialize the application
 			application.initApplication();
@@ -428,10 +425,10 @@ public class BaseWicketTester
 		if (lastResponse != null)
 		{
 			List<Cookie> lastResponseCookies = lastResponse.getCookies();
-			if (lastResponse.isRedirect()) 
+			if (lastResponse.isRedirect())
 			{
 				CookieCollection responseCookies = new CookieCollection();
-				
+
 				// if the last request is a redirect, all cookies from last response should appear in current response
 				// this call will filter duplicates
 				responseCookies.addAll(lastResponseCookies);
@@ -439,7 +436,7 @@ public class BaseWicketTester
 				{
 					response.addCookie(cookie);
 				}
-				
+
 				// copy all request cookies from last request to the new request because of redirect handling
 				// this way, the cookie will be send to the next requested page
 				if (lastRequest != null)
@@ -449,10 +446,10 @@ public class BaseWicketTester
 					requestCookies.addAll(lastRequest.getCookies());
 					request.addCookies(requestCookies.asList());
 				}
-			} 
+			}
 			else
 			{
-				// if the last response is not a redirect 
+				// if the last response is not a redirect
 				// - copy last request cookies to collection
 				// - copy last response cookies to collection
 				// - set only the not expired cookies to the next request
@@ -1169,7 +1166,7 @@ public class BaseWicketTester
 			Form<?> form = formSubmitBehavior.getForm();
 			getRequest().setUseMultiPartContentType(form.isMultiPart());
 			serializeFormToRequest(form);
-			
+
 			// mark behavior's component as the form submitter,
 			String name = Form.getRootFormRelativeId(new PropertyModel<Component>(behavior,
 					"component").getObject());
@@ -1542,15 +1539,15 @@ public class BaseWicketTester
 
 	/**
 	 * A helper method for starting a component for a test without attaching it to a Page.
-	 * 
+	 *
 	 * Components which are somehow dependent on the page structure can not be currently tested with
 	 * this method.
-	 * 
+	 *
 	 * Example:
-	 * 
+	 *
 	 * UserDataView view = new UserDataView("view", new ListDataProvider(userList));
 	 * tester.startComponent(view); assertEquals(4, view.size());
-	 * 
+	 *
 	 * @param component
 	 * @return the processed component
 	 * @see #startComponentInPage(Class)
@@ -2186,7 +2183,7 @@ public class BaseWicketTester
 
 	/**
 	 * Retrieves <code>FeedbackMessages</code>.
-	 * 
+	 *
 	 * @param level
 	 *            level of feedback message, for example:
 	 *            <code>FeedbackMessage.DEBUG or FeedbackMessage.INFO.. etc</code>


[2/2] wicket git commit: Merge branch 'wicket-6/WICKET-6053' into wicket-6.x

Posted by cm...@apache.org.
Merge branch 'wicket-6/WICKET-6053' into wicket-6.x


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/1fccffb7
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/1fccffb7
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/1fccffb7

Branch: refs/heads/wicket-6.x
Commit: 1fccffb76a5fb695c017c395eb7f91821c6962b7
Parents: 2678faa 8c3b656
Author: Carl-Eric Menzel <cm...@apache.org>
Authored: Mon Jul 4 17:12:46 2016 +0200
Committer: Carl-Eric Menzel <cm...@apache.org>
Committed: Mon Jul 4 17:12:46 2016 +0200

----------------------------------------------------------------------
 .../wicket/util/tester/BaseWicketTester.java    | 35 +++++++++-----------
 1 file changed, 16 insertions(+), 19 deletions(-)
----------------------------------------------------------------------