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