Package org.apache.wink.common.internal.uritemplate

Examples of org.apache.wink.common.internal.uritemplate.JaxRsUriTemplateProcessor.matcher()


    }

    public void testMatches() {
        String template = "/path1/{var1}/path2{var2:[ab]*}/tail";
        JaxRsUriTemplateProcessor processor = new JaxRsUriTemplateProcessor(template);
        UriTemplateMatcher matcher = processor.matcher();
        assertEquals(template, processor.getTemplate());

        boolean matches = matcher.matches("/path1/value1/path2/tail");
        assertTrue(matches);
        matches = matcher.matches("/path1/value1/path2ab/tail");
View Full Code Here


    }

    public void testGetVariables() {
        JaxRsUriTemplateProcessor processor =
            new JaxRsUriTemplateProcessor("/path1/{var1}/path2{var2:[ab]*}/{var1}");
        UriTemplateMatcher matcher = processor.matcher();
        matcher.matches("/path1/value%20a/path2abab/valueB/tail%20part");

        // variable value
        assertEquals("value a", matcher.getVariableValue("var1"));
        assertEquals("value%20a", matcher.getVariableValue("var1", false));
View Full Code Here

    }

    public void testTail() {
        JaxRsUriTemplateProcessor processor =
            new JaxRsUriTemplateProcessor("/path1/{var1}/path2{var2:[ab]*}/{var3}");
        UriTemplateMatcher matcher = processor.matcher();
        matcher.matches("/path1/value%20a/path2abab/valueB/tail%20part");

        String tail = matcher.getTail();
        assertEquals("/tail part", tail);
        assertEquals("/tail%20part", matcher.getTail(false));
View Full Code Here

    }

    public void testHead() {
        JaxRsUriTemplateProcessor processor =
            new JaxRsUriTemplateProcessor("/path1/{var1}/path2{var2:[ab]*}/{var3}");
        UriTemplateMatcher matcher = processor.matcher();
        matcher.matches("/path1/value%20a/path2abab/valueB/tail%20part");

        String head = matcher.getHead();
        assertEquals("/path1/value a/path2abab/valueB", head);
        assertEquals("/path1/value%20a/path2abab/valueB", matcher.getHead(false));
View Full Code Here

    }

    public void testSameVariableTwice() {
        JaxRsUriTemplateProcessor processor =
            new JaxRsUriTemplateProcessor("/path1/{var1}/path2{var1:[ab]*}/tail");
        UriTemplateMatcher matcher = processor.matcher();
        boolean matches = matcher.matches("/path1/value%20a/path2abab/tail");
        assertTrue(matches);
        assertEquals("value a", matcher.getVariableValue("var1"));
        assertEquals("value%20a", matcher.getVariableValue("var1", false));

View Full Code Here

    }

    public void testTemplateWithCapturingGroupsInRegex() {
        JaxRsUriTemplateProcessor processor =
            new JaxRsUriTemplateProcessor("/path1/{var1}/{var2:(a)(b)*}/path2/{var3}/tail");
        UriTemplateMatcher matcher = processor.matcher();
        boolean matches = matcher.matches("/path1/cc/abb/path2/dd/tail");
        assertTrue(matches);
        assertEquals("cc", matcher.getVariableValue("var1"));
        assertEquals("abb", matcher.getVariableValue("var2"));
        assertEquals("dd", matcher.getVariableValue("var3"));
View Full Code Here

    public void testCompileMatchExpand() {
        JaxRsUriTemplateProcessor processor = new JaxRsUriTemplateProcessor();
        // 1
        processor.compile("/path1/{var1}");
        UriTemplateMatcher matcher = processor.matcher();
        boolean matches = matcher.matches("/path1/abc");
        assertTrue(matches);
        MultivaluedMap<String, String> values = new MultivaluedMapImpl<String, String>();
        values.add("var1", "xyz");
        String expanded = processor.expand(values);
View Full Code Here

        String expanded = processor.expand(values);
        assertEquals("/path1/xyz", expanded);

        // 2
        processor.compile("/path2/{var1}");
        matcher = processor.matcher();
        matches = matcher.matches("/path1/abc");
        assertFalse(matches);
        matches = matcher.matches("/path2/abc");
        assertTrue(matches);
        values = new MultivaluedMapImpl<String, String>();
View Full Code Here

        JaxRsUriTemplateProcessor processor = new JaxRsUriTemplateProcessor();
        assertNull(processor.getTemplate());

        // not yet compiled
        try {
            processor.matcher();
            fail("expected IllegalStateException to be thrown");
        } catch (IllegalStateException e) {
        }

        try {
View Full Code Here

        } catch (IllegalStateException e) {
        }

        // compiled but not matched
        processor.compile("/path1/{var1}");
        UriTemplateMatcher matcher = processor.matcher();
        assertFalse(matcher.matches("/path2"));

        try {
            matcher.getVariables(false);
            fail("expected IllegalStateException to be thrown");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.