@BeforeClass
 public static void setUpBeforeClass() throws Exception {
   sessionFactory = HibernateUtil.getSessionFactory();
   session = sessionFactory.openSession();
   container = new HbnContainer<SampleNode>(SampleNode.class, sessionFactory);
   HibernateUtil.insertExampleNodes(recordsToLoad);
 }
Ejemplo n.º 2
0
  @Test
  public void test() throws Exception {

    SqlSession session = SessionFactory.getSession();
    AgileListDao agileListDao = session.getMapper(AgileListDao.class);

    try {

      AgileList agileList = TestAgileListDao.createAgileList();
      String where = "KEY='" + agileList.getKey() + "' ";
      Map<String, Object> map = new HashMap<String, Object>();
      map.put("where", where);

      int count = agileListDao.create(agileList);
      assertEquals(1, count);
      assertNotNull(agileList.getKey());

      AgileList readRecord = agileListDao.read(map);
      assertNotNull(readRecord.getKey());

      compareRecords(agileList, readRecord);

      List<AgileList> list1 = agileListDao.getListByStoryId(agileList.getStoryId());
      assertEquals(1, list1.size());
      compareRecords(agileList, list1.get(0));

      modifyRecord(agileList);
      count = agileListDao.update(agileList);
      assertEquals(1, count);

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

      compareRecords(agileList, readRecord);

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

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

    } finally {
      if (session != null) {
        session.rollback();
        session.close();
      }
    }
  }
Ejemplo n.º 3
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();
      }
    }
  }
Ejemplo n.º 4
0
 @Before
 public void setup() {
   SessionFactory.initializeForTest();
 }