Package org.jboss.resteasy.client.jaxrs

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


   @Test
   public void testXmlType() throws Exception
   {
      before();
     
      ResteasyWebTarget target = client.target(generateURL("/xmlType"));
      FavoriteMovieXmlType movie = new FavoriteMovieXmlType();
      movie.setTitle("La Cage Aux Folles");
      Response response = target.request().post(Entity.entity(movie,"application/xml"));
      Assert.assertEquals(200, response.getStatus());
      String entity = response.readEntity(String.class);
      System.out.println("Result: " + entity);
      Assert.assertEquals("La Cage Aux Folles", entity);
   }
View Full Code Here


   public void testList() throws Exception
   {
      String xml = "<list>"
              + "<foo test=\"hello\"/></list>";

      ResteasyWebTarget target = client.target(generateURL("/list"));
      Response response = target.request().post(Entity.xml(xml));
      Foo[] list = response.readEntity(new GenericType<Foo[]>()
      {
      });
      Assert.assertEquals(1, list.length);
      Assert.assertEquals(list[0].getTest(), "hello");
View Full Code Here

  
   @Test
   public void testJAXBElement() throws Exception
   {
      before();
      ResteasyWebTarget target = client.target(generateURL("/JAXBElement"));
      String str = "<?xml version=\"1.0\"?>\r" +
                   "<favoriteMovieXmlType xmlns=\"http://abc.com\"><title>La Cage Aux Folles</title></favoriteMovieXmlType>";
      System.out.println(str);
      Response response = target.request().post(Entity.entity(str,"application/xml"));
      Assert.assertEquals(200, response.getStatus());
      String entity = response.readEntity(String.class);
      System.out.println("Result: " + entity);
      Assert.assertEquals("La Cage Aux Folles", entity);
   }
View Full Code Here

   public void testNamespacedNakedArray() throws Exception
   {
      String xml = "<collection xmlns:foo=\"http://foo.com\">"
              + "<foo:foo test=\"hello\"/></collection>";

      ResteasyWebTarget target = client.target(generateURL("/namespaced/array"));
      Response response = target.request().post(Entity.xml(xml));
      List<NamespacedFoo> list = response.readEntity(new GenericType<List<NamespacedFoo>>()
      {
      });
      Assert.assertEquals(1, list.size());
      Assert.assertEquals(list.get(0).getTest(), "hello");
View Full Code Here

  
   void doCollectionTest(String path) throws Exception
   {
      before();
     
      ResteasyWebTarget target = client.target(generateURL("/" + path));
      String str = "<?xml version=\"1.0\"?>\r" +
                   "<collection xmlns=\"http://abc.com\">" +
                   "<favoriteMovieXmlRootElement><title>La Cage Aux Folles</title></favoriteMovieXmlRootElement>" +
                   "<favoriteMovieXmlRootElement><title>La Regle du Jeu</title></favoriteMovieXmlRootElement>" +
                   "</collection>";
      System.out.println(str);
      Response response = target.request().post(Entity.entity(str,"application/xml"));
      Assert.assertEquals(200, response.getStatus());
      String entity = response.readEntity(String.class);
      System.out.println("Result: " + entity);
      if (entity.indexOf("Cage") < entity.indexOf("Regle"))
      {
View Full Code Here

   public void testNamespacedList() throws Exception
   {
      String xml = "<list xmlns:foo=\"http://foo.com\">"
              + "<foo:foo test=\"hello\"/></list>";

      ResteasyWebTarget target = client.target(generateURL("/namespaced/list"));
      Response response = target.request().post(Entity.xml(xml));
      NamespacedFoo[] list = response.readEntity(new GenericType<NamespacedFoo[]>()
      {
      });
      Assert.assertEquals(1, list.length);
      Assert.assertEquals(list[0].getTest(), "hello");
View Full Code Here

  
   void doMapTest() throws Exception
   {
      before();
     
      ResteasyWebTarget target = client.target(generateURL("/map"));
      String str = "<?xml version=\"1.0\"?>\r" +
                   "<map xmlns=\"http://abc.com\">" +
                     "<entry key=\"new\">" +
                       "<favoriteMovieXmlRootElement><title>La Cage Aux Folles</title></favoriteMovieXmlRootElement>" +
                     "</entry>" +
                     "<entry key=\"old\">" +
                       "<favoriteMovieXmlRootElement><title>La Regle du Jeu</title></favoriteMovieXmlRootElement>" +
                     "</entry>" +
                   "</map>";
      System.out.println(str);
      Response response = target.request().post(Entity.entity(str,"application/xml"));
      Assert.assertEquals(200, response.getStatus());
      String entity = response.readEntity(String.class);
      System.out.println("Result: " + entity);
      if (entity.indexOf("Cage") < entity.indexOf("Règle"))
      {
View Full Code Here

   public void testBadList() throws Exception
   {
      String xml = "<bad-list>"
              + "<foo test=\"hello\"/></bad-list>";

      ResteasyWebTarget target = client.target(generateURL("/list"));
      Response response = target.request().post(Entity.xml(xml));
      Assert.assertEquals(400, response.getStatus());
      response.close();

   }
View Full Code Here

     @Test
     public void testEcho()
     {
       ResteasyClient client = new ResteasyClientBuilder().build();
       ResteasyWebTarget target = client.target("http://localhost:9095");
       HelloString proxy = target.proxy(HelloString.class);
       String hello = proxy.sayHi("hello");
       Assert.assertEquals("hello", hello);
     }
View Full Code Here

      ResteasyClient client1 = new ResteasyClientBuilder().socketTimeout(2, TimeUnit.SECONDS).build();
      ClientHttpEngine engine = client1.httpEngine();
      Assert.assertNotNull(engine);

      ResteasyClient client = new ResteasyClientBuilder().httpEngine(engine).build();
      ResteasyWebTarget target = client.target(TestPortProvider.generateURL("/timeout"));
      try
      {
         Response response = target.queryParam("sleep", "5").request().get();
         Assert.fail();
      }
      catch (ProcessingException e)
      {
         Assert.assertEquals(e.getCause().getClass(), SocketTimeoutException.class);
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.