EntityManagerFactoryDecorator implements TestClassDecorator { @Override public void beforeAll(final TestInvocation invocation) throws Exception { ExecutionContext context = invocation.getContext(); final PersistenceUnitDescriptor descriptor = context.getDescriptor(); final EntityManagerFactory emf = Persistence.createEntityManagerFactory(descriptor.getUnitName(), descriptor.getProperties()); context.storeData(Constants.KEY_ENTITY_MANAGER_FACTORY, emf); }  @Override int getPriority(); @Override void beforeAll(final TestInvocation invocation); @Override void afterAll(final TestInvocation invocation); @Override boolean isConfigurationSupported(final ExecutionContext ctx);  }
@Test public void testBeforeAll() throws Throwable { final EntityManagerFactoryDecorator decorator = new EntityManagerFactoryDecorator(); decorator.beforeAll(invocation); verify(ctx).storeData(eq(Constants.KEY_ENTITY_MANAGER_FACTORY), eq(factory)); }