/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. package org.sigmah.server.dao.hibernate;
  6. import com.google.inject.Inject;
  7. import org.junit.Test;
  8. import org.junit.runner.RunWith;
  9. import org.sigmah.shared.dao.CountryDAO;
  10. import org.sigmah.server.dao.OnDataSet;
  11. import org.sigmah.shared.domain.Country;
  12. import org.sigmah.test.InjectionSupport;
  13. import org.sigmah.test.MockHibernateModule;
  14. import org.sigmah.test.Modules;
  15. import java.util.List;
  16. import static org.hamcrest.CoreMatchers.equalTo;
  17. import static org.hamcrest.CoreMatchers.is;
  18. import static org.junit.Assert.assertThat;
  19. @RunWith(InjectionSupport.class)
  20. @Modules({MockHibernateModule.class})
  21. public class CountryDAOTest {
  22. @Inject
  23. private CountryDAO countryDAO;
  24. @Test @OnDataSet("/dbunit/multicountry.db.xml")
  25. public void testQueryAll() {
  26. List<Country> countries = countryDAO.queryAllCountriesAlphabetically();
  27. assertThat(countries.size(), is(equalTo(3)));
  28. assertThat(countries.get(0).getName(), equalTo("Azerbaijan"));
  29. }
  30. }