Package org.apache.abdera.i18n.templates

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


    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

    assertFalse(route.match("1/-"));
  }

  @Test
  public void testBaseURI() throws Exception {
    Route route = new Route("entry", "/base/:collection/:entry");

    assertTrue(route.match("/base/test/123"));
    assertFalse(route.match("/base/test"));
    assertFalse(route.match("base/test"));
   
    Map<String, String> vars = route.parse("/base/1/2");
    assertEquals("1", vars.get("collection"));
    assertEquals("2", vars.get("entry"));
  }
View Full Code Here

  }
 

  @Test
  public void testNonVariablesAtBothEnds() throws Exception {
    Route route = new Route("entry", "/base/:collection/:entry;categories");

    assertTrue(route.match("/base/test/123;categories"));
    assertFalse(route.match("/base/test/123"));
   
    Map<String, String> vars = route.parse("/base/1/2;categories");
    assertEquals("1", vars.get("collection"));
    assertEquals("2", vars.get("entry"));
  }
View Full Code Here

    assertEquals("1", vars.get("collection"));
    assertEquals("2", vars.get("entry"));
  }
  @Test
  public void testSubDelims() throws Exception {
    Route route = new Route("entry", "/base/:collection/:entry");

    assertTrue(route.match("/base/test/123"));
    assertFalse(route.match("/base/test/123;categories"));
   
    Map<String, String> vars = route.parse("/base/test/123");
    assertEquals("test", vars.get("collection"));
    assertEquals("123", vars.get("entry"));
  }
View Full Code Here

    assertEquals("test", vars.get("collection"));
    assertEquals("123", vars.get("entry"));
  }
  @Test
  public void testGenDelims() throws Exception {
    Route route = new Route("entry", "/base/:collection/");

    assertTrue(route.match("/base/test/"));
    assertFalse(route.match("/base/test/123/"));
   
    Map<String, String> vars = route.parse("/base/test/");
    assertEquals("test", vars.get("collection"));
  }
View Full Code Here

  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

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.