Package org.jboss.resteasy.client.jaxrs

Examples of org.jboss.resteasy.client.jaxrs.ResteasyWebTarget


   {     
      InputStream in = null;
      ResteasyClient client = new ResteasyClientBuilder().build();
      try
      {
         ResteasyWebTarget target = client.target(TEST_URI);
         Invocation.Builder request = target.request();
         request.header("custom-header", "42");
         Form form = new Form().param(BOOLEAN_VALUE_FIELD, "true")
                               .param(NAME_FIELD, "This is My Name")
                               .param(DOUBLE_VALUE_FIELD, "123.45")
                               .param(LONG_VALUE_FIELD, "566780")
View Full Code Here


   }

   @Test
   public void testMatrixParamRequestDecoded() throws Exception
   {
      ResteasyWebTarget target = client.target("http://localhost:8081/decoded").matrixParam("param", "ac/dc");
      Response response = target.request().get();
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals("ac/dc", response.readEntity(String.class));
      response.close();
   }
View Full Code Here

   }
  
   @Test
   public void testMatrixParamRequestEncoded() throws Exception
   {
      ResteasyWebTarget target = client.target("http://localhost:8081/encoded").matrixParam("param", "ac/dc");
      Response response = target.request().get();
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals("ac%2Fdc", response.readEntity(String.class));
      response.close();
   }
View Full Code Here

   @Test
   public void testMatrixParamUriBuilderDecoded() throws Exception
   {
      UriBuilder uriBuilder = ResteasyUriBuilder.fromUri("http://localhost:8081/decoded");
      uriBuilder.matrixParam("param", "ac/dc");
      ResteasyWebTarget target = client.target(uriBuilder.build().toString());
      System.out.println("Sending request to " + uriBuilder.build().toString());
      Response response = target.request().get();
      String entity = response.readEntity(String.class);
      System.out.println("Received response: " + entity);
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals("ac/dc", entity);
      response.close();
View Full Code Here

   @Test
   public void testMatrixParamUriBuilderEncoded() throws Exception
   {
      UriBuilder uriBuilder = ResteasyUriBuilder.fromUri("http://localhost:8081/encoded");
      uriBuilder.matrixParam("param", "ac/dc");
      ResteasyWebTarget target = client.target(uriBuilder.build().toString());
      System.out.println("Sending request to " + uriBuilder.build().toString());
      Response response = target.request().get();
      String entity = response.readEntity(String.class);
      System.out.println("Received response: " + entity);
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals("ac%2Fdc", entity);
      response.close();
View Full Code Here

   @Test
   public void testProxy() throws Exception
   {
      count = 0;
      ResteasyClient client = new ResteasyClientBuilder().build();
      ResteasyWebTarget target = client.target(generateBaseUrl());
      target.register(BrowserCacheFeature.class);

      MyProxy proxy = target.proxy(MyProxy.class);
      String rtn = null;
      rtn = proxy.get();
      Assert.assertEquals("hello world" + 1, rtn);
      Assert.assertEquals(1, count);
      rtn = proxy.get();
View Full Code Here

   @Test
   public void testMaxSize() throws Exception
   {
      ResteasyClient client = new ResteasyClientBuilder().build();
      ResteasyWebTarget target = client.target(generateBaseUrl());
      target.register(BrowserCacheFeature.class);
      LightweightBrowserCache cache = (LightweightBrowserCache)target.getConfiguration().getProperty(BrowserCache.class.getName());
      cache.setMaxBytes(20);
      MyProxy proxy = target.proxy(MyProxy.class);


      count = 0;

      String rtn = proxy.getCacheit("1");
View Full Code Here

   @Test
   public void testProxy() throws Exception
   {
      ResteasyClient client = new ResteasyClientBuilder().build();
      ResteasyWebTarget target = client.target(generateBaseUrl());
      IGZIP proxy = target.proxy(IGZIP.class);
      Assert.assertEquals("HELLO WORLD", proxy.getText());
      Assert.assertEquals("HELLO WORLD", proxy.getGzipText());

      // resteasy-651
      try
View Full Code Here

   @Test
   public void testProjects()
   {
      String newProject = "{ \"project\" : { \"name\" : \"Resteasy\", \"description\" : \"The Best of REST\", \"enabled\" : true } }";
      ResteasyClient client = new ResteasyClientBuilder().providerFactory(deployment.getProviderFactory()).build();
      ResteasyWebTarget projectsTarget = client.target(generateURL("/projects"));
      Response response = projectsTarget.request().post(Entity.json(newProject));
      Assert.assertEquals(response.getStatus(), 201);
      response.close();
      ResteasyWebTarget target = client.target(response.getLocation());
      String project = target.request().get(String.class);
      System.out.println(project);
      Project u = target.request().get(Project.class);
      System.out.println(u);
      Assert.assertEquals("Resteasy", u.getName());
      Assert.assertEquals("The Best of REST", u.getDescription());
      Assert.assertTrue(u.getEnabled());
      u.setName("Resteasy JAX-RS");
      Assert.assertEquals(target.request().put(Entity.json(u)).getStatus(), 204);
      u = target.request().get(Project.class);
      Assert.assertEquals("Resteasy JAX-RS", u.getName());
      Assert.assertEquals(target.request().delete().getStatus(), 204);
      response = target.request().get();
      Assert.assertEquals(404, response.getStatus());
      response.close();

      projectsTarget = client.target(generateURL("/projects"));
      Mappers.registerContextResolver(projectsTarget);
View Full Code Here

      String newProject = "{ \"project\" : { \"id\" : \"5\", \"name\" : \"Resteasy\", \"description\" : \"The Best of REST\", \"enabled\" : true } }";
      ResteasyClient client = new ResteasyClientBuilder().providerFactory(deployment.getProviderFactory()).build();
      Response response = client.target(generateURL("/projects")).request().post(Entity.json(newProject));
      Assert.assertEquals(response.getStatus(), 201);
      response.close();
      ResteasyWebTarget target = client.target(response.getLocation());
      String project = target.request().get(String.class);
      System.out.println(project);
      Project u = target.request().get(Project.class);
      System.out.println(u);
      Assert.assertEquals("5", u.getId());
      Assert.assertEquals("Resteasy", u.getName());
      Assert.assertEquals("The Best of REST", u.getDescription());
      Assert.assertTrue(u.getEnabled());
      u.setName("Resteasy JAX-RS");
      Assert.assertEquals(target.request().put(Entity.json(u)).getStatus(), 204);
      u = target.request().get(Project.class);
      Assert.assertEquals("Resteasy JAX-RS", u.getName());
      Assert.assertEquals(target.request().delete().getStatus(), 204);
      response = target.request().get();
      Assert.assertEquals(404, response.getStatus());
      client.close();
   }
View Full Code Here

TOP

Related Classes of org.jboss.resteasy.client.jaxrs.ResteasyWebTarget

Copyright © 2018 www.massapicom. 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.