if (!weldContext.isActive()){
wasNotActive = true;
weldContext.activate();
}
EntityManager m1 = Beans.getReference(EntityManager.class, new NameQualifier("pu"));
assertNotNull(m1);
assertEquals(EntityManagerProxy.class, m1.getClass());
MyEntity entity = new MyEntity();
entity.setId(createId("testID"));
m1.persist(entity);
assertTrue(m1.contains(entity));
weldContext.invalidate();
weldContext.deactivate();
if (!weldContext.isActive()){
weldContext.activate();
}
EntityManager m2 = Beans.getReference(EntityManager.class, new NameQualifier("pu"));
assertTrue( m2.isOpen() );
assertTrue( !m2.contains(entity));
if (wasNotActive && weldContext.isActive()){