/** * Set up. * * <p>Load configuration, prepare database, and create the testing instances. * * @throws Exception to JUnit. */ protected void setUp() throws Exception { TestHelper.loadConfigurations(); TestHelper.executeDBScript(TestHelper.SCRIPT_FILL); generator = IDGeneratorFactory.getIDGenerator("phase_id_seq"); persistence = new InformixPhasePersistence( new DBConnectionFactoryImpl(TestHelper.CONNECTION_FACTORY_NAMESPACE), "informix", generator); }
/** * Test <code>getIDGenerator()</code>. * * @throws Exception to JUnit. */ public void testGetIDGenerator() throws Exception { assertEquals( "getIDGenerator() should be correct.", generator, TestHelper.invokeMethod( AbstractDbPhasePersistence.class, persistence, "getIDGenerator", new Class[] {}, new Object[] {})); }
/** * Test <code>getConnection()</code>. * * @throws Exception to JUnit. */ public void testGetConnection() throws Exception { Connection connection = (Connection) TestHelper.invokeMethod( AbstractDbPhasePersistence.class, persistence, "getConnection", new Class[] {}, new Object[] {}); assertEquals("getConnection() should be correct.", "demo", connection.getCatalog()); }
/** * Test <code>getConnection()</code> when connectionName does not exist in configuration. The * connection should be created. * * @throws Exception to JUnit. */ public void testGetConnectionNoConnectionName() throws Exception { persistence = new InformixPhasePersistence(TestHelper.PHASE_PERSISTENCE_NAMESPACE + ".NoConnectionName"); Connection connection = (Connection) TestHelper.invokeMethod( AbstractDbPhasePersistence.class, persistence, "getConnection", new Class[] {}, new Object[] {}); assertEquals("getConnection() should be correct.", "demo", connection.getCatalog()); }
/** * Tear down. * * <p>Clear database, close all connections, clear configurations. * * @throws Exception to JUnit. */ protected void tearDown() throws Exception { TestHelper.executeDBScript(TestHelper.SCRIPT_CLEAR); TestHelper.closeAllConnections(); TestHelper.clearAllConfigurations(); }