public void testBuildFromMapTest5() throws Exception
{
StringBuffer sb = new StringBuffer();
boolean pass = true;
URI uri;
UriBuilder ub;
Map maps = new HashMap();
maps.put("x", "x%yz");
maps.put("y", "/path-absolute/test1");
maps.put("z", "fred@example.com");
maps.put("w", "path-rootless/test2");
Map maps1 = new HashMap();
maps1.put("x", "x%20yz");
maps1.put("y", "/path-absolute/test1");
maps1.put("z", "fred@example.com");
maps1.put("w", "path-rootless/test2");
Map maps2 = new HashMap();
maps2.put("x", "x%yz");
maps2.put("y", "/path-absolute/test1");
maps2.put("z", "fred@example.com");
maps2.put("w", "path-rootless/test2");
maps2.put("v", "xyz");
String expected_path =
"path-rootless/test2/x%25yz//path-absolute/test1/fred@example.com/x%25yz";
String expected_path_1 =
"path-rootless/test2/x%2520yz//path-absolute/test1/fred@example.com/x%2520yz";
String expected_path_2 =
"path-rootless/test2/x%25yz//path-absolute/test1/fred@example.com/x%25yz";
try
{
ub = UriBuilder.fromPath("").path("{w}/{x}/{y}/{z}/{x}");
uri = ub.buildFromMap(maps);
if (uri.getRawPath().compareToIgnoreCase(expected_path) != 0)
{
pass = false;
sb.append("Test failed for expected path: " + expected_path +
" Got " + uri.getRawPath() + " instead" + "\n");
}
else
{
sb.append("Got expected path: " + uri.getRawPath() + "\n");
}
uri = ub.buildFromMap(maps1);
if (uri.getRawPath().compareToIgnoreCase(expected_path_1) != 0)
{
pass = false;
sb.append("Test failed for expected path: " + expected_path_1 +
" Got " + uri.getRawPath() + " instead" + "\n");
}
else
{
sb.append("Got expected path: " + uri.getRawPath() + "\n");
}
uri = ub.buildFromMap(maps2);
if (uri.getRawPath().compareToIgnoreCase(expected_path_2) != 0)
{
pass = false;
sb.append("Test failed for expected path: " + expected_path_2 +