Package org.apache.shindig.gadgets.features.FeatureRegistry

Examples of org.apache.shindig.gadgets.features.FeatureRegistry.FeatureBundle


  @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",
        getContent(actual));
View Full Code Here


    replay(result);
    return result;
  }

  private FeatureBundle mockBundle(List<FeatureResource> resources) {
    FeatureBundle result = createMock(FeatureBundle.class);
    expect(result.getResources()).andReturn(resources).anyTimes();
    expect(result.getName()).andReturn("feature").anyTimes();
    replay(result);
    return result;
  }
View Full Code Here

  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),
        loadLibs, ImmutableList.of(bundle2));
View Full Code Here

    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),
        loadLibs, EMPTY_BUNDLE_LIST);
View Full Code Here

    expect(result.isProxyCacheable()).andReturn(proxyCacheable).anyTimes();
    return result;
  }

  private FeatureBundle mockBundle(String name, String export, String extern, List<FeatureResource> resources) {
    FeatureBundle result = control.createMock(FeatureBundle.class);
    expect(result.getName()).andReturn(name).anyTimes();
    if (export != null) {
      expect(result.getApis(ApiDirective.Type.JS, true)).andReturn(ImmutableList.of(export));
    }
    if (extern != null) {
      expect(result.getApis(ApiDirective.Type.JS, false)).andReturn(ImmutableList.of(extern));
    }
    if (resources != null) {
      expect(result.getResources()).andReturn(resources);
    }
    return result;
  }
View Full Code Here

        actualResponse.toJsString());
  }

  @Test
  public void testNeighboringSameFeatures() throws Exception {
    FeatureBundle bundle = mockBundle("bundle");
    JsContent js1 = JsContent.fromFeature("content1", "source1", bundle, null);
    JsContent js2 = JsContent.fromFeature("content2", "source2", bundle, null);
    JsResponseBuilder builder = newBuilder(js1, js2);

    control.replay();
View Full Code Here

        -1, -1, false, ERRORS, null);
    return new JsResponseBuilder(response);
  }

  private FeatureBundle mockBundle(String name) {
    FeatureBundle result = control.createMock(FeatureBundle.class);
    expect(result.getName()).andReturn(name).anyTimes();
    return result;
  }
View Full Code Here

  }

  private FeatureBundle mockBundle(List<String> exports) {
    List<ApiDirective> apis = Lists.newArrayList();
    for (String e : exports) apis.add(mockApiDirective(true, e));
    FeatureBundle result = createMock(FeatureBundle.class);
    expect(result.getApis(ApiDirective.Type.JS, true)).andReturn(exports).anyTimes();
    expect(result.isSupportDefer()).andReturn(false).anyTimes();
    replay(result);
    return result;
  }
View Full Code Here

     * @return {@link JsContent} for this component
     */
    private JsContent getJsContent(String codeFragment, String mappingIdentifier) {
      JsContent sourceJs = orig.get(getRootSrc(mappingIdentifier));
      String sourceName = DEFAULT_JSSOURCE;
      FeatureBundle bundle = null;
      if (sourceJs != null) {
        sourceName = sourceJs.getSource() != null ? sourceJs.getSource() : "";
        bundle = sourceJs.getFeatureBundle();
      }
      return JsContent.fromFeature(codeFragment, sourceName, bundle, null);
View Full Code Here

    JsUri jsUri = jsRequest.getJsUri();
    ImmutableList.Builder<JsContent> resp = ImmutableList.builder();
    FeatureRegistry featureRegistry = getFeatureRegistry(jsUri);

    boolean needExports = false;
    FeatureBundle last = null;
    if (!jsUri.isJsload()) {
      for (JsContent jsc : builder.build().getAllJsContent()) {
        FeatureBundle current = jsc.getFeatureBundle();
        if (last != null && current != last) {
          needExports |= appendExportJsStatements(resp, jsUri, last);
        }
        resp.add(jsc);
        last = current;
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.features.FeatureRegistry.FeatureBundle

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.