Package org.jboss.resteasy.cdi.injection

Examples of org.jboss.resteasy.cdi.injection.Book


         Queue queue = (Queue)ic.lookup(destinationName);
         connection = cf.createConnection();
         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageProducer producer = session.createProducer(queue);
         connection.start();
         Book book1 = new Book("Dead Man Snoring");
         TextMessage message = session.createTextMessage(book1.getName());
         producer.send(message);
         log.info("Message sent to to the JMS Provider: " + book1.getName());
         Book book2 = new Book("Dead Man Drooling");
         message = session.createTextMessage(book2.getName());
         producer.send(message);
         log.info("Message sent to to the JMS Provider: " + book2.getName());
         ClientRequest request = new ClientRequest("http://localhost:8080/resteasy-reverse-injection-test/rest/mdb/books");
         ClientResponse<?> response = request.get();
         log.info("status: " + response.getStatus());
         Assert.assertEquals(200, response.getStatus());
         @SuppressWarnings("unchecked")
         Collection<Book> books = response.getEntity(Collection.class, BookCollectionType);
         log.info("Collection: " + books);
         Assert.assertEquals(2, books.size());
         Iterator<Book> it = books.iterator();
         Book b1 = it.next();
         Book b2 = it.next();
         Assert.assertTrue(book1.equals(b1) && book2.equals(b2) || book1.equals(b2) && book2.equals(b1));
      }
      catch (Exception exc)
      {
         exc.printStackTrace();
View Full Code Here


   @Override
   public void setup()
   {
      log.info("");
      log.info("entering EJBHolder.setup()");
      resource.getSet().add(new Book("Disappearing Book"));
      store.put("sle", sle);
      store.put("sfde", sfde);
      store.put("sfre", sfre);
      store.put("sfae", sfae);
      store.put("sli", sli);
View Full Code Here

      log.info("entered ReverseInjectionResource.setup()");
      store.put("this.secret", this.secret);
      store.put("holder.secret", holder.theSecret());
      store.put("resource.secret", resource.theSecret());
      store.put("resource", resource);
      resource.getSet().add(new Book("test"));
      holder.setup();
      return Response.ok().build();
   }
View Full Code Here

   {
      log.info("starting testEJBs()");

      // Create book.
      ClientRequest request = new ClientRequest("http://localhost:8080/resteasy-cdi-ejb-test/rest/create/");
      Book book1 = new Book("RESTEasy: the Sequel");
      request.body("application/test+xml", book1);
      ClientResponse<?> response = request.post();
      invocationCounter++;
      assertEquals(200, response.getStatus());
      log.info("Status: " + response.getStatus());
      int id1 = response.getEntity(int.class);
      log.info("id: " + id1);
      Assert.assertEquals(Counter.INITIAL_VALUE, id1);

      // Create another book.
      request = new ClientRequest("http://localhost:8080/resteasy-cdi-ejb-test/rest/create/");
      Book book2 = new Book("RESTEasy: It's Alive");
      request.body("application/test+xml", book2);
      response = request.post();
      invocationCounter++;
      assertEquals(200, response.getStatus());
      log.info("Status: " + response.getStatus());
      int id2 = response.getEntity(int.class);
      log.info("id: " + id2);
      Assert.assertEquals(Counter.INITIAL_VALUE + 1, id2);

      // Retrieve first book.
      request = new ClientRequest("http://localhost:8080/resteasy-cdi-ejb-test/rest/book/" + id1);
      request.accept("application/test+xml");
      response = request.get();
      invocationCounter++;
      log.info("Status: " + response.getStatus());
      assertEquals(200, response.getStatus());
      Book result = response.getEntity(Book.class);
      log.info("book: " + book1);
      Assert.assertEquals(book1, result);

      // Retrieve second book.
      request = new ClientRequest("http://localhost:8080/resteasy-cdi-ejb-test/rest/book/" + id2);
      request.accept("application/test+xml");
      response = request.get();
      invocationCounter++;
      log.info("Status: " + response.getStatus());
      assertEquals(200, response.getStatus());
      result = response.getEntity(Book.class);
      log.info("book: " + book2);
      Assert.assertEquals(book2, result);

      // Retrieve all books.
      request = new ClientRequest("http://localhost:8080/resteasy-cdi-ejb-test/rest/books/");
      request.accept(MediaType.APPLICATION_XML);
      response = request.get();
      invocationCounter++;
      log.info("Status: " + response.getStatus());
      @SuppressWarnings("unchecked")
      Collection<Book> books  = response.getEntity(Collection.class, BookCollectionType);
      log.info("Collection: " + books);
      Assert.assertEquals(2, books.size());
      Iterator<Book> it = books.iterator();
      Book b1 = it.next();
      Book b2 = it.next();
      log.info("First book in list: " + b1);
      log.info("Second book in list: " + b2);
      Assert.assertTrue(book1.equals(b1) && book2.equals(b2) || book1.equals(b2) && book2.equals(b1));

      // Test EntityManager injected in BookResource
View Full Code Here

      // cookie cache, which keeps the session alive.
      ClientExecutor executor = new ApacheHttpClient4Executor();

      // Create a book, which gets stored in the session scoped BookBag.
      ClientRequest request = new ClientRequest("http://localhost:8080/resteasy-cdi-ejb-test/rest/session/add/", executor);
      Book book1 = new Book(13, "Dead Man Napping");
      request.body(Constants.MEDIA_TYPE_TEST_XML, book1);
      ClientResponse<?> response = request.post();
      invocationCounter++;
      log.info("status: " + response.getStatus());
      Assert.assertEquals(200, response.getStatus());
      response.releaseConnection();

      // Create another book, which should get stored in the same BookBag.
      request = new ClientRequest("http://localhost:8080/resteasy-cdi-ejb-test/rest/session/add/", executor);
      Book book2 = new Book(Counter.INITIAL_VALUE, "Dead Man Dozing");
      request.body(Constants.MEDIA_TYPE_TEST_XML, book2);
      response = request.post();
      invocationCounter++;
      log.info("status: " + response.getStatus());
      Assert.assertEquals(200, response.getStatus());
      response.releaseConnection();

      // Get the current contents of the BookBag, and verify that it holds both of the books sent in the
      // previous two invocations.  When this method is called, the session is terminated.
      request = new ClientRequest("http://localhost:8080/resteasy-cdi-ejb-test/rest/session/get/", executor);
      response = request.get();
      invocationCounter++;
      log.info("status: " + response.getStatus());
      Assert.assertEquals(200, response.getStatus());
      @SuppressWarnings("unchecked")
      Collection<Book> books = response.getEntity(Collection.class, BookCollectionType);
      log.info("Collection: " + books);
      Assert.assertEquals(2, books.size());
      Iterator<Book> it = books.iterator();
      Book b1 = it.next();
      Book b2 = it.next();
      log.info("First book in list: " + b1);
      log.info("Second book in list: " + b2);
      Assert.assertTrue(book1.equals(b1) && book2.equals(b2) || book1.equals(b2) && book2.equals(b1));

      // Verify that the BookBag has been replaced by a new, empty one for the new session.
View Full Code Here

      log.info("starting testJMS()");
     
      // Send a book title.
      ClientRequest request = new ClientRequest("http://localhost:8080/resteasy-cdi-ejb-test/rest/produceMessage/");
      String title = "Dead Man Lounging";
      Book book = new Book(23, title);
      request.body(Constants.MEDIA_TYPE_TEST_XML, book);
      ClientResponse<?> response = request.post();
      invocationCounter++;
      log.info("status: " + response.getStatus());
      log.info(response.getEntity(String.class));
View Full Code Here

      log.info("starting testJMS()");
     
      // Send a book title.
      ClientRequest request = new ClientRequest("http://localhost:8080/resteasy-cdi-ejb-test/rest/produceMessage/");
      String title = "Dead Man Lounging";
      Book book = new Book(23, title);
      request.body(Constants.MEDIA_TYPE_TEST_XML, book);
      ClientResponse<?> response = request.post();
      log.info("status: " + response.getStatus());
      log.info(response.getEntity(String.class));
      Assert.assertEquals(200, response.getStatus());
View Full Code Here

TOP

Related Classes of org.jboss.resteasy.cdi.injection.Book

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.