Package org.apache.abdera.i18n.templates

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


        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


        Map<String, String> requirements = new HashMap<String, String>() {
            {
                put("entry", "\\d+");
            }
        };
        return new Route("entry", "/base/:collection/:entry", null, requirements);
    }
View Full Code Here

import org.junit.Test;

public class RouteTest {
    @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

        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

            targets.add(new RouteTargetType(route, type));
        return this;
    }

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

        return addRoute(new Route(name, pattern), type);
    }

    public RouteManager addRoute(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

    private Target getTarget(RequestContext context, Route route, String uri, TargetType type) {
        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;
    }
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

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.