Package org.apache.shindig.gadgets.features

Examples of org.apache.shindig.gadgets.features.FeatureResource


      }
    };

    Gadget gadget = makeGadgetWithSpec(gadgetXml).setContext(context);

    FeatureResource fooResource = inline("foo-content", "foo-debug");
    expectFeatureCalls(gadget,
        ImmutableList.of(fooResource),
        libs,
        ImmutableList.of(fooResource, inline("bar-c", "bar-d"), inline("baz-c", "baz-d")));
   
View Full Code Here


    assertEquals(UriStatus.VALID_VERSIONED, status);
    verify(registry);
  }
 
  private void expectReq(String feature, String content) {
    FeatureResource resource = new FeatureResource.Simple(content, "");
    Collection<String> libs = Lists.newArrayList(feature);
    List<FeatureResource> resources = Lists.newArrayList(resource);
    expect(registry.getFeatureResources(isA(GadgetContext.class), eq(libs),
        EasyMock.<List<String>>isNull())).andReturn(resources).anyTimes();
  }
View Full Code Here

  @Before
  public void setUp() throws Exception {
    GadgetContext ctx = new GadgetContext();
    Provider<GadgetContext> contextProviderMock = Providers.of(ctx);
    FeatureResource resource = mockResource(DEFER_JS_DEB);
    FeatureRegistry.FeatureBundle bundle = mockExportJsBundle(resource);
    LookupResult lookupMock = mockLookupResult(bundle);
    final FeatureRegistry featureRegistryMock = mockRegistry(lookupMock);
    featureRegistry = featureRegistryMock;
    FeatureRegistryProvider registryProvider = new FeatureRegistryProvider() {
View Full Code Here

    replay(result);
    return result;
  }

  private FeatureResource mockResource(String debContent) {
    FeatureResource result = createMock(FeatureResource.class);
    expect(result.getDebugContent()).andReturn(debContent).anyTimes();
    expect(result.getName()).andReturn("js").anyTimes();
    replay(result);
    return result;
  }
View Full Code Here

  }

  @Test
  public void testGetJsContentWithDeb() throws Exception {
    JsUri jsUri = mockJsUri(true); // debug
    FeatureResource extRes = mockResource(true, RESOURCE_URL_DEB, RESOURCE_URL_OPT);
    FeatureResource intRes = mockResource(false, RESOURCE_CONTENT_DEB, RESOURCE_CONTENT_OPT);
    FeatureBundle bundle = mockBundle(Lists.newArrayList(extRes, intRes));
    Iterable<JsContent> actual = compiler.getJsContent(jsUri, bundle);
    assertEquals(
        "document.write('<script src=\"" + RESOURCE_URL_DEB + "\"></script>');\n" +
        RESOURCE_CONTENT_DEB + ";\n",
View Full Code Here

  }

  @Test
  public void testGetJsContentWithOpt() throws Exception {
    JsUri jsUri = mockJsUri(false); // optimized
    FeatureResource extRes = mockResource(true, RESOURCE_URL_DEB, RESOURCE_URL_OPT);
    FeatureResource intRes = mockResource(false, RESOURCE_CONTENT_DEB, RESOURCE_CONTENT_OPT);
    FeatureBundle bundle = mockBundle(Lists.newArrayList(extRes, intRes));
    Iterable<JsContent> actual = compiler.getJsContent(jsUri, bundle);
    assertEquals(
        "document.write('<script src=\"" + RESOURCE_URL_OPT + "\"></script>');\n" +
        RESOURCE_CONTENT_OPT + ";\n",
View Full Code Here

    replay(result);
    return result;
  }

  private FeatureResource mockResource(boolean external, String debContent, String optContent) {
    FeatureResource result = createMock(FeatureResource.class);
    expect(result.getDebugContent()).andReturn(debContent).anyTimes();
    expect(result.getContent()).andReturn(optContent).anyTimes();
    expect(result.isExternal()).andReturn(external).anyTimes();
    expect(result.getName()).andReturn("source").anyTimes();
    replay(result);
    return result;
  }
View Full Code Here

  @Test
  public void testPopulateWithLoadedFeatures() throws Exception {
    List<String> reqLibs = ImmutableList.of("feature1", "feature2");
    List<String> loadLibs = ImmutableList.of("feature2");

    FeatureResource resource1 = mockResource(true);
    FeatureBundle bundle1 = mockBundle("feature1", null, null, Lists.newArrayList(resource1));
    FeatureBundle bundle2 = mockBundle("feature2", "export2", "extern2", null);

    setupJsUriAndRegistry(UriStatus.VALID_UNVERSIONED,
        reqLibs, ImmutableList.of(bundle1, bundle2),
View Full Code Here

  private void setupForVersionAndProxy(boolean proxyCacheable, UriStatus uriStatus) {
    List<String> reqLibs = ImmutableList.of("feature");
    List<String> loadLibs = EMPTY_STRING_LIST;

    FeatureResource resource1 = mockResource(proxyCacheable);
    FeatureResource resource2 = mockResource(proxyCacheable);
    FeatureBundle bundle = mockBundle("feature", null, null,
        Lists.newArrayList(resource1, resource2));

    setupJsUriAndRegistry(uriStatus,
        reqLibs, Lists.newArrayList(bundle),
View Full Code Here

    expect(result.getBundles()).andReturn(bundles);
    return result;
  }

  private FeatureResource mockResource(boolean proxyCacheable) {
    FeatureResource result = control.createMock(FeatureResource.class);
    expect(result.isProxyCacheable()).andReturn(proxyCacheable).anyTimes();
    return result;
  }
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.features.FeatureResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.