source: extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/service/ServicesTest.java @ 6963

Last change on this file since 6963 was 6963, checked in by mlg, 14 years ago

Add unit tests :
New unit tests for the services :

  • CategoryServiceTest that tests the listing of the categories and the creation of a category
  • ServicesTest that tests the listing of the categories, then the listing of images of a category and finally adding a comment to an image.

Add informations in the install.txt file to explain how to build the executable jar file via maven (this allows to execute the tests before building, and does not build if tests fail).

File size: 895 bytes
Line 
1package fr.mael.jiwigo.service;
2
3import junit.framework.Assert;
4
5import org.junit.Test;
6
7import fr.mael.jiwigo.TestBase;
8import fr.mael.jiwigo.om.Category;
9import fr.mael.jiwigo.om.Image;
10
11public class ServicesTest extends TestBase {
12
13    public ServicesTest() {
14        super();
15    }
16
17    @Test
18    public void testCreer() throws Exception {
19        Category cat = null;
20        for (Category category : CategoryService.getInstance().lister(true)) {
21            if (category.getIdentifiant().equals(3)) {
22                cat = category;
23                break;
24            }
25        }
26        Image image = ImageService.getInstance().listerParCategory(cat.getIdentifiant(), true).get(0);
27        int firstCount = CommentService.getInstance().lister(image.getIdentifiant()).size();
28        CommentService.getInstance().creer("comment test", image.getIdentifiant(), "none");
29        Assert.assertSame(firstCount + 1, CommentService.getInstance().lister(image.getIdentifiant()).size());
30    }
31}
Note: See TracBrowser for help on using the repository browser.