Package org.apache.shindig.gadgets

Examples of org.apache.shindig.gadgets.Gadget


    String gadgetXml =
      "<Module><ModulePrefs title='' />" +
      "<Content type='html' href='http://foo.com/bar/baz.html' />" +
      "</Module>";

    Gadget gadget = makeGadgetWithSpec(gadgetXml);
    gadget.setCurrentView(gadget.getSpec().getView("default"));

    String rewritten = rewrite(gadget, BODY_CONTENT);

    boolean containsConfig = rewritten.contains("\"shindig.xhrwrapper\"");
    assertFalse("shindig.xhrwrapper configuration present in rewritten HTML.", containsConfig);
View Full Code Here


      "  <Require feature='foo'/>" +
      "</ModulePrefs>" +
      "<Content type='html'/>" +
      "</Module>";

    Gadget gadget = makeGadgetWithSpec(gadgetXml);

    reset(featureRegistry);
    FeatureRegistry.LookupResult lr = createMock(FeatureRegistry.LookupResult.class);
    expect(lr.getResources()).andReturn(ImmutableList.<FeatureResource>of());
    replay(lr);
    expect(featureRegistry.getFeatureResources(same(gadget.getContext()),
        eq(ImmutableSet.<String>of()), eq(Lists.<String>newLinkedList())))
        .andReturn(lr);
    final FeatureRegistry.LookupResult lr2 = createMock(FeatureRegistry.LookupResult.class);
    expect(lr2.getResources()).andReturn(ImmutableList.<FeatureResource>of());
    replay(lr2);
    assertTrue(gadget.getDirectFeatureDeps().contains("core"));
    assertTrue(gadget.getDirectFeatureDeps().contains("foo"));
    assertEquals(gadget.getDirectFeatureDeps().size(),2);
    expect(featureRegistry.getFeatureResources(same(gadget.getContext()),
        eq(Lists.newLinkedList(gadget.getDirectFeatureDeps())), eq(Lists.<String>newLinkedList())))
        .andAnswer(new IAnswer<FeatureRegistry.LookupResult>() {
          @SuppressWarnings("unchecked")
          public FeatureRegistry.LookupResult answer() throws Throwable {
            List<String> unsupported = (List<String>)getCurrentArguments()[2];
            unsupported.add("foo");
View Full Code Here

      "  <Require feature='foo' views='default'/>" +
      "</ModulePrefs>" +
      "<Content view='default' type='html'/>" +
      "</Module>";

    Gadget gadget = makeGadgetWithSpec(gadgetXml);

    reset(featureRegistry);
    FeatureRegistry.LookupResult lr = createMock(FeatureRegistry.LookupResult.class);
    expect(lr.getResources()).andReturn(ImmutableList.<FeatureResource>of());
    replay(lr);
    expect(featureRegistry.getFeatureResources(same(gadget.getContext()),
        eq(ImmutableSet.<String>of()), eq(Lists.<String>newLinkedList())))
        .andReturn(lr);
    final FeatureRegistry.LookupResult lr2 = createMock(FeatureRegistry.LookupResult.class);
    expect(lr2.getResources()).andReturn(ImmutableList.<FeatureResource>of());
    replay(lr2);
    assertTrue(gadget.getDirectFeatureDeps().contains("core"));
    assertTrue(gadget.getDirectFeatureDeps().contains("foo"));
    assertEquals(gadget.getDirectFeatureDeps().size(),2);
    Lists.newLinkedList();
    expect(featureRegistry.getFeatureResources(same(gadget.getContext()),
        eq(Lists.newLinkedList(gadget.getDirectFeatureDeps())), eq(Lists.<String>newLinkedList())))
        .andAnswer(new IAnswer<FeatureRegistry.LookupResult>() {
          @SuppressWarnings("unchecked")
          public FeatureRegistry.LookupResult answer() throws Throwable {
            List<String> unsupported = (List<String>)getCurrentArguments()[2];
            unsupported.add("foo");
View Full Code Here

        }
        return null;
      }
    };

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

    reset(featureRegistry);
    final FeatureRegistry.LookupResult lr = createMock(FeatureRegistry.LookupResult.class);
    expect(lr.getResources()).andReturn(ImmutableList.<FeatureResource>of()).anyTimes();
    replay(lr);
    expect(featureRegistry.getFeatureResources(same(gadget.getContext()),
        eq(ImmutableSet.<String>of("bar")), eq(Lists.<String>newArrayList())))
        .andAnswer(new IAnswer<FeatureRegistry.LookupResult>() {
          @SuppressWarnings("unchecked")
          public FeatureRegistry.LookupResult answer() throws Throwable {
            List<String> unsupported = (List<String>)getCurrentArguments()[2];
            unsupported.add("bar");
            return lr;
          }
        });
    expect(featureRegistry.getFeatureResources(same(gadget.getContext()),
        eq(ImmutableList.<String>of("core")), eq(Lists.<String>newArrayList())))
        .andReturn(lr);
    expect(featureRegistry.getFeatures(eq(ImmutableSet.of("core", "bar"))))
        .andReturn(ImmutableList.of("core"));
    expect(featureRegistry.getFeatures(eq(ImmutableList.of("core"))))
View Full Code Here

      "  <Optional feature='foo'/>" +
      "</ModulePrefs>" +
      "<Content type='html'/>" +
      "</Module>";

    Gadget gadget = makeGadgetWithSpec(gadgetXml);

    rewrite(gadget, "");
    // rewrite will throw if the optional unsupported feature doesn't work.
  }
View Full Code Here

      "  <Optional feature='bar'/>" +
      "</ModulePrefs>" +
      "<Content type='html'/>" +
      "</Module>";

    Gadget gadget = makeGadgetWithSpec(gadgetXml);

    rewrite(gadget, "");
    // rewrite will throw if the optional unsupported feature doesn't work.
  }
View Full Code Here

      "  <Optional feature='bar3' views='view1'/>" +
      "</ModulePrefs>" +
      "<Content type='html'/>" +
      "</Module>";

    Gadget gadget = makeGadgetWithSpec(gadgetXml);

    rewrite(gadget, "");
    // rewrite will throw if the optional unsupported feature doesn't work.
  }
View Full Code Here

    PreloadedData preloadedData = new PreloadedData() {
      public Collection<Object> toJson() {
        return someData;
      }
    };
    Gadget gadget = makeDefaultGadget().setPreloads(ImmutableList.of(preloadedData));

    String rewritten = rewrite(gadget, "");

    JSONArray json = getPreloadedJson(rewritten);
    int i = 0;
View Full Code Here

      public Collection<Object> toJson() throws PreloadException {
        throw new PreloadException("test");
      }
    };

    Gadget gadget = makeDefaultGadget().setPreloads(ImmutableList.of(preloadedData));
    String rewritten = rewrite(gadget, "");

    JSONArray json = getPreloadedJson(rewritten);

    assertEquals(0, json.length());
View Full Code Here

    return baseElementMatcher.group(1);
  }

  @Test
  public void baseElementInsertedWhenContentIsInline() throws Exception {
    Gadget gadget = makeDefaultGadget();

    config.data.put(INSERT_BASE_ELEMENT_KEY, true);

    String rewritten = rewrite(gadget, BODY_CONTENT);
    String base = getBaseElement(rewritten);
View Full Code Here

TOP

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

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.