hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahue...@apache.org
Subject svn commit: r439316 - in /hivemind/branches/branch-2-0-annot/xml/src: java/org/apache/hivemind/impl/ java/org/apache/hivemind/parse/ java/org/apache/hivemind/schema/ java/org/apache/hivemind/schema/impl/ java/org/apache/hivemind/schema/rules/ test/hive...
Date Fri, 01 Sep 2006 13:35:40 GMT
Author: ahuegen
Date: Fri Sep  1 06:35:38 2006
New Revision: 439316

URL: http://svn.apache.org/viewvc?rev=439316&view=rev
Log:
Reintroduced support for key-attribute. 

Modified:
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaElement.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaProcessorImpl.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/parse/DescriptorParser.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/parse/DescriptorParser.properties
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/ElementModel.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/Schema.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/SchemaProcessor.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/impl/ElementModelImpl.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/impl/SchemaImpl.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/rules/InvokeParentRule.java
    hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/rules/TestInvokeParentRule.java
    hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestSchemaProcessor.java

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaElement.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaElement.java?rev=439316&r1=439315&r2=439316&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaElement.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaElement.java
Fri Sep  1 06:35:38 2006
@@ -272,4 +272,9 @@
         return (String) _attributeDefaults.get(attributeName);
     }
 
+    public ElementModel getModel()
+    {
+        return _model;
+    }
+
 }

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaProcessorImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaProcessorImpl.java?rev=439316&r1=439315&r2=439316&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaProcessorImpl.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaProcessorImpl.java
Fri Sep  1 06:35:38 2006
@@ -53,6 +53,8 @@
      */
     private Map _elementMap = new HashMap();
 
+    private boolean _canElementsBeMapped;
+
     /**
      * Used to track the nesting of elements.
      */
@@ -74,9 +76,55 @@
                 _elementMap.put(model.getElementName(), new SchemaElement(this, model));
             }
 
+            // That is for backward compatibility only, key-attribute is deprecated
+            _canElementsBeMapped = schema.canInstancesBeKeyed();
         }
     }
 
+    private Element peekElement()
+    {
+        return (Element) _elementStack.get(_elementStack.size() - 1);
+    }
+    
+    /**
+     * Invoked over reflection by the {@link org.apache.hivemind.schema.rules.InvokeParentRule}.
+     * Only if {@link #isInBackwardCompatibilityModeForMaps()} returns true.
+     * Places the element in the map which is expected to be the first object in the stack.
+     */
+    public void addKeyedElement(Object element)
+    {
+        if (_canElementsBeMapped)
+        {
+            Element currentElement = peekElement();
+            String keyAttribute = _activeElement.getModel().getKeyAttribute();
+
+            String expandedKey = getContributingModule().expandSymbols(
+                    currentElement.getAttributeValue(keyAttribute),
+                    currentElement.getLocation());
+
+            Translator t = getAttributeTranslator(keyAttribute);
+
+            Object finalValue = t.translate(
+                    getContributingModule(),
+                    Object.class,
+                    expandedKey,
+                    currentElement.getLocation());
+            
+            // SchemaProcessorImpl ensures that the root container is a Map
+            Map container = (Map) _stack.get(0);
+            container.put(finalValue, element);
+
+        }
+    }
+    
+    /**
+     * @see org.apache.hivemind.schema.SchemaProcessor#isInBackwardCompatibilityModeForMaps()
+     */
+    public boolean isInBackwardCompatibilityModeForMaps()
+    {
+        return _canElementsBeMapped;
+    }
+    
     public void push(Object object)
     {
         _stack.add(object);
@@ -154,7 +202,7 @@
 
     /**
      * Processes a single extension.
-     * @param container  the configuration container in that the contribution is placed
+     * @param container  the container object in that the parsed elements are placed
      */
     public void process(Object container, List elements, Module contributingModule,
             TranslatorManager translatorManager)

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java?rev=439316&r1=439315&r2=439316&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java
Fri Sep  1 06:35:38 2006
@@ -264,6 +264,11 @@
             // If schema is embedded we can process it now, otherwise it must
             // be resolved and processed later
             if (cpd.getContributionsSchema() != null) {
+                // TODO: compare container class name and rootElementClassName
+                if (HashMap.class.getName().equals(cpd.getContributionsSchema().getRootElementClassName()))
{
+                    configurationPoint.setContainerClassName(Map.class.getName());
+                }
+
                 constructor.setContainerClassName(cpd.getContributionsSchema().getRootElementClassName());
                 xmlNature.setSchema(cpd.getContributionsSchema());
             }
@@ -350,6 +355,10 @@
                     // TODO: check if schema has already been set (by resolveSubsequentSchemaAssociations)
                     xmlNature.setSchema(schema);
                     XmlConfigurationConstructor constructor = (XmlConfigurationConstructor)
point.getConstructor();
+
+                    if (HashMap.class.getName().equals(schema.getRootElementClassName()))
{
+                        point.setContainerClassName(Map.class.getName());
+                    }
                     // store the root-element-classname in the constructor
                     constructor.setContainerClassName(schema.getRootElementClassName());
                 }

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/parse/DescriptorParser.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/parse/DescriptorParser.java?rev=439316&r1=439315&r2=439316&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/parse/DescriptorParser.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/parse/DescriptorParser.java
Fri Sep  1 06:35:38 2006
@@ -17,7 +17,6 @@
 import java.io.BufferedInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -699,6 +698,16 @@
         SchemaImpl schema = (SchemaImpl) peekObject();
 
         schema.setAnnotation(peekContent());
