Пример #1
0
  @Test
  public void test() throws Exception {

    SqlSession session = SessionFactory.getSession();
    EventDao eventDao = session.getMapper(EventDao.class);

    try {

      Event event = TestEventDao.createEvent();
      String where = "KEY='" + event.getKey() + "' ";
      Map<String, Object> map = new HashMap<String, Object>();
      map.put("where", where);

      int count = eventDao.create(event);
      assertEquals(1, count);
      assertNotNull(event.getKey());

      Event readRecord = eventDao.read(map);
      assertNotNull(readRecord.getKey());

      compareRecords(event, readRecord);

      modifyRecord(event);
      count = eventDao.update(event);
      assertEquals(1, count);

      readRecord = eventDao.read(map);
      assertNotNull(readRecord.getKey());

      compareRecords(event, readRecord);

      count = eventDao.delete(map);
      assertEquals(1, count);

      readRecord = eventDao.read(map);
      assertNull(readRecord);

    } finally {
      if (session != null) {
        session.rollback();
        session.close();
      }
    }
  }
Пример #2
0
 @Before
 public void setup() {
   SessionFactory.initializeForTest();
 }