Examples of GadgetSpec


Examples of org.apache.shindig.gadgets.spec.GadgetSpec

  @Test
  public void doesNothingWhenNotSanitized() throws Exception {
    String markup = "<script src=\"http://evil.org/evil\"></script> <b>hello</b>";
    Gadget gadget = new Gadget().setContext(unsanitaryGadgetContext);
    gadget.setSpec(new GadgetSpec(Uri.parse("www.example.org/gadget.xml"),
        "<Module><ModulePrefs title=''/><Content type='html'/></Module>"));
    gadget.setCurrentView(gadget.getSpec().getViews().values().iterator().next());
    assertEquals(markup, rewrite(gadget, markup, set("b"), set()));
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.spec.GadgetSpec

    String sanitized = "<html><head></head><body><p><style>A {\n  font: bold\n}</style>text " +
        "<b>bold text</b></p><b>Bold text</b></body></html>";

    Gadget gadget = new Gadget().setContext(sanitaryGadgetContext);
    gadget.setSpec(new GadgetSpec(Uri.parse("www.example.org/gadget.xml"),
        "<Module><ModulePrefs title=''/><Content type='html'/></Module>"));
    gadget.setCurrentView(gadget.getSpec().getViews().values().iterator().next());
    assertEquals(sanitized, rewrite(gadget, markup, set("p", "b", "style"), set()));
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.spec.GadgetSpec

  @Test
  public void getLocale() throws Exception {
    Gadget gadget = new Gadget()
        .setContext(context)
        .setSpec(new GadgetSpec(Uri.parse(SPEC_URL), SPEC_XML));

    LocaleSpec localeSpec = gadget.getLocale();
    assertEquals("VALUE", localeSpec.getMessageBundle().getMessages().get("name"));
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.spec.GadgetSpec

        makeFeature("required4", null));
    GadgetFeatureRegistry registry = mock(GadgetFeatureRegistry.class);
    Gadget gadget = new Gadget()
        .setContext(context)
        .setGadgetFeatureRegistry(registry)
        .setSpec(new GadgetSpec(Uri.parse(SPEC_URL), xml));
    Set<String> needed = Sets.newHashSet("required1", "required2");
    expect(registry.getFeatures(needed)).andReturn(features).anyTimes();
    replay(registry);
    List<String> requiredFeatures = gadget.getAllFeatures();
    assertEquals(5, requiredFeatures.size());
View Full Code Here

Examples of org.apache.shindig.gadgets.spec.GadgetSpec

          new ArrayList<JsLibrary>(), null));
    } else {
      gadgetXml = "<Module><ModulePrefs title=''/><Content/></Module>";
    }

    GadgetSpec spec = null;
    try {
      spec = new GadgetSpec(Uri.parse(url), gadgetXml);
    } catch (GadgetException e) {
      return null;
    }

    GadgetFeatureRegistry registry = mock(GadgetFeatureRegistry.class);
View Full Code Here

Examples of org.apache.shindig.gadgets.spec.GadgetSpec

    public GadgetSpec getGadgetSpec(GadgetContext context) throws GadgetException {
      if (exception != null) {
        throw exception;
      }
      return new GadgetSpec(context.getUrl(), GADGET);
    }
View Full Code Here

Examples of org.apache.shindig.gadgets.spec.GadgetSpec

    assertTrue("Template tag was removed (" + condition + ")",
        content.getContent().indexOf("text/os-template") > 0);
  }
 
  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
View Full Code Here

Examples of org.apache.shindig.gadgets.spec.GadgetSpec

  private GadgetSpec spec;

  @Override
  public void setUp() throws Exception {
    super.setUp();
    spec = new GadgetSpec(Uri.parse("#"), DEFAULT_XML);
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.spec.GadgetSpec

    HttpRequest request = createIgnoreCacheRequest();
    HttpResponse response = new HttpResponse(LOCAL_SPEC_XML);
    expect(pipeline.execute(request)).andReturn(response);
    replay(pipeline);

    GadgetSpec spec = specFactory.getGadgetSpec(createContext(SPEC_URL, true));

    assertEquals(LOCAL_CONTENT, spec.getView(GadgetSpec.DEFAULT_VIEW).getContent());
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.spec.GadgetSpec

    HttpResponse manifestResponse = new HttpResponse(MANIFEST_XML);
    expect(pipeline.execute(manifestRequest)).andReturn(manifestResponse);

    replay(pipeline);

    GadgetSpec spec = specFactory.getGadgetSpec(createContext(MANIFEST_URI, true));

    assertEquals(LOCAL_CONTENT, spec.getView(GadgetSpec.DEFAULT_VIEW).getContent());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.