+        
+        try
+        {
+            schema.validateKeyAttributes();
+        }
+        catch (ApplicationRuntimeException e)
+        {
+            _errorHandler.error(LOG, ParseMessages.invalidElementKeyAttribute(schema.getId(),
e), e
+                    .getLocation(), e);
+        }
 
     }
 
@@ -873,6 +882,7 @@
 
         result.setElementName(getAttribute("name"));
         result.setContentTranslator(getAttribute("content-translator"));
+        result.setKeyAttribute(getAttribute("key-attribute"));
 
         return result;
     }
@@ -903,16 +913,17 @@
     private void processRootElementClassName(SchemaImpl schema)
     {
         // Get the type of the root element
-        // For backward compatibility, ArrayList is the default
-        String rootElementClassName = getAttribute("root-element-class", ArrayList.class.getName());
+        String rootElementClassName = getAttribute("root-element-class");
 
         // Qualify the interface name with the defined package name (which will
         // often implicitly or explicitly match the module id).
 
-        String fullRootElementClassName = IdUtils.qualify(
-                _moduleDescriptor.getPackageName(),
-                rootElementClassName);
-        schema.setRootElementClassName(fullRootElementClassName);
+        if (rootElementClassName != null) {
+            String fullRootElementClassName = IdUtils.qualify(
+                    _moduleDescriptor.getPackageName(),
+                    rootElementClassName);
+            schema.setRootElementClassName(fullRootElementClassName);
+        }
     }
 
     private void enterParametersSchema(String elementName)

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/parse/DescriptorParser.properties
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/parse/DescriptorParser.properties?rev=439316&r1=439315&r2=439316&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/parse/DescriptorParser.properties
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/parse/DescriptorParser.properties
Fri Sep  1 06:35:38 2006
@@ -43,6 +43,7 @@
 required.interceptor.service-id=true
 
 required.element.name=true
+required.element.key-attribute=false
 required.element.content-translator=false
 
 required.attribute.name=true

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/ElementModel.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/ElementModel.java?rev=439316&r1=439315&r2=439316&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/ElementModel.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/ElementModel.java
Fri Sep  1 06:35:38 2006
@@ -47,6 +47,15 @@
     public List getAttributeModels();
 
     public AttributeModel getAttributeModel(String name);
+    
+    /**
+     * Returns the name of the attribute whose value can be used as a key for an instance
of an
+     * Element with this ElementModel. This key is usually used to index a configuration
+     * contribution inside a Map.
+     * 
+     * @since 1.1
+     */
+    public String getKeyAttribute();
 
     /**
      * Returns a List of {@link org.apache.hivemind.schema.Rule}. The List is unmodifiable
and

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/Schema.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/Schema.java?rev=439316&r1=439315&r2=439316&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/Schema.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/Schema.java
Fri Sep  1 06:35:38 2006
@@ -49,6 +49,15 @@
     public List getElementModel();
 
     /**
+     * Returns true if Elements conforming to this Schema can be indexed using a key. For
this to be
+     * true every {@link #getElementModel() top-level ElementModel} must define a non-null
+     * {@link ElementModel#getKeyAttribute() key attribute}.
+     * 
+     * @since 1.1
+     */
+    public boolean canInstancesBeKeyed();
+
+    /**
      * Returns true if the schema is visible to the specified module, false otherwise.
      * 
      * @since 1.1

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/SchemaProcessor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/SchemaProcessor.java?rev=439316&r1=439315&r2=439316&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/SchemaProcessor.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/SchemaProcessor.java
Fri Sep  1 06:35:38 2006
@@ -96,4 +96,11 @@
      */
 
     public Translator getTranslator(String translator);
