Package javax.ws.rs.core

Examples of javax.ws.rs.core.UriBuilder.resolveTemplate()


    public void resolveTemplatesTest() {
        final UriBuilder uriBuilder = UriBuilder.fromPath("http://localhost:8080").path("{a}").path
                ("{b}").queryParam("query", "{q}");

        uriBuilder.resolveTemplate("a", "param-a");
        uriBuilder.resolveTemplate("q", "param-q");
        Map<String, Object> buildMap = new HashMap<String, Object>();
        buildMap.put("a", "ignored-a");
        buildMap.put("b", "param-b");
        buildMap.put("q", "ignored-q");
        Assert.assertEquals(URI.create("http://localhost:8080/param-a/param-b?query=param-q"), uriBuilder.buildFromMap(buildMap));
View Full Code Here


                ("{b}").queryParam("query", "{q}");
        Map<String, Object> resolveMap = new HashMap<String, Object>();
        resolveMap.put("a", "param-a/withSlash");
        resolveMap.put("q", "param-q");
        uriBuilder.resolveTemplates(resolveMap, false);
        uriBuilder.resolveTemplate("b", "param-b/withEncodedSlash", true);
        Assert.assertEquals(URI.create("http://localhost:8080/param-a/withSlash/param-b%2FwithEncodedSlash?query=param-q"),
                uriBuilder.build());
        uriBuilder.build();
    }
View Full Code Here

   public void testTemplate() throws Exception
   {
      UriBuilder builder = UriBuilder.fromUri("http://{host}/x/y/{path}?{q}={qval}");
      String template = builder.toTemplate();
      Assert.assertEquals(template, "http://{host}/x/y/{path}?{q}={qval}");
      builder = builder.resolveTemplate("host", "localhost");
      template = builder.toTemplate();
      Assert.assertEquals(template, "http://localhost/x/y/{path}?{q}={qval}");

      builder = builder.resolveTemplate("q", "name");
      template = builder.toTemplate();
View Full Code Here

      Assert.assertEquals(template, "http://{host}/x/y/{path}?{q}={qval}");
      builder = builder.resolveTemplate("host", "localhost");
      template = builder.toTemplate();
      Assert.assertEquals(template, "http://localhost/x/y/{path}?{q}={qval}");

      builder = builder.resolveTemplate("q", "name");
      template = builder.toTemplate();
      Assert.assertEquals(template, "http://localhost/x/y/{path}?name={qval}");
      Map<String, Object> values = new HashMap<String, Object>();
      values.put("path", "z");
      values.put("qval", new Integer(42));
View Full Code Here

   @Test
   public void testPercentage() throws Exception
   {
      UriBuilder path = UriBuilder.fromUri(URL).path("{path}");
      String template = path.resolveTemplate("path", ENCODED, false).toTemplate();
      System.out.println(template);
   }

   private static final String ENCODED_EXPECTED_PATH = "path-rootless%2Ftest2/x%25yz/%2Fpath-absolute%2F%2525test1/fred@example.com/x%25yz";
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.