InitialContext ic = new InitialContext();
EmbeddedDataSource ds = new EmbeddedDataSource();
ds.setDatabaseName("target/test");
ds.setCreateDatabase("create");
ic.bind("osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/derbyds)", ds);
PersonServiceImpl personService = new PersonServiceImpl();
EntityManagerFactory emf = Persistence.createEntityManagerFactory("personTest", System.getProperties());
EntityManager em = emf.createEntityManager();
personService.setEntityManager(em);
em.getTransaction().begin();
personService.deleteAll();
personService.add(new Person("Christian Schneider", "@schneider_chris"));
em.getTransaction().commit();
List<Person> persons = personService.getAll();
Assert.assertEquals(1, persons.size());
Assert.assertEquals("Christian Schneider", persons.get(0).getName());
Assert.assertEquals("@schneider_chris", persons.get(0).getTwitterName());
}