@SmallTest
 public void testExpandVarArgs() throws Exception {
   UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
   URI result = template.expand("1", "42");
   assertEquals(
       "Invalid expanded template", new URI("http://example.com/hotels/1/bookings/42"), result);
 }
 @SmallTest
 public void testExpandEncoded() throws Exception {
   UriTemplate template = new UriTemplate("http://example.com/hotel list/{hotel}");
   URI result = template.expand("Z\u00fcrich");
   assertEquals(
       "Invalid expanded template",
       new URI("http://example.com/hotel%20list/Z%C3%BCrich"),
       result);
 }
 @SmallTest
 public void testExpandMapEncoded() throws Exception {
   Map<String, String> uriVariables = Collections.singletonMap("hotel", "Z\u00fcrich");
   UriTemplate template = new UriTemplate("http://example.com/hotel list/{hotel}");
   URI result = template.expand(uriVariables);
   assertEquals(
       "Invalid expanded template",
       new URI("http://example.com/hotel%20list/Z%C3%BCrich"),
       result);
 }
 @SmallTest
 public void testExpandMapNonString() throws Exception {
   Map<String, Integer> uriVariables = new HashMap<String, Integer>(2);
   uriVariables.put("booking", 42);
   uriVariables.put("hotel", 1);
   UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
   URI result = template.expand(uriVariables);
   assertEquals(
       "Invalid expanded template", new URI("http://example.com/hotels/1/bookings/42"), result);
 }
 @SmallTest
 public void testExpandMapDuplicateVariables() throws Exception {
   UriTemplate template = new UriTemplate("/order/{c}/{c}/{c}");
   assertEquals(
       "Invalid variable names", Arrays.asList("c", "c", "c"), template.getVariableNames());
   URI result = template.expand(Collections.singletonMap("c", "cheeseburger"));
   assertEquals(
       "Invalid expanded template",
       new URI("/order/cheeseburger/cheeseburger/cheeseburger"),
       result);
 }
 @SmallTest
 public void testExpandVarArgsNotEnoughVariables() throws Exception {
   boolean success = false;
   try {
     UriTemplate template =
         new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
     template.expand("1");
   } catch (IllegalArgumentException e) {
     success = true;
   }
   assertTrue("expected IllegalArgumentException", success);
 }
 public void testEscapeAmpersandInRequestParameterValueForGet() {
   UriTemplate template =
       new UriTemplate("http://localhost:8080/app/{dir}/{file}?param1={param1}&param2={param2}");
   HashMap<String, String> vars = new HashMap<String, String>();
   vars.put("dir", "tmp");
   vars.put("file", "test.html");
   vars.put("param1", "foo");
   vars.put("param2", "foo&bar");
   URI uri = template.expand(vars);
   assertEquals(
       "http://localhost:8080/app/tmp/test.html?param1=foo&param2=foo%26bar", uri.toString());
 }
 @SmallTest
 public void expandMapUnboundVariables() throws Exception {
   boolean success = false;
   try {
     Map<String, String> uriVariables = new HashMap<String, String>(2);
     uriVariables.put("booking", "42");
     uriVariables.put("bar", "1");
     UriTemplate template =
         new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
     template.expand(uriVariables);
   } catch (IllegalArgumentException e) {
     success = true;
   }
   assertTrue("expected IllegalArgumentException", success);
 }
 @SmallTest
 public void testExpandWithAtSign() {
   UriTemplate template = new UriTemplate("http://localhost/query={query}");
   URI uri = template.expand("foo@bar");
   assertEquals("http://localhost/query=foo@bar", uri.toString());
 }
 @SmallTest
 public void testExpandWithDollar() {
   UriTemplate template = new UriTemplate("/{a}");
   URI uri = template.expand("$replacement");
   assertEquals("/$replacement", uri.toString());
 }