@@ -0,0 +1,2566 @@
+/*%0A * To change this license header, choose License Headers in Project Properties.%0A * To change this template file, choose Tools %7C Templates%0A * and open the template in the editor.%0A */%0Apackage de.hsbo.fbg.sm4c.common.dao.hibernate;%0A%0Aimport de.hsbo.fbg.sm4c.common.model.geonames.Admin4;%0Aimport de.hsbo.fbg.sm4c.common.dao.DaoFactory;%0Aimport de.hsbo.fbg.sm4c.common.dao.geonames.Admin03Dao;%0Aimport de.hsbo.fbg.sm4c.common.dao.geonames.Admin04Dao;%0Aimport de.hsbo.fbg.sm4c.common.dao.geonames.GeonameDao;%0Aimport de.hsbo.fbg.sm4c.common.model.geonames.Geoname;%0Aimport de.hsbo.fbg.sm4c.common.model.geonames.GeonameEntity;%0Aimport org.hamcrest.CoreMatchers;%0Aimport org.hibernate.Session;%0Aimport org.junit.After;%0Aimport org.junit.Assert;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0A/**%0A *%0A * @author Seba%0A */%0Apublic class HibernateGeonamesDaoIT %7B%0A%0A    HibernateDatabaseConnection dbc;%0A    DaoFactory daoFactory;%0A    Session session;%0A%0A    @Before%0A    public void setup() throws Exception %7B%0A        dbc = new HibernateDatabaseConnection();%0A        dbc.afterPropertiesSet();%0A%0A        daoFactory = new HibernateDaoFactory(dbc);%0A        session = (Session) daoFactory.initializeContext();%0A    %7D%0A%0A    @Test%0A    public void roundTrip() %7B%0A        Admin04Dao admin04Dao = daoFactory.createAdmin04Dao(session);%0A        Admin03Dao admin03Dao = daoFactory.createAdmin03Dao(session);%0A        Admin4 admin4 = admin04Dao.retrieveByName(%22Wonneberg%22).get();%0A%0A        Assert.assertThat(admin4.getName(), CoreMatchers.equalTo(%22Wonneberg%22));%0A        Assert.assertThat(admin4.getAdmin3().getName(), CoreMatchers.equalTo(%22Landkreis Traunstein%22));%0A        Assert.assertThat(admin4.getAdmin3().getAdmin2().getName(), CoreMatchers.equalTo(%22Upper Bavaria%22));%0A        Assert.assertThat(admin4.getAdmin3().getAdmin2().getAdmin1().getName(), CoreMatchers.equalTo(%22Bavaria%22));%0A%0A        GeonameDao geonameDao = daoFactory.createGeonameDao(session);%0A        Geoname geoname = geonameDao.retrieveByName(%22Zwieselhof%22).get();%0A        Assert.assertThat(geoname.getName(), CoreMatchers.equalTo(%22Zwieselhof%22));%0A%0A        Geoname geoname2 = geonameDao.retrieveByName(%22Holste%22).get();%0A        Assert.assertThat(geoname2.getParent().getFeatureCode(), CoreMatchers.equalTo(%22ADM3%22));%0A        Assert.assertThat(geoname2.getParent().getParent().getFeatureCode(), CoreMatchers.equalTo(%22ADM1%22));%0A%0A    %7D%0A%0A    @After%0A    public void shutDown() %7B%0A        try %7B%0A            dbc.destroy();%0A        %7D catch (Exception e) %7B%0A            // TODO Auto-generated catch block%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%0A%7D%0A

introduce geonames dao testing