Commits

Anonymous committed 6d6f6ec

all the tests (again) pass in a single suite -- let's try to keep it this way ;)

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

  • Participants
  • Parent commits 3ddbb81

Comments (0)

Files changed (4)

File src/test/com/opensymphony/xwork/LocaleAwareTest.java

 
 import com.opensymphony.xwork.config.ConfigurationManager;
 import com.opensymphony.xwork.config.providers.MockConfigurationProvider;
-
+import com.opensymphony.xwork.util.OgnlValueStack;
 import junit.framework.TestCase;
 
 import java.util.Locale;
     }
 
     protected void setUp() throws Exception {
-        ConfigurationManager.clearConfigurationProviders();
+        ConfigurationManager.destroyConfiguration();
         ConfigurationManager.addConfigurationProvider(new MockConfigurationProvider());
         ConfigurationManager.getConfiguration().reload();
+
+        OgnlValueStack stack = new OgnlValueStack();
+        ActionContext.setContext(new ActionContext(stack.getContext()));
     }
 }

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

 import com.opensymphony.xwork.ActionContext;
 import com.opensymphony.xwork.XWorkMessages;
 import com.opensymphony.xwork.config.ConfigurationManager;
-
 import junit.framework.TestCase;
 
 import java.util.Locale;
 
     public void testParameterizedDefaultMessage() {
         try {
-            String message = LocalizedTextUtil.findDefaultText(XWorkMessages.MISSING_ACTION_EXCEPTION, new String[] {
-                    "AddUser"
-                });
+            String message = LocalizedTextUtil.findDefaultText(XWorkMessages.MISSING_ACTION_EXCEPTION, new String[]{
+                "AddUser"
+            });
             assertEquals("There is no Action mapped for action name AddUser", message);
         } catch (MissingResourceException e) {
             e.printStackTrace();
 
     public void testParameterizedDefaultMessageWithPackage() {
         try {
-            String message = LocalizedTextUtil.findDefaultText(XWorkMessages.MISSING_PACKAGE_ACTION_EXCEPTION, new String[] {
-                    "blah", "AddUser"
-                });
+            String message = LocalizedTextUtil.findDefaultText(XWorkMessages.MISSING_PACKAGE_ACTION_EXCEPTION, new String[]{
+                "blah", "AddUser"
+            });
             assertEquals("There is no Action mapped for namespace blah and action name AddUser", message);
         } catch (MissingResourceException e) {
             e.printStackTrace();
 
     protected void setUp() throws Exception {
         super.setUp();
-        ConfigurationManager.clearConfigurationProviders();
+        ConfigurationManager.destroyConfiguration();
         ConfigurationManager.getConfiguration().reload();
+        OgnlValueStack stack = new OgnlValueStack();
+        ActionContext.setContext(new ActionContext(stack.getContext()));
         ActionContext.getContext().setLocale(Locale.US);
     }
 }

File src/test/com/opensymphony/xwork/util/XWorkConverterTest.java

 import com.opensymphony.xwork.ActionContext;
 import com.opensymphony.xwork.ModelDrivenAction;
 import com.opensymphony.xwork.SimpleAction;
-
+import com.opensymphony.xwork.config.ConfigurationManager;
 import junit.framework.TestCase;
-
 import ognl.Ognl;
 import ognl.OgnlException;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 
 /**
 
         OgnlValueStack stack = new OgnlValueStack();
         stack.push(action);
-        ActionContext.getContext().setValueStack(stack);
-        assertNull("Conversion should have failed.", converter.convertValue(context, action, null, "date", new String[] {
-                    "invalid date"
-                }, Date.class));
+        ActionContext.setContext(new ActionContext(stack.getContext()));
+        assertNull("Conversion should have failed.", converter.convertValue(context, action, null, "date", new String[]{
+            "invalid date"
+        }, Date.class));
         stack.pop();
         assertTrue(action.hasFieldErrors());
         assertNotNull(action.getFieldErrors().get("date"));
         OgnlValueStack stack = new OgnlValueStack();
         stack.push(action);
         stack.push(action.getModel());
-        ActionContext.getContext().setValueStack(stack);
-        assertNull("Conversion should have failed.", converter.convertValue(context, action, null, "birth", new String[] {
-                    "invalid date"
-                }, Date.class));
+        ActionContext.setContext(new ActionContext(stack.getContext()));
+        assertNull("Conversion should have failed.", converter.convertValue(context, action, null, "birth", new String[]{
+            "invalid date"
+        }, Date.class));
         stack.pop();
         stack.pop();
         assertTrue(action.hasFieldErrors());
 
         OgnlValueStack stack = new OgnlValueStack();
         stack.push(action);
-        ActionContext.getContext().setValueStack(stack);
-        assertNull("Conversion should have failed.", converter.convertValue(context, action, null, "bar", new String[] {
-                    ""
-                }, Integer.class));
+        ActionContext.setContext(new ActionContext(stack.getContext()));
+        assertNull("Conversion should have failed.", converter.convertValue(context, action, null, "bar", new String[]{
+            ""
+        }, Integer.class));
         stack.pop();
         assertFalse(action.hasFieldErrors());
     }
         list.add("foo");
         list.add("bar");
         list.add("baz");
-        assertEquals(list, converter.convertValue(context, null, null, null, new String[] {
-                    "foo", "bar", "baz"
-                }, Collection.class));
+        assertEquals(list, converter.convertValue(context, null, null, null, new String[]{
+            "foo", "bar", "baz"
+        }, Collection.class));
     }
 
     public void testStringArrayToList() {
         list.add("foo");
         list.add("bar");
         list.add("baz");
-        assertEquals(list, converter.convertValue(context, null, null, null, new String[] {
-                    "foo", "bar", "baz"
-                }, List.class));
+        assertEquals(list, converter.convertValue(context, null, null, null, new String[]{
+            "foo", "bar", "baz"
+        }, List.class));
     }
 
     public void testStringArrayToPrimitiveWrappers() {
-        Long[] longs = (Long[]) converter.convertValue(context, null, null, null, new String[] {
-                "123", "456"
-            }, Long[].class);
+        Long[] longs = (Long[]) converter.convertValue(context, null, null, null, new String[]{
+            "123", "456"
+        }, Long[].class);
         assertNotNull(longs);
-        assertTrue(Arrays.equals(new Long[] {new Long(123), new Long(456)}, longs));
+        assertTrue(Arrays.equals(new Long[]{new Long(123), new Long(456)}, longs));
 
-        Integer[] ints = (Integer[]) converter.convertValue(context, null, null, null, new String[] {
-                "123", "456"
-            }, Integer[].class);
+        Integer[] ints = (Integer[]) converter.convertValue(context, null, null, null, new String[]{
+            "123", "456"
+        }, Integer[].class);
         assertNotNull(ints);
-        assertTrue(Arrays.equals(new Integer[] {
-                    new Integer(123), new Integer(456)
-                }, ints));
+        assertTrue(Arrays.equals(new Integer[]{
+            new Integer(123), new Integer(456)
+        }, ints));
 
-        Double[] doubles = (Double[]) converter.convertValue(context, null, null, null, new String[] {
-                "123", "456"
-            }, Double[].class);
+        Double[] doubles = (Double[]) converter.convertValue(context, null, null, null, new String[]{
+            "123", "456"
+        }, Double[].class);
         assertNotNull(doubles);
-        assertTrue(Arrays.equals(new Double[] {new Double(123), new Double(456)}, doubles));
+        assertTrue(Arrays.equals(new Double[]{new Double(123), new Double(456)}, doubles));
 
-        Float[] floats = (Float[]) converter.convertValue(context, null, null, null, new String[] {
-                "123", "456"
-            }, Float[].class);
+        Float[] floats = (Float[]) converter.convertValue(context, null, null, null, new String[]{
+            "123", "456"
+        }, Float[].class);
         assertNotNull(floats);
-        assertTrue(Arrays.equals(new Float[] {new Float(123), new Float(456)}, floats));
+        assertTrue(Arrays.equals(new Float[]{new Float(123), new Float(456)}, floats));
 
-        Boolean[] booleans = (Boolean[]) converter.convertValue(context, null, null, null, new String[] {
-                "true", "false"
-            }, Boolean[].class);
+        Boolean[] booleans = (Boolean[]) converter.convertValue(context, null, null, null, new String[]{
+            "true", "false"
+        }, Boolean[].class);
         assertNotNull(booleans);
-        assertTrue(Arrays.equals(new Boolean[] {Boolean.TRUE, Boolean.FALSE}, booleans));
+        assertTrue(Arrays.equals(new Boolean[]{Boolean.TRUE, Boolean.FALSE}, booleans));
     }
 
     public void testStringArrayToPrimitives() throws OgnlException {
-        long[] longs = (long[]) converter.convertValue(context, null, null, null, new String[] {
-                "123", "456"
-            }, long[].class);
+        long[] longs = (long[]) converter.convertValue(context, null, null, null, new String[]{
+            "123", "456"
+        }, long[].class);
         assertNotNull(longs);
-        assertTrue(Arrays.equals(new long[] {123, 456}, longs));
+        assertTrue(Arrays.equals(new long[]{123, 456}, longs));
 
-        int[] ints = (int[]) converter.convertValue(context, null, null, null, new String[] {
-                "123", "456"
-            }, int[].class);
+        int[] ints = (int[]) converter.convertValue(context, null, null, null, new String[]{
+            "123", "456"
+        }, int[].class);
         assertNotNull(ints);
-        assertTrue(Arrays.equals(new int[] {123, 456}, ints));
+        assertTrue(Arrays.equals(new int[]{123, 456}, ints));
 
-        double[] doubles = (double[]) converter.convertValue(context, null, null, null, new String[] {
-                "123", "456"
-            }, double[].class);
+        double[] doubles = (double[]) converter.convertValue(context, null, null, null, new String[]{
+            "123", "456"
+        }, double[].class);
         assertNotNull(doubles);
-        assertTrue(Arrays.equals(new double[] {123, 456}, doubles));
+        assertTrue(Arrays.equals(new double[]{123, 456}, doubles));
 
-        float[] floats = (float[]) converter.convertValue(context, null, null, null, new String[] {
-                "123", "456"
-            }, float[].class);
+        float[] floats = (float[]) converter.convertValue(context, null, null, null, new String[]{
+            "123", "456"
+        }, float[].class);
         assertNotNull(floats);
-        assertTrue(Arrays.equals(new float[] {123, 456}, floats));
+        assertTrue(Arrays.equals(new float[]{123, 456}, floats));
 
-        boolean[] booleans = (boolean[]) converter.convertValue(context, null, null, null, new String[] {
-                "true", "false"
-            }, boolean[].class);
+        boolean[] booleans = (boolean[]) converter.convertValue(context, null, null, null, new String[]{
+            "true", "false"
+        }, boolean[].class);
         assertNotNull(booleans);
-        assertTrue(Arrays.equals(new boolean[] {true, false}, booleans));
+        assertTrue(Arrays.equals(new boolean[]{true, false}, booleans));
     }
 
     public void testStringArrayToSet() {
         list.add("foo");
         list.add("bar");
         list.add("baz");
-        assertEquals(list, converter.convertValue(context, null, null, null, new String[] {
-                    "foo", "bar", "bar", "baz"
-                }, Set.class));
+        assertEquals(list, converter.convertValue(context, null, null, null, new String[]{
+            "foo", "bar", "bar", "baz"
+        }, Set.class));
     }
 
     public void testStringToCustomTypeUsingCustomConverter() {
 
     protected void setUp() throws Exception {
         converter = XWorkConverter.getInstance();
+        ConfigurationManager.destroyConfiguration();
+        ActionContext.setContext(null);
     }
 
     protected void tearDown() throws Exception {

File src/test/com/opensymphony/xwork/validator/SimpleActionValidationTest.java

 import com.opensymphony.xwork.ValidationAware;
 import com.opensymphony.xwork.config.ConfigurationManager;
 import com.opensymphony.xwork.config.providers.MockConfigurationProvider;
-
+import com.opensymphony.xwork.util.OgnlValueStack;
 import junit.framework.TestCase;
 
 import java.util.HashMap;
 
         try {
             ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy("", MockConfigurationProvider.VALIDATION_ACTION_NAME, extraContext);
+            OgnlValueStack stack = new OgnlValueStack();
+            ActionContext.setContext(new ActionContext(stack.getContext()));
             ActionContext.getContext().setLocale(Locale.US);
             proxy.execute();
             assertTrue(((ValidationAware) proxy.getAction()).hasFieldErrors());
     }
 
     protected void setUp() throws Exception {
-        ConfigurationManager.clearConfigurationProviders();
+        ConfigurationManager.destroyConfiguration();
         ConfigurationManager.addConfigurationProvider(new MockConfigurationProvider());
         ConfigurationManager.getConfiguration().reload();
     }