Package org.apache.cocoon.sitemap.matcher

Examples of org.apache.cocoon.sitemap.matcher.WildcardMatcher


public class WildcardMatcherTest {

    @Test
    public void testMatcher() {
        WildcardMatcher matcher = new WildcardMatcher();
        Map<String, String> result = matcher.match("*/{name}/**/{id}", "abc/def/ghi/jkl/5");
        Assert.assertEquals("A parameter 'name' is expected.", "def", result.get("name"));
        Assert.assertEquals("A parameter 'id' is expected.", "5", result.get("id"));
        Assert.assertEquals("A result value '1' is expected.", "abc", result.get("1"));
        Assert.assertEquals("A result value '2' is expected.", "def", result.get("2"));
        Assert.assertEquals("A result value '3' is expected.", "ghi/jkl", result.get("3"));
View Full Code Here


        Assert.assertEquals("A result value '0' is expected.", "abc/def/ghi/jkl/5", result.get("0"));
    }

    @Test
    public void testMatcherWithoutParamters() {
        WildcardMatcher matcher = new WildcardMatcher();
        Map<String, String> result = matcher.match("*/**", "abc/def/ghi/jkl/5");
        Assert.assertEquals("A result value '1' is expected.", "abc", result.get("1"));
        Assert.assertEquals("A result value '2' is expected.", "def/ghi/jkl/5", result.get("2"));
        Assert.assertEquals("A result value '0' is expected.", "abc/def/ghi/jkl/5", result.get("0"));
    }
View Full Code Here

        Assert.assertEquals("A result value '0' is expected.", "abc/def/ghi/jkl/5", result.get("0"));
    }

    @Test
    public void testMatcherWithoutWildcards() {
        WildcardMatcher matcher = new WildcardMatcher();
        Map<String, String> result = matcher.match("abc", "abc");
        Assert.assertNull("No matching result", result.get("1"));
        Assert.assertEquals("A result value '0' is expected.", "abc", result.get("0"));
    }
View Full Code Here

    }

    @Test
    public void testWrongNamedParameters() {
        try {
            new WildcardMatcher().match("*/{name}{id}", "abc/def/ghi");
            Assert.fail("}{ is not allowed without some character in between "
                    + "because this would be translated into a '**' which has a different meaning");
        } catch (UnsupportedNamedWildcardExpressionException e) {
            // expected
        }
View Full Code Here

     */
    protected MatcherContext lookupMatcherContext() {
        // determine the matching type and check if there are conflicting match attributes
        LinkedList<MatcherContext> matcherContextList = new LinkedList<MatcherContext>();
        if (this.pattern != null) {
            matcherContextList.add(new MatcherContext(new WildcardMatcher(), this.pattern));
        }
        if (this.regexp != null) {
            matcherContextList.add(new MatcherContext(new RegexpMatcher(), this.regexp));
        }
        if (this.equals != null) {
            matcherContextList.add(new MatcherContext(new EqualsMatcher(), this.equals));
        }
        if (this.contains != null) {
            matcherContextList.add(new MatcherContext(new ContainsMatcher(), this.contains));
        }
        if (this.wildcard != null) {
            matcherContextList.add(new MatcherContext(new WildcardMatcher(), this.wildcard));
        }
        if (this.startsWith != null) {
            matcherContextList.add(new MatcherContext(new StartsWithMatcher(), this.startsWith));
        }
        if (this.endsWith != null) {
View Full Code Here

     */
    protected MatcherContext lookupMatcherContext() {
        // determine the matching type and check if there are conflicting match attributes
        LinkedList<MatcherContext> matcherContextList = new LinkedList<MatcherContext>();
        if (this.pattern != null) {
            matcherContextList.add(new MatcherContext(new WildcardMatcher(), this.pattern));
        }
        if (this.regexp != null) {
            matcherContextList.add(new MatcherContext(new RegexpMatcher(), this.regexp));
        }
        if (this.equals != null) {
            matcherContextList.add(new MatcherContext(new EqualsMatcher(), this.equals));
        }
        if (this.contains != null) {
            matcherContextList.add(new MatcherContext(new ContainsMatcher(), this.contains));
        }
        if (this.wildcard != null) {
            matcherContextList.add(new MatcherContext(new WildcardMatcher(), this.wildcard));
        }
        if (this.startsWith != null) {
            matcherContextList.add(new MatcherContext(new StartsWithMatcher(), this.startsWith));
        }
        if (this.endsWith != null) {
View Full Code Here

TOP

Related Classes of org.apache.cocoon.sitemap.matcher.WildcardMatcher

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.