Package org.apache.shindig.gadgets

Examples of org.apache.shindig.gadgets.GadgetContext


    MutableContent mc = new MutableContent(parser, s);

    GadgetSpec spec = new GadgetSpec(SPEC_URL,
        "<Module><ModulePrefs title=''/><Content><![CDATA[" + s + "]]></Content></Module>");

    GadgetContext context = new GadgetContext() {
      @Override
      public Uri getUrl() {
        return SPEC_URL;
      }
View Full Code Here


 
  private void setupGadget(String gadgetXml) throws SpecParserException, JSONException {
    gadgetSpec = new GadgetSpec(GADGET_URI, gadgetXml);
    gadget = new Gadget();
    gadget.setSpec(gadgetSpec);
    gadget.setContext(new GadgetContext() {

      @Override
      public Uri getUrl() {
        return GADGET_URI;
      }
View Full Code Here

    checkExactFeatureResources("container", RenderingContext.CONTAINER);
  }
 
  private void checkExactFeatureResources(String type, RenderingContext rctx) throws Exception {
    setupFullRegistry(type, null);
    GadgetContext ctx = getCtx(rctx, null);
    List<String> needed = Lists.newArrayList("nodep", "bottom");
    List<String> unsupported = Lists.newLinkedList();
    List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported);
    assertEquals(0, unsupported.size());
    assertEquals(2, resources.size());
View Full Code Here

  }
 
  private void checkNoContentValidFeatureResources(
      String type, RenderingContext rctx) throws Exception {
    setupFullRegistry(type, null);
    GadgetContext ctx = getCtx(rctx, null);
    List<String> needed = Lists.newArrayList("nodep", "bottom");
    List<String> unsupported = Lists.newLinkedList();
    List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported);
    assertEquals(0, resources.size());
  }
View Full Code Here

  }
 
  private void checkTransitiveFeatureResources(String type, RenderingContext rctx)
      throws Exception {
    setupFullRegistry(type, null);
    GadgetContext ctx = getCtx(rctx, null);
    List<String> needed = Lists.newArrayList("top", "nodep");
    List<String> unsupported = Lists.newLinkedList();
   
    // Should come back in insertable order (from bottom of the graph up),
    // querying in feature.xml dependency order.
View Full Code Here

  @Test
  public void unsupportedFeaturesPopulated() throws Exception {
    // Test only for gadget case; above tests are sufficient to ensure
    // that type and RenderingContext filter results properly.
    setupFullRegistry("gadget", null);
    GadgetContext ctx = getCtx(RenderingContext.GADGET, null);
    List<String> needed = Lists.newArrayList("nodep", "does-not-exist");
    List<String> unsupported = Lists.newLinkedList();
    List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported);
    assertEquals(1, resources.size());
    assertEquals("nodep", resources.get(0).getContent());
View Full Code Here

 
  @Test
  public void filterFeaturesByContainerMatch() throws Exception {
    // Again test only for gadget case; above tests cover type <-> RenderingContext
    setupFullRegistry("gadget", "one, two , three");
    GadgetContext ctx = getCtx(RenderingContext.GADGET, "two");
    List<String> needed = Lists.newArrayList("nodep", "bottom");
    List<String> unsupported = Lists.newLinkedList();
    List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported);
    assertEquals(2, resources.size());
    assertEquals("nodep", resources.get(0).getContent());
View Full Code Here

 
  @Test
  public void filterFeaturesByContainerNoMatch() throws Exception {
    // Again test only for gadget case; above tests cover type <-> RenderingContext
    setupFullRegistry("gadget", "one, two, three");
    GadgetContext ctx = getCtx(RenderingContext.GADGET, "four");
    List<String> needed = Lists.newArrayList("nodep", "bottom");
    List<String> unsupported = Lists.newLinkedList();
    List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported);
    assertEquals(0, resources.size())// no resource matches but all feature keys valid
    assertEquals(0, unsupported.size());
View Full Code Here

  }
 
  @Test
  public void getFeatureResourcesNoTransitiveSingle() throws Exception {
    setupFullRegistry("gadget", null);
    GadgetContext ctx = getCtx(RenderingContext.GADGET, null);
    List<String> needed = Lists.newArrayList("top", "bottom");
    List<String> unsupported = Lists.newLinkedList();
    List<FeatureResource> resources = registry.getFeatureResources(ctx, needed, unsupported, false);
    // Should return in order requested.
    assertEquals(2, resources.size());
View Full Code Here

    return getCtx(rctx, container, false);
  }
 
  private GadgetContext getCtx(final RenderingContext rctx, final String container,
      final boolean ignoreCache) {
    return new GadgetContext() {
      @Override
      public RenderingContext getRenderingContext() {
        return rctx;
      }
     
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.GadgetContext

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.