[jbpm-commits] JBoss JBPM SVN: r6885 - in jbpm3/branches/jbpm-3.2-soa/core/src: main/java/org/jbpm/instantiation and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sat Jan 22 04:16:50 EST 2011


Author: alex.guizar at jboss.com
Date: 2011-01-22 04:16:50 -0500 (Sat, 22 Jan 2011)
New Revision: 6885

Modified:
   jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/AbstractObjectInfo.java
   jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/JbpmTypeObjectInfo.java
   jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java
   jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/ObjectFactoryParser.java
   jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/SharedProcessClassLoaderFactory.java
   jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/JbpmConfigurationTest.java
   jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/configuration/BeanFactoryTest.java
   jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/configuration/ObjectFactoryTest.java
Log:
JBPM-3023 refine synchronized blocks in ObjectFactoryImpl to decrease likelihood of deadlock involving ProcessClassLoader

Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/AbstractObjectInfo.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/AbstractObjectInfo.java	2011-01-17 05:22:26 UTC (rev 6884)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/AbstractObjectInfo.java	2011-01-22 09:16:50 UTC (rev 6885)
@@ -27,10 +27,10 @@
 public abstract class AbstractObjectInfo implements ObjectInfo {
 
   private static final long serialVersionUID = 1L;
-  
-  String name;
-  boolean isSingleton;
 
+  private String name;
+  private boolean singleton;
+
   public AbstractObjectInfo() {
   }
 
@@ -38,34 +38,33 @@
     if (element.hasAttribute("name")) {
       name = element.getAttribute("name");
     }
-    if ("true".equalsIgnoreCase(element.getAttribute("singleton"))) {
-      isSingleton = true;
+    if (element.hasAttribute("singleton")) {
+      singleton = Boolean.valueOf(element.getAttribute("singleton")).booleanValue();
     }
   }
-  
+
   protected String getValueString(Element element) {
-    String value = null;
-    if (element.hasAttribute("value")) {
-      value = element.getAttribute("value");
-    } else {
-      value = XmlUtil.getContentText(element);
-    }
-    return value;
+    return element.hasAttribute("value") ? element.getAttribute("value")
+      : XmlUtil.getContentText(element);
   }
 
   public boolean hasName() {
-    return (name!=null);
+    return name != null;
   }
+
   public String getName() {
     return name;
   }
+
   public void setName(String name) {
     this.name = name;
   }
+
   public boolean isSingleton() {
-    return isSingleton;
+    return singleton;
   }
-  public void setSingleton(boolean isSingleton) {
-    this.isSingleton = isSingleton;
+
+  public void setSingleton(boolean singleton) {
+    this.singleton = singleton;
   }
 }

Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/JbpmTypeObjectInfo.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/JbpmTypeObjectInfo.java	2011-01-17 05:22:26 UTC (rev 6884)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/JbpmTypeObjectInfo.java	2011-01-22 09:16:50 UTC (rev 6885)
@@ -100,7 +100,7 @@
 
   public Object createObject(ObjectFactoryImpl objectFactory) {
     JbpmTypeMatcher jbpmTypeMatcher = typeMatcherObjectInfo == null ? NoTypeMatcher.INSTANCE
-      : (JbpmTypeMatcher) objectFactory.createObject(typeMatcherObjectInfo);
+      : (JbpmTypeMatcher) objectFactory.getObject(typeMatcherObjectInfo);
     return new JbpmType(jbpmTypeMatcher, converter, variableInstanceClass);
   }
 

Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java	2011-01-17 05:22:26 UTC (rev 6884)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java	2011-01-22 09:16:50 UTC (rev 6885)
@@ -21,7 +21,6 @@
  */
 package org.jbpm.configuration;
 
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -31,99 +30,98 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import org.jbpm.JbpmException;
 import org.jbpm.util.ClassLoaderUtil;
 
 public class ObjectFactoryImpl implements ObjectFactory {
 
-  private static final long serialVersionUID = 1L;
+  private static final long serialVersionUID = 2L;
 
-  private final List objectInfos;
   private final Map namedObjectInfos;
   private final Map singletons = new HashMap();
-  private final Map objects = new HashMap();
-  private final Collection objectsUnderConstruction = new HashSet();
-  private ClassLoader classLoader;
+  private transient final Map objects = new HashMap();
+  private transient final Collection objectsUnderConstruction = new HashSet();
+  private transient ClassLoader classLoader;
 
   public ObjectFactoryImpl() {
-    objectInfos = new ArrayList();
     namedObjectInfos = new HashMap();
   }
 
+  ObjectFactoryImpl(Map namedObjectInfos) {
+    this.namedObjectInfos = namedObjectInfos;
+  }
+
+  /** @deprecated creating objects by index is no longer supported */
   public ObjectFactoryImpl(Map namedObjectInfos, List objectInfos) {
     this.namedObjectInfos = namedObjectInfos;
-    this.objectInfos = objectInfos;
   }
 
   public void addObjectInfo(ObjectInfo objectInfo) {
-    if (objectInfo.hasName()) {
-      if (log.isDebugEnabled()) log.debug("adding object info: " + objectInfo.getName());
-      Object removed = namedObjectInfos.put(objectInfo.getName(), objectInfo);
-      if (removed != null) objectInfos.remove(removed);
+    if (!objectInfo.hasName()) {
+      throw new ConfigurationException(objectInfo + " has no name");
     }
-    objectInfos.add(objectInfo);
+
+    String name = objectInfo.getName();
+    if (log.isDebugEnabled()) log.debug("adding object info: " + name);
+    synchronized (namedObjectInfos) {
+      namedObjectInfos.put(name, objectInfo);
+    }
   }
 
+  private ObjectInfo getObjectInfo(String name) {
+    synchronized (namedObjectInfos) {
+      ObjectInfo objectInfo = (ObjectInfo) namedObjectInfos.get(name);
+      if (objectInfo == null) {
+        throw new ConfigurationException("no info for object '" + name + "'; defined objects: "
+          + namedObjectInfos.keySet());
+      }
+      return objectInfo;
+    }
+  }
+
   /**
-   * create a new object of the given name. Before creation starts, the non-singleton objects
-   * will be cleared from the registry. The singletons will remain in the registry.
+   * create a new object of the given name. Before creation starts, non-singleton objects will
+   * be cleared from the registry. Singletons will remain.
    */
-  public synchronized Object createObject(String name) {
-    ObjectInfo objectInfo = (ObjectInfo) namedObjectInfos.get(name);
-    if (objectInfo == null) {
-      throw new ConfigurationException("name '" + name
-        + "' is not defined in the configuration. configured names: "
-        + namedObjectInfos.keySet());
-    }
+  public Object createObject(String name) {
+    ObjectInfo objectInfo = getObjectInfo(name);
     return createObject(objectInfo);
   }
 
-  public synchronized boolean hasObject(String name) {
-    return namedObjectInfos.containsKey(name);
+  public boolean hasObject(String name) {
+    synchronized (namedObjectInfos) {
+      return namedObjectInfos.containsKey(name);
+    }
   }
 
   /**
-   * create a new object for the given index. Before creation starts, the non-singlton objects
-   * will be cleared from the registry. The singletons will remain in the registry.
+   * create a new object for the given index. Before creation starts, non-singleton objects will
+   * be cleared from the registry. Singletons will remain.
+   * 
+   * @deprecated creating objects by index is no longer supported
    */
   public Object createObject(int index) {
-    if (index < 0 || index >= objectInfos.size()) {
-      throw new ConfigurationException("index '" + index
-        + "' is not defined in the configuration.  range [0.." + (objectInfos.size() - 1) + "]");
-    }
-    return createObject((ObjectInfo) objectInfos.get(index));
+    throw new UnsupportedOperationException();
   }
 
   /**
-   * create a new object for the given {@link ObjectInfo}. Before creation starts, the
-   * non-singleton objects will be cleared from the registry. The singletons will remain in the
-   * registry.
+   * create a new object for the given {@link ObjectInfo}. Before creation starts, non-singleton
+   * objects will be cleared from the registry. Singletons will remain.
    */
   public Object createObject(ObjectInfo objectInfo) {
-    clearRegistry();
-    return getObject(objectInfo);
+    synchronized (objects) {
+      objects.clear();
+      objectsUnderConstruction.clear();
+      return getObject(objectInfo);
+    }
   }
 
-  private void clearRegistry() {
-    objects.clear();
-    objectsUnderConstruction.clear();
-  }
-
   /**
    * create an object of the given name. If the object was created before, that object is
    * returned from the registry.
    */
   Object getObject(String name) {
-    Object object = null;
-    ObjectInfo objectInfo = (ObjectInfo) namedObjectInfos.get(name);
-    if (objectInfo != null) {
-      object = getObject(objectInfo);
-    }
-    else {
-      log.warn("no info for object '" + name + "'. defined objects: "
-        + namedObjectInfos.keySet().toString());
-    }
-    return object;
+    ObjectInfo objectInfo = getObjectInfo(name);
+    return getObject(objectInfo);
   }
 
   /**
@@ -131,69 +129,36 @@
    * object is returned from the registry.
    */
   Object getObject(ObjectInfo objectInfo) {
-    Object object = null;
+    // use object name as registry key
+    String registryKey = objectInfo.hasName() ? objectInfo.getName() : null;
+    // if name is not specified, just create object without registering it
+    if (registryKey == null) return objectInfo.createObject(this);
 
-    Object registryKey = getRegistryKey(objectInfo);
-    if (isInRegistry(registryKey)) {
-      object = findInRegistry(registryKey);
-    }
-    else {
-      if (registryKey != null) {
-        if (objectsUnderConstruction.contains(registryKey)) {
-          throw new JbpmException("circular object dependency on bean '" + registryKey + "'");
-        }
-        objectsUnderConstruction.add(registryKey);
-        try {
-          object = objectInfo.createObject(this);
-        }
-        finally {
-          objectsUnderConstruction.remove(registryKey);
-        }
-        putInRegistry(objectInfo, object, registryKey);
-      }
-      else {
-        object = objectInfo.createObject(this);
-      }
-    }
-    return object;
-  }
+    // select appropriate registry based on singleton property
+    Map registry = objectInfo.isSingleton() ? singletons : objects;
+    // if object is already registered, use existing object
+    if (registry.containsKey(registryKey)) return registry.get(registryKey);
 
-  Class classForName(String className) throws ClassNotFoundException {
-    if (classLoader == null) {
-      classLoader = ClassLoaderUtil.getClassLoader();
+    // prevent circular references
+    if (objectsUnderConstruction.contains(registryKey)) {
+      throw new ConfigurationException("circular reference to object '" + registryKey + "'");
     }
-    return Class.forName(className, false, classLoader);
-  }
 
-  private Object getRegistryKey(ObjectInfo objectInfo) {
-    Object key = null;
-    if (objectInfo.hasName()) {
-      key = objectInfo.getName();
+    objectsUnderConstruction.add(registryKey);
+    try {
+      // create and register object
+      Object object = objectInfo.createObject(this);
+      registry.put(registryKey, object);
+      return object;
     }
-    return key;
-  }
-
-  private boolean isInRegistry(Object registryKey) {
-    return registryKey != null
-      && (objects.containsKey(registryKey) || singletons.containsKey(registryKey));
-  }
-
-  private void putInRegistry(ObjectInfo objectInfo, Object object, Object registryKey) {
-    if (objectInfo.isSingleton()) {
-      singletons.put(registryKey, object);
+    finally {
+      objectsUnderConstruction.remove(registryKey);
     }
-    else {
-      objects.put(registryKey, object);
-    }
   }
 
-  private Object findInRegistry(Object registryKey) {
-    Object object = null;
-    if (registryKey != null) {
-      object = objects.get(registryKey);
-      if (object == null) object = singletons.get(registryKey);
-    }
-    return object;
+  Class classForName(String className) throws ClassNotFoundException {
+    if (classLoader == null) classLoader = ClassLoaderUtil.getClassLoader();
+    return Class.forName(className, false, classLoader);
   }
 
   private static final Log log = LogFactory.getLog(ObjectFactoryImpl.class);

Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/ObjectFactoryParser.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/ObjectFactoryParser.java	2011-01-17 05:22:26 UTC (rev 6884)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/ObjectFactoryParser.java	2011-01-22 09:16:50 UTC (rev 6885)
@@ -38,9 +38,8 @@
 
   private static final long serialVersionUID = 1L;
 
-  private static final Class[] constructorParameterTypes = {
-    Element.class, ObjectFactoryParser.class
-  };
+  private static final Class[] constructorParameterTypes = { Element.class,
+    ObjectFactoryParser.class };
 
   private static final Map defaultMappings = getDefaultMappings();
 
@@ -97,9 +96,12 @@
   }
 
   public static ObjectFactoryImpl createObjectFactory(Element infosElement) {
-    ObjectFactoryImpl objectFactory = new ObjectFactoryImpl();
-    new ObjectFactoryParser().parseElements(infosElement, objectFactory);
-    return objectFactory;
+    ObjectFactoryParser parser = new ObjectFactoryParser();
+    for (Iterator iter = XmlUtil.elementIterator(infosElement); iter.hasNext();) {
+      Element infoElement = (Element) iter.next();
+      parser.parse(infoElement);
+    }
+    return new ObjectFactoryImpl(parser.namedObjectInfos);
   }
 
   public void parseElementsFromResource(String resource, ObjectFactoryImpl objectFactory) {
@@ -123,6 +125,7 @@
   }
 
   private Map mappings;
+  private final Map namedObjectInfos = new HashMap();
 
   public ObjectFactoryParser() {
     this(getDefaultMappings());
@@ -139,9 +142,9 @@
       throw new JbpmException("no ObjectInfo class specified for element: " + tagName);
     }
     try {
-      return (ObjectInfo) constructor.newInstance(new Object[] {
-        element, this
-      });
+      ObjectInfo objectInfo = (ObjectInfo) constructor.newInstance(new Object[] { element, this });
+      if (objectInfo.hasName()) addNamedObjectInfo(objectInfo.getName(), objectInfo);
+      return objectInfo;
     }
     catch (InstantiationException e) {
       throw new JbpmException("failed to instantiate " + constructor.getDeclaringClass(), e);
@@ -154,14 +157,12 @@
     }
   }
 
-  /** @deprecated */
   public void addNamedObjectInfo(String name, ObjectInfo objectInfo) {
+    namedObjectInfos.put(name, objectInfo);
   }
 
   public void addMapping(String elementName, Class objectInfoClass) {
-    if (mappings == defaultMappings) {
-      mappings = new HashMap(defaultMappings);
-    }
+    if (mappings == defaultMappings) mappings = new HashMap(defaultMappings);
     addMapping(mappings, elementName, objectInfoClass);
   }
 }

Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/SharedProcessClassLoaderFactory.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/SharedProcessClassLoaderFactory.java	2011-01-17 05:22:26 UTC (rev 6884)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/instantiation/SharedProcessClassLoaderFactory.java	2011-01-22 09:16:50 UTC (rev 6885)
@@ -33,9 +33,9 @@
 import org.jbpm.util.ClassLoaderUtil;
 
 /**
- * Factory that caches the class loaders it produces, in order to prevent duplicate class
- * loaders from eating up the permanent generation space. The cache does not prevent class
- * loaders from being discarded by the garbage collector.
+ * Factory that keeps soft references to the class loaders it produces, in order to prevent
+ * duplicate class loaders from eating up the permanent generation space. The cache does not
+ * prevent the garbage collector from discarding the class loaders.
  * 
  * @author Alejandro Guizar
  */
@@ -61,8 +61,7 @@
       // if class loader is not cached,
       if (processClassLoader == null) {
         // (re-)create class loader
-        processClassLoader = new ProcessClassLoader(parentClassLoader, processDefinition,
-          jbpmConfiguration);
+        processClassLoader = new ProcessClassLoader(parentClassLoader, processDefinition, jbpmConfiguration);
         // add class loader to cache
         putProcessClassLoader(key, processClassLoader);
       }

Modified: jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/JbpmConfigurationTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/JbpmConfigurationTest.java	2011-01-17 05:22:26 UTC (rev 6884)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/JbpmConfigurationTest.java	2011-01-22 09:16:50 UTC (rev 6885)
@@ -42,7 +42,7 @@
   }
 
   public void testSingleton() {
-    JbpmConfiguration.setDefaultObjectFactory(new ObjectFactoryImpl(null, null));
+    JbpmConfiguration.setDefaultObjectFactory(new ObjectFactoryImpl());
     JbpmConfiguration instance = JbpmConfiguration.getInstance();
     assertSame(instance, JbpmConfiguration.getInstance());
     assertSame(instance, JbpmConfiguration.getInstance());

Modified: jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/configuration/BeanFactoryTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/configuration/BeanFactoryTest.java	2011-01-17 05:22:26 UTC (rev 6884)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/configuration/BeanFactoryTest.java	2011-01-22 09:16:50 UTC (rev 6885)
@@ -22,6 +22,7 @@
 package org.jbpm.configuration;
 
 import java.util.List;
+import java.util.Map;
 
 import org.jbpm.AbstractJbpmTestCase;
 
@@ -59,16 +60,16 @@
 
   public void testBeanDefaultConstructor() {
     parse("<beans>"
-      + "  <bean class='" + MyBean.class.getName() + "' />"
+      + "  <bean name='mybean' class='" + MyBean.class.getName() + "' />"
       + "</beans>");
 
-    MyBean myBean = (MyBean) objectFactory.createObject(0);
+    MyBean myBean = (MyBean) objectFactory.createObject("mybean");
     assertNull(myBean.text);
   }
 
   public void testBeanConstructor() {
     parse("<beans>"
-      + "  <bean class='" + MyBean.class.getName() + "'>"
+      + "  <bean name='mybean' class='" + MyBean.class.getName() + "'>"
       + "    <constructor>"
       + "      <parameter class='java.lang.String'>"
       + "        <string>hello</string>"
@@ -80,7 +81,7 @@
       + "  </bean>"
       + "</beans>");
 
-    MyBean myBean = (MyBean) objectFactory.createObject(0);
+    MyBean myBean = (MyBean) objectFactory.createObject("mybean");
     assertEquals("hello", myBean.text);
     assertEquals(new Integer(6), myBean.number);
     assertFalse(myBean.isSetterUsed);
@@ -142,13 +143,13 @@
 
   public void testFieldInjection() {
     parse("<beans>"
-      + "  <bean class='" + MyBean.class.getName() + "'>"
+      + "  <bean name='mybean' class='" + MyBean.class.getName() + "'>"
       + "    <field name='text'><string>hello</string></field>"
       + "    <field name='number'><integer>6</integer></field>"
       + "  </bean>"
       + "</beans>");
 
-    MyBean myBean = (MyBean) objectFactory.createObject(0);
+    MyBean myBean = (MyBean) objectFactory.createObject("mybean");
     assertEquals("hello", myBean.text);
     assertEquals(new Integer(6), myBean.number);
     assertFalse(myBean.isSetterUsed);
@@ -156,13 +157,13 @@
 
   public void testPropertyInjection() {
     parse("<beans>"
-      + "  <bean class='" + MyBean.class.getName() + "'>"
+      + "  <bean name='mybean' class='" + MyBean.class.getName() + "'>"
       + "    <property name='text'><string>hello</string></property>"
       + "    <property name='number'><integer>6</integer></property>"
       + "  </bean>"
       + "</beans>");
 
-    MyBean myBean = (MyBean) objectFactory.createObject(0);
+    MyBean myBean = (MyBean) objectFactory.createObject("mybean");
     assertEquals("hello", myBean.text);
     assertEquals(new Integer(6), myBean.number);
     assertTrue(myBean.isSetterUsed);
@@ -212,24 +213,24 @@
       objectFactory.createObject("first");
       fail("expected exception");
     }
-    catch (RuntimeException e) {
-      assertTrue(e.getMessage().startsWith("circular object dependency"));
+    catch (ConfigurationException e) {
+      assertTrue(e.getMessage().indexOf("first") != -1);
     }
 
     try {
       objectFactory.createObject("second");
       fail("expected exception");
     }
-    catch (RuntimeException e) {
-      assertTrue(e.getMessage().startsWith("circular object dependency"));
+    catch (ConfigurationException e) {
+      assertTrue(e.getMessage().indexOf("second") != -1);
     }
 
     try {
       objectFactory.createObject("third");
       fail("expected exception");
     }
-    catch (RuntimeException e) {
-      assertTrue(e.getMessage().startsWith("circular object dependency"));
+    catch (ConfigurationException e) {
+      assertTrue(e.getMessage().indexOf("third") != -1);
     }
   }
 
@@ -238,17 +239,36 @@
 
   public void testListWithBeanRef() {
     parse("<beans>"
-      + "  <list>"
+      + "  <list name='mylist'>"
       + "    <bean name='a' class='" + A.class.getName() + "' />"
       + "    <ref bean='a' />"
       + "  </list>"
       + "</beans>");
 
-    List list = (List) objectFactory.createObject(0);
-    assertNotNull(list);
+    List list = (List) objectFactory.createObject("mylist");
     assertEquals(2, list.size());
+    assertSame(list.get(0), list.get(1));
   }
 
+  public void testMapWithBeanRef() {
+    parse("<beans>"
+      + "  <map name='mymap'>"
+      +	"    <entry>"
+      +	"      <key><string value='1st'/></key>"
+      + "      <value><bean name='a' class='" + A.class.getName() + "'/></value>"
+      + "    </entry>"
+      + "    <entry>"
+      + "      <key><string value='2nd'/></key>"
+      + "      <value><ref bean='a'/></value>"
+      + "    </entry>"
+      + "  </map>"
+      + "</beans>");
+
+    Map map = (Map) objectFactory.createObject("mymap");
+    assertEquals(2, map.size());
+    assertSame(map.get("1st"), map.get("2nd"));
+  }
+
   public static class Shape {
     String color;
     int lineSize = -1;

Modified: jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/configuration/ObjectFactoryTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/configuration/ObjectFactoryTest.java	2011-01-17 05:22:26 UTC (rev 6884)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/configuration/ObjectFactoryTest.java	2011-01-22 09:16:50 UTC (rev 6885)
@@ -35,17 +35,6 @@
     objectFactory = ObjectFactoryParser.parseXmlString(xml);
   }
 
-  public void testBean() {
-    parse(
-      "<beans>" +
-      "  <bean class='java.util.HashMap' />" +
-      "</beans>"
-    );
-    
-    HashMap m = (HashMap) objectFactory.createObject(0);
-    assertNotNull(m);
-  }
-
   public void testNamedBean() {
     parse(
       "<beans>" +
@@ -93,23 +82,6 @@
     assertSame(m1, m2);
   }
 
-  public void testMap() {
-    parse(
-      "<beans>" +
-      "  <map>" +
-      "    <entry><key><string>a</string></key><value><int>1</int></value></entry>" +
-      "    <entry><key><string>b</string></key><value><int>2</int></value></entry>" +
-      "    <entry><key><string>c</string></key><value><int>3</int></value></entry>" +
-      "  </map>" +
-      "</beans>"
-    );
-    
-    Map m = (Map) objectFactory.createObject(0);
-    assertEquals(new Integer(1), m.get("a"));
-    assertEquals(new Integer(2), m.get("b"));
-    assertEquals(new Integer(3), m.get("c"));
-  }
-
   public void testNamedMap() {
     parse(
       "<beans>" +
@@ -157,23 +129,6 @@
     assertSame(m1, m2);
   }
 
-  public void testList() {
-    parse(
-      "<beans>" +
-      "  <list>" +
-      "    <string>a</string>" +
-      "    <string>b</string>" +
-      "    <string>c</string>" +
-      "  </list>" +
-      "</beans>"
-    );
-    
-    List l = (List) objectFactory.createObject(0);
-    assertEquals("a", l.get(0));
-    assertEquals("b", l.get(1));
-    assertEquals("c", l.get(2));
-  }
-
   public void testNamedList() {
     parse(
       "<beans>" +
@@ -221,16 +176,6 @@
     assertSame(l1, l2);
   }
 
-  public void testNull() {
-    parse(
-      "<beans>" +
-      "  <null />" +
-      "</beans>"
-    );
-    
-    assertNull(objectFactory.createObject(0));
-  }
-
   public void testNamedNull() {
     parse(
       "<beans>" +
@@ -241,16 +186,6 @@
     assertNull(objectFactory.createObject("mynull"));
   }
 
-  public void testString() {
-    parse(
-      "<beans>" +
-      "  <string>mytext</string>" +
-      "</beans>"
-    );
-    
-    assertEquals("mytext", objectFactory.createObject(0));
-  }
-
   public void testNamedString() {
     parse(
       "<beans>" +
@@ -261,16 +196,6 @@
     assertEquals("four", objectFactory.createObject("level"));
   }
 
-  public void testInt() {
-    parse(
-      "<beans>" +
-      "  <int>5</int>" +
-      "</beans>"
-    );
-    
-    assertEquals(new Integer(5), objectFactory.createObject(0));
-  }
-  
   public void testNamedInt() {
     parse(
       "<beans>" +
@@ -281,16 +206,6 @@
     assertEquals(new Integer(5), objectFactory.createObject("level"));
   }
 
-  public void testInteger() {
-    parse(
-      "<beans>" +
-      "  <integer>6</integer>" +
-      "</beans>"
-    );
-    
-    assertEquals(new Integer(6), objectFactory.createObject(0));
-  }
-
   public void testNamedInteger() {
     parse(
       "<beans>" +
@@ -301,16 +216,6 @@
     assertEquals(new Integer(6), objectFactory.createObject("level"));
   }
 
-  public void testLong() {
-    parse(
-      "<beans>" +
-      "  <long>7</long>" +
-      "</beans>"
-    );
-    
-    assertEquals(new Long(7), objectFactory.createObject(0));
-  }
-
   public void testNamedLong() {
     parse(
       "<beans>" +
@@ -321,16 +226,6 @@
     assertEquals(new Long(7), objectFactory.createObject("level"));
   }
 
-  public void testFloat() {
-    parse(
-      "<beans>" +
-      "  <float>7.7</float>" +
-      "</beans>"
-    );
-    
-    assertEquals(new Float(7.7), objectFactory.createObject(0));
-  }
-
   public void testNamedFloat() {
     parse(
       "<beans>" +
@@ -341,16 +236,6 @@
     assertEquals(new Float(7.7), objectFactory.createObject("level"));
   }
 
-  public void testDouble() {
-    parse(
-      "<beans>" +
-      "  <double>8.8</double>" +
-      "</beans>"
-    );
-    
-    assertEquals(new Double(8.8), objectFactory.createObject(0));
-  }
-
   public void testNamedDouble() {
     parse(
       "<beans>" +
@@ -361,16 +246,6 @@
     assertEquals(new Double(8.8), objectFactory.createObject("level"));
   }
 
-  public void testChar() {
-    parse(
-      "<beans>" +
-      "  <char>a</char>" +
-      "</beans>"
-    );
-    
-    assertEquals(new Character('a'), objectFactory.createObject(0));
-  }
-  
   public void testNamedChar() {
     parse(
       "<beans>" +
@@ -381,18 +256,6 @@
     assertEquals(new Character('a'), objectFactory.createObject("level"));
   }
   
-  public void testBoolean() {
-    parse(
-      "<beans>" +
-      "  <boolean>true</boolean>" +
-      "  <boolean>false</boolean>" +
-      "</beans>"
-    );
-    
-    assertEquals(Boolean.TRUE, objectFactory.createObject(0));
-    assertEquals(Boolean.FALSE, objectFactory.createObject(1));
-  }
-
   public void testNamedBoolean() {
     parse(
       "<beans>" +
@@ -420,20 +283,4 @@
       // OK
     }
   }
-
-  public void testUndefinedIndex() {
-    parse(
-      "<beans>" +
-      "  <string>1</string>" +
-      "  <string>2</string>" +
-      "</beans>"
-    );
-    
-    try {
-      objectFactory.createObject(5);
-      fail("expected exception");
-    } catch (ConfigurationException e) {
-      // OK
-    }
-  }
 }



More information about the jbpm-commits mailing list