[jboss-cvs] jboss-seam/src/main/org/jboss/seam/mock ...
Gavin King
gavin.king at jboss.com
Fri Feb 9 00:31:47 EST 2007
User: gavin
Date: 07/02/09 00:31:47
Modified: src/main/org/jboss/seam/mock MockExternalContext.java
MockHttpServletRequest.java SeamTest.java
Log:
JBSEAM-795
Revision Changes Path
1.14 +8 -2 jboss-seam/src/main/org/jboss/seam/mock/MockExternalContext.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MockExternalContext.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/mock/MockExternalContext.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- MockExternalContext.java 4 Feb 2007 21:14:50 -0000 1.13
+++ MockExternalContext.java 9 Feb 2007 05:31:47 -0000 1.14
@@ -24,6 +24,7 @@
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;
+import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@@ -33,7 +34,7 @@
/**
* @author Gavin King
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.13 $
+ * @version $Revision: 1.14 $
*/
public class MockExternalContext extends ExternalContext
{
@@ -176,7 +177,12 @@
@Override
public Map getRequestCookieMap()
{
- return null;
+ Map<String, Cookie> cookieMap = new HashMap<String, Cookie>();
+ for ( Cookie cookie : request.getCookies() )
+ {
+ cookieMap.put(cookie.getName(), cookie);
+ }
+ return cookieMap;
}
@Override
1.12 +10 -3 jboss-seam/src/main/org/jboss/seam/mock/MockHttpServletRequest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MockHttpServletRequest.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/mock/MockHttpServletRequest.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- MockHttpServletRequest.java 4 Feb 2007 20:26:14 -0000 1.11
+++ MockHttpServletRequest.java 9 Feb 2007 05:31:47 -0000 1.12
@@ -26,7 +26,7 @@
/**
* @author Gavin King
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.11 $
+ * @version $Revision: 1.12 $
*/
public class MockHttpServletRequest implements HttpServletRequest
{
@@ -37,6 +37,7 @@
private Map<String, String[]> headers = new HashMap<String, String[]>();
private String principalName;
private Set<String> principalRoles;
+ private Cookie[] cookies;
public MockHttpServletRequest(HttpSession session)
{
@@ -50,6 +51,13 @@
this.principalRoles = principalRoles;
}
+ public MockHttpServletRequest(HttpSession session, String principalName, Set<String> principalRoles, Cookie[] cookies)
+ {
+ this.session = session;
+ this.principalName = principalName;
+ this.principalRoles = principalRoles;
+ }
+
public Map<String, String[]> getParameters()
{
return parameters;
@@ -68,8 +76,7 @@
public Cookie[] getCookies()
{
- //TODO
- return null;
+ return cookies;
}
public long getDateHeader(String arg0)
1.61 +10 -2 jboss-seam/src/main/org/jboss/seam/mock/SeamTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SeamTest.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/mock/SeamTest.java,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -b -r1.60 -r1.61
--- SeamTest.java 9 Jan 2007 07:17:20 -0000 1.60
+++ SeamTest.java 9 Feb 2007 05:31:47 -0000 1.61
@@ -8,8 +8,10 @@
import java.lang.reflect.Field;
import java.util.AbstractSet;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -21,6 +23,7 @@
import javax.faces.event.PhaseId;
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.transaction.UserTransaction;
@@ -51,7 +54,7 @@
*
* @author Gavin King
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.60 $
+ * @version $Revision: 1.61 $
*/
public class SeamTest
{
@@ -194,6 +197,11 @@
};
}
+ public List<Cookie> getCookies()
+ {
+ return Collections.EMPTY_LIST;
+ }
+
/**
* A script for a JSF interaction with
* no existing long-running conversation.
@@ -396,7 +404,7 @@
*/
public String run() throws Exception
{
- HttpServletRequest request = new MockHttpServletRequest( session, getPrincipalName(), getPrincipalRoles() );
+ HttpServletRequest request = new MockHttpServletRequest( session, getPrincipalName(), getPrincipalRoles(), getCookies().toArray( new Cookie[]{} ) );
externalContext = new MockExternalContext(servletContext, request);
application = new SeamApplication11(SeamTest.this.application);
facesContext = new MockFacesContext( externalContext, application );
More information about the jboss-cvs-commits
mailing list