Commits

Anonymous committed aee05b6

- make unit tests runs ok using 'ant clean test'
- removed uncessary import to make eclipse happy
- added license header
- added version tag

actually nothing much.

git-svn-id: http://svn.opensymphony.com/svn/xwork/branches/xwork_1-2/src@1329e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (5)

java/com/opensymphony/xwork/DefaultActionInvocation.java

 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
 import java.util.*;
 
 

test/com/opensymphony/xwork/ActionProxyTest.java

+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import com.opensymphony.xwork.config.Configuration;
+import com.opensymphony.xwork.config.ConfigurationException;
+import com.opensymphony.xwork.config.ConfigurationManager;
+import com.opensymphony.xwork.config.ConfigurationProvider;
+import com.opensymphony.xwork.config.entities.ActionConfig;
+import com.opensymphony.xwork.config.entities.PackageConfig;
+import com.opensymphony.xwork.config.entities.ResultConfig;
+
+import junit.framework.TestCase;
+
+/**
+ * Test for XW-465
+ * 
+ * @author tmjee
+ * @version $Date$ $Id$
+ */
+public class ActionProxyTest extends TestCase {
+	
+	public static interface ProxyAction {
+		String show() throws Exception;
+	}
+
+	public void testExecuteProxyAction() throws Exception {
+		final ProxyAction action = new ProxyAction() {
+			public String show() throws Exception {
+				return "success";
+			}
+		};
+		
+		ObjectFactory.setObjectFactory(new ObjectFactory() {
+			public Object buildAction(String actionName, String namespace, ActionConfig config, Map extraContext) throws Exception {
+				return Proxy.newProxyInstance(
+						Thread.currentThread().getContextClassLoader(), 
+						new Class[] { ProxyAction.class }, 
+						new InvocationHandler() {
+							public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+								return method.invoke(action, args);
+							}
+						});
+			}
+		});
+		
+		Map results = new LinkedHashMap();
+		results.put("success", new ResultConfig("success", "com.opensymphony.xwork.mock.MockResult"));
+		
+		ActionConfig actionConfig = new ActionConfig("show", 
+				"ProxyAction", 
+				Collections.EMPTY_MAP, 
+				results, 
+				Collections.EMPTY_LIST);
+		
+		final PackageConfig packageConfig = new PackageConfig("myPackage", "/namespace", false, null);
+		packageConfig.addActionConfig("show", actionConfig);
+		
+		
+		ConfigurationManager.addConfigurationProvider(new ConfigurationProvider() {
+			public void destroy() {}
+			public void init(Configuration configuration) throws ConfigurationException {
+				configuration.addPackageConfig("myPackage", packageConfig);
+			};
+			public boolean needsReload() { return false; }
+		});
+	
+		ActionProxy actionProxy = ActionProxyFactory.getFactory().createActionProxy("/namespace", "show", new LinkedHashMap());
+		String result = actionProxy.execute();
+		
+		assertEquals(result, "success");
+	}
+}

test/com/opensymphony/xwork/ProxyInvocationAction.java

+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
 package com.opensymphony.xwork;
 
+/**
+ * @version $Date$ $Id$
+ */
 public class ProxyInvocationAction extends ActionSupport implements ProxyInvocationInterface {
-    public String show() {
+	
+	private static final long serialVersionUID = -3336083736424831839L;
+
+	public String show() {
         return "proxyResult";
     }
 }

test/com/opensymphony/xwork/ProxyInvocationInterface.java

+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
 package com.opensymphony.xwork;
 
+/**
+ * @version $Date$ $Id$
+ */
 public interface ProxyInvocationInterface {
     public String show();
 }

test/com/opensymphony/xwork/ProxyInvocationTest.java

+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
 package com.opensymphony.xwork;
 
 import java.lang.reflect.InvocationHandler;
 
 import junit.framework.TestCase;
 
+import com.opensymphony.xwork.config.ConfigurationManager;
 import com.opensymphony.xwork.config.entities.ActionConfig;
 
 /**
  * Contribed by: Ruben Inoto
+ * @version $Date$ $Id$
  */
 public class ProxyInvocationTest extends TestCase {
 
      * Subclass of DefaultActionInvocation, to provide a visible constructor
      */
     private class TestActionInvocation extends DefaultActionInvocation {
-        protected TestActionInvocation(ActionProxy proxy) throws Exception {
+    	
+		private static final long serialVersionUID = -7015263281680465248L;
+
+		protected TestActionInvocation(ActionProxy proxy) throws Exception {
             super(proxy);
         }
 
             return bean;
         }
     }
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // ensure we're using the default configuration, not simple config
+        ConfigurationManager.clearConfigurationProviders();
+        ConfigurationManager.getConfiguration().reload();
+    }
 }