Examples of Substitutions


Examples of org.apache.shindig.gadgets.variables.Substitutions

  public void parseRelativeLink() throws Exception {
    String xml = "<Link rel='" + REL_VALUE + "' href='/foo'/>";

    LinkSpec link = new LinkSpec(XmlUtil.parse(xml), SPEC_URL);

    link = link.substitute(new Substitutions());

    assertEquals(REL_VALUE, link.getRel());
    assertEquals(HREF_VALUE.resolve(Uri.parse("/foo")), link.getHref());
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.variables.Substitutions

    String href = "jp-DE.xml";
    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

Examples of org.apache.shindig.gadgets.variables.Substitutions

                 "  <Link rel='" + link1Rel + "' href='" + link1Href + "'/>" +
                 "  <Link rel='" + link2Rel + "' href='" + link2Href + "'/>" +
                 "</ModulePrefs>";

    ModulePrefs prefs = new ModulePrefs(XmlUtil.parse(xml), SPEC_URL)
        .substitute(new Substitutions());

    assertEquals(link1Href, prefs.getLinks().get(link1Rel).getHref());
    assertEquals(SPEC_URL.resolve(link2Href), prefs.getLinks().get(link2Rel).getHref());
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.variables.Substitutions

    String rel = "foo-bar";
    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);

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

Examples of org.apache.shindig.gadgets.variables.Substitutions

      assertTrue(e.getMessage().contains(SPEC_URL.toString()));
    }
  }

  public void testSubstitutions() throws Exception {
    Substitutions substituter = new Substitutions();
    String title = "Hello, World!";
    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

Examples of org.apache.shindig.gadgets.variables.Substitutions

                 " <EnumValue value=\"0\" display_value=\"__MSG_dv__\"/>" +
                 "</UserPref>";
    String displayName = "This is the display name";
    String defaultValue = "This is the default value";
    String displayValue = "This is the display value";
    Substitutions substituter = new Substitutions();
    substituter.addSubstitution(Substitutions.Type.MESSAGE,
        "display_name", displayName);
    substituter.addSubstitution(Substitutions.Type.MESSAGE,
        "default_value", defaultValue);
    substituter.addSubstitution(Substitutions.Type.MESSAGE, "dv", displayValue);
    UserPref userPref
        = new UserPref(XmlUtil.parse(xml)).substitute(substituter);
    assertEquals(displayName, userPref.getDisplayName());
    assertEquals(defaultValue, userPref.getDefaultValue());
    assertEquals(displayValue, userPref.getEnumValues().get("0"));
View Full Code Here

Examples of org.apache.shindig.gadgets.variables.Substitutions

    }
  }

  public void testSubstitutions() throws Exception {
    String xml = "<Icon>http://__MSG_domain__/icon.png</Icon>";
    Substitutions substituter = new Substitutions();
    substituter.addSubstitution(Substitutions.Type.MESSAGE, "domain",
        "example.org");
    Icon icon = new Icon(XmlUtil.parse(xml)).substitute(substituter);
    assertEquals("http://example.org/icon.png", icon.getContent());
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.variables.Substitutions

  @Test
  public void substitutionsOk() throws Exception {
    String xml = "<Preload href='__MSG_preload__'/>";

    Preload preload = new Preload(XmlUtil.parse(xml), SPEC_URL);
    Substitutions substituter = new Substitutions();
    substituter.addSubstitution(Substitutions.Type.MESSAGE, "preload", HREF);
    Preload substituted = preload.substitute(substituter);

    assertEquals(HREF, substituted.getHref().toString());
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.variables.Substitutions

  @Test
  public void relativeSubstitutionsOk() throws Exception {
    String xml = "<Preload href='__MSG_preload__'/>";

    Preload preload = new Preload(XmlUtil.parse(xml), SPEC_URL);
    Substitutions substituter = new Substitutions();
    substituter.addSubstitution(Substitutions.Type.MESSAGE, "preload", "relative");
    Preload substituted = preload.substitute(substituter);

    assertEquals(SPEC_URL.resolve(Uri.parse("relative")), substituted.getHref());
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.variables.Substitutions

  @Test
  public void arbitraryAttributes() throws Exception {
    String xml = "<Preload href='" + HREF + "' foo='bar' yo='momma' sub='__MSG_preload__'/>";

    Preload preload = new Preload(XmlUtil.parse(xml), SPEC_URL);
    Substitutions substituter = new Substitutions();
    substituter.addSubstitution(Substitutions.Type.MESSAGE, "preload", "stuff");
    Preload substituted = preload.substitute(substituter);
    assertEquals("bar", substituted.getAttributes().get("foo"));
    assertEquals("momma", substituted.getAttributes().get("yo"));
    assertEquals("stuff", substituted.getAttributes().get("sub"));
  }
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.