PageRenderTime 14ms CodeModel.GetById 10ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/sigmah/src/test/java/org/sigmah/server/dao/hibernate/CountryDAOTest.java

http://sigma-h.googlecode.com/
Java | 40 lines | 26 code | 10 blank | 4 comment | 0 complexity | 46890410ed5f80f1cf8e1727ffbd9280 MD5 | raw file
 1/*
 2 * All Sigmah code is released under the GNU General Public License v3
 3 * See COPYRIGHT.txt and LICENSE.txt.
 4 */
 5
 6package org.sigmah.server.dao.hibernate;
 7
 8import com.google.inject.Inject;
 9import org.junit.Test;
10import org.junit.runner.RunWith;
11import org.sigmah.shared.dao.CountryDAO;
12import org.sigmah.server.dao.OnDataSet;
13import org.sigmah.shared.domain.Country;
14import org.sigmah.test.InjectionSupport;
15import org.sigmah.test.MockHibernateModule;
16import org.sigmah.test.Modules;
17
18import java.util.List;
19
20import static org.hamcrest.CoreMatchers.equalTo;
21import static org.hamcrest.CoreMatchers.is;
22import static org.junit.Assert.assertThat;
23
24@RunWith(InjectionSupport.class)
25@Modules({MockHibernateModule.class})
26public class CountryDAOTest {
27
28    @Inject
29    private CountryDAO countryDAO;
30
31    @Test @OnDataSet("/dbunit/multicountry.db.xml")
32    public void testQueryAll() {
33
34        List<Country> countries = countryDAO.queryAllCountriesAlphabetically();
35
36        assertThat(countries.size(), is(equalTo(3)));
37        assertThat(countries.get(0).getName(), equalTo("Azerbaijan"));
38    }
39
40}