SmsContentDAO extends BaseIbatisDAO { @SuppressWarnings("unchecked") public List<SmsContent> query(final Map<String, Object> parameters) { if (LOG.isDebugEnabled()) { LOG.debug("Want to query,condition: " + parameters); } return (List<SmsContent>) super.queryForList("SMS_CONTENT.query", parameters); }  SmsContent save(final SmsContent sms); @SuppressWarnings("unchecked") List<SmsContent> query(final Map<String, Object> parameters); void deleteByPrimaryKey(final Serializable id); void delete(final Map<String, Object> parameters); void updateFailureCount(final Serializable id); SmsContent getByPrimaryKey(final Serializable id); void retrySend(final Serializable serialId); static int getRule(); static void setRule(int rule); @SuppressWarnings("unchecked") List<SmsContent> queryByParam(Map<String, Object> param); void reSendSmsByMap(Map<Object, Object> extendParam); int update(SmsContent smsContent); void insert(SmsContent smsContent);  }
@SuppressWarnings("deprecation") @Test public void testQuery() throws Exception { smsContentDAO.save(new SmsContent("Test Sms 1", "13917677725")); Thread.sleep(1000); smsContentDAO.save(new SmsContent("Test Sms 2", "13917677725")); Thread.sleep(1000); smsContentDAO.save(new SmsContent("Test Sms 3", "13917677725")); Thread.sleep(1000); smsContentDAO.save(new SmsContent("Test Sms 4", "13917677725")); Thread.sleep(1000); smsContentDAO.save(new SmsContent("Test Sms 5", "13000000000")); Date date = new Date(); date.setYear(date.getYear() + 10); smsContentDAO.save(new SmsContent("Test Sms 6", "13917677725", date)); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("condition", "mobile = '13917677725'"); List<SmsContent> contents = smsContentDAO.query(parameters); Assert.assertEquals(4, contents.size()); int i = 1; for (SmsContent content : contents) { Assert.assertEquals("Test Sms " + i++, content.getContent()); } parameters.clear(); parameters.put("limit", "3"); contents = smsContentDAO.query(parameters); Assert.assertEquals(3, contents.size()); i = 1; for (SmsContent content : contents) { Assert.assertEquals("Test Sms " + i++, content.getContent()); } parameters.clear(); Assert.assertEquals(5, smsContentDAO.query(parameters).size()); parameters.clear(); parameters.put("condition", "mobile = '13917677725'"); parameters.put("failure", "-1"); Assert.assertEquals(0, smsContentDAO.query(parameters).size()); }