Exemplo n.º 1
0
 /**
  * Verify that EJBBookReaderImpl, EJBBookWriterImpl, and EJBBookResource are placed in the correct
  * scope.
  *
  * @throws Exception
  */
 @Test
 public void testVerifyScopesLocalEJB() throws Exception {
   log.info("starting testVerifyScopesLocalEJB()");
   int result = localResource.verifyScopes();
   log.info("result: " + result);
   assertEquals(200, result);
 }
Exemplo n.º 2
0
  /** Invokes additional methods of JAX-RS resource as local EJB. */
  @Test
  public void testAsLocalEJB() throws Exception {
    log.info("entering testAsLocalEJB()");

    // Create book.
    Book book1 = new Book("RESTEasy: the Sequel");
    int id1 = localResource.createBook(book1);
    log.info("id1: " + id1);
    Assert.assertEquals(Counter.INITIAL_VALUE, id1);

    // Create another book.
    Book book2 = new Book("RESTEasy: It's Alive");
    int id2 = localResource.createBook(book2);
    log.info("id2: " + id2);
    Assert.assertEquals(Counter.INITIAL_VALUE + 1, id2);

    // Retrieve first book.
    Book bookResponse1 = localResource.lookupBookById(id1);
    log.info("book1 response: " + bookResponse1);
    Assert.assertEquals(book1, bookResponse1);

    // Retrieve second book.
    Book bookResponse2 = localResource.lookupBookById(id2);
    log.info("book2 response: " + bookResponse2);
    Assert.assertEquals(book2, bookResponse2);

    // Verify that EJBBookReader and EJBBookWriter haven't been used.
    localResource.testUse(0);

    // Reset counter.
    localResource.reset();
  }