Package org.jboss.resteasy.client.jaxrs

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


   }

   @Test
   public void testPutStream() throws Exception
   {
      ResteasyClient client = new ResteasyClientBuilder().build();
      WebTarget target = client.target(TestPortProvider.generateURL("/stream"));
      Response res = target.request().header("Content-Encoding", "gzip").put(Entity.text("hello world"));
      Assert.assertEquals(204, res.getStatus());
      client.close();
   }
View Full Code Here


   }

   @Test
   public void testPutText() throws Exception
   {
      ResteasyClient client = new ResteasyClientBuilder().build();
      WebTarget target = client.target(TestPortProvider.generateURL("/text"));
      Response res = target.request().header("Content-Encoding", "gzip").put(Entity.text("hello world"));
      Assert.assertEquals(204, res.getStatus());
      client.close();
   }
View Full Code Here

   }

   @Test
   public void testRequest() throws Exception
   {
      ResteasyClient client = new ResteasyClientBuilder().build();
      WebTarget target = client.target(TestPortProvider.generateURL("/text"));
      String val = target.request().get(String.class);
      Assert.assertEquals("HELLO WORLD", val);
      client.close();

   }
View Full Code Here

   public void test6() throws Exception
   {

      String[] Headers = {"list=abcdef"};//, "list=fedcba"};

      ResteasyClient client = new ResteasyClientBuilder().build();
      for (String header : Headers)
      {
         Invocation.Builder request = client.target(TestPortProvider.generateURL("/PathParamTest/a/b/c/d/e/f")).request();
         request.header("Accept", "text/plain");
         Response response = request.get();
         Assert.assertEquals(200, response.getStatus());
         Assert.assertEquals(header, response.readEntity(String.class));
      }
      client.close();
   }
View Full Code Here

   }

   @Test
   public void test178() throws Exception
   {
      ResteasyClient client = new ResteasyClientBuilder().build();
      {
         Invocation.Builder request = client.target(TestPortProvider.generateURL("/digits/5150")).request();
         Response response = request.get();
         Assert.assertEquals(200, response.getStatus());
         response.close();
      }
     
      {
         Invocation.Builder request = client.target(TestPortProvider.generateURL("/digits/5150A")).request();
         Response response = request.get();
         Assert.assertEquals(404, response.getStatus());
         response.close();
      }
      client.close();
   }
View Full Code Here

   }

   @Test
   public void testRequest2() throws Exception
   {
      ResteasyClient client = new ResteasyClientBuilder().build();
      WebTarget target = client.target(TestPortProvider.generateURL("/encoded/text"));
      Response response = target.request().get();
      Assert.assertEquals("HELLO WORLD", response.readEntity(String.class));
      client.close();

   }
View Full Code Here

   }

   @Test
   public void testCarResource() throws Exception
   {
      ResteasyClient client = new ResteasyClientBuilder().build();
      System.out.println("**** Via @MatrixParam ***");
      Invocation.Builder request = client.target(TestPortProvider.generateURL("/cars/mercedes/matrixparam/e55;color=black/2006")).request();
      Response response = request.get();
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals("A black 2006 mercedes e55", response.readEntity(String.class));
      // This must be a typo.  Should be "A midnight blue 2006 Porsche 911 Carrera S".

      System.out.println("**** Via PathSegment ***");
      request = client.target(TestPortProvider.generateURL("/cars/mercedes/pathsegment/e55;color=black/2006")).request();
      response = request.get();
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals("A black 2006 mercedes e55", response.readEntity(String.class));

      System.out.println("**** Via PathSegments ***");
      request = client.target(TestPortProvider.generateURL("/cars/mercedes/pathsegments/e55/amg/year/2006")).request();
      response = request.get();
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals("A 2006 mercedes e55 amg", response.readEntity(String.class));

      System.out.println("**** Via PathSegment ***");
      request = client.target(TestPortProvider.generateURL("/cars/mercedes/uriinfo/e55;color=black/2006")).request();
      response = request.get();
      Assert.assertEquals(200, response.getStatus());
      Assert.assertEquals("A black 2006 mercedes e55", response.readEntity(String.class));
      client.close();
   }
View Full Code Here

   }

    @Test
    public void test() throws Exception
    {
       ResteasyClient client = new ResteasyClientBuilder().build();
        WebTarget target = client.target("http://localhost:8081/test/one/");
        System.out.println("Sending request");
        Response response = target.request().get();
       String entity = response.readEntity(String.class);
       System.out.println("Received response: " + entity);
        Assert.assertEquals(200, response.getStatus());
        Assert.assertTrue("Type property is missing.", entity.contains("type"));
       response.close();

       target = client.target("http://localhost:8081/test/list/");
        System.out.println("Sending request");
        response = target.request().get();
        entity = response.readEntity(String.class);
       System.out.println("Received response: " + entity);
        Assert.assertEquals(200, response.getStatus());
        Assert.assertTrue("Type property is missing.", entity.contains("type"));
       response.close();
       client.close();
    }
View Full Code Here

      clearCache();
      startDeployment();
      init();
      stopDeployment();
      startDeployment();
      ResteasyClient client = new ResteasyClientBuilder().build();
      WebTarget target = client.target(generateBaseUrl());
      SkeletonKeyAdminClient admin = new SkeletonKeyClientBuilder().username("wburke").password("geheim").idp(target).admin();

      StoredUser newUser = new StoredUser();
      newUser.setName("John Smith");
      newUser.setUsername("jsmith");
      newUser.setEnabled(true);
      Map creds = new HashMap();
      creds.put("password", "foobar");
      newUser.setCredentials(creds);
      Response response = admin.users().create(newUser);
      User user = response.readEntity(User.class);
      response = admin.roles().create("user");
      Role role = response.readEntity(Role.class);
      Projects projects = admin.projects().query("Skeleton Key");
      Project project = projects.getList().get(0);
      admin.projects().addUserRole(project.getId(), user.getId(), role.getId());

      admin = new SkeletonKeyClientBuilder().username("jsmith").password("foobar").idp(target).admin();
      response = admin.roles().create("error");
      Assert.assertEquals(403, response.getStatus());
      client.close();
      stopDeployment();
   }
View Full Code Here

      stopDeployment();
      startDeployment();
      Assert.assertTrue(0 < app.getCache().size());


      ResteasyClient client = new ResteasyClientBuilder().build();
      WebTarget target = client.target(generateBaseUrl());
      SkeletonKeyAdminClient admin = new SkeletonKeyClientBuilder().username("wburke").password("geheim").idp(target).admin();

      StoredUser newUser = new StoredUser();
      newUser.setName("John Smith");
      newUser.setUsername("jsmith");
      newUser.setEnabled(true);
      Map creds = new HashMap();
      creds.put("password", "foobar");
      newUser.setCredentials(creds);
      Response response = admin.users().create(newUser);
      User user = response.readEntity(User.class);
      response = admin.roles().create("user");
      Role role = response.readEntity(Role.class);
      String json = target.path("projects").queryParam("name", "Skeleton Key").request().get(String.class);
      Projects projects = admin.projects().query("Skeleton Key");
      Project project = projects.getList().get(0);
      admin.projects().addUserRole(project.getId(), user.getId(), role.getId());

      admin = new SkeletonKeyClientBuilder().username("jsmith").password("foobar").idp(target).admin();
      response = admin.roles().create("error");
      Assert.assertEquals(403, response.getStatus());
      client.close();
      stopDeployment();
   }
View Full Code Here

TOP

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

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.