Examples of HashMapContext


Examples of org.apache.abdera.i18n.templates.HashMapContext

  @SuppressWarnings("unchecked")
  private Context getContext(Object param) {
    Context context = new EmptyContext();
    if (param != null) {
      if (param instanceof Map) {
        context = new HashMapContext(cleanMapCtx(param), true);
      } else if (param instanceof Context) {
        context = (Context)param;
      } else {
        context = new ObjectContext(param,true);
      }
View Full Code Here

Examples of org.apache.abdera.i18n.templates.HashMapContext

 
  public static Context getContext(RequestContext request, Object param) {
    Context context = null;
    if (param != null) {
      if (param instanceof Map) {
        context = new HashMapContext((Map<String,Object>)param, true);
      } else if (param instanceof Context) {
        context = (Context)param;
      } else {
        context = new ObjectContext(param,true);
      }
View Full Code Here

Examples of org.apache.abdera.i18n.templates.HashMapContext

public class RouteTest extends Assert {
  @Test
  public void testSimpleRoute() throws Exception {
    Route route = new Route("feed", "/:collection");
   
    HashMapContext ctx = new HashMapContext();
    ctx.put("collection", "test");
    assertEquals("/test", route.expand(ctx));
   
    assertTrue(route.match("/foo"));
    assertFalse(route.match("/foo/test"));
    assertFalse(route.match("foo"));
View Full Code Here

Examples of org.apache.abdera.i18n.templates.HashMapContext

  }
  @Test
  public void testStaticRoute() throws Exception {
    Route route = new Route("feed", "/feed");
   
    HashMapContext ctx = new HashMapContext();
    assertEquals("/feed", route.expand(ctx));
   
    assertTrue(route.match("/feed"));
    assertFalse(route.match("/feed/test"));
    assertFalse(route.match("feed"));
View Full Code Here

Examples of org.apache.abdera.i18n.templates.HashMapContext

 
  @Test
  public void testTwoPathRoute() throws Exception {
    Route route = new Route("entry", "/:collection/:entry");
   
    HashMapContext ctx = new HashMapContext();
    ctx.put("collection", "c");
    ctx.put("entry", "e");
    assertEquals("/c/e", route.expand(ctx));
   
    assertFalse(route.match("/foo"));
    assertTrue(route.match("/foo/test"));
    assertFalse(route.match("foo"));
View Full Code Here

Examples of org.apache.abdera.i18n.templates.HashMapContext

  public void testTwoPathRouteWithSubstitution() throws Exception {
    Map<String, String> defaults = new HashMap<String,String>();
    defaults.put("collection", "c");
    Route route = new Route("entry", "/:collection/:entry", defaults, null);
   
    HashMapContext ctx = new HashMapContext();
    ctx.put("entry", "e");
    assertEquals("/c/e", route.expand(ctx));
  }
View Full Code Here

Examples of org.apache.abdera.i18n.templates.HashMapContext

  @Test
  public void testDashedRoute() throws Exception {
    Route route = new Route("entry", ":collection/:entry-:foo");
   
    HashMapContext ctx = new HashMapContext();
    ctx.put("collection", "c");
    ctx.put("entry", "e");
    ctx.put("foo", "f");
    assertEquals("c/e-f", route.expand(ctx));
   
    assertTrue(route.match("1/2-3"));
    assertFalse(route.match("1/2-"));
    assertFalse(route.match("1/-"));
View Full Code Here

Examples of org.apache.abdera.i18n.templates.HashMapContext

  public void testDashedRouteWithSubstitution() throws Exception {
    Map<String, String> defaults = new HashMap<String,String>();
    defaults.put("foo", "f");
    Route route = new Route("entry", ":collection/:entry-:foo", defaults, null);
   
    HashMapContext ctx = new HashMapContext();
    ctx.put("collection", "c");
    ctx.put("entry", "e");
    assertEquals("c/e-f", route.expand(ctx));
   
    assertTrue(route.match("1/2-3"));
    assertFalse(route.match("1/2-"));
    assertFalse(route.match("1/-"));
View Full Code Here

Examples of org.apache.abdera.i18n.templates.HashMapContext

  @Test
  public void test1() throws Exception {
    String t = "http://bitworking.org/news/{entry}";
    String e = "http://bitworking.org/news/RESTLog_Specification";
    HashMapContext c = new HashMapContext();
    c.put("entry", "RESTLog_Specification");
    eval(t,e,c);
  }
View Full Code Here

Examples of org.apache.abdera.i18n.templates.HashMapContext

 
  @Test
  public void test2() throws Exception {
    String t = "http://example.org/wiki/{entry=FrontPage}";
    String e = "http://example.org/wiki/FrontPage";
    HashMapContext c = new HashMapContext();
    eval(t,e,c);
  }
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.