Package org.apache.abdera.i18n.templates

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


    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 void testUrlForEmptyContext() throws Exception {
    runTestUrlFor("/app/base/", null);
  }
 
  private void runTestUrlFor(String expected, Map<String, String> context) {
    RouteManager manager = new RouteManager().addRoute(new Route("entry", "/base/:entry"));

    RequestContext request = createMock(RequestContext.class);
    expect(request.getContextPath()).andReturn("/app");
    replay(request);
View Full Code Here

  }
 
  @Test
  public void testStaticResolve() throws Exception {
    RouteManager manager = new RouteManager();
    manager.addRoute(new Route("collection", "/:coll"), TargetType.TYPE_COLLECTION)
      .addRoute(new Route("openSearch", "/openSearch.xml"), TargetType.TYPE_ENTRY);
   
    RequestContext request = createMock(RequestContext.class);
      expect(request.getTargetPath()).andReturn("/openSearch.xml");
      replay(request);
     
View Full Code Here

      assertEquals("/openSearch.xml", target.getRoute().getPattern());
  }
 
  @Test 
  public void testRouteRequirementsMatches() {   
    Route route = getRouteWithRequirements();
    assertTrue(route.match("/base/collection/1234"));
  }
View Full Code Here

    assertTrue(route.match("/base/collection/1234"));
  }
   
  @Test 
  public void testRouteRequirementsNotMatch() throws Exception {
    Route route = getRouteWithRequirements();
    assertFalse(route.match("/base/collection/entry"));
  }
View Full Code Here

  @SuppressWarnings("serial")
  private Route getRouteWithRequirements() {
    Map<String, String> requirements = new HashMap<String, String>() {{
      put("entry", "\\d+");
    }};
    return new Route("entry", "/base/:collection/:entry", null, requirements);
  }
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

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.