Examples of JaxRsUriTemplateProcessor


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

        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

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

        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

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

        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

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

        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

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

        assertTrue(matcher.isExactMatch());

    }

    public void testIllegalStates() {
        JaxRsUriTemplateProcessor processor = new JaxRsUriTemplateProcessor();
        assertNull(processor.getTemplate());

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

        try {
            processor.expand(new MultivaluedMapImpl<String, String>());
            fail("expected IllegalStateException to be thrown");
        } catch (IllegalStateException e) {
        }

        try {
            processor.getPatternString();
            fail("expected IllegalStateException to be thrown");
        } catch (IllegalStateException e) {
        }

        try {
            processor.getVariableNames();
            fail("expected IllegalStateException to be thrown");
        } 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

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

        }
    }

    public void testBadUserRegex() {
        try {
            new JaxRsUriTemplateProcessor("path/{var:?.*}");
            fail("expected PatternSyntaxException to be thrown");
        } catch (PatternSyntaxException e) {
        }
    }
View Full Code Here

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

        }
    }

    public void testBadTemplateForm() {
        try {
            new JaxRsUriTemplateProcessor("/path{/{var:?.*}");
            fail("expected IllegalArgumentException to be thrown");
        } catch (IllegalArgumentException e) {
        }

        try {
            new JaxRsUriTemplateProcessor("/path{}/{var:?.*}");
            fail("expected IllegalArgumentException to be thrown");
        } catch (IllegalArgumentException e) {
        }
    }
View Full Code Here

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

        } catch (IllegalArgumentException e) {
        }
    }

    public void testCompareTo() {
        JaxRsUriTemplateProcessor p1 = new JaxRsUriTemplateProcessor();
        JaxRsUriTemplateProcessor p2 = new JaxRsUriTemplateProcessor();

        p1.compile("/path1/path2");
        p2.compile("/path1/path2");
        assertTrue(p1.compareTo(p2) == 0);

        p1.compile("/path2/path1");
        p2.compile("/path1/path2");
        assertTrue(p1.compareTo(p2) == 0);

        p1.compile("/path1/path2/path3");
        p2.compile("/path1/path2");
        assertTrue(p1.compareTo(p2) > 0);

        p1.compile("/path1/path2");
        p2.compile("/path1/path2/path3");
        assertTrue(p1.compareTo(p2) < 0);

        p1.compile("/path1/path2/{var1}");
        p2.compile("/path1/path2/{var1}");
        assertTrue(p1.compareTo(p2) == 0);

        p1.compile("/path1/path2/{var1}");
        p2.compile("/path1/path2/{variable1}");
        assertTrue(p1.compareTo(p2) == 0);

        p1.compile("/path1/path2/{var1}");
        p2.compile("/path1/{variable1}/path2");
        assertTrue(p1.compareTo(p2) == 0);

        p1.compile("/path1/path2/path3/{var1}");
        p2.compile("/path1/path2/{var1}");
        assertTrue(p1.compareTo(p2) > 0);

        p1.compile("/path1/path2/{var1}");
        p2.compile("/path1/path2/path3/{var1}");
        assertTrue(p1.compareTo(p2) < 0);

        p1.compile("/path1/path2/{var1}/{var2}");
        p2.compile("/path1/path2/{var1}");
        assertTrue(p1.compareTo(p2) > 0);

        p1.compile("/path1/path2/{var1}");
        p2.compile("/path1/path2/{var1}/{var2}");
        assertTrue(p1.compareTo(p2) < 0);

        p1.compile("/path1/path2/path3/{var1}");
        p2.compile("/path1/path2/{var1}/{var2}");
        assertTrue(p1.compareTo(p2) > 0);

        p1.compile("/path1/path2/{var1}/{var2}");
        p2.compile("/path1/path2/path3/{var1}");
        assertTrue(p1.compareTo(p2) < 0);

        p1.compile("/path1/path2/{var1}/{var2:.*}");
        p2.compile("/path1/path2/{var1}/{var2:.*}");
        assertTrue(p1.compareTo(p2) == 0);

        p1.compile("/path1/path2/{var1}/{var2:.*}");
        p2.compile("/path1/path2/{var1}/{var2}");
        assertTrue(p1.compareTo(p2) > 0);

        p1.compile("/path1/path2/{var1}/{var2}");
        p2.compile("/path1/path2/{var1}/{var2:.*}");
        assertTrue(p1.compareTo(p2) < 0);

        p1.compile("/path1/path2/{var1:.*}/{var2}");
        p2.compile("/path1/path2/{var1}/{var2:.*}");
        assertTrue(p1.compareTo(p2) == 0);
    }
View Full Code Here

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

                                  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

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

                                  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
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.