package no.dusken.aranea.service;
import no.dusken.aranea.model.BannerLocation;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
/**
* @author Marvin B. Lillehaug <lillehau@underdusken.no>
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"/META-INF/integrationTest.xml"})
@TransactionConfiguration(transactionManager="transactionManager", defaultRollback=true)
@Transactional
public class BannerLocationServiceImplTest {
@Autowired
private BannerLocationService bannerLocationService;
@Before
public void setUp() throws Exception {
BannerLocation bl1 = new BannerLocation();
bl1.setName("bl1");
bl1.setUrl("bl1");
bl1 = bannerLocationService.saveOrUpdate(bl1);
BannerLocation bl2 = new BannerLocation();
bl2.setName("bl2");
bl2.setUrl("bl2");
bl2 = bannerLocationService.saveOrUpdate(bl2);
}
@Test
public void testGetBannerLocations() throws Exception {
List<BannerLocation> bls = bannerLocationService.getBannerLocations();
assertEquals("Wrong number of bannerlocations", 2, bls.size());
}
@Test
public void testGetByUrl() throws Exception {
BannerLocation bl1 = bannerLocationService.getByUrl("bl1");
assertNotNull("bl1 was null", bl1);
BannerLocation bl2 = bannerLocationService.getByUrl("bl2");
assertNotNull("bl2 was null", bl2);
}
}