You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by hu...@apache.org on 2006/11/06 16:02:22 UTC
svn commit: r471756 [24/31] - in /struts/struts2/trunk: apps/blank/
apps/blank/src/main/java/example/ apps/blank/src/test/java/example/
apps/mailreader/src/main/java/mailreader2/
apps/portlet/src/main/java/org/apache/struts2/portlet/example/ apps/portl...
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/impl/RequestContextTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/impl/RequestContextTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/impl/RequestContextTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/impl/RequestContextTest.java Mon Nov 6 07:01:43 2006
@@ -1,3 +1,23 @@
+/*
+ * $Id$
+ *
+ * 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.
+ */
// Copyright 2006 Google Inc. All Rights Reserved.
package org.apache.struts2.impl;
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/CreateSessionInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/CreateSessionInterceptorTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/CreateSessionInterceptorTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/CreateSessionInterceptorTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * 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
*
- * Licensed 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
*
- * 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.
+ * 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.struts2.interceptor;
@@ -29,20 +32,20 @@
/**
* Test case for CreateSessionInterceptor.
- *
+ *
*/
public class CreateSessionInterceptorTest extends StrutsTestCase {
- public void testCreateSession() throws Exception {
- Mock httpServletRequestMock = new Mock(HttpServletRequest.class);
- httpServletRequestMock.expects(new InvokeOnceMatcher()).method("getSession").with(new IsEqual(Boolean.TRUE));
- HttpServletRequest request = (HttpServletRequest) httpServletRequestMock.proxy();
+ public void testCreateSession() throws Exception {
+ Mock httpServletRequestMock = new Mock(HttpServletRequest.class);
+ httpServletRequestMock.expects(new InvokeOnceMatcher()).method("getSession").with(new IsEqual(Boolean.TRUE));
+ HttpServletRequest request = (HttpServletRequest) httpServletRequestMock.proxy();
- ServletActionContext.setRequest(request);
+ ServletActionContext.setRequest(request);
- CreateSessionInterceptor interceptor = new CreateSessionInterceptor();
- interceptor.intercept(new MockActionInvocation());
+ CreateSessionInterceptor interceptor = new CreateSessionInterceptor();
+ interceptor.intercept(new MockActionInvocation());
- httpServletRequestMock.verify();
- }
+ httpServletRequestMock.verify();
+ }
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitDelayAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitDelayAction.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitDelayAction.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitDelayAction.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * 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
*
- * Licensed 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
*
- * 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.
+ * 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.struts2.interceptor;
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ExecuteAndWaitInterceptorTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * 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
*
- * Licensed 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
*
- * 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.
+ * 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.struts2.interceptor;
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * 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
*
- * Licensed 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
*
- * 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.
+ * 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.struts2.interceptor;
@@ -242,9 +245,9 @@
private class MyFileupAction extends ActionSupport {
- private static final long serialVersionUID = 6255238895447968889L;
-
- // no methods
+ private static final long serialVersionUID = 6255238895447968889L;
+
+ // no methods
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * 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
*
- * Licensed 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
*
- * 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.
+ * 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.struts2.interceptor;
@@ -34,211 +37,211 @@
/**
* Test case for MessageStoreInterceptor.
- *
+ *
* @version $Date$ $Id$
*/
public class MessageStoreInterceptorTest extends StrutsTestCase {
- public void testStoreMessage() throws Exception {
- MessageStoreInterceptor interceptor = new MessageStoreInterceptor();
- interceptor.setAllowRequestParameterSwitch(true);
- interceptor.setOperationMode(MessageStoreInterceptor.STORE_MODE);
-
-
- Map paramMap = new LinkedHashMap();
- Map sessionMap = new LinkedHashMap();
-
- ActionSupport action = new ActionSupport();
- action.addActionError("some action error 1");
- action.addActionError("some action error 2");
- action.addActionMessage("some action message 1");
- action.addActionMessage("some action message 2");
- action.addFieldError("field1", "some field error 1");
- action.addFieldError("field2", "some field error 2");
-
- ActionContext actionContext = new ActionContext(new HashMap());
- actionContext.put(ActionContext.PARAMETERS, paramMap);
- actionContext.put(ActionContext.SESSION, sessionMap);
-
- // Mock (ActionInvocation)
- ActionInvocation mockActionInvocation = EasyMock.createControl().createMock(ActionInvocation.class);
- mockActionInvocation.getInvocationContext();
- EasyMock.expectLastCall().andReturn(actionContext);
- EasyMock.expectLastCall().anyTimes();
-
- mockActionInvocation.invoke();
- EasyMock.expectLastCall().andReturn(Action.SUCCESS);
-
- mockActionInvocation.getAction();
- EasyMock.expectLastCall().andReturn(action);
-
-
- EasyMock.replay(mockActionInvocation);
-
- interceptor.init();
- interceptor.intercept(mockActionInvocation);
- interceptor.destroy();
-
- assertEquals(sessionMap.size(), 3);
- assertTrue(sessionMap.containsKey(MessageStoreInterceptor.actionErrorsSessionKey));
- assertTrue(sessionMap.containsKey(MessageStoreInterceptor.actionMessagesSessionKey));
- assertTrue(sessionMap.containsKey(MessageStoreInterceptor.fieldErrorsSessionKey));
-
- List actionErrors = (List) sessionMap.get(MessageStoreInterceptor.actionErrorsSessionKey);
- List actionMessages = (List) sessionMap.get(MessageStoreInterceptor.actionMessagesSessionKey);
- Map fieldErrors = (Map) sessionMap.get(MessageStoreInterceptor.fieldErrorsSessionKey);
-
- assertEquals(actionErrors.size(), 2);
- assertEquals(actionMessages.size(), 2);
- assertEquals(fieldErrors.size(), 2);
-
- assertTrue(actionErrors.contains("some action error 1"));
- assertTrue(actionErrors.contains("some action error 2"));
- assertTrue(actionMessages.contains("some action message 1"));
- assertTrue(actionMessages.contains("some action message 2"));
- assertTrue(fieldErrors.containsKey("field1"));
- assertTrue(fieldErrors.containsKey("field2"));
- assertEquals(((List)fieldErrors.get("field1")).size(), 1);
- assertEquals(((List)fieldErrors.get("field2")).size(), 1);
- assertEquals(((List)fieldErrors.get("field1")).get(0), "some field error 1");
- assertEquals(((List)fieldErrors.get("field2")).get(0), "some field error 2");
-
- EasyMock.verify(mockActionInvocation);
- }
-
- public void testRetrieveMessage() throws Exception {
- MessageStoreInterceptor interceptor = new MessageStoreInterceptor();
- interceptor.setOperationMode(MessageStoreInterceptor.RETRIEVE_MODE);
- interceptor.setAllowRequestParameterSwitch(true);
-
-
- ActionSupport action = new ActionSupport();
-
- ActionInvocation mockActionInvocation = EasyMock.createControl().createMock(ActionInvocation.class);
- mockActionInvocation.invoke();
- EasyMock.expectLastCall().andReturn(Action.SUCCESS);
-
- Map paramsMap = new LinkedHashMap();
- Map sessionMap = new LinkedHashMap();
-
- List actionErrors = new ArrayList();
- List actionMessages = new ArrayList();
- Map fieldErrors = new LinkedHashMap();
-
- actionErrors.add("some action error 1");
- actionErrors.add("some action error 2");
- actionMessages.add("some action messages 1");
- actionMessages.add("some action messages 2");
- List field1Errors = new ArrayList();
- field1Errors.add("some field error 1");
- List field2Errors = new ArrayList();
- field2Errors.add("some field error 2");
- fieldErrors.put("field1", field1Errors);
- fieldErrors.put("field2", field2Errors);
-
- sessionMap.put(MessageStoreInterceptor.actionErrorsSessionKey, actionErrors);
- sessionMap.put(MessageStoreInterceptor.actionMessagesSessionKey, actionMessages);
- sessionMap.put(MessageStoreInterceptor.fieldErrorsSessionKey, fieldErrors);
-
-
- ActionContext actionContext = new ActionContext(new HashMap());
- actionContext.put(ActionContext.PARAMETERS, paramsMap);
- actionContext.put(ActionContext.SESSION, sessionMap);
-
- mockActionInvocation.getInvocationContext();
- EasyMock.expectLastCall().andReturn(actionContext);
- EasyMock.expectLastCall().anyTimes();
-
- mockActionInvocation.getAction();
- EasyMock.expectLastCall().andReturn(action);
-
- EasyMock.replay(mockActionInvocation);
-
- interceptor.init();
- interceptor.intercept(mockActionInvocation);
- interceptor.destroy();
-
- assertEquals(action.getActionErrors().size(), 2);
- assertEquals(action.getActionMessages().size(), 2);
- assertEquals(action.getFieldErrors().size(), 2);
- assertTrue(action.getActionErrors().contains("some action error 1"));
- assertTrue(action.getActionErrors().contains("some action error 2"));
- assertTrue(action.getActionMessages().contains("some action messages 1"));
- assertTrue(action.getActionMessages().contains("some action messages 2"));
- assertEquals(((List)action.getFieldErrors().get("field1")).size(), 1);
- assertEquals(((List)action.getFieldErrors().get("field2")).size(), 1);
- assertEquals(((List)action.getFieldErrors().get("field1")).get(0), "some field error 1");
- assertEquals(((List)action.getFieldErrors().get("field2")).get(0), "some field error 2");
-
- EasyMock.verify(mockActionInvocation);
- }
-
- public void testRequestOperationMode1() throws Exception {
-
- Map paramMap = new LinkedHashMap();
- paramMap.put("operationMode", new String[] { MessageStoreInterceptor.RETRIEVE_MODE });
-
- ActionContext actionContext = new ActionContext(new HashMap());
- actionContext.put(ActionContext.PARAMETERS, paramMap);
-
- ActionInvocation mockActionInvocation = EasyMock.createControl().createMock(ActionInvocation.class);
- mockActionInvocation.getInvocationContext();
- EasyMock.expectLastCall().andReturn(actionContext);
- EasyMock.expectLastCall().anyTimes();
-
- EasyMock.replay(mockActionInvocation);
-
- MessageStoreInterceptor interceptor = new MessageStoreInterceptor();
- String operationMode = interceptor.getRequestOperationMode(mockActionInvocation);
-
- assertEquals(operationMode, MessageStoreInterceptor.RETRIEVE_MODE);
-
- EasyMock.verify(mockActionInvocation);
- }
-
- public void testRequestOperationMode2() throws Exception {
-
- Map paramMap = new LinkedHashMap();
- paramMap.put("operationMode", new String[] { MessageStoreInterceptor.STORE_MODE });
-
- ActionContext actionContext = new ActionContext(new HashMap());
- actionContext.put(ActionContext.PARAMETERS, paramMap);
-
- ActionInvocation mockActionInvocation = EasyMock.createControl().createMock(ActionInvocation.class);
- mockActionInvocation.getInvocationContext();
- EasyMock.expectLastCall().andReturn(actionContext);
- EasyMock.expectLastCall().anyTimes();
-
- EasyMock.replay(mockActionInvocation);
-
- MessageStoreInterceptor interceptor = new MessageStoreInterceptor();
- String operationMode = interceptor.getRequestOperationMode(mockActionInvocation);
-
- assertEquals(operationMode, MessageStoreInterceptor.STORE_MODE);
-
- EasyMock.verify(mockActionInvocation);
- }
-
- public void testRequestOperationMode3() throws Exception {
-
- Map paramMap = new LinkedHashMap();
-
- ActionContext actionContext = new ActionContext(new HashMap());
- actionContext.put(ActionContext.PARAMETERS, paramMap);
-
- ActionInvocation mockActionInvocation = EasyMock.createControl().createMock(ActionInvocation.class);
- mockActionInvocation.getInvocationContext();
- EasyMock.expectLastCall().andReturn(actionContext);
- EasyMock.expectLastCall().anyTimes();
-
- EasyMock.replay(mockActionInvocation);
-
- MessageStoreInterceptor interceptor = new MessageStoreInterceptor();
- String operationMode = interceptor.getRequestOperationMode(mockActionInvocation);
-
- assertEquals(operationMode, MessageStoreInterceptor.NONE);
-
- EasyMock.verify(mockActionInvocation);
-
- }
+ public void testStoreMessage() throws Exception {
+ MessageStoreInterceptor interceptor = new MessageStoreInterceptor();
+ interceptor.setAllowRequestParameterSwitch(true);
+ interceptor.setOperationMode(MessageStoreInterceptor.STORE_MODE);
+
+
+ Map paramMap = new LinkedHashMap();
+ Map sessionMap = new LinkedHashMap();
+
+ ActionSupport action = new ActionSupport();
+ action.addActionError("some action error 1");
+ action.addActionError("some action error 2");
+ action.addActionMessage("some action message 1");
+ action.addActionMessage("some action message 2");
+ action.addFieldError("field1", "some field error 1");
+ action.addFieldError("field2", "some field error 2");
+
+ ActionContext actionContext = new ActionContext(new HashMap());
+ actionContext.put(ActionContext.PARAMETERS, paramMap);
+ actionContext.put(ActionContext.SESSION, sessionMap);
+
+ // Mock (ActionInvocation)
+ ActionInvocation mockActionInvocation = EasyMock.createControl().createMock(ActionInvocation.class);
+ mockActionInvocation.getInvocationContext();
+ EasyMock.expectLastCall().andReturn(actionContext);
+ EasyMock.expectLastCall().anyTimes();
+
+ mockActionInvocation.invoke();
+ EasyMock.expectLastCall().andReturn(Action.SUCCESS);
+
+ mockActionInvocation.getAction();
+ EasyMock.expectLastCall().andReturn(action);
+
+
+ EasyMock.replay(mockActionInvocation);
+
+ interceptor.init();
+ interceptor.intercept(mockActionInvocation);
+ interceptor.destroy();
+
+ assertEquals(sessionMap.size(), 3);
+ assertTrue(sessionMap.containsKey(MessageStoreInterceptor.actionErrorsSessionKey));
+ assertTrue(sessionMap.containsKey(MessageStoreInterceptor.actionMessagesSessionKey));
+ assertTrue(sessionMap.containsKey(MessageStoreInterceptor.fieldErrorsSessionKey));
+
+ List actionErrors = (List) sessionMap.get(MessageStoreInterceptor.actionErrorsSessionKey);
+ List actionMessages = (List) sessionMap.get(MessageStoreInterceptor.actionMessagesSessionKey);
+ Map fieldErrors = (Map) sessionMap.get(MessageStoreInterceptor.fieldErrorsSessionKey);
+
+ assertEquals(actionErrors.size(), 2);
+ assertEquals(actionMessages.size(), 2);
+ assertEquals(fieldErrors.size(), 2);
+
+ assertTrue(actionErrors.contains("some action error 1"));
+ assertTrue(actionErrors.contains("some action error 2"));
+ assertTrue(actionMessages.contains("some action message 1"));
+ assertTrue(actionMessages.contains("some action message 2"));
+ assertTrue(fieldErrors.containsKey("field1"));
+ assertTrue(fieldErrors.containsKey("field2"));
+ assertEquals(((List)fieldErrors.get("field1")).size(), 1);
+ assertEquals(((List)fieldErrors.get("field2")).size(), 1);
+ assertEquals(((List)fieldErrors.get("field1")).get(0), "some field error 1");
+ assertEquals(((List)fieldErrors.get("field2")).get(0), "some field error 2");
+
+ EasyMock.verify(mockActionInvocation);
+ }
+
+ public void testRetrieveMessage() throws Exception {
+ MessageStoreInterceptor interceptor = new MessageStoreInterceptor();
+ interceptor.setOperationMode(MessageStoreInterceptor.RETRIEVE_MODE);
+ interceptor.setAllowRequestParameterSwitch(true);
+
+
+ ActionSupport action = new ActionSupport();
+
+ ActionInvocation mockActionInvocation = EasyMock.createControl().createMock(ActionInvocation.class);
+ mockActionInvocation.invoke();
+ EasyMock.expectLastCall().andReturn(Action.SUCCESS);
+
+ Map paramsMap = new LinkedHashMap();
+ Map sessionMap = new LinkedHashMap();
+
+ List actionErrors = new ArrayList();
+ List actionMessages = new ArrayList();
+ Map fieldErrors = new LinkedHashMap();
+
+ actionErrors.add("some action error 1");
+ actionErrors.add("some action error 2");
+ actionMessages.add("some action messages 1");
+ actionMessages.add("some action messages 2");
+ List field1Errors = new ArrayList();
+ field1Errors.add("some field error 1");
+ List field2Errors = new ArrayList();
+ field2Errors.add("some field error 2");
+ fieldErrors.put("field1", field1Errors);
+ fieldErrors.put("field2", field2Errors);
+
+ sessionMap.put(MessageStoreInterceptor.actionErrorsSessionKey, actionErrors);
+ sessionMap.put(MessageStoreInterceptor.actionMessagesSessionKey, actionMessages);
+ sessionMap.put(MessageStoreInterceptor.fieldErrorsSessionKey, fieldErrors);
+
+
+ ActionContext actionContext = new ActionContext(new HashMap());
+ actionContext.put(ActionContext.PARAMETERS, paramsMap);
+ actionContext.put(ActionContext.SESSION, sessionMap);
+
+ mockActionInvocation.getInvocationContext();
+ EasyMock.expectLastCall().andReturn(actionContext);
+ EasyMock.expectLastCall().anyTimes();
+
+ mockActionInvocation.getAction();
+ EasyMock.expectLastCall().andReturn(action);
+
+ EasyMock.replay(mockActionInvocation);
+
+ interceptor.init();
+ interceptor.intercept(mockActionInvocation);
+ interceptor.destroy();
+
+ assertEquals(action.getActionErrors().size(), 2);
+ assertEquals(action.getActionMessages().size(), 2);
+ assertEquals(action.getFieldErrors().size(), 2);
+ assertTrue(action.getActionErrors().contains("some action error 1"));
+ assertTrue(action.getActionErrors().contains("some action error 2"));
+ assertTrue(action.getActionMessages().contains("some action messages 1"));
+ assertTrue(action.getActionMessages().contains("some action messages 2"));
+ assertEquals(((List)action.getFieldErrors().get("field1")).size(), 1);
+ assertEquals(((List)action.getFieldErrors().get("field2")).size(), 1);
+ assertEquals(((List)action.getFieldErrors().get("field1")).get(0), "some field error 1");
+ assertEquals(((List)action.getFieldErrors().get("field2")).get(0), "some field error 2");
+
+ EasyMock.verify(mockActionInvocation);
+ }
+
+ public void testRequestOperationMode1() throws Exception {
+
+ Map paramMap = new LinkedHashMap();
+ paramMap.put("operationMode", new String[] { MessageStoreInterceptor.RETRIEVE_MODE });
+
+ ActionContext actionContext = new ActionContext(new HashMap());
+ actionContext.put(ActionContext.PARAMETERS, paramMap);
+
+ ActionInvocation mockActionInvocation = EasyMock.createControl().createMock(ActionInvocation.class);
+ mockActionInvocation.getInvocationContext();
+ EasyMock.expectLastCall().andReturn(actionContext);
+ EasyMock.expectLastCall().anyTimes();
+
+ EasyMock.replay(mockActionInvocation);
+
+ MessageStoreInterceptor interceptor = new MessageStoreInterceptor();
+ String operationMode = interceptor.getRequestOperationMode(mockActionInvocation);
+
+ assertEquals(operationMode, MessageStoreInterceptor.RETRIEVE_MODE);
+
+ EasyMock.verify(mockActionInvocation);
+ }
+
+ public void testRequestOperationMode2() throws Exception {
+
+ Map paramMap = new LinkedHashMap();
+ paramMap.put("operationMode", new String[] { MessageStoreInterceptor.STORE_MODE });
+
+ ActionContext actionContext = new ActionContext(new HashMap());
+ actionContext.put(ActionContext.PARAMETERS, paramMap);
+
+ ActionInvocation mockActionInvocation = EasyMock.createControl().createMock(ActionInvocation.class);
+ mockActionInvocation.getInvocationContext();
+ EasyMock.expectLastCall().andReturn(actionContext);
+ EasyMock.expectLastCall().anyTimes();
+
+ EasyMock.replay(mockActionInvocation);
+
+ MessageStoreInterceptor interceptor = new MessageStoreInterceptor();
+ String operationMode = interceptor.getRequestOperationMode(mockActionInvocation);
+
+ assertEquals(operationMode, MessageStoreInterceptor.STORE_MODE);
+
+ EasyMock.verify(mockActionInvocation);
+ }
+
+ public void testRequestOperationMode3() throws Exception {
+
+ Map paramMap = new LinkedHashMap();
+
+ ActionContext actionContext = new ActionContext(new HashMap());
+ actionContext.put(ActionContext.PARAMETERS, paramMap);
+
+ ActionInvocation mockActionInvocation = EasyMock.createControl().createMock(ActionInvocation.class);
+ mockActionInvocation.getInvocationContext();
+ EasyMock.expectLastCall().andReturn(actionContext);
+ EasyMock.expectLastCall().anyTimes();
+
+ EasyMock.replay(mockActionInvocation);
+
+ MessageStoreInterceptor interceptor = new MessageStoreInterceptor();
+ String operationMode = interceptor.getRequestOperationMode(mockActionInvocation);
+
+ assertEquals(operationMode, MessageStoreInterceptor.NONE);
+
+ EasyMock.verify(mockActionInvocation);
+
+ }
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/RolesInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/RolesInterceptorTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/RolesInterceptorTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/RolesInterceptorTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
- * $Id: FileUploadInterceptorTest.java 441909 2006-09-10 05:28:16Z mrdon $
+ * $Id: $
*
- * Copyright 2006 The Apache Software Foundation.
+ * 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
*
- * Licensed 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
*
- * 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.
+ * 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.struts2.interceptor;
@@ -27,30 +30,30 @@
public class RolesInterceptorTest extends StrutsTestCase {
private RolesInterceptor interceptor = new RolesInterceptor();
-
+
public void setUp() throws Exception {
super.setUp();
interceptor = new RolesInterceptor();
}
-
+
public void testStringToList() {
List list = interceptor.stringToList("foo");
assertNotNull(list);
assertEquals(1, list.size());
-
+
list = interceptor.stringToList("foo,bar");
assertEquals(2, list.size());
assertEquals("foo", (String)list.get(0));
-
+
list = interceptor.stringToList("foo, bar");
assertEquals(2, list.size());
assertEquals("bar", (String)list.get(1));
-
+
list = interceptor.stringToList("foo , bar");
assertEquals(2, list.size());
assertEquals("bar", (String)list.get(1));
}
-
+
public void testIsAllowed() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest() {
public boolean isUserInRole(String role) {
@@ -59,21 +62,21 @@
};
interceptor.setAllowedRoles("admin");
assertTrue(interceptor.isAllowed(request, null));
-
+
interceptor.setAllowedRoles("bar, admin");
assertTrue(interceptor.isAllowed(request, null));
-
+
interceptor.setAllowedRoles(null);
assertTrue(interceptor.isAllowed(request, null));
-
+
interceptor.setDisallowedRoles("bar");
assertTrue(interceptor.isAllowed(request, null));
-
+
interceptor.setDisallowedRoles("bar, admin");
assertTrue(!interceptor.isAllowed(request, null));
-
+
}
-
+
public void testHandleRejection() throws Exception {
MockHttpServletResponse response = new MockHttpServletResponse();
response.setExpectedError(response.SC_FORBIDDEN);
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * 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
*
- * Licensed 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
*
- * 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.
+ * 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.struts2.interceptor;
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/StrutsConversionErrorInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/StrutsConversionErrorInterceptorTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/StrutsConversionErrorInterceptorTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/StrutsConversionErrorInterceptorTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * 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
*
- * Licensed 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
*
- * 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.
+ * 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.struts2.interceptor;
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenInterceptorTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenInterceptorTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenInterceptorTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * 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
*
- * Licensed 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
*
- * 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.
+ * 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.struts2.interceptor;
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptorTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptorTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptorTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * 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
*
- * Licensed 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
*
- * 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.
+ * 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.struts2.interceptor;
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/PortletApplicationMapTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/PortletApplicationMapTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/PortletApplicationMapTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/PortletApplicationMapTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * 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
*
- * Licensed 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
*
- * 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.
+ * 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.struts2.portlet;
@@ -149,7 +152,7 @@
}
public void testClear() {
-
+
mockPortletContext.expects(once()).method("removeAttribute").with(eq("key1"));
mockPortletContext.expects(once()).method("removeAttribute").with(eq("key2"));
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/PortletRequestMapTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/PortletRequestMapTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/PortletRequestMapTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/PortletRequestMapTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * 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
*
- * Licensed 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
*
- * 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.
+ * 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.struts2.portlet;
@@ -35,14 +38,14 @@
/**
* PortletRequestMapTest. Insert description.
- *
+ *
*/
public class PortletRequestMapTest extends MockObjectTestCase {
public void testSetAttribute() {
-
+
}
-
+
public void testGet() {
Mock mockRequest = mock(PortletRequest.class, "testGet");
mockRequest.expects(once()).method("getAttribute").with(eq("testAttribute")).will(returnValue("testValue"));
@@ -51,7 +54,7 @@
mockRequest.verify();
assertEquals("testValue", value);
}
-
+
public void testPut() {
Mock mockRequest = mock(PortletRequest.class, "testPut");
Object value = new String("testValue");
@@ -63,49 +66,49 @@
mockRequest.verify();
assertEquals(obj, value);
}
-
+
public void testClear() {
Mock mockRequest = mock(PortletRequest.class, "testClear");
mockRequest.expects(once()).method("removeAttribute").with(eq("a"));
mockRequest.expects(once()).method("removeAttribute").with(eq("b"));
-
+
ArrayList dummy = new ArrayList();
dummy.add("a");
dummy.add("b");
-
+
mockRequest.expects(once()).method("getAttributeNames").will(returnValue(Collections.enumeration(dummy)));
-
+
PortletRequestMap map = new PortletRequestMap((PortletRequest)mockRequest.proxy());
map.clear();
mockRequest.verify();
}
-
+
public void testRemove() {
Mock mockRequest = mock(PortletRequest.class);
-
+
PortletRequest req = (PortletRequest)mockRequest.proxy();
-
-
+
+
mockRequest.expects(once()).method("getAttribute").with(eq("dummyKey")).will(returnValue("dummyValue"));
-
+
mockRequest.expects(once()).method("removeAttribute").with(eq("dummyKey"));
-
+
PortletRequestMap map = new PortletRequestMap(req);
Object ret = map.remove("dummyKey");
assertEquals("dummyValue", ret);
}
-
+
public void testEntrySet() {
Mock mockRequest = mock(PortletRequest.class);
-
+
PortletRequest req = (PortletRequest)mockRequest.proxy();
-
+
Enumeration names = new Enumeration() {
List keys = Arrays.asList(new Object[]{"key1", "key2"});
Iterator it = keys.iterator();
-
+
public boolean hasMoreElements() {
return it.hasNext();
}
@@ -113,16 +116,16 @@
public Object nextElement() {
return it.next();
}
-
+
};
-
+
mockRequest.stubs().method("getAttributeNames").will(returnValue(names));
mockRequest.stubs().method("getAttribute").with(eq("key1")).will(returnValue("value1"));
mockRequest.stubs().method("getAttribute").with(eq("key2")).will(returnValue("value2"));
-
+
PortletRequestMap map = new PortletRequestMap(req);
Set entries = map.entrySet();
-
+
assertEquals(2, entries.size());
Iterator it = entries.iterator();
Map.Entry entry = (Map.Entry)it.next();
@@ -131,7 +134,7 @@
entry = (Map.Entry)it.next();
assertEquals("key1", entry.getKey());
assertEquals("value1", entry.getValue());
-
+
}
-
+
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/PortletSessionMapTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/PortletSessionMapTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/PortletSessionMapTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/PortletSessionMapTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * 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
*
- * Licensed 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
*
- * 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.
+ * 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.struts2.portlet;
@@ -34,18 +37,18 @@
/**
* PortletSessionMapTest. Insert description.
- *
+ *
*/
public class PortletSessionMapTest extends MockObjectTestCase {
public void testPut() {
-
+
Mock mockSession = mock(PortletSession.class);
Mock mockRequest = mock(PortletRequest.class);
-
+
PortletRequest req = (PortletRequest)mockRequest.proxy();
PortletSession session = (PortletSession)mockSession.proxy();
-
+
mockRequest.expects(once()).method("getPortletSession").will(returnValue(session));
Constraint[] params = new Constraint[]{eq("testAttribute1"), eq("testValue1")};
mockSession.expects(once()).method("setAttribute").with(params);
@@ -53,74 +56,74 @@
params = new Constraint[]{eq("testAttribute2"), eq("testValue2")};
mockSession.expects(once()).method("setAttribute").with(params);
mockSession.expects(once()).method("getAttribute").with(eq("testAttribute2")).will(returnValue("testValue2"));
-
+
PortletSessionMap map = new PortletSessionMap(req);
map.put("testAttribute1", "testValue1");
map.put("testAttribute2", "testValue2");
-
+
}
-
+
public void testGet() {
Mock mockSession = mock(PortletSession.class);
Mock mockRequest = mock(PortletRequest.class);
-
+
PortletRequest req = (PortletRequest)mockRequest.proxy();
PortletSession session = (PortletSession)mockSession.proxy();
-
+
mockRequest.expects(once()).method("getPortletSession").will(returnValue(session));
mockSession.expects(once()).method("getAttribute").with(eq("testAttribute1")).will(returnValue("testValue1"));
mockSession.expects(once()).method("getAttribute").with(eq("testAttribute2")).will(returnValue("testValue2"));
-
+
PortletSessionMap map = new PortletSessionMap(req);
Object val1 = map.get("testAttribute1");
Object val2 = map.get("testAttribute2");
assertEquals("testValue1", val1);
assertEquals("testValue2", val2);
}
-
+
public void testClear() {
Mock mockSession = mock(PortletSession.class);
Mock mockRequest = mock(PortletRequest.class);
-
+
PortletRequest req = (PortletRequest)mockRequest.proxy();
PortletSession session = (PortletSession)mockSession.proxy();
-
+
mockRequest.expects(once()).method("getPortletSession").will(returnValue(session));
mockSession.expects(once()).method("invalidate");
-
+
PortletSessionMap map = new PortletSessionMap(req);
map.clear();
}
-
+
public void testRemove() {
Mock mockSession = mock(PortletSession.class);
Mock mockRequest = mock(PortletRequest.class);
-
+
PortletRequest req = (PortletRequest)mockRequest.proxy();
PortletSession session = (PortletSession)mockSession.proxy();
-
-
+
+
mockRequest.expects(once()).method("getPortletSession").will(returnValue(session));
mockSession.stubs().method("getAttribute").with(eq("dummyKey")).will(returnValue("dummyValue"));
mockSession.expects(once()).method("removeAttribute").with(eq("dummyKey"));
-
+
PortletSessionMap map = new PortletSessionMap(req);
Object ret = map.remove("dummyKey");
assertEquals("dummyValue", ret);
}
-
+
public void testEntrySet() {
Mock mockSession = mock(PortletSession.class);
Mock mockRequest = mock(PortletRequest.class);
-
+
PortletRequest req = (PortletRequest)mockRequest.proxy();
PortletSession session = (PortletSession)mockSession.proxy();
-
+
Enumeration names = new Enumeration() {
List keys = Arrays.asList(new Object[]{"key1", "key2"});
Iterator it = keys.iterator();
-
+
public boolean hasMoreElements() {
return it.hasNext();
}
@@ -128,18 +131,18 @@
public Object nextElement() {
return it.next();
}
-
+
};
-
+
mockSession.stubs().method("getAttributeNames").will(returnValue(names));
mockSession.stubs().method("getAttribute").with(eq("key1")).will(returnValue("value1"));
mockSession.stubs().method("getAttribute").with(eq("key2")).will(returnValue("value2"));
-
+
mockRequest.expects(once()).method("getPortletSession").will(returnValue(session));
-
+
PortletSessionMap map = new PortletSessionMap(req);
Set entries = map.entrySet();
-
+
assertEquals(2, entries.size());
Iterator it = entries.iterator();
Map.Entry entry = (Map.Entry)it.next();
@@ -148,7 +151,7 @@
entry = (Map.Entry)it.next();
assertEquals("key1", entry.getKey());
assertEquals("value1", entry.getValue());
-
+
}
-
+
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/context/PortletActionContextTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/context/PortletActionContextTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/context/PortletActionContextTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/context/PortletActionContextTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * 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
*
- * Licensed 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
*
- * 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.
+ * 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.struts2.portlet.context;
@@ -37,23 +40,23 @@
/**
*/
public class PortletActionContextTest extends MockObjectTestCase {
-
+
Mock mockRenderRequest;
Mock mockRenderResponse;
Mock mockPortletConfig;
Mock mockActionRequest;
Mock mockActionResponse;
-
+
RenderRequest renderRequest;
RenderResponse renderResponse;
-
+
ActionRequest actionRequest;
ActionResponse actionResponse;
-
+
PortletConfig portletConfig;
-
+
Map context = new HashMap();
-
+
public void setUp() throws Exception {
super.setUp();
mockRenderRequest = mock(RenderRequest.class);
@@ -61,42 +64,42 @@
mockActionRequest = mock(ActionRequest.class);
mockActionResponse = mock(ActionResponse.class);
mockPortletConfig = mock(PortletConfig.class);
-
+
renderRequest = (RenderRequest)mockRenderRequest.proxy();
renderResponse = (RenderResponse)mockRenderResponse.proxy();
actionRequest = (ActionRequest)mockActionRequest.proxy();
actionResponse = (ActionResponse)mockActionResponse.proxy();
portletConfig = (PortletConfig)mockPortletConfig.proxy();
-
-
+
+
ActionContext.setContext(new ActionContext(context));
}
-
+
public void testGetPhase() {
context.put(PortletActionConstants.PHASE, PortletActionConstants.RENDER_PHASE);
-
+
assertEquals(PortletActionConstants.RENDER_PHASE, PortletActionContext.getPhase());
}
-
+
public void testIsRender() {
context.put(PortletActionConstants.PHASE, PortletActionConstants.RENDER_PHASE);
-
+
assertTrue(PortletActionContext.isRender());
assertFalse(PortletActionContext.isEvent());
}
-
+
public void testIsEvent() {
context.put(PortletActionConstants.PHASE, PortletActionConstants.EVENT_PHASE);
-
+
assertTrue(PortletActionContext.isEvent());
assertFalse(PortletActionContext.isRender());
}
-
+
public void testGetPortletConfig() {
context.put(PortletActionConstants.PORTLET_CONFIG, portletConfig);
assertSame(portletConfig, PortletActionContext.getPortletConfig());
}
-
+
public void testGetRenderRequestAndResponse() {
context.put(PortletActionConstants.REQUEST, renderRequest);
context.put(PortletActionConstants.RESPONSE, renderResponse);
@@ -106,7 +109,7 @@
assertSame(renderRequest, PortletActionContext.getRequest());
assertSame(renderResponse, PortletActionContext.getResponse());
}
-
+
public void testGetRenderRequestAndResponseInEventPhase() {
context.put(PortletActionConstants.REQUEST, renderRequest);
context.put(PortletActionConstants.RESPONSE, renderResponse);
@@ -126,7 +129,7 @@
assertTrue(true);
}
}
-
+
public void testGetActionRequestAndResponse() {
context.put(PortletActionConstants.REQUEST, actionRequest);
context.put(PortletActionConstants.RESPONSE, actionResponse);
@@ -136,7 +139,7 @@
assertSame(actionRequest, PortletActionContext.getRequest());
assertSame(actionResponse, PortletActionContext.getResponse());
}
-
+
public void testGetActionRequestAndResponseInRenderPhase() {
context.put(PortletActionConstants.REQUEST, actionRequest);
context.put(PortletActionConstants.RESPONSE, actionResponse);
@@ -156,22 +159,22 @@
assertTrue(true);
}
}
-
+
public void testGetNamespace() {
context.put(PortletActionConstants.PORTLET_NAMESPACE, "testNamespace");
assertEquals("testNamespace", PortletActionContext.getPortletNamespace());
}
-
+
public void testGetDefaultActionForMode() {
context.put(PortletActionConstants.DEFAULT_ACTION_FOR_MODE, "testAction");
assertEquals("testAction", PortletActionContext.getDefaultActionForMode());
}
-
+
public void tearDown() throws Exception {
ActionContext.setContext(null);
super.tearDown();
}
-
+
public static void main(String[] args) {
TestRunner.run(PortletActionContextTest.class);
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/context/PreparatorServletTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/context/PreparatorServletTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/context/PreparatorServletTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/context/PreparatorServletTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * 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
*
- * Licensed 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
*
- * 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.
+ * 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.struts2.portlet.context;
@@ -27,9 +30,9 @@
import org.easymock.MockControl;
/**
- *
+ *
* Test for the {@link PreparatorServletTest}
- *
+ *
*/
public class PreparatorServletTest extends StrutsTestCase {
@@ -42,22 +45,22 @@
MockControl mockResponse = MockControl.createNiceControl(HttpServletResponse.class);
MockControl mockContext = MockControl.createNiceControl(ServletContext.class);
MockControl mockConfig = MockControl.createNiceControl(ServletConfig.class);
-
+
HttpServletRequest req = (HttpServletRequest)mockRequest.getMock();
HttpServletResponse res = (HttpServletResponse)mockResponse.getMock();
ServletContext context = (ServletContext)mockContext.getMock();
ServletConfig config = (ServletConfig)mockConfig.getMock();
-
+
mockConfig.expectAndDefaultReturn(config.getServletContext(), context);
mockConfig.replay();
-
+
PreparatorServlet servlet = new PreparatorServlet();
servlet.init(config);
servlet.service(req, res);
assertSame(req, ServletActionContext.getRequest());
assertSame(res, ServletActionContext.getResponse());
assertSame(context, ServletActionContext.getServletContext());
-
+
mockConfig.verify();
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/context/ServletContextHolderListenerTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/context/ServletContextHolderListenerTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/context/ServletContextHolderListenerTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/context/ServletContextHolderListenerTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * 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
*
- * Licensed 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
*
- * 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.
+ * 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.struts2.portlet.context;
@@ -35,7 +38,7 @@
ServletContextHolderListener listener = new ServletContextHolderListener();
listener.contextInitialized(event);
assertSame(ServletContextHolderListener.getServletContext(), context);
-
+
listener.contextDestroyed(event);
assertNull(ServletContextHolderListener.getServletContext());
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * 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
*
- * Licensed 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
*
- * 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.
+ * 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.struts2.portlet.dispatcher;
@@ -54,10 +57,10 @@
/**
* Jsr168DispatcherTest. Insert description.
- *
+ *
*/
public class Jsr168DispatcherTest extends MockObjectTestCase implements PortletActionConstants {
-
+
Jsr168Dispatcher dispatcher = null;
Mock mockConfig = null;
Mock mockCtx = null;
@@ -67,11 +70,11 @@
Mock mockActionProxy = null;
Mock mockAction = null;
Mock mockInvocation = null;
-
+
public void setUp() {
dispatcher = new Jsr168Dispatcher();
}
-
+
private void initPortletConfig(final Map initParams, final Map attributes) {
mockConfig = mock(PortletConfig.class);
mockCtx = mock(PortletContext.class);
@@ -82,7 +85,7 @@
mockConfig.stubs().method("getPortletContext").will(returnValue(mockCtx.proxy()));
mockCtx.stubs().method("getInitParameterNames").will(returnValue(Collections.enumeration(initParams.keySet())));
setupStub(initParams, mockCtx, "getInitParameter");
-
+
mockConfig.stubs().method("getResourceBundle").will(returnValue(new ListResourceBundle() {
protected Object[][] getContents() {
return new String[][]{{"javax.portlet.title", "MyTitle"}};
@@ -97,13 +100,13 @@
mockAction = mock(Action.class);
mockActionProxy = mock(ActionProxy.class);
mockInvocation = mock(ActionInvocation.class);
-
+
mockActionFactory.expects(once()).method("createActionProxy").with(new Constraint[]{isA(Configuration.class), eq(namespace), eq(actionName), isA(Map.class)}).will(returnValue(mockActionProxy.proxy()));
mockActionProxy.stubs().method("getAction").will(returnValue(mockAction.proxy()));
mockActionProxy.expects(once()).method("execute").will(returnValue(result));
mockActionProxy.expects(once()).method("getInvocation").will(returnValue(mockInvocation.proxy()));
mockInvocation.stubs().method("getStack").will(returnValue(stack));
-
+
}
public void testRender_ok() {
@@ -119,11 +122,11 @@
requestParams.put(PortletActionConstants.ACTION_PARAM, new String[]{"/view/testAction"});
requestParams.put(EVENT_ACTION, new String[]{"true"});
requestParams.put(PortletActionConstants.MODE_PARAM, new String[]{mode.toString()});
-
+
Map sessionMap = new HashMap();
-
-
-
+
+
+
Map initParams = new HashMap();
initParams.put("viewNamespace", "/view");
@@ -153,11 +156,11 @@
PortletMode mode = PortletMode.VIEW;
Map initParams = new HashMap();
initParams.put("viewNamespace", "/view");
-
+
Map requestParams = new HashMap();
requestParams.put(PortletActionConstants.ACTION_PARAM, new String[]{"/view/testAction"});
requestParams.put(PortletActionConstants.MODE_PARAM, new String[]{mode.toString()});
-
+
initPortletConfig(initParams, new HashMap());
initRequest(requestParams, new HashMap(), new HashMap(), new HashMap(), PortletMode.VIEW, WindowState.NORMAL, true, null);
setupActionFactory("/view", "testAction", "success", ValueStackFactory.getFactory().createValueStack());
@@ -184,7 +187,7 @@
fail("Error occured");
}
}
-
+
/**
* Initialize the mock request (and as a result, the mock session)
* @param requestParams The request parameters
@@ -197,28 +200,28 @@
* @param locale The locale. If <code>null</code>, the request will return <code>Locale.getDefault()</code>
*/
private void initRequest(Map requestParams, Map requestAttributes, Map sessionParams, Map renderParams, PortletMode mode, WindowState state, boolean isEvent, Locale locale) {
- mockRequest = isEvent ? mock(ActionRequest.class) : mock(RenderRequest.class);
- mockSession = mock(PortletSession.class);
- mockSession.stubs().method(ANYTHING);
- mockRequest.stubs().method(ANYTHING);
- setupStub(sessionParams, mockSession, "getAttribute");
- mockSession.stubs().method("getAttributeNames").will(returnValue(Collections.enumeration(sessionParams.keySet())));
- setupParamStub(requestParams, mockRequest, "getParameter");
- setupStub(requestAttributes, mockRequest, "getAttribute");
- mockRequest.stubs().method("getAttributeNames").will(returnValue(Collections.enumeration(requestAttributes.keySet())));
- mockRequest.stubs().method("getParameterMap").will(returnValue(requestParams));
- mockRequest.stubs().method("getParameterNames").will(returnValue(Collections.enumeration(requestParams.keySet())));
- mockRequest.stubs().method("getPortletSession").will(returnValue(mockSession.proxy()));
- if(locale != null) {
- mockRequest.stubs().method("getLocale").will(returnValue(locale));
- }
- else {
- mockRequest.stubs().method("getLocale").will(returnValue(Locale.getDefault()));
- }
- mockRequest.stubs().method("getPortletMode").will(returnValue(mode));
- mockRequest.stubs().method("getWindowState").will(returnValue(state));
+ mockRequest = isEvent ? mock(ActionRequest.class) : mock(RenderRequest.class);
+ mockSession = mock(PortletSession.class);
+ mockSession.stubs().method(ANYTHING);
+ mockRequest.stubs().method(ANYTHING);
+ setupStub(sessionParams, mockSession, "getAttribute");
+ mockSession.stubs().method("getAttributeNames").will(returnValue(Collections.enumeration(sessionParams.keySet())));
+ setupParamStub(requestParams, mockRequest, "getParameter");
+ setupStub(requestAttributes, mockRequest, "getAttribute");
+ mockRequest.stubs().method("getAttributeNames").will(returnValue(Collections.enumeration(requestAttributes.keySet())));
+ mockRequest.stubs().method("getParameterMap").will(returnValue(requestParams));
+ mockRequest.stubs().method("getParameterNames").will(returnValue(Collections.enumeration(requestParams.keySet())));
+ mockRequest.stubs().method("getPortletSession").will(returnValue(mockSession.proxy()));
+ if(locale != null) {
+ mockRequest.stubs().method("getLocale").will(returnValue(locale));
+ }
+ else {
+ mockRequest.stubs().method("getLocale").will(returnValue(Locale.getDefault()));
+ }
+ mockRequest.stubs().method("getPortletMode").will(returnValue(mode));
+ mockRequest.stubs().method("getWindowState").will(returnValue(state));
}
-
+
/**
* @param requestParams
* @param mockRequest2
@@ -233,26 +236,26 @@
newMap.put(key, val[0]);
}
setupStub(newMap, mockRequest, method);
-
+
}
/**
* Set up stubs for the mock.
- * @param map The map containing the <code>key</code> and <code>values</code>. The key is the
+ * @param map The map containing the <code>key</code> and <code>values</code>. The key is the
* expected parameter to <code>method</code>, and value is the value that should be returned from
* the stub.
* @param mock The mock to initialize.
* @param method The name of the method to stub.
*/
private void setupStub(Map map, Mock mock, String method) {
- Iterator it = map.keySet().iterator();
- while(it.hasNext()) {
- Object key = it.next();
- Object val = map.get(key);
- mock.stubs().method(method).with(eq(key)).will(returnValue(val));
- }
+ Iterator it = map.keySet().iterator();
+ while(it.hasNext()) {
+ Object key = it.next();
+ Object val = map.get(key);
+ mock.stubs().method(method).with(eq(key)).will(returnValue(val));
+ }
}
-
+
public void testModeChangeUsingPortletWidgets() {
final Mock mockResponse = mock(RenderResponse.class);
mockResponse.stubs().method(ANYTHING);
@@ -262,9 +265,9 @@
requestParams.put(PortletActionConstants.ACTION_PARAM, new String[]{"/view/testAction"});
requestParams.put(EVENT_ACTION, new String[]{"false"});
requestParams.put(PortletActionConstants.MODE_PARAM, new String[]{PortletMode.VIEW.toString()});
-
+
Map sessionMap = new HashMap();
-
+
Map initParams = new HashMap();
initParams.put("viewNamespace", "/view");
initParams.put("editNamespace", "/edit");
@@ -288,9 +291,9 @@
fail("Error occured");
}
}
-
+
public static void main(String[] args) {
- TestRunner.run(Jsr168DispatcherTest.class);
+ TestRunner.run(Jsr168DispatcherTest.class);
}
}