Author: etnu
Date: Tue Dec 16 12:16:25 2008
New Revision: 727127

URL: http://svn.apache.org/viewvc?rev=727127&view=rev
Log:
Applied fix for gadget uri / container name propagation to HttpFetcher in 
DefaultGadgetSpecFactory. MessageBundleFactory is not yet updated because it 
requires changing the API signature to fix the problem.


Modified:
    
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/GadgetSpec.java
    
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/GadgetSpecTest.java

Modified: 
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/GadgetSpec.java
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/GadgetSpec.java?rev=727127&r1=727126&r2=727127&view=diff
==============================================================================
--- 
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/GadgetSpec.java
 (original)
+++ 
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/GadgetSpec.java
 Tue Dec 16 12:16:25 2008
@@ -17,21 +17,25 @@
  */
 package org.apache.shindig.gadgets.spec;
 
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
 import org.apache.shindig.common.uri.Uri;
 import org.apache.shindig.common.util.HashUtil;
 import org.apache.shindig.common.xml.XmlException;
 import org.apache.shindig.common.xml.XmlUtil;
 import org.apache.shindig.gadgets.variables.Substitutions;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import java.util.*;
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
@@ -128,6 +132,7 @@
   private GadgetSpec(GadgetSpec spec) {
     url = spec.url;
     checksum = spec.checksum;
+    attributes.putAll(spec.attributes);
   }
 
   /**
@@ -191,6 +196,13 @@
     return attributes.get(key);
   }
 
+  /**
+   * Sets an attribute on the gadget spec. This should only be done during a 
constructing phase, as
+   * a GadgetSpec should be effectively immutable after it is constructed.
+   *
+   * @param key The attribute name.
+   * @param o The value of the attribute.
+   */
   public void setAttribute(String key, Object o) {
     attributes.put(key, o);
   }

Modified: 
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/GadgetSpecTest.java
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/GadgetSpecTest.java?rev=727127&r1=727126&r2=727127&view=diff
==============================================================================
--- 
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/GadgetSpecTest.java
 (original)
+++ 
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/GadgetSpecTest.java
 Tue Dec 16 12:16:25 2008
@@ -103,8 +103,14 @@
     substituter.addSubstitution(Type.USER_PREF, "title", title);
     substituter.addSubstitution(Type.MESSAGE, "content", content);
 
-    GadgetSpec spec = new GadgetSpec(SPEC_URL, xml).substitute(substituter);
+    GadgetSpec baseSpec = new GadgetSpec(SPEC_URL, xml);
+    baseSpec.setAttribute("foo", 100);
+    baseSpec.setAttribute("bar", "baz");
+
+    GadgetSpec spec = baseSpec.substitute(substituter);
     assertEquals(title, spec.getModulePrefs().getTitle());
     assertEquals(content, spec.getView(GadgetSpec.DEFAULT_VIEW).getContent());
+    assertEquals(100, spec.getAttribute("foo"));
+    assertEquals("baz", spec.getAttribute("bar"));
   }
 }


Reply via email to