Commits

Anonymous committed 7d62b7d

Upgraded OGNL to 2.6.3 -- also fixed up statics/configuration wackiness that was causing me to not be able to run all the tests in a single Suite (a la IDEA-style).

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

  • Participants
  • Parent commits 82b9da8

Comments (0)

Files changed (12)

lib/core/ognl-2.5.1.jar

Binary file removed.

lib/core/ognl-2.6.3.jar

Binary file added.

src/java/com/opensymphony/xwork/config/ConfigurationManager.java

 package com.opensymphony.xwork.config;
 
 import com.opensymphony.util.FileManager;
-
 import com.opensymphony.xwork.config.impl.DefaultConfiguration;
 import com.opensymphony.xwork.config.providers.XmlConfigurationProvider;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
     //~ Static fields/initializers /////////////////////////////////////////////
 
     protected static final Log LOG = LogFactory.getLog(ConfigurationManager.class);
-    protected static Configuration configurationInstance = null;
-    private static List configurationProviders = Collections.synchronizedList(new ArrayList());
+    protected static Configuration configurationInstance;
+    private static List configurationProviders;
+
+    static {
+        destroyConfiguration();
+    }
 
     //~ Constructors ///////////////////////////////////////////////////////////
 
 
     //~ Methods ////////////////////////////////////////////////////////////////
 
+    public static void destroyConfiguration() {
+        configurationProviders = Collections.synchronizedList(new ArrayList());
+        configurationInstance = null;
+    }
+
     /**
-    * Get the current XWork configuration object.  By default an instance of DefaultConfiguration will be returned
-    * @see com.opensymphony.xwork.config.impl.DefaultConfiguration
-    */
+     * Get the current XWork configuration object.  By default an instance of DefaultConfiguration will be returned
+     * @see com.opensymphony.xwork.config.impl.DefaultConfiguration
+     */
     public static Configuration getConfiguration() {
         if (configurationInstance == null) {
             configurationInstance = new DefaultConfiguration();
     }
 
     /**
-    * <p>
-    * get the current list of ConfigurationProviders.
-    * </p>
-    * <p>
-    * if no custom ConfigurationProviders have been added, this method
-    * will return a list containing only the default ConfigurationProvider, XMLConfigurationProvider.  if a custom
-    * ConfigurationProvider has been added, then the XmlConfigurationProvider must be added by hand.
-    * </p>
-    * @todo the lazy instantiation of XmlConfigurationProvider should be refactored to be elsewhere.  the behavior described above seems unintuitive.
-    * @return the list of registered ConfigurationProvider objects
-    * @see com.opensymphony.xwork.config.ConfigurationProvider
-    */
+     * <p>
+     * get the current list of ConfigurationProviders.
+     * </p>
+     * <p>
+     * if no custom ConfigurationProviders have been added, this method
+     * will return a list containing only the default ConfigurationProvider, XMLConfigurationProvider.  if a custom
+     * ConfigurationProvider has been added, then the XmlConfigurationProvider must be added by hand.
+     * </p>
+     * @todo the lazy instantiation of XmlConfigurationProvider should be refactored to be elsewhere.  the behavior described above seems unintuitive.
+     * @return the list of registered ConfigurationProvider objects
+     * @see com.opensymphony.xwork.config.ConfigurationProvider
+     */
     public static List getConfigurationProviders() {
         if (configurationProviders.size() == 0) {
             configurationProviders.add(new XmlConfigurationProvider());
     }
 
     /**
-    * adds a configuration provider to the List of ConfigurationProviders.  a given ConfigurationProvider may be added
-    * more than once
-    * @todo what does it mean to have a configuration provider added more than once?  should configurationProviders be a set instead?
-    * @param provider the ConfigurationProvider to register
-    */
+     * adds a configuration provider to the List of ConfigurationProviders.  a given ConfigurationProvider may be added
+     * more than once
+     * @todo what does it mean to have a configuration provider added more than once?  should configurationProviders be a set instead?
+     * @param provider the ConfigurationProvider to register
+     */
     public static void addConfigurationProvider(ConfigurationProvider provider) {
         configurationProviders.add(provider);
     }
 
     /**
-    * clears the registered ConfigurationProviders.  this method will call destroy() on each of the registered
-    * ConfigurationProviders
-    * @see com.opensymphony.xwork.config.ConfigurationProvider#destroy
-    */
+     * clears the registered ConfigurationProviders.  this method will call destroy() on each of the registered
+     * ConfigurationProviders
+     * @see com.opensymphony.xwork.config.ConfigurationProvider#destroy
+     */
     public synchronized static void clearConfigurationProviders() {
         for (Iterator iterator = configurationProviders.iterator();
-                iterator.hasNext();) {
+             iterator.hasNext();) {
             ConfigurationProvider provider = (ConfigurationProvider) iterator.next();
             provider.destroy();
         }
     }
 
     /**
-    * reloads the Configuration files if the configuration files indicate that they need to be reloaded.
-    *
-    * @todo as FileManager.setReloadingConfigs never appears to be set anywhere, will this ever do anything?
-    * @todo it currently appears that the reload strategy is to check on each call to getConfiguration().  this seems extremely burdensome.  a caching mechanism should be implemented
-    */
+     * reloads the Configuration files if the configuration files indicate that they need to be reloaded.
+     *
+     * @todo as FileManager.setReloadingConfigs never appears to be set anywhere, will this ever do anything?
+     * @todo it currently appears that the reload strategy is to check on each call to getConfiguration().  this seems extremely burdensome.  a caching mechanism should be implemented
+     */
     private static void conditionalReload() {
         if (FileManager.isReloadingConfigs()) {
             LOG.debug("Checking ConfigurationProviders for reload.");
             boolean reload = false;
 
             for (Iterator iterator = getConfigurationProviders().iterator();
-                    iterator.hasNext();) {
+                 iterator.hasNext();) {
                 ConfigurationProvider provider = (ConfigurationProvider) iterator.next();
 
                 if (provider.needsReload()) {

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

  */
 package com.opensymphony.xwork.util;
 
-import com.opensymphony.xwork.util.CompoundRoot;
-
 import ognl.*;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import java.beans.IntrospectionException;
-
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 
 
         }
     }
 
-    public Object callMethod(Map context, Object target, String name, List list) throws MethodFailedException {
+    public Object callMethod(Map context, Object target, String name, Object[] objects) throws MethodFailedException {
         CompoundRoot root = (CompoundRoot) target;
 
         for (Iterator iterator = root.iterator(); iterator.hasNext();) {
             Object o = iterator.next();
 
             try {
-                Object value = OgnlRuntime.callMethod((OgnlContext) context, o, name, name, list);
+                Object value = OgnlRuntime.callMethod((OgnlContext) context, o, name, name, objects);
 
                 if (value != null) {
                     return value;
         return null;
     }
 
-    public Object callStaticMethod(Map transientVars, Class aClass, String s, List list) throws MethodFailedException {
+    public Object callStaticMethod(Map transientVars, Class aClass, String s, Object[] objects) throws MethodFailedException {
         return null;
     }
 

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

 package com.opensymphony.xwork.util;
 
 import ognl.Ognl;
+import ognl.OgnlContext;
 import ognl.OgnlException;
 import ognl.OgnlRuntime;
 
 import java.io.ObjectStreamException;
 import java.io.Serializable;
-
 import java.util.Map;
 
 
         this.context = Ognl.createDefaultContext(this.root, accessor, XWorkConverter.getInstance());
         context.put(VALUE_STACK, this);
         Ognl.setClassResolver(context, accessor);
+        ((OgnlContext) context).setTraceEvaluations(true);
     }
 
     private Object readResolve() throws ObjectStreamException {

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

 
 import com.opensymphony.xwork.config.ConfigurationManager;
 import com.opensymphony.xwork.config.providers.MockConfigurationProvider;
-
 import junit.framework.TestCase;
 
 
     //~ Methods ////////////////////////////////////////////////////////////////
 
     public void setUp() {
-        ConfigurationManager.clearConfigurationProviders();
+        ConfigurationManager.destroyConfiguration();
         ConfigurationManager.addConfigurationProvider(new MockConfigurationProvider());
     }
 

src/test/com/opensymphony/xwork/config/ConfigurationManagerTest.java

 
 import com.mockobjects.dynamic.C;
 import com.mockobjects.dynamic.Mock;
-
 import com.opensymphony.util.FileManager;
-
 import junit.framework.TestCase;
 
 
 
     protected void setUp() throws Exception {
         super.setUp();
-        ConfigurationManager.clearConfigurationProviders();
+        ConfigurationManager.destroyConfiguration();
+
         configProviderMock = new Mock(ConfigurationProvider.class);
 
         ConfigurationProvider mockProvider = (ConfigurationProvider) configProviderMock.proxy();
 
     protected void tearDown() throws Exception {
         super.tearDown();
-        ConfigurationManager.configurationInstance = null;
+        ConfigurationManager.destroyConfiguration();
     }
 }

src/test/com/opensymphony/xwork/config/ConfigurationTest.java

  * All rights reserved.
  */
 
-/**
- * Copyright (c) 2002 Notiva. All Rights Reserved.
- *
- * This software is the confidential and proprietary information of Notiva.
- * ("Confidential Information").  You shall not disclose such Confidential
- * Information and shall use it only in accordance with the terms of the
- * license agreement you entered into with Notiva.
- *
- * NOTIVA MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
- * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
- * PURPOSE, OR NON-INFRINGEMENT. NOTIVA SHALL NOT BE LIABLE FOR ANY DAMAGES
- * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
- * THIS SOFTWARE OR ITS DERIVATIVES.
- */
 package com.opensymphony.xwork.config;
 
-import com.opensymphony.xwork.ActionContext;
-import com.opensymphony.xwork.ActionProxy;
-import com.opensymphony.xwork.ActionProxyFactory;
-import com.opensymphony.xwork.MockInterceptor;
-import com.opensymphony.xwork.SimpleAction;
+import com.opensymphony.xwork.*;
 import com.opensymphony.xwork.config.providers.MockConfigurationProvider;
 import com.opensymphony.xwork.config.providers.XmlConfigurationProvider;
-
 import junit.framework.TestCase;
 
 import java.util.HashMap;

src/test/com/opensymphony/xwork/config/providers/ConfigurationTestBase.java

 import com.opensymphony.xwork.config.Configuration;
 import com.opensymphony.xwork.config.ConfigurationProvider;
 import com.opensymphony.xwork.config.impl.MockConfiguration;
-
 import junit.framework.TestCase;
 
 
  * @author Jason Carreira
  * Created Jun 9, 2003 7:42:12 AM
  */
-public class ConfigurationTestBase extends TestCase {
+public abstract class ConfigurationTestBase extends TestCase {
     //~ Instance fields ////////////////////////////////////////////////////////
 
     protected Configuration configuration;

src/test/com/opensymphony/xwork/config/providers/XmlConfigurationProviderInterceptorsTest.java

 public class XmlConfigurationProviderInterceptorsTest extends ConfigurationTestBase {
     //~ Methods ////////////////////////////////////////////////////////////////
 
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        ConfigurationManager.destroyConfiguration();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+
+        ConfigurationManager.destroyConfiguration();
+    }
+
     public void testBasicInterceptors() throws ConfigurationException {
         final String filename = "com/opensymphony/xwork/config/providers/xwork-test-interceptors-basic.xml";
         ConfigurationProvider provider = buildConfigurationProvider(filename);

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

 package com.opensymphony.xwork.util;
 
 import junit.framework.TestCase;
-
 import ognl.Ognl;
 
 import java.util.Calendar;
 
         foo1.setTitle("blah");
         foo1.setNumber(1);
-        foo1.setPoints(new long[] {1, 2, 3});
+        foo1.setPoints(new long[]{1, 2, 3});
         foo1.setBirthday(cal.getTime());
         foo1.setUseful(false);
 
 
         foo.setTitle("blah");
         foo.setNumber(1);
-        foo.setPoints(new long[] {1, 2, 3});
+        foo.setPoints(new long[]{1, 2, 3});
         foo.setBirthday(cal.getTime());
         foo.setUseful(false);
 
         assertEquals(foo.getBar().getTitle(), "i am barbaz");
     }
 
-    public void testSetBarAsString() {
-        Foo foo = new Foo();
-
-        Map context = Ognl.createDefaultContext(foo);
-
-        HashMap props = new HashMap();
-        props.put("bar", "bar:123");
-
-        OgnlUtil.setProperties(props, foo, context);
-
-        assertEquals("bar", foo.getBar().getTitle());
-        assertEquals(123, foo.getBar().getSomethingElse());
-    }
-
     public void testSetPropertiesBoolean() {
         Foo foo = new Foo();
 
 
         assertEquals(true, foo.isUseful());
 
-        //        props = new HashMap();
-        //        props.put("useful", "false");
-        //        OgnlUtil.setProperties(props, foo, context);
-        //
-        //        assertEquals(false, foo.isUseful());
+        props = new HashMap();
+        props.put("useful", "false");
+        OgnlUtil.setProperties(props, foo, context);
+
+        assertEquals(false, foo.isUseful());
     }
 
     public void testSetPropertiesDate() {
         Map context = Ognl.createDefaultContext(foo);
 
         HashMap props = new HashMap();
-        props.put("points", new String[] {"1", "2"});
+        props.put("points", new String[]{"1", "2"});
         OgnlUtil.setProperties(props, foo, context);
 
         assertNotNull(foo.getPoints());
         OgnlUtil.setProperties(props, foo, context);
         assertEquals(123, foo.getaLong());
 
-        props.put("aLong", new String[] {"123"});
+        props.put("aLong", new String[]{"123"});
 
         foo.setaLong(0);
         OgnlUtil.setProperties(props, foo, context);

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

 
 import junit.framework.TestCase;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
+import java.io.*;
 import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.Map;
 
 
 /**
         Dog dog = new Dog();
         dog.setAge(12);
         dog.setName("Rover");
-        dog.setChildAges(new int[] {1, 2});
+        dog.setChildAges(new int[]{1, 2});
 
         vs.push(dog);
         assertEquals("1, 2", vs.findValue("childAges", String.class));
         Dog dog = new Dog();
         dog.setAge(12);
         dog.setName("Rover");
-        dog.setChildAges(new int[] {1, 2});
+        dog.setChildAges(new int[]{1, 2});
         dog.setHates(cat);
 
         vs.push(dog);
         assertEquals(dog2, vs.pop());
         assertEquals("Rover", vs.findValue("name"));
     }
+
+    public void testSetBarAsString() {
+        Foo foo = new Foo();
+
+        OgnlValueStack vs = new OgnlValueStack();
+        vs.push(foo);
+
+        Map context = vs.getContext();
+
+        HashMap props = new HashMap();
+        props.put("bar", "bar:123");
+
+        OgnlUtil.setProperties(props, foo, context);
+
+        assertEquals("bar", foo.getBar().getTitle());
+        assertEquals(123, foo.getBar().getSomethingElse());
+    }
 }