- /**
- * Starts the builder, which in particular, mocks JNDI, binds the datasource
- * the JNDI where the persistence unit expects it, creates the entity
- * manager factory, and forces creation of the database schema.
- */
- public void start() throws Exception {
- try {
- InitialContext ctx = new InitialContext();
- ctx.bind(persistenceUnit.getJndiName(), dataSource);
- } catch (NamingException e) {
- throw new RuntimeException("JNDI problem", e);
- }
- factory = createFactory();
- execute(new JpaUnitOfWork<Void>() {
- public Void execute(EntityManager em) {
- // Empty, just to trigger database schema creation.
- return null;
- }
- });
- }
+ /**
+ * Creates a new entity manager factory. Typically not used by test code.
+ *
+ * @return Entity manager factory.
+ */
+ public EntityManagerFactory createFactory() {
+ Map<String, String> jpaProps = new TreeMap<String, String>();
+
+ jpaProps.put("javax.persistence.jtaDataSource", null);
+ jpaProps.put("javax.persistence.transactionType", "RESOURCE_LOCAL");
+ jpaProps.put("javax.persistence.jdbc.url", url);
+ jpaProps.put("javax.persistence.jdbc.user", user);
+ jpaProps.put("javax.persistence.jdbc.password", password);