@Test public void test_bootstrap_bootstrap_jpa_compliant_EntityManagerFactory_example() { try { //tag::bootstrap-jpa-compliant-EntityManagerFactory-example[] // Create an EMF for our CRM persistence-unit. EntityManagerFactory emf = Persistence.createEntityManagerFactory( "CRM" ); //end::bootstrap-jpa-compliant-EntityManagerFactory-example[] } catch (Exception ignore) {} }
/** * This method does all of the setup for the test and returns a HashMap * containing the persistence objects that the test might need. * * @param persistenceUnitName * The name of the persistence unit used by the test. * @return Map with persistence objects, such as the EntityManagerFactory and DataSource */ public static Map<String, Object> setupWithPoolingDataSource(final String persistenceUnitName, String dataSourceName, final boolean testMarshalling) { // Setup the datasource PoolingDataSourceWrapper ds1 = setupPoolingDataSource(getDatasourceProperties(), dataSourceName); Map<String, Object> context = new HashMap<String, Object>(); context.put(DATASOURCE, ds1); EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnitName); context.put(ENTITY_MANAGER_FACTORY, emf); return context; }
@Before public void beforeThis() { emf = Persistence.createEntityManagerFactory("org.jbpm.logging.jta"); logService = new JPAAuditLogService(emf); }
/** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { propertyMap.put("index.home.dir", "./lucene"); emf = Persistence.createEntityManagerFactory("redisLucene_pu", propertyMap); em = emf.createEntityManager(); }
/** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { CassandraCli.cassandraSetUp(); Map propertyMap = new HashMap(); propertyMap.put(CassandraConstants.CQL_VERSION, CassandraConstants.CQL_VERSION_3_0); emf = Persistence.createEntityManagerFactory(persistenceUnit, propertyMap); }
/** * On named query batch test. */ @Test public void onNamedQueryBatchTest() { Map propertyMap = new HashMap(); propertyMap.put("kundera.batch.size", "5"); emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT, propertyMap); insertUpdateBatch(); deleteBatch(); }
/** * Sets the up before class. */ @BeforeClass public static void setUpBeforeClass() { propertyMap.put("index.home.dir", "lucene"); emf = Persistence.createEntityManagerFactory(HBASE_PU, propertyMap); }
@Before public void setUp() throws Exception { emf = Persistence.createEntityManagerFactory("hbaseTest"); em = emf.createEntityManager(); }
@SuppressWarnings("unchecked") @Test public void testPerRequestManagerDestorySession() { EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa"); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get() .newDefaultBuilder() .get(); EntityManager em = emf.createEntityManager(); List<SessionInfo> sessions = em.createQuery("from SessionInfo").getResultList(); assertEquals(0, sessions.size());
@BeforeClass public static void configure() { pds = setupPoolingDataSource(); emf = Persistence.createEntityManagerFactory( "org.jbpm.services.task" ); hackTheDatabaseMetadataLoggerBecauseTheresALogbackXmlInTheClasspath(); }
/** * Sets the up before class. * * @throws Exception * the exception */ @BeforeClass public static void setUpBeforeClass() throws Exception { emf = Persistence.createEntityManagerFactory(_PU); em = emf.createEntityManager(); }
public static void main(String[] args) { Map<String, String> configurationOverrides = new HashMap<String, String>(); EntityManagerFactory emf = Persistence.createEntityManagerFactory("ConsolePU", configurationOverrides); EntityManager entityManager = emf.createEntityManager(); TestConsole console = new TestConsole(entityManager); System.out.println(""); System.out.println("Welcome to EntityVersions demo!"); // If you would like to use HSQLDB, uncomment relevant entries in // hibernate-envers/src/demo/resources/META-INF/persistence.xml descriptor and add required JAR libraries. // String userDbFile = System.getProperty("java.io.tmpdir") + File.separator + "_versions_demo.db"; // System.out.println("HSQLDB database file location: " + userDbFile); console.populateTestData(); console.start(); entityManager.close(); emf.close(); } }
@Before public void setUp() throws Exception { propertyMap.put("index.home.dir", "lucene"); emf = Persistence.createEntityManagerFactory(PU, propertyMap); em = emf.createEntityManager(); }
/** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { CassandraCli.cassandraSetUp(); Map<String, Object> puProperties = new HashMap<String, Object>(); puProperties.put("kundera.ddl.auto.prepare", "create-drop"); emf = Persistence.createEntityManagerFactory(_PU, puProperties); }
@Test public void testCreate() { Map<String, Object> props = new HashMap<String, Object>(); props.put(PersistenceProperties.KUNDERA_DDL_AUTO_PREPARE, "create"); EntityManagerFactory emf = Persistence.createEntityManagerFactory("metaDataTest", props); Assert.assertTrue(CoreSchemaManager.validateAction("create")); emf.close(); Assert.assertTrue(CoreSchemaManager.validateAction("create")); Assert.assertFalse(CoreSchemaManager.validateAction("drop")); }
@BeforeClass public static void setUpBeforeClass() throws Exception { CassandraCli.cassandraSetUp(); propertyMap = new HashMap(); propertyMap.put(PersistenceProperties.KUNDERA_DDL_AUTO_PREPARE, "create"); propertyMap.put(CassandraConstants.CQL_VERSION, CassandraConstants.CQL_VERSION_3_0); emf = Persistence.createEntityManagerFactory(PU, propertyMap); } /**
@Test public void testRuntimeEnvironmentUserDataServiceProviderUserInfo() { EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa"); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get() .newDefaultBuilder() .entityManagerFactory(emf) .get(); LocalTaskServiceFactory factory = new LocalTaskServiceFactory(environment); InternalTaskService service = (InternalTaskService) factory.newTaskService(); // the instance provided should be the one setup at custom and not the default one Assert.assertTrue(service.getUserInfo() instanceof CustomUserInfoImpl); } }
@Before public void beforeThis() { emf = Persistence.createEntityManagerFactory("org.jbpm.logging.local"); logService = new JPAAuditLogService(emf, PersistenceStrategyType.STANDALONE_LOCAL); }
/** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { emf = Persistence.createEntityManagerFactory("mongoTest"); em = emf.createEntityManager(); }
@SuppressWarnings("unchecked") @Test public void testPerProcessInstanceManagerDestorySession() { EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa"); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get() .newDefaultBuilder() .get(); EntityManager em = emf.createEntityManager(); List<SessionInfo> sessions = em.createQuery("from SessionInfo").getResultList(); assertEquals(0, sessions.size());