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

Examples of org.apache.wink.common.internal.uritemplate.JaxRsUriTemplateProcessor


                                  host,
                                  port,
                                  constructedPath,
                                  constructedQuery,
                                  fragment);
        JaxRsUriTemplateProcessor uriTemplate = new JaxRsUriTemplateProcessor(uriStr);
        return uriTemplate.getVariableNames();
    }
View Full Code Here


                                  host,
                                  port,
                                  constructedPath,
                                  constructedQuery,
                                  fragment);
        JaxRsUriTemplateProcessor uriTemplate = new JaxRsUriTemplateProcessor(uriStr);
        Set<String> ret = uriTemplate.getVariableNames();
        logger.debug("getVariableNamesList() returning {}", ret); //$NON-NLS-1$
        return ret;
    }
View Full Code Here

                                  host,
                                  port,
                                  constructedPath,
                                  constructedQuery,
                                  fragment);
        JaxRsUriTemplateProcessor uriTemplate = new JaxRsUriTemplateProcessor(uriStr);
        Set<String> ret = uriTemplate.getVariableNames();
        logger.trace("getVariableNamesList() returning {}", ret); //$NON-NLS-1$
        return ret;
    }
View Full Code Here

        }
    }

    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");
        assertTrue(matches);
View Full Code Here

        matches = matcher.matches("/path1/value1/path2c/tailZ");
        assertFalse(matches);
    }

    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));
        assertEquals("abab", matcher.getVariableValue("var2"));
        assertEquals("abab", matcher.getVariableValue("var2", false));
        assertNull(matcher.getVariableValue("var3"));

        // variable values as list
        List<String> varValues = matcher.getVariableValues("var1");
        assertEquals(2, varValues.size());
        assertEquals("value a", varValues.get(0));
        assertEquals("valueB", varValues.get(1));
        varValues = matcher.getVariableValues("var1", false);
        assertEquals(2, varValues.size());
        assertEquals("value%20a", varValues.get(0));
        assertEquals("valueB", varValues.get(1));
        varValues = matcher.getVariableValues("var2");
        assertEquals(1, varValues.size());
        assertEquals("abab", varValues.get(0));

        // variable names set
        Set<String> variableNames = processor.getVariableNames();
        assertEquals(2, variableNames.size());
        assertTrue(variableNames.contains("var1"));
        assertTrue(variableNames.contains("var2"));

        // get all variables
View Full Code Here

        assertEquals(1, varValues.size());
        assertEquals("abab", varValues.get(0));
    }

    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

        tail = matcher.getTail();
        assertEquals("", tail);
    }

    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

        head = matcher.getHead();
        assertEquals("/path1/value a/path2abab/valueB", head);
    }

    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

        assertEquals("value%20a", varValues.get(0));
        assertEquals("abab", varValues.get(1));
    }

    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

        matches = matcher.matches("/path1/cc/bb/path2/dd/tail");
        assertFalse(matches);
    }

    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);
        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>();
        values.add("var1", "xyz");
        expanded = processor.expand(values);
        assertEquals("/path2/xyz", expanded);
    }
View Full Code Here

TOP

Related Classes of org.apache.wink.common.internal.uritemplate.JaxRsUriTemplateProcessor

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.