+    
+    /**
+     * @return true  if the key-attribute attribute is used in all top level elements of
the schema.
+     *               The elements are placed in a map to maintain backward compatibility

+     */
+    public boolean isInBackwardCompatibilityModeForMaps();
+
 }

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/impl/ElementModelImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/impl/ElementModelImpl.java?rev=439316&r1=439315&r2=439316&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/impl/ElementModelImpl.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/impl/ElementModelImpl.java
Fri Sep  1 06:35:38 2006
@@ -41,6 +41,8 @@
     private List _shareableRules;
 
     private String _contentTranslator;
+    
+    private String _keyAttribute;
 
     public ElementModelImpl(String moduleId)
     {
@@ -117,6 +119,16 @@
     public void setContentTranslator(String string)
     {
         _contentTranslator = string;
+    }
+
+    public String getKeyAttribute()
+    {
+        return _keyAttribute;
+    }
+
+    public void setKeyAttribute(String keyAttribute)
+    {
+        _keyAttribute = keyAttribute;
     }
 
 }

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/impl/SchemaImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/impl/SchemaImpl.java?rev=439316&r1=439315&r2=439316&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/impl/SchemaImpl.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/impl/SchemaImpl.java
Fri Sep  1 06:35:38 2006
@@ -16,10 +16,14 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 
+import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.internal.Visibility;
 import org.apache.hivemind.parse.BaseAnnotationHolder;
+import org.apache.hivemind.schema.AttributeModel;
 import org.apache.hivemind.schema.ElementModel;
 import org.apache.hivemind.schema.Schema;
 
@@ -111,6 +115,50 @@
         return _shareableElementModels;
     }
 
+    public boolean canInstancesBeKeyed()
+    {
+        boolean emptyModel = _elementModels == null || _elementModels.isEmpty();
+
+        if (emptyModel)
+            return false;
+
+        for (Iterator i = _elementModels.iterator(); i.hasNext();)
+        {
+            ElementModel model = (ElementModel) i.next();
+
+            if (model.getKeyAttribute() == null)
+                return false;
+        }
+
+        return true;
+    }
+    
+    /**
+     * Called by the {@link org.apache.hivemind.parse.DescriptorParser} to make sure that
key
+     * attributes specified by the top-level elements actually are defined.
+     */
+    public void validateKeyAttributes()
+    {
+        if (_elementModels == null)
+            return;
+
+        for (Iterator i = _elementModels.iterator(); i.hasNext();)
+        {
+            ElementModel em = (ElementModel) i.next();
+
+            String key = em.getKeyAttribute();
+
+            if (key == null)
+                continue;
+
+            AttributeModel keyAm = em.getAttributeModel(key);
+
+            if (keyAm == null)
+                throw new ApplicationRuntimeException("Key attribute \'" + key + "\' of element
\'"
+                        + em.getElementName() + "\' never declared.", em.getLocation(), null);
+        }
+    }
+
     /**
      * @since 1.1
      */
