/** @throws java.lang.Exception */ @Before public void setUp() throws Exception { try { helper = new DatabaseHelper(Config.getInstance()); helper.createDatabaseSchema(); connection = helper.getConnection(); // create the dao under test dao = new MySQLExcpetionDAO(connection); mockapplication = new MockApplication(); applicationDAO = new MySQLApplicaitonDAO(connection); mockanalysis = new MockAnalysis(); mockanalysis.setApp(mockapplication); // make a second one so we can test update later (attach exception to different analysis) mockanalysis2 = new MockAnalysis(); mockanalysis2.setApp(mockapplication); analysisDAO = new MySQLAnalysisDAO(connection); mockapplication.setId(applicationDAO.create(mockapplication)); mockanalysis.setId(analysisDAO.create(mockanalysis)); mockanalysis2.setId(analysisDAO.create(mockanalysis2)); } catch (Exception e) { logger.error("Unable to connect to DB!", e); } }
@After public void tearDown() throws Exception { helper.dropTables(); connection.close(); }