Package org.jboss.resteasy.client.jaxrs

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


    */
   @Test
   public void testApacheHttpClient4ExecutorNonSharedHttpClientFinalize() throws Throwable
   {
      ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine();
      ResteasyClient client = new ResteasyClientBuilder().httpEngine(engine).build();
      Response response = client.target(generateURL("/test")).request().post(null);
      Assert.assertEquals(204, response.getStatus());
      engine.finalize();
      HttpClient httpClient = engine.getHttpClient();
      HttpPost post = new HttpPost(generateURL("/test"));
      try
View Full Code Here


    */
   @Test
   public void testApacheHttpClient4ExecutorNonSharedHttpClientClose() throws Throwable
   {
      ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine();
      ResteasyClient client = new ResteasyClientBuilder().httpEngine(engine).build();
      Response response = client.target(generateURL("/test")).request().post(null);
      Assert.assertEquals(204, response.getStatus());
      engine.close();
      HttpClient httpClient = engine.getHttpClient();
      HttpPost post = new HttpPost(generateURL("/test"));
      try
View Full Code Here

   @Test
   public void testApacheHttpClient4ExecutorSharedHttpClientFinalize() throws Throwable
   {
      HttpClient httpClient = new DefaultHttpClient();
      ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient);
      ResteasyClient client = new ResteasyClientBuilder().httpEngine(engine).build();
      Response response = client.target(generateURL("/test")).request().post(null);
      Assert.assertEquals(204, response.getStatus());
      engine.finalize();
      Assert.assertEquals(httpClient, engine.getHttpClient());
      HttpPost post = new HttpPost(generateURL("/test"));
      HttpResponse httpResponse = httpClient.execute(post);
View Full Code Here

   @Test
   public void testApacheHttpClient4ExecutorSharedHttpClientClose() throws Throwable
   {
      HttpClient httpClient = new DefaultHttpClient();
      ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient);
      ResteasyClient client = new ResteasyClientBuilder().httpEngine(engine).build();
      Response response = client.target(generateURL("/test")).request().post(null);
      Assert.assertEquals(204, response.getStatus());
      engine.close();
      Assert.assertEquals(httpClient, engine.getHttpClient());
      HttpPost post = new HttpPost(generateURL("/test"));
      HttpResponse httpResponse = httpClient.execute(post);
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();
      Assert.assertEquals("hello world" + 1, rtn);
      Assert.assertEquals(1, count);
      Thread.sleep(2000);
      rtn = proxy.get();
      Assert.assertEquals("hello world" + 2, rtn);
      Assert.assertEquals(2, count);
      rtn = proxy.get();
      Assert.assertEquals("hello world" + 2, rtn);
      Assert.assertEquals(2, count);

      // Test always good etag
      count = 0;
      rtn = proxy.getAlwaysGoodEtag();
      Assert.assertEquals("hello1", rtn);
      Assert.assertEquals(1, count);
      rtn = proxy.getAlwaysGoodEtag();
      Assert.assertEquals("hello1", rtn);
      Assert.assertEquals(1, count);
      Thread.sleep(2000);
      rtn = proxy.getAlwaysGoodEtag();
      Assert.assertEquals("hello1", rtn);
      Assert.assertEquals(2, count);
      rtn = proxy.getAlwaysGoodEtag();
      Assert.assertEquals("hello1", rtn);
      Assert.assertEquals(2, count);

      // Test never good etag
      count = 0;
      rtn = proxy.getNeverGoodEtag();
      Assert.assertEquals("hello1", rtn);
      Assert.assertEquals(1, count);
      rtn = proxy.getNeverGoodEtag();
      Assert.assertEquals("hello1", rtn);
      Assert.assertEquals(1, count);
      Thread.sleep(2000);
      rtn = proxy.getNeverGoodEtag();
      Assert.assertEquals("hello2", rtn);
      Assert.assertEquals(2, count);
      rtn = proxy.getNeverGoodEtag();
      Assert.assertEquals("hello2", rtn);
      Assert.assertEquals(2, count);


      // Test always validate etag
      count = 0;
      rtn = proxy.getValidateEtagged();
      Assert.assertEquals("hello1", rtn);
      Assert.assertEquals(1, count);
      rtn = proxy.getValidateEtagged();
      Assert.assertEquals("hello1", rtn);
      Assert.assertEquals(2, count);
      rtn = proxy.getValidateEtagged();
      Assert.assertEquals("hello1", rtn);
      Assert.assertEquals(3, count);
      rtn = proxy.getValidateEtagged();
      Assert.assertEquals("hello1", rtn);
      Assert.assertEquals(4, count);
      client.close();
   }
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");
      Assert.assertEquals("cachecache" + 1, rtn);
      Assert.assertEquals(1, count);

      rtn = proxy.getCacheit("1");
      System.out.println("rtn: " + rtn);
      Assert.assertEquals("cachecache" + 1, rtn);
      Assert.assertEquals(1, count);

      rtn = proxy.getCacheit("2");
      Assert.assertEquals("cachecache" + 2, rtn);
      Assert.assertEquals(2, count);

      rtn = proxy.getCacheit("2");
      Assert.assertEquals("cachecache" + 2, rtn);
      Assert.assertEquals(2, count);

      rtn = proxy.getCacheit("1");
      Assert.assertEquals("cachecache" + 3, rtn);
      Assert.assertEquals(3, count);
      client.close();


   }
View Full Code Here

   }

   @Test
   public void testPerson() throws Exception
   {
      ResteasyClient client = new ResteasyClientBuilder().build();
      client.register(PersonConverter.class);
      client.register(CompanyConverter.class);

      MyClient proxy = ProxyBuilder.builder(MyClient.class, client.target(generateBaseUrl())).build();
      Person person = new Person("name");
      proxy.put(person);
      client.close();
   }
View Full Code Here

   }

   @Test
   public void testCompany() throws Exception
   {
      ResteasyClient client = new ResteasyClientBuilder().build();
      client.register(PersonConverter.class);
      client.register(CompanyConverter.class);
      MyClient proxy = ProxyBuilder.builder(MyClient.class, client.target(generateBaseUrl())).build();
      Company company = new Company("name");
      proxy.putCompany(company);
      client.close();
   }
View Full Code Here

   }

   @Test
   public void testMe() throws Exception
   {
      ResteasyClient client = new ResteasyClientBuilder().build();
      Invocation.Builder request = client.target(generateURL("/datetest/04-23-1977")).request();
      System.out.println(request.get(String.class));
      client.close();
   }
View Full Code Here

   @Test
   public void test() throws Exception
   {
      final Dispatcher dispatcher = EmbeddedContainer.start().getDispatcher();
      ResteasyClient client = new ResteasyClientBuilder().build();
      try
      {
         dispatcher.getRegistry().addPerRequestResource(FormResourceImpl.class);
         final FormResource proxy = ProxyBuilder.builder(FormResource.class, client.target(generateBaseUrl())).build();
         final String result = proxy.put("value");
         Assert.assertEquals(result, "value");
         final String result1 = client.target(generateURL("/form")).request().post(Entity.form(new Form().param("value", "value")), String.class);
         Assert.assertEquals(result1, "value");

         Form form = new Form().param("bill", "burke").param("foo", "bar");
         Form rtn = proxy.post(form);
         Assert.assertEquals(rtn.asMap().size(), form.asMap().size());
         Assert.assertEquals(rtn.asMap().getFirst("bill"), "burke");
         Assert.assertEquals(rtn.asMap().getFirst("foo"), "bar");

      }
      finally
      {
         client.close();
         EmbeddedContainer.stop();
      }
   }
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.