public void onSetUp() throws Exception { databaseTester.onSetup(); pipelineTimeline.clearWhichIsEvilAndShouldNotBeUsedInRealWorld(); if (sqlMapClient != null) { sqlMapClient.flushDataCache(); } }
@Before public void setUp() throws Exception { IDataSet dataSet = new FlatXmlDataSetBuilder().build(new File("src/test/resources/CustomerTest.xml")); databaseTester.setDataSet(dataSet); databaseTester.setSetUpOperation(DatabaseOperation.CLEAN_INSERT); databaseTester.setTearDownOperation(DatabaseOperation.DELETE_ALL); databaseTester.onSetup(); }
@AroundInvoke public Object execute(InvocationContext invocationContext) throws Exception { // Execute following logic only if @Test method Test testAnnotation = invocationContext.getMethod().getAnnotation(Test.class); if (testAnnotation == null) { return invocationContext.proceed(); } dbUnitSetup(); DbUnitTestContext testContext = new DbUnitTestContext(); Object returnValue = null; Class<?> testClass = ProxyUtils.getUnproxiedClass(invocationContext.getTarget().getClass()); testContext.setTestClass(testClass); testContext.setTestInstance(invocationContext.getTarget()); testContext.setTestMethod(invocationContext.getMethod()); DbUnitConfiguration dbUnitConfiguration = testClass.getAnnotation(DbUnitConfiguration.class); try { dbUnitRunner.prepareTesterSetup(testContext, dbUnitConfiguration, databaseTester); // try { databaseTester.onSetup(); // } catch (Throwable e) { // do not propagate db setup exception or transaction // will not rollback // e.printStackTrace(); // } returnValue = invocationContext.proceed(); dbUnitRunner.verifyExpected(testContext); } finally { dbUnitRunner.prepareTesterTearDown(testContext, dbUnitConfiguration, databaseTester); databaseTester.onTearDown(); try { if (connection != null) { connection.close(); } } catch (Exception e) { connection = null; } } return returnValue; }
public void beforeTestMethod(TestContext testCtx) throws Exception { // Check for existence of DataSets annotation for the method under testing DataSets dataSetAnnotation = testCtx.getTestMethod().getAnnotation(DataSets.class); if (dataSetAnnotation == null) { return; } String dataSetName = dataSetAnnotation.setUpDataSet(); // Populate data set if data set name exists if (!dataSetName.equals("")) { databaseTester = (IDatabaseTester) testCtx.getApplicationContext().getBean("databaseTester"); XlsDataFileLoader xlsDataFileLoader = (XlsDataFileLoader) testCtx.getApplicationContext().getBean("xlsDataFileLoader"); IDataSet dataSet = xlsDataFileLoader.load(dataSetName); databaseTester.setDataSet(dataSet); databaseTester.onSetup(); } }
@Before public void setUpBeforeTest() throws Exception { databaseTester.onSetup(); }