Package org.apache.abdera.i18n.templates

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


  public RouteManager addRoute(
    String name,
    String pattern,
    TargetType type) {
      return addRoute(
        new Route(
          name,
          pattern),
        type);
  }
View Full Code Here


    String name,
    String pattern,
    TargetType type,
    CollectionAdapter collectionAdapter) {
   
    Route route = new Route(name,  pattern);
    route2CA.put(route, collectionAdapter);
    return addRoute(route, type);
  }
View Full Code Here

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

        super();
    }

    public void setRoute(String routePattern)
    {
        route = new Route("", routePattern);
    }
View Full Code Here

import org.junit.Test;

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"));
   
    Map<String, String> vars = route.parse("/test");
    assertEquals("test", vars.get("collection"));
  }
View Full Code Here

    Map<String, String> vars = route.parse("/test");
    assertEquals("test", vars.get("collection"));
  }
  @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"));
   
    Map<String, String> vars = route.parse("/test");
    assertEquals(0, vars.size());
  }
View Full Code Here

    assertEquals(0, vars.size());
  }
 
  @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"));
    assertFalse(route.match("/foo/test/bar"));

    Map<String, String> vars = route.parse("/1/2");
    assertEquals("1", vars.get("collection"));
    assertEquals("2", vars.get("entry"));
   
    vars = route.parse("/1/");
    assertEquals("1", vars.get("collection"));
    assertNull(vars.get("entry"));
  }
View Full Code Here

  @Test
  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

    assertEquals("/c/e", route.expand(ctx));
  }

  @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

  @Test
  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

TOP

Related Classes of org.apache.abdera.i18n.templates.Route

Copyright © 2018 www.massapicom. 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.