shindig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhor...@apache.org
Subject svn commit: r1152351 - in /shindig/trunk/java/gadgets/src: main/java/org/apache/shindig/gadgets/js/AddJslLoadedVariableProcessor.java test/java/org/apache/shindig/gadgets/js/AddJslLoadedVariableProcessorTest.java
Date Fri, 29 Jul 2011 19:41:20 GMT
Author: zhoresh
Date: Fri Jul 29 19:41:19 2011
New Revision: 1152351

URL: http://svn.apache.org/viewvc?rev=1152351&view=rev
Log:
List only requested features and not dependent | https://reviews.apache.org/r/1221/

Modified:
    shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/js/AddJslLoadedVariableProcessor.java
    shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/js/AddJslLoadedVariableProcessorTest.java

Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/js/AddJslLoadedVariableProcessor.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/js/AddJslLoadedVariableProcessor.java?rev=1152351&r1=1152350&r2=1152351&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/js/AddJslLoadedVariableProcessor.java
(original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/js/AddJslLoadedVariableProcessor.java
Fri Jul 29 19:41:19 2011
@@ -24,10 +24,6 @@ import com.google.inject.Inject;
 
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.shindig.gadgets.GadgetContext;
-import org.apache.shindig.gadgets.GadgetException;
-import org.apache.shindig.gadgets.features.FeatureRegistry;
-import org.apache.shindig.gadgets.features.FeatureRegistry.FeatureBundle;
-import org.apache.shindig.gadgets.features.FeatureRegistryProvider;
 import org.apache.shindig.gadgets.uri.JsUriManager.JsUri;
 
 import java.util.Collection;
@@ -45,13 +41,6 @@ public class AddJslLoadedVariableProcess
   static final String TEMPLATE =
       "window['___jsl']['l'] = (window['___jsl']['l'] || []).concat(%s);";
 
-  private final FeatureRegistryProvider registryProvider;
-
-  @Inject
-  public AddJslLoadedVariableProcessor(FeatureRegistryProvider featureRegistryProvider) {
-    this.registryProvider = featureRegistryProvider;
-  }
-
   public boolean process(JsRequest jsRequest, JsResponseBuilder builder) throws JsException
{
     JsUri jsUri = jsRequest.getJsUri();
     if (!jsUri.isNohint()) {
@@ -63,23 +52,11 @@ public class AddJslLoadedVariableProcess
     return true;
   }
 
-  // TODO: factor this logic into somewhere shared. it's now used in GetJsContentProcessor.
-  private Set<String> getBundleNames(JsUri jsUri, boolean loaded) throws JsException
{
+  protected Set<String> getBundleNames(JsUri jsUri, boolean loaded) throws JsException
{
     GadgetContext ctx = new JsGadgetContext(jsUri);
     Collection<String> libs = loaded ? jsUri.getLoadedLibs() : jsUri.getLibs();
-    FeatureRegistry registry;
-    try {
-      registry = registryProvider.get(jsUri.getRepository());
-    } catch (GadgetException e) {
-      throw new JsException(e.getHttpStatusCode(), e.getMessage());
-    }
-
-    // TODO: possibly warn on unknown/unrecognized libs.
-    FeatureRegistry.LookupResult lookup = registry.getFeatureResources(ctx, libs, null);
     Set<String> ret = Sets.newLinkedHashSet(); // ordered set for testability.
-    for (FeatureBundle bundle : lookup.getBundles()) {
-      ret.add(bundle.getName());
-    }
+    ret.addAll(libs);
     return ret;
   }
 

Modified: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/js/AddJslLoadedVariableProcessorTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/js/AddJslLoadedVariableProcessorTest.java?rev=1152351&r1=1152350&r2=1152351&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/js/AddJslLoadedVariableProcessorTest.java
(original)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/js/AddJslLoadedVariableProcessorTest.java
Fri Jul 29 19:41:19 2011
@@ -18,20 +18,11 @@
 
 package org.apache.shindig.gadgets.js;
 
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.isA;
-import static org.easymock.EasyMock.isNull;
 import static org.junit.Assert.assertEquals;
 
 import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
 
 import org.apache.shindig.common.uri.Uri;
-import org.apache.shindig.gadgets.features.FeatureRegistry;
-import org.apache.shindig.gadgets.features.FeatureRegistry.FeatureBundle;
-import org.apache.shindig.gadgets.features.FeatureRegistry.LookupResult;
-import org.apache.shindig.gadgets.features.FeatureRegistryProvider;
 import org.apache.shindig.gadgets.uri.JsUriManager.JsUri;
 import org.apache.shindig.gadgets.uri.UriStatus;
 import org.easymock.EasyMock;
@@ -46,18 +37,16 @@ import java.util.List;
  */
 public class AddJslLoadedVariableProcessorTest {
   private static final String REQ_1_LIB = "foo";
-  private static final String REQ_1_DEP_LIB = "bar";
   private static final String REQ_2_LIB = "gig";
   private static final String LOAD_LIB = "bar";
   private static final String URI = "http://localhost";
   private static final List<String> REQ_LIBS = ImmutableList.of(
-      REQ_1_LIB, REQ_2_LIB, REQ_1_LIB, REQ_2_LIB);
+      REQ_1_LIB, REQ_2_LIB, REQ_1_LIB, REQ_2_LIB, LOAD_LIB);
   private static final List<String> LOAD_LIBS = ImmutableList.of(
       LOAD_LIB, LOAD_LIB);
 
   private IMocksControl control;
   private JsRequest request;
-  private FeatureRegistry registry;
   private JsUri jsUri;
   private JsResponseBuilder response;
   private AddJslLoadedVariableProcessor processor;
@@ -66,20 +55,13 @@ public class AddJslLoadedVariableProcess
   public void setUp() {
     control = EasyMock.createControl();
     request = control.createMock(JsRequest.class);
-    registry = control.createMock(FeatureRegistry.class);
     response = new JsResponseBuilder();
-    FeatureRegistryProvider registryProvider = new FeatureRegistryProvider() {
-      public FeatureRegistry get(String repository) {
-        return registry;
-      }
-    };
-    processor = new AddJslLoadedVariableProcessor(registryProvider);
+    processor = new AddJslLoadedVariableProcessor();
   }
 
   @Test
   public void testSucceeds() throws Exception {
     setUpJsUri(URI + "/" + REQ_1_LIB + ".js");
-    setUpRegistry();
     control.replay();
     processor.process(request, response);
     assertEquals(String.format(AddJslLoadedVariableProcessor.TEMPLATE,
@@ -100,30 +82,4 @@ public class AddJslLoadedVariableProcess
     jsUri = new JsUri(UriStatus.VALID_UNVERSIONED, Uri.parse(uri), REQ_LIBS, LOAD_LIBS);
     EasyMock.expect(request.getJsUri()).andReturn(jsUri);
   }
-
-  @SuppressWarnings("unchecked")
-  private void setUpRegistry() {
-    FeatureBundle bundle1 = mockBundle(REQ_1_LIB);
-    FeatureBundle bundle2 = mockBundle(REQ_1_DEP_LIB);
-    FeatureBundle bundle3 = mockBundle(REQ_2_LIB);
-    FeatureBundle bundle4 = mockBundle(LOAD_LIB);
-    LookupResult reqResult = mockLookupResult(Lists.newArrayList(bundle1, bundle2, bundle3));
-    expect(registry.getFeatureResources(isA(JsGadgetContext.class), eq(REQ_LIBS),
-        isNull(List.class))).andReturn(reqResult);
-    LookupResult loadResult = mockLookupResult(Lists.newArrayList(bundle4));
-    expect(registry.getFeatureResources(isA(JsGadgetContext.class), eq(LOAD_LIBS),
-        isNull(List.class))).andReturn(loadResult);
-  }
-
-  private LookupResult mockLookupResult(List<FeatureBundle> bundles) {
-    LookupResult result = control.createMock(LookupResult.class);
-    expect(result.getBundles()).andReturn(bundles);
-    return result;
-  }
-
-  private FeatureBundle mockBundle(String name) {
-    FeatureBundle result = control.createMock(FeatureBundle.class);
-    expect(result.getName()).andReturn(name);
-    return result;
-  }
 }



Mime
View raw message