@@ -134,7 +182,23 @@
 
     public String getRootElementClassName()
     {
+        if (_rootElementClassName == null) {
+            return getDefaultRootElementClassName();
+        }
         return _rootElementClassName;
+    }
+
+    /**
+     * @return  returns the default root element class. For backward compatibility it is
either ArrayList 
+     * or in the case of a keyed elements, a HashMap.
+     */
+    private String getDefaultRootElementClassName()
+    {
+        // if one element of the schema has defined a key-attribute, then use a map 
+        // in that case {@link InvokeParentRule} does the rest to handle element addition
correctly
+        if (canInstancesBeKeyed())
+            return HashMap.class.getName();
+        else return ArrayList.class.getName();
     }
 
     public void setRootElementClassName(String rootElementClassName)

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/rules/InvokeParentRule.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/rules/InvokeParentRule.java?rev=439316&r1=439315&r2=439316&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/rules/InvokeParentRule.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/rules/InvokeParentRule.java
Fri Sep  1 06:35:38 2006
@@ -51,24 +51,29 @@
      */
     public void begin(SchemaProcessor processor, Element element)
     {
-        // Get all parameters from the stack in the order they where pushed on it
         Object[] parameters = new Object[_parameterCount];
         Class[] parameterTypes = new Class[_parameterCount];
+        // Get all parameters from the stack in the order they where pushed on it
         for (int i = 0; i < parameters.length; i++)
         {
             parameters[i] = processor.peek(_parameterCount - i - 1);
             if (parameterTypes[i] != null)
                 parameterTypes[i] = parameters[i].getClass();
         }
-        
+
         Object parent = processor.peek(_parameterCount + _depth - 1);
-        
-        // For Backward compatiblity: If parent is a list and the method is 'addElement'
-        // then change it to add
-        if (parent instanceof List && "addElement".equals(_methodName) ) {
-            _methodName = "add"; 
+        if (processor.isInBackwardCompatibilityModeForMaps() && _parameterCount ==
1) {
+            _methodName = "addKeyedElement";
+            // We can't call the map (parent) directly, since we must calculate the key attribute
+            // value, but don't have access to its definition.
+            // Let the processor do the work. It knows the current element-model and its
attributes
+            parent = processor;
+        } else if (parent instanceof List && "addElement".equals(_methodName) ) {
+                // For Backward compatiblity: If parent is a list and the method is 'addElement'
+                // then change it to add. 
+                _methodName = "add"; 
         }
-
+        
         try
         {
             Method m = findMethod(parent, _methodName, parameterTypes);
@@ -162,4 +167,5 @@
     {
         _parameterCount = parameterCount;
     }
+
 }

Modified: hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/rules/TestInvokeParentRule.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/rules/TestInvokeParentRule.java?rev=439316&r1=439315&r2=439316&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/rules/TestInvokeParentRule.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/rules/TestInvokeParentRule.java
Fri Sep  1 06:35:38 2006
@@ -66,6 +66,9 @@
         proc.peek(1);
         procControl.setReturnValue(list);
 
+        proc.isInBackwardCompatibilityModeForMaps();
+        procControl.setReturnValue(false);
+        
         list.add(null);
         listControl.setReturnValue(true);
 
@@ -84,7 +87,10 @@
 
         proc.peek(1);
         procControl.setReturnValue(list);
-
+        
+        proc.isInBackwardCompatibilityModeForMaps();
+        procControl.setReturnValue(false);
+        
         replayControls();
 
         try

Modified: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestSchemaProcessor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestSchemaProcessor.java?rev=439316&r1=439315&r2=439316&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestSchemaProcessor.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestSchemaProcessor.java
Fri Sep  1 06:35:38 2006
@@ -37,7 +37,6 @@
 import org.apache.hivemind.schema.rules.CreateObjectRule;
 import org.apache.hivemind.schema.rules.InvokeParentRule;
 import org.apache.hivemind.schema.rules.NullTranslator;
-import org.apache.hivemind.schema.rules.PushAttributeRule;
 import org.apache.hivemind.schema.rules.ReadAttributeRule;
 import org.apache.hivemind.schema.rules.ReadContentRule;
 import org.apache.hivemind.test.HiveMindTestCase;
@@ -264,6 +263,7 @@
         TranslatorManager tm = (TranslatorManager) tmControl.getMock();
 
         em.setElementName("cartoon");
+        em.setKeyAttribute("name");
 
         AttributeModelImpl am = new AttributeModelImpl();
         am.setName("name");
@@ -271,11 +271,6 @@
 
         em.addAttributeModel(am);
         
-        PushAttributeRule nameRule = new PushAttributeRule();
-        nameRule.setAttributeName("name");
-
-        em.addRule(nameRule);
-        
         em.addRule(new CreateObjectRule("StringHolderImpl"));
         
         ReadContentRule rule = new ReadContentRule();
@@ -283,9 +278,7 @@
 
         em.addRule(rule);
         
-        InvokeParentRule rule2 = new InvokeParentRule("put");
-        rule2.setParameterCount(2);
-        em.addRule(rule2);
+        em.addRule(new InvokeParentRule("addElement"));
 
         SchemaImpl schema = new SchemaImpl("module");
         schema.addElementModel(em);
@@ -302,29 +295,23 @@
 
         List elements = Collections.singletonList(element);
 
-        tm.getTranslator("cartoon");
-        tmControl.setReturnValue(new NullTranslator());
-        
-        m.expandSymbols("${flintstone}", null);
-        control.setReturnValue("flintstone");
-        
         m.getModule("module");
         control.setReturnValue(m);
-
+        
         m.resolveType("StringHolderImpl");
         control.setReturnValue(StringHolderImpl.class);
-
+        
         m.expandSymbols("${fred}", null);
         control.setReturnValue("fred");
 
-        m.expandSymbols("${fred}", null);
-        control.setReturnValue("fred");
+        m.expandSymbols("${flintstone}", null);
+        control.setReturnValue("flintstone");
 
         MockControl tControl = newControl(Translator.class);
         Translator t = (Translator) tControl.getMock();
 
-//        tm.getTranslator("cartoon");
-//        tmControl.setReturnValue(t);
+        tm.getTranslator("cartoon");
+        tmControl.setReturnValue(t);
 
         Object flintstoneKey = new Object();
         t.translate(m, Object.class, "flintstone", element.getLocation());



Mime
View raw message