Java tutorial
/* Copyright 2013 Mael Le Guvel This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See the COPYING file for more details. */ package fr.mael.microrss.service; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.AccessDeniedException; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.annotation.Transactional; import fr.mael.microrss.BaseTest; import fr.mael.microrss.ttrss.TTRssImporter; import fr.mael.microrss.util.Configuration; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/fr/mael/microrss/conf/application-context-test.xml" }) @Transactional public class FeedServiceTest extends BaseTest { @Autowired private FeedService feedService; @Autowired private Configuration configuration; @Autowired private TTRssImporter importer; @Test(expected = AccessDeniedException.class) public void testNbFail() { login(18); feedService.pageNumber(feedService.get(1)); } @Test public void testNb() { login(17); configuration.setArticlePageSize(4); Long nb = feedService.pageNumber(feedService.get(1)); Assert.assertEquals(new Long(2), new Long(nb)); configuration.setArticlePageSize(3); nb = feedService.pageNumber(feedService.get(1)); Assert.assertEquals(new Long(3), new Long(nb)); } }