Package org.apache.cocoon.sitemap.node

Examples of org.apache.cocoon.sitemap.node.MatchNode$MatcherContext


public class MatchNodeTest {

    @Test
    public void endsWithMatchingAttribute() throws Exception {
        MatchNode matchNode = new MatchNode();
        PrivateAccessor.setField(matchNode, "endsWith", ".xml");
        MatcherContext matcherContext = matchNode.lookupMatcherContext();
        Map<String, String> matches = matcherContext.match("abc.xml");
        assertTrue(matches.containsValue("abc.xml"));
        assertTrue(matches.containsValue("abc"));
        assertEquals(2, matches.size());
    }
View Full Code Here


        assertEquals(2, matches.size());
    }

    @Test
    public void startsWithMatchingAttribute() throws Exception {
        MatchNode matchNode = new MatchNode();
        PrivateAccessor.setField(matchNode, "startsWith", "abc");
        MatcherContext matcherContext = matchNode.lookupMatcherContext();
        Map<String, String> matches = matcherContext.match("abc/44");
        assertTrue(matches.containsValue("abc/44"));
        assertTrue(matches.containsValue("/44"));
        assertEquals(2, matches.size());
    }
View Full Code Here

        assertEquals(2, matches.size());
    }

    @Test
    public void regexpMatchingAttribute() throws Exception {
        MatchNode matchNode = new MatchNode();
        PrivateAccessor.setField(matchNode, "regexp", "([a-zA-Z\\-]+)/(.*)");
        MatcherContext matcherContext = matchNode.lookupMatcherContext();
        Map<String, String> matches = matcherContext.match("abc/44");
        assertTrue(matches.containsValue("abc/44"));
        assertTrue(matches.containsValue("abc"));
        assertTrue(matches.containsValue("44"));
        assertEquals(3, matches.size());
View Full Code Here

        assertEquals(3, matches.size());
    }

    @Test
    public void regexpMatchingAttributeWithSlash() throws Exception {
        MatchNode matchNode = new MatchNode();
        PrivateAccessor.setField(matchNode, "regexp", "([a-zA-Z\\-]+)/(.*)");
        MatcherContext matcherContext = matchNode.lookupMatcherContext();
        Map<String, String> matches = matcherContext.match("abc/44");
        assertTrue(matches.containsValue("abc/44"));
        assertTrue(matches.containsValue("abc"));
        assertTrue(matches.containsValue("44"));
        assertEquals(3, matches.size());
View Full Code Here

        assertEquals(3, matches.size());
    }

    @Test
    public void containsMatchingAttribute() throws Exception {
        MatchNode matchNode = new MatchNode();
        PrivateAccessor.setField(matchNode, "contains", "123");
        MatcherContext matcherContext = matchNode.lookupMatcherContext();
        Map<String, String> matches = matcherContext.match("000123456");
        assertTrue(matches.containsValue("000123456"));
        assertEquals(1, matches.size());
    }
View Full Code Here

        assertEquals(1, matches.size());
    }

    @Test
    public void equalsMatchingAttribute() throws Exception {
        MatchNode matchNode = new MatchNode();
        PrivateAccessor.setField(matchNode, "equals", "123");
        MatcherContext matcherContext = matchNode.lookupMatcherContext();
        Map<String, String> matches = matcherContext.match("123");
        assertTrue(matches.containsValue("123"));
        assertEquals(1, matches.size());
    }
View Full Code Here

        assertEquals(1, matches.size());
    }

    @Test
    public void wildcardMatchingPathAttribute() throws Exception {
        MatchNode matchNode = new MatchNode();
        PrivateAccessor.setField(matchNode, "wildcard", "abc/*/*");
        MatcherContext matcherContext = matchNode.lookupMatcherContext();
        Map<String, String> matches = matcherContext.match("abc/def/ghi");
        assertTrue(matches.containsValue("abc/def/ghi"));
        assertTrue(matches.containsValue("def"));
        assertTrue(matches.containsValue("ghi"));
        assertEquals(3, matches.size());
View Full Code Here

        assertEquals(3, matches.size());
    }

    @Test
    public void wildcardMatchingPathAttributeWithSlash() throws Exception {
        MatchNode matchNode = new MatchNode();
        PrivateAccessor.setField(matchNode, "wildcard", "abc/*/*");
        MatcherContext matcherContext = matchNode.lookupMatcherContext();
        Map<String, String> matches = matcherContext.match("abc/def/ghi");
        assertTrue(matches.containsValue("abc/def/ghi"));
        assertTrue(matches.containsValue("def"));
        assertTrue(matches.containsValue("ghi"));
        assertEquals(3, matches.size());
View Full Code Here

        assertEquals(3, matches.size());
    }

    @Test
    public void noMatchingAttribute() {
        MatchNode matchNode = new MatchNode();
        MatcherContext matcherContext = matchNode.lookupMatcherContext();
        assertNull("If there is no match attribute, no matcher can be found.", matcherContext);
    }
View Full Code Here

        assertNull("If there is no match attribute, no matcher can be found.", matcherContext);
    }

    @Test
    public void moreThanOneMatchingAttribute() throws Exception {
        MatchNode matchNode = new MatchNode();
        PrivateAccessor.setField(matchNode, "pattern", "123");
        PrivateAccessor.setField(matchNode, "equals", "123");
        try {
            matchNode.lookupMatcherContext();
            fail();
        } catch (Exception e) {
            // expected
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.sitemap.node.MatchNode$MatcherContext

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.