svn commit: r446875 - in /struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui: CheckboxTest.java LabelTest.java

2006-09-16 Thread tmjee
Author: tmjee
Date: Sat Sep 16 06:49:55 2006
New Revision: 446875

URL: http://svn.apache.org/viewvc?view=rev&rev=446875
Log:
WW-1349
  - fixed failing test due to refactoring (removed deprecated setLabelPosition 
method)


Modified:

struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/CheckboxTest.java

struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/LabelTest.java

Modified: 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/CheckboxTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/CheckboxTest.java?view=diff&rev=446875&r1=446874&r2=446875
==
--- 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/CheckboxTest.java
 (original)
+++ 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/CheckboxTest.java
 Sat Sep 16 06:49:55 2006
@@ -90,7 +90,7 @@
 tag.setFieldValue("baz");
 tag.setOnfocus("test();");
 tag.setTitle("mytitle");
-tag.setLabelPosition("top");
+tag.setLabelposition("top");
 
 tag.doStartTag();
 tag.doEndTag();
@@ -110,7 +110,7 @@
 tag.setFieldValue("baz");
 tag.setOnfocus("test();");
 tag.setTitle("mytitle");
-tag.setLabelPosition("left");
+tag.setLabelposition("left");
 
 tag.doStartTag();
 tag.doEndTag();

Modified: 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/LabelTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/LabelTest.java?view=diff&rev=446875&r1=446874&r2=446875
==
--- 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/LabelTest.java
 (original)
+++ 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/LabelTest.java
 Sat Sep 16 06:49:55 2006
@@ -54,7 +54,7 @@
 tag.setLabel("mylabel");
 tag.setName("myname");
 tag.setValue("%{foo}");
-tag.setLabelPosition("top");
+tag.setLabelposition("top");
 
 tag.doStartTag();
 tag.doEndTag();




svn commit: r446876 - in /struts/struts2/trunk/core/src: main/java/org/apache/struts2/dispatcher/SessionMap.java test/java/org/apache/struts2/dispatcher/SessionMapTest.java

2006-09-16 Thread tmjee
Author: tmjee
Date: Sat Sep 16 06:57:43 2006
New Revision: 446876

URL: http://svn.apache.org/viewvc?view=rev&rev=446876
Log:
WW-1448
  -  SessionAware Session map clear() method not functioning correctly


Modified:

struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java

struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/SessionMapTest.java

Modified: 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java?view=diff&rev=446876&r1=446875&r2=446876
==
--- 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java
 (original)
+++ 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java
 Sat Sep 16 06:57:43 2006
@@ -19,6 +19,7 @@
 
 import java.io.Serializable;
 import java.util.AbstractMap;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashSet;
@@ -84,14 +85,13 @@
 }
 
 synchronized (session) {
-if (entries != null ) {
-for ( Iterator iter = entries.iterator(); iter.hasNext(); ) {
-Object key = iter.next();
-session.removeAttribute(key.toString());
-}
-entries = null;
+   Enumeration attributeNamesEnum = 
session.getAttributeNames();
+String[] attributeNames = 
Collections.list(attributeNamesEnum).toArray(new String[0]);
+for (int a=0; a< attributeNames.length; a++) {
+   session.removeAttribute(attributeNames[a]);
 }
 }
+
 }
 
 /**

Modified: 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/SessionMapTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/SessionMapTest.java?view=diff&rev=446876&r1=446875&r2=446876
==
--- 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/SessionMapTest.java
 (original)
+++ 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/SessionMapTest.java
 Sat Sep 16 06:57:43 2006
@@ -17,7 +17,12 @@
  */
 package org.apache.struts2.dispatcher;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
@@ -28,6 +33,7 @@
 import com.mockobjects.constraint.Constraint;
 import com.mockobjects.constraint.IsAnything;
 import com.mockobjects.constraint.IsEqual;
+import com.mockobjects.dynamic.ConstraintMatcher;
 import com.mockobjects.dynamic.Mock;
 
 
@@ -40,8 +46,34 @@
 
 
 public void testClearInvalidatesTheSession() throws Exception {
+   List attributeNames = new ArrayList();
+   attributeNames.add("test");
+   attributeNames.add("anotherTest");
+   Enumeration attributeNamesEnum = 
Collections.enumeration(attributeNames);
+   
 MockSessionMap sessionMap = new MockSessionMap((HttpServletRequest) 
requestMock.proxy());
+sessionMock.expect("setAttribute", 
+   new Constraint[] {
+   new IsEqual("test"), new IsEqual("test value")
+   });
+sessionMock.expect("setAttribute", 
+   new Constraint[] {
+   new IsEqual("anotherTest"), new 
IsEqual("another test value")
+   });
+sessionMock.expectAndReturn("getAttributeNames", attributeNamesEnum);
+sessionMock.expect("removeAttribute", 
+   new Constraint[]{
+   new IsEqual("test")
+   });
+sessionMock.expect("removeAttribute", 
+   new Constraint[]{
+   new IsEqual("anotherTest")
+   });
+sessionMap.put("test", "test value");
+sessionMap.put("anotherTest", "another test value");
 sessionMap.clear();
+assertNull(sessionMap.get("test"));
+assertNull(sessionMap.get("anotherTest"));
 sessionMock.verify();
 }
 
@@ -149,6 +181,11 @@
 map.put(key, value); //put the value into our map after putting it 
in the superclass map to avoid polluting the get call.
 
 return originalValue;
+}
+
+public void clear() {
+   super.clear();
+   map.clear();
 }
 }
 }




svn commit: r446903 - /struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java

2006-09-16 Thread tmjee
Author: tmjee
Date: Sat Sep 16 10:33:39 2006
New Revision: 446903

URL: http://svn.apache.org/viewvc?view=rev&rev=446903
Log:
WW-1448
  - SessionAware Session map clear() method not functioning correctly
  - added statement to nullify entries member variable, such that entrySet will 
not used invalid entries after clear() is called
  - use a better way to remove session attribute in clear() method.
  


Modified:

struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java

Modified: 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java?view=diff&rev=446903&r1=446902&r2=446903
==
--- 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java
 (original)
+++ 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java
 Sat Sep 16 10:33:39 2006
@@ -85,11 +85,11 @@
 }
 
 synchronized (session) {
+   entries = null;
Enumeration attributeNamesEnum = 
session.getAttributeNames();
-String[] attributeNames = 
Collections.list(attributeNamesEnum).toArray(new String[0]);
-for (int a=0; a< attributeNames.length; a++) {
-   session.removeAttribute(attributeNames[a]);
-}
+   while(attributeNamesEnum.hasMoreElements()) {
+   
session.removeAttribute(attributeNamesEnum.nextElement());
+   }
 }
 
 }