Package org.apache.abdera.i18n.templates

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


    @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

        assertEquals("2", vars.get("entry"));
    }

    @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("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("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

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.