@Before public void setUp() throws Exception { super.setUp(); EntityManagerFactory entityManagerFactory = applicationContext.getBean("entityManagerFactory", EntityManagerFactory.class); transactionTemplate = applicationContext.getBean("transactionTemplate", TransactionTemplate.class); entityManager = entityManagerFactory.createEntityManager(); cleanupRepository(); }
@Override protected CamelContext createCamelContext() throws Exception { setThreadContextClassLoader(); applicationContext = new OsgiBundleXmlApplicationContext( new String[] {"org/apache/camel/itest/osgi/jpa/springJpaRouteContext.xml"}); if (bundleContext != null) { applicationContext.setBundleContext(bundleContext); applicationContext.refresh(); } return SpringCamelContext.springCamelContext(applicationContext); }
@After public void tearDown() { try { super.tearDown(); if (applicationContext != null) { if (applicationContext.isActive()) { IOHelper.close(applicationContext); } applicationContext = null; } } catch (Exception exception) { // Don't throw the exception in the tearDown method } }