Examples of UriBuilder


Examples of javax.ws.rs.core.UriBuilder

   }

   @Test
   public void testQuery()
   {
      UriBuilder builder = UriBuilder.fromPath("/foo");
      builder.queryParam("mama", "   ");
      Assert.assertEquals(builder.build().toString(), "/foo?mama=+++");
   }
View Full Code Here

Examples of javax.ws.rs.core.UriBuilder

   }

   @Test
   public void testQuery2()
   {
      UriBuilder builder = UriBuilder.fromUri("http://localhost/test");
      builder.replaceQuery("a={b}");
      URI uri = builder.build("=");
      Assert.assertEquals(uri.toString(), "http://localhost/test?a=%3D");
   }
View Full Code Here

Examples of javax.ws.rs.core.UriBuilder

   public void testReplaceMatrixParam()
   {
      URI bu = UriBuilder.fromUri("http://localhost:8080/a/b/c;a=x;b=y").
              replaceMatrix("x=a;y=b").build();
      Assert.assertEquals(URI.create("http://localhost:8080/a/b/c;x=a;y=b"), bu);
      UriBuilder builder = UriBuilder.fromUri("http://localhost:8080/a").path("/{b:A{0:10}}/c;a=x;b=y");
      builder.replaceMatrixParam("a", "1", "2");
      bu = builder.build("b");
      Assert.assertEquals(URI.create("http://localhost:8080/a/b/c;b=y;a=1;a=2"), bu);
   }
View Full Code Here

Examples of javax.ws.rs.core.UriBuilder

   {
      URI bu = UriBuilder.fromUri("http://localhost:8080/a/b/c?a=x&b=y").
              replaceQuery("x=a&y=b").build();
      Assert.assertEquals(URI.create("http://localhost:8080/a/b/c?x=a&y=b"), bu);

      UriBuilder builder = UriBuilder.fromUri("http://localhost:8080/a/b/c?a=x&b=y");
      builder.replaceQueryParam("a", "1", "2");
      bu = builder.build();
      Assert.assertEquals(URI.create("http://localhost:8080/a/b/c?b=y&a=1&a=2"), bu);

   }
View Full Code Here

Examples of javax.ws.rs.core.UriBuilder

   }

   @Test
   public void testClone()
   {
      UriBuilder ub = UriBuilder.fromUri("http://user@localhost:8080/?query#fragment").path("a");
      URI full = ub.clone().path("b").build();
      URI base = ub.build();

      Assert.assertEquals(URI.create("http://user@localhost:8080/a?query#fragment"), base);
      Assert.assertEquals(URI.create("http://user@localhost:8080/a/b?query#fragment"), full);
   }
View Full Code Here

Examples of javax.ws.rs.core.UriBuilder

   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 +
View Full Code Here

Examples of javax.ws.rs.core.UriBuilder

           throw new RuntimeException(consumerKey + " scopes can not be registered");
       }
   }
  
   private String getCallbackURI() {
       UriBuilder ub = ui.getBaseUriBuilder();
       return ub.path(SubscriberReceiver.class).build().toString();
   }
View Full Code Here

Examples of javax.ws.rs.core.UriBuilder

        }
       
        @Override
        protected void setDefaultEntryProperties(Entry entry, List<LogRecord> rs, int entryIndex) {
            super.setDefaultEntryProperties(entry, rs, entryIndex);
            UriBuilder builder = context.getUriInfo().getAbsolutePathBuilder().path("entry");
            Integer realIndex = page == 1 ? entryIndex : page * pageSize + entryIndex;

            entry.addLink(builder.clone().path(realIndex.toString()).build().toString(), "self");
            entry.addLink(builder.path("alternate").path(realIndex.toString()).build().toString(),
                          "alternate");
        }
View Full Code Here

Examples of javax.ws.rs.core.UriBuilder

        return callback;
    }
   
    private URI buildCallbackURI(String callback, final Map<String, String> queryParams) {

        UriBuilder builder = UriBuilder.fromUri(callback);
        for (Map.Entry<String, String> entry : queryParams.entrySet()) {
            builder.queryParam(entry.getKey(), entry.getValue());
        }

        return builder.build();
    }
View Full Code Here

Examples of javax.ws.rs.core.UriBuilder

    public Response createCategory(Category category) {
        User user = userService.getAuthenticatedUser();

        org.apache.rave.model.Category newCategory = categoryService.create(category.getText(), user);

        UriBuilder builder = UriBuilder.fromResource(CategoriesResource.class).path("/{id}");
        return Response.created(builder.build(newCategory.getId())).entity(new Category(newCategory)).build();
    }
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.