public void testNonDefaultStorageVersion() { em.close(); emf.close(); Map<String, String> props = Utils.newHashMap(); props.put( StorageVersion.STORAGE_VERSION_PROPERTY, StorageVersion.PARENTS_DO_NOT_REFER_TO_CHILDREN.name()); emf = Persistence.createEntityManagerFactory(getEntityManagerFactoryName().name(), props); em = emf.createEntityManager(); DatastoreManager storeMgr = (DatastoreManager) getExecutionContext().getStoreManager(); assertEquals(StorageVersion.PARENTS_DO_NOT_REFER_TO_CHILDREN, storeMgr.getStorageVersion()); }
public void testUnknownStorageVersion() { em.close(); emf.close(); Map<String, String> props = Utils.newHashMap(); props.put(StorageVersion.STORAGE_VERSION_PROPERTY, "does not exist"); try { emf = Persistence.createEntityManagerFactory(getEntityManagerFactoryName().name(), props); } catch (Exception e) { // not all Persistence impls wrap EMF creation exception into PersistenceException Throwable cause = (e instanceof PersistenceException) ? e.getCause() : e; // good assertTrue(cause.getMessage().startsWith("'does not exist'")); } }