DBMessageResourceDAOImpl extends JdbcDaoSupport implements
        DBMessageResourceDAO { @Override protected void initDao() { DataSource dataSource = getDataSource(); if (dataSource == null) { log.error("Missing dataSource in spring configuration file."); throw new IllegalArgumentException("Missing dataSource in spring" + " configuration file."); } this.dBMessageQuery = new DBMessageQuery(dataSource, makeSql(), codeColumn, languageColumn, countryColumn, variantColumn, messageColumn); } protected  DBMessageResourceDAOImpl(); void setTableName(String tableName); void setCodeColumn(String codeColumn); void setLanguageColumn(String languageColumn); void setCountryColumn(String countryColumn); void setVariantColumn(String variantColumn); void setMessageColumn(String messageColumn); void setFindMessageSql(String findMessageSql); @SuppressWarnings("unchecked") @Override List<DBMessage> findDBMessages();  }
@Test public void testInitDao01() throws Exception { DataSource dataSource = mock(DataSource.class); DBMessageResourceDAOImpl_JdbcTemplateStub01 jdbc = new DBMessageResourceDAOImpl_JdbcTemplateStub01(); DBMessageResourceDAOImpl_DBMessageResourceDAOImplStub01 dbmr = new DBMessageResourceDAOImpl_DBMessageResourceDAOImplStub01(); jdbc.ds = dataSource; ReflectionTestUtils.setField(dbmr, "jdbcTemplate", jdbc); dbmr.dBMessageQuery = null; dbmr.codeColumn = "CODE"; dbmr.languageColumn = "LANGUAGE"; dbmr.countryColumn = "COUNTRY"; dbmr.variantColumn = "VARIANT"; dbmr.messageColumn = "MESSAGE"; dbmr.initDao(); DBMessageQuery query = dbmr.dBMessageQuery; assertEquals("CODE", query.rsCodeColumn); assertEquals("LANGUAGE", query.rsLanguageColumn); assertEquals("COUNTRY", query.rsCountryColumn); assertEquals("VARIANT", query.rsVariantColumn); assertEquals("MESSAGE", query.rsMessageColumn); assertTrue(dbmr.isRead); }
@Test public void testInitDao02() throws Exception { DBMessageResourceDAOImpl_JdbcTemplateStub01 jdbc = new DBMessageResourceDAOImpl_JdbcTemplateStub01(); DBMessageResourceDAOImpl_DBMessageResourceDAOImplStub01 dbmr = new DBMessageResourceDAOImpl_DBMessageResourceDAOImplStub01(); jdbc.ds = null; dbmr.dBMessageQuery = null; dbmr.codeColumn = "CODE"; dbmr.languageColumn = "LANGUAGE"; dbmr.countryColumn = "COUNTRY"; dbmr.variantColumn = "VARIANT"; dbmr.messageColumn = "MESSAGE"; try { dbmr.initDao(); fail(); } catch (IllegalArgumentException e) { assertEquals("Missing dataSource in spring configuration file.", e .getMessage()); assertThat(logger.getLoggingEvents(), is(asList(error( "Missing dataSource in spring configuration file.")))); } }
@Test public void testInitDao03() throws Exception { DataSource dataSource = mock(DataSource.class); DBMessageResourceDAOImpl_JdbcTemplateStub01 jdbc = new DBMessageResourceDAOImpl_JdbcTemplateStub01(); DBMessageResourceDAOImpl_DBMessageResourceDAOImplStub01 dbmr = new DBMessageResourceDAOImpl_DBMessageResourceDAOImplStub01(); jdbc.ds = dataSource; ReflectionTestUtils.setField(dbmr, "jdbcTemplate", jdbc); dbmr.dBMessageQuery = null; dbmr.codeColumn = "CODE"; dbmr.languageColumn = null; dbmr.countryColumn = null; dbmr.variantColumn = null; dbmr.messageColumn = "MESSAGE"; dbmr.initDao(); DBMessageQuery query = dbmr.dBMessageQuery; assertEquals("CODE", query.rsCodeColumn); assertNull(query.rsLanguageColumn); assertNull(query.rsCountryColumn); assertNull(query.rsVariantColumn); assertEquals("MESSAGE", query.rsMessageColumn); assertTrue(dbmr.isRead); }