Commits

Anonymous committed 7d165ac

- some test cleanup
- Unchainable interface causes objects not to be copied in the chaining interceptor
- made DefaultTextProvider implement Unchainable

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@406e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (7)

src/java/com/opensymphony/xwork/DefaultTextProvider.java

  *
  * @author Jason Carreira <jcarreira@gmail.com>
  */
-public class DefaultTextProvider implements TextProvider, Serializable {
+public class DefaultTextProvider implements TextProvider, Serializable, Unchainable {
 
     public static final DefaultTextProvider INSTANCE = new DefaultTextProvider();
 

src/java/com/opensymphony/xwork/Unchainable.java

+package com.opensymphony.xwork;
+
+public interface Unchainable {
+}

src/java/com/opensymphony/xwork/interceptor/ChainingInterceptor.java

 package com.opensymphony.xwork.interceptor;
 
 import com.opensymphony.xwork.ActionInvocation;
+import com.opensymphony.xwork.Unchainable;
 import com.opensymphony.xwork.util.CompoundRoot;
 import com.opensymphony.xwork.util.OgnlUtil;
 import com.opensymphony.xwork.util.OgnlValueStack;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
+import java.util.*;
 
 
 /**
             list.remove(0);
             Collections.reverse(list);
 
+            Map ctxMap = invocation.getInvocationContext().getContextMap();
             Iterator iterator = list.iterator();
-
             while (iterator.hasNext()) {
                 Object o = iterator.next();
-                OgnlUtil.copy(o, invocation.getAction(), invocation.getInvocationContext().getContextMap());
+                if (!(o instanceof Unchainable)) {
+                    OgnlUtil.copy(o, invocation.getAction(), ctxMap);
+                }
             }
         }
     }

src/java/com/opensymphony/xwork/util/LocalizedTextUtil.java

 public class LocalizedTextUtil {
     //~ Static fields/initializers /////////////////////////////////////////////
 
-    private static final List DEFAULT_RESOURCE_BUNDLES = Collections.synchronizedList(new ArrayList());
+    private static List DEFAULT_RESOURCE_BUNDLES = null;
     private static final Log LOG = LogFactory.getLog(LocalizedTextUtil.class);
     private static boolean reloadBundles = false;
     private static Collection misses = new HashSet();
 
     static {
-        DEFAULT_RESOURCE_BUNDLES.add("com/opensymphony/xwork/xwork-messages");
+        clearDefaultResourceBundles();
     }
 
     //~ Methods ////////////////////////////////////////////////////////////////
 
+    public static void clearDefaultResourceBundles() {
+        DEFAULT_RESOURCE_BUNDLES = Collections.synchronizedList(new ArrayList());
+        DEFAULT_RESOURCE_BUNDLES.add("com/opensymphony/xwork/xwork-messages");
+    }
+
     public static void setReloadBundles(boolean reloadBundles) {
         LocalizedTextUtil.reloadBundles = reloadBundles;
     }

src/test/com/opensymphony/xwork/ActionContextTest.java

 
 /**
  * ActionContextTest
+ *
  * @author Jason Carreira
- * Created Feb 26, 2003 11:22:50 PM
+ *         Created Feb 26, 2003 11:22:50 PM
  */
 public class ActionContextTest extends TestCase {
     //~ Static fields/initializers /////////////////////////////////////////////
         OgnlValueStack valueStack = context.getValueStack();
         String actionErrorMessage = (String) valueStack.findValue("getText('xwork.error.action.execution')");
         assertNotNull(actionErrorMessage);
-        assertEquals("Error during Action invocation",actionErrorMessage);
+        assertEquals("Error during Action invocation", actionErrorMessage);
     }
 }

src/test/com/opensymphony/xwork/interceptor/ChainingInterceptorTest.java

         mockInvocation = new Mock(ActionInvocation.class);
         mockInvocation.expectAndReturn("getStack", stack);
         mockInvocation.expectAndReturn("invoke", Action.SUCCESS);
-        mockInvocation.matchAndReturn("getInvocationContext", new ActionContext(new HashMap()));
+        mockInvocation.expectAndReturn("getInvocationContext", new ActionContext(new HashMap()));
         invocation = (ActionInvocation) mockInvocation.proxy();
         interceptor = new ChainingInterceptor();
     }

src/test/com/opensymphony/xwork/util/LocalizedTextUtilTest.java

         ActionContext.setContext(new ActionContext(stack.getContext()));
         ActionContext.getContext().setLocale(Locale.US);
     }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+
+        LocalizedTextUtil.clearDefaultResourceBundles();
+    }
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.