UoWFactory { public void init(String persistenceUnitName) { if (isInitialized()) throw new ExceptionInInitializerError("Already initialized"); entityManagerFactory = Persistence.createEntityManagerFactory(persistenceUnitName); } private  UoWFactory(); static UoWFactory getInstance(); void init(String persistenceUnitName); IUnitOfWork createUoW(); boolean isInitialized();  }
@Test(expected = ExceptionInInitializerError.class) public void initTest() { UoWFactory.getInstance().init("TEST_PERSISTENCE"); UoWFactory.getInstance().init("TEST_PERSISTENCE"); }