[seam-dev] Arquillian questions

Mark Struberg struberg at yahoo.de
Tue Nov 29 10:59:19 EST 2011


 Hi folks!

I'm not sure if this is the right list, but I have some Arquillian questions.

I have a testng test for services which use a @RequestScoped EntityManager:


MyTest extends Arquillian {

  private @Inject EntityManager em;
  private @Inject MyService mySvc;

  @BeforeClass
  public void setupTests() {
    em.getTransaction().begin();
    em.delete(em.find(MyEntity.class, TEST_ID));
    em.getTransaction().commit();
  }

  @Test
  public void test1() {
    mySvc.doDbStuff1();
  }

  @Test
  public void test2() {
    mySvc.doDbStuff2();
  }
}

Since my service methods in the tests and @BeforeClass @AfterClass, etc all use the @RequestScoped EntityManager, each of those methods needs to get treated like an own Request.

Also: is there some way to manually restart the RequestContext? This is e.g. needed to simulate some issues with detached entities. I basically need full programmatical control over the various Context start/stop in my unit tests!

LieGrue,
strub



More information about the seam-dev mailing list