Package org.apache.abdera.i18n.templates

Examples of org.apache.abdera.i18n.templates.Route.expand()


        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


    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

    @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

        return new RouteTarget(type, context, route, uri);
    }

    public String urlFor(RequestContext context, Object key, Object param) {
        Route route = routes.get(key);
        return route != null ? context.getContextPath() + route.expand(getContext(param)) : null;
    }

    @SuppressWarnings("unchecked")
    private Context getContext(Object param) {
        Context context = new EmptyContext();
View Full Code Here

  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

  @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

    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"));
    assertFalse(route.match("/foo/test/bar"));
View Full Code Here

    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));
  }

  @Test
  public void testDashedRoute() throws Exception {
    Route route = new Route("entry", ":collection/:entry-:foo");
View Full Code Here

   
    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

    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

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.