Package org.apache.shindig.gadgets.variables

Examples of org.apache.shindig.gadgets.variables.Substitutions.addSubstitution()


  public void testHrefRelativeSubstitution() throws Exception {
    String href = "__MSG_foo__";
    String xml = "<Content type=\"url\" href=\"" + href + "\"/>";

    Substitutions substituter = new Substitutions();
    substituter.addSubstitution(Type.MESSAGE, "foo", "/bar");

    View view = new View("test", Arrays.asList(XmlUtil.parse(xml)), SPEC_URL);
    view = view.substitute(substituter);
    assertEquals(SPEC_URL.resolve(Uri.parse("/bar")), view.getHref());
  }
View Full Code Here


    String xml = "<Content type='html' sign_owner='false' sign_viewer='false' foo='bar' " +
                 "yo='momma' sub='__MSG_view__'/>";

    View view = new View("test", Arrays.asList(XmlUtil.parse(xml)), SPEC_URL);
    Substitutions substituter = new Substitutions();
    substituter.addSubstitution(Substitutions.Type.MESSAGE, "view", "stuff");
    View substituted = view.substitute(substituter);
    assertEquals("bar", substituted.getAttributes().get("foo"));
    assertEquals("momma", substituted.getAttributes().get("yo"));
    assertEquals("stuff", substituted.getAttributes().get("sub"));
    assertFalse("sign_owner parsed incorrectly.", view.isSignOwner());
View Full Code Here

    Uri expectedHref = Uri.parse("http://example.org/jp-DE.xml");
    String xml = "<Link rel='__MSG_rel__' href='http://example.org/__MSG_href__'/>";

    LinkSpec link = new LinkSpec(XmlUtil.parse(xml), SPEC_URL);
    Substitutions substitutions = new Substitutions();
    substitutions.addSubstitution(Substitutions.Type.MESSAGE, "rel", rel);
    substitutions.addSubstitution(Substitutions.Type.MESSAGE, "href", href);
    LinkSpec substituted = link.substitute(substitutions);

    assertEquals(rel, substituted.getRel());
    assertEquals(expectedHref, substituted.getHref());
View Full Code Here

    String xml = "<Link rel='__MSG_rel__' href='http://example.org/__MSG_href__'/>";

    LinkSpec link = new LinkSpec(XmlUtil.parse(xml), SPEC_URL);
    Substitutions substitutions = new Substitutions();
    substitutions.addSubstitution(Substitutions.Type.MESSAGE, "rel", rel);
    substitutions.addSubstitution(Substitutions.Type.MESSAGE, "href", href);
    LinkSpec substituted = link.substitute(substitutions);

    assertEquals(rel, substituted.getRel());
    assertEquals(expectedHref, substituted.getHref());
  }
View Full Code Here

    String linkHref = "http://example.org/link.html";
    String preHref = "http://example.org/preload.html";

    ModulePrefs prefs = new ModulePrefs(XmlUtil.parse(xml), SPEC_URL);
    Substitutions subst = new Substitutions();
    subst.addSubstitution(Substitutions.Type.MESSAGE, "title", title);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "icon", icon);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "rel", rel);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "link_href", linkHref);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "pre_href", preHref);
    prefs = prefs.substitute(subst);
View Full Code Here

    String preHref = "http://example.org/preload.html";

    ModulePrefs prefs = new ModulePrefs(XmlUtil.parse(xml), SPEC_URL);
    Substitutions subst = new Substitutions();
    subst.addSubstitution(Substitutions.Type.MESSAGE, "title", title);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "icon", icon);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "rel", rel);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "link_href", linkHref);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "pre_href", preHref);
    prefs = prefs.substitute(subst);
View Full Code Here

    ModulePrefs prefs = new ModulePrefs(XmlUtil.parse(xml), SPEC_URL);
    Substitutions subst = new Substitutions();
    subst.addSubstitution(Substitutions.Type.MESSAGE, "title", title);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "icon", icon);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "rel", rel);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "link_href", linkHref);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "pre_href", preHref);
    prefs = prefs.substitute(subst);

    assertEquals(title, prefs.getTitle());
View Full Code Here

    ModulePrefs prefs = new ModulePrefs(XmlUtil.parse(xml), SPEC_URL);
    Substitutions subst = new Substitutions();
    subst.addSubstitution(Substitutions.Type.MESSAGE, "title", title);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "icon", icon);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "rel", rel);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "link_href", linkHref);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "pre_href", preHref);
    prefs = prefs.substitute(subst);

    assertEquals(title, prefs.getTitle());
    assertEquals(icon, prefs.getIcons().get(0).getContent());
View Full Code Here

    Substitutions subst = new Substitutions();
    subst.addSubstitution(Substitutions.Type.MESSAGE, "title", title);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "icon", icon);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "rel", rel);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "link_href", linkHref);
    subst.addSubstitution(Substitutions.Type.MESSAGE, "pre_href", preHref);
    prefs = prefs.substitute(subst);

    assertEquals(title, prefs.getTitle());
    assertEquals(icon, prefs.getIcons().get(0).getContent());
    assertEquals(rel, prefs.getLinks().get(rel).getRel());
View Full Code Here

    String content = "Goodbye, world :(";
    String xml = "<Module>" +
                 "<ModulePrefs title=\"__UP_title__\"/>" +
                 "<Content type=\"html\">__MSG_content__</Content>" +
                 "</Module>";
    substituter.addSubstitution(Type.USER_PREF, "title", title);
    substituter.addSubstitution(Type.MESSAGE, "content", content);

    GadgetSpec spec = new GadgetSpec(SPEC_URL, xml).substitute(substituter);
    assertEquals(title, spec.getModulePrefs().getTitle());
    assertEquals(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.