Ignore:
Timestamp:
Mar 29, 2011, 8:24:34 PM (14 years ago)
Author:
mlg
Message:

Adds spring for the dependency injection
Deletion of jdom (not useful just for a class that manipulates a simple XML file)

Location:
extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/TestBase.java

    r9431 r9921  
    66
    77import fr.mael.jiwigo.transverse.session.SessionManager;
     8import fr.mael.jiwigo.transverse.util.spring.SpringUtils;
    89
    910public class TestBase {
    1011    public TestBase() {
    11         Main.sessionManager = new SessionManager("mael", "motdepasse", "http://mael.piwigo.com");
    12         if (Main.sessionManager.processLogin() != 0) {
     12        SessionManager sessionManager = SpringUtils.getSessionManager();
     13        sessionManager.setLogin("mael");
     14        sessionManager.setPassword("motdepasse");
     15        sessionManager.setUrl("http://mael.piwigo.com/ws.php");
     16        if (sessionManager.processLogin() != 0) {
    1317            try {
    1418                throw new Exception("Connection failed");
  • extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/service/CategoryServiceTest.java

    r9431 r9921  
    88import org.junit.Test;
    99
    10 import fr.mael.jiwigo.Main;
    1110import fr.mael.jiwigo.TestBase;
    12 import fr.mael.jiwigo.dao.CategoryDao;
    1311import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException;
     12import fr.mael.jiwigo.transverse.util.spring.SpringUtils;
    1413
    1514public class CategoryServiceTest extends TestBase {
     
    2524    public void ListerTest() throws ProxyAuthenticationException {
    2625        try {
    27             CategoryDao.getInstance(Main.sessionManager).list(true);
    28             CategoryDao.getInstance(Main.sessionManager).list(false);
     26            SpringUtils.getCategoryService().list(true);
     27            SpringUtils.getCategoryService().list(false);
    2928        } catch (IOException e) {
    3029            e.printStackTrace();
     
    3938    public void creerTest() throws ProxyAuthenticationException {
    4039        Date date = new Date();
    41         Assert.assertSame(true, CategoryService.getInstance(Main.sessionManager).create("Category" + date.getTime()));
     40        Assert.assertSame(true, SpringUtils.getCategoryService().create("Category" + date.getTime()));
    4241    }
    4342
  • extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/service/ServicesTest.java

    r9878 r9921  
    55import org.junit.Test;
    66
    7 import fr.mael.jiwigo.Main;
    87import fr.mael.jiwigo.TestBase;
    98import fr.mael.jiwigo.om.Category;
    109import fr.mael.jiwigo.om.Comment;
    1110import fr.mael.jiwigo.om.Image;
     11import fr.mael.jiwigo.transverse.util.spring.SpringUtils;
    1212
    1313public class ServicesTest extends TestBase {
     
    2020    public void testCreer() throws Exception {
    2121        Category cat = null;
    22         for (Category category : CategoryService.getInstance(Main.sessionManager).list(true)) {
     22        for (Category category : SpringUtils.getCategoryService().list(true)) {
    2323            if (category.getIdentifier().equals(3)) {
    2424                cat = category;
     
    2727        }
    2828
    29         Image image = ImageService.getInstance(Main.sessionManager).listByCategory(cat.getIdentifier(), true).get(0);
    30         List<Comment> comments = CommentService.getInstance(Main.sessionManager).list(image.getIdentifier());
     29        Image image = SpringUtils.getImageService().listByCategory(cat.getIdentifier(), true).get(0);
     30        List<Comment> comments = SpringUtils.getCommentService().list(image.getIdentifier());
    3131        //      int firstCount = comments.size();
    32         CommentService.getInstance(Main.sessionManager).create("comment test", image.getIdentifier(), "none");
     32        SpringUtils.getCommentService().create("comment test", image.getIdentifier(), "none");
    3333        //      int secondCount = CommentService.getInstance(Main.sessionManager).list(image.getIdentifier()).size();
    3434        //      Assert.assertSame(firstCount + 1, secondCount);
  • extensions/jiwigo/trunk/src/test/java/fr/mael/jiwigo/service/TagServiceTest.java

    r9431 r9921  
    88import org.junit.Test;
    99
    10 import fr.mael.jiwigo.Main;
    1110import fr.mael.jiwigo.TestBase;
    12 import fr.mael.jiwigo.dao.TagDao;
    1311import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException;
     12import fr.mael.jiwigo.transverse.util.spring.SpringUtils;
    1413
    1514public class TagServiceTest extends TestBase {
     
    2625    public void ListerTest() throws ProxyAuthenticationException {
    2726        try {
    28             TagDao.getInstance(Main.sessionManager).list();
     27            SpringUtils.getTagService().list();
    2928        } catch (IOException e) {
    3029            e.printStackTrace();
     
    4039        Date date = new Date();
    4140        try {
    42             Assert.assertSame(true, TagService.getInstance(Main.sessionManager).create("Tag" + date.getTime()));
     41            Assert.assertSame(true, SpringUtils.getTagService().create("Tag" + date.getTime()));
    4342        } catch (IOException e) {
    4443            // TODO Auto-generated catch block
Note: See TracChangeset for help on using the changeset viewer.