Ignore:
Timestamp:
Apr 20, 2011, 5:17:02 AM (13 years ago)
Author:
anthony43
Message:

huge refactoring to introduce JiwigoException : a generic exception encapsulating low level exceptions (IOException, ProxyAuthentication, etc...)
The aim is to have, on the consumer side, just one exception to catch them all.
this refactoring may need a code review to check the changes.

Location:
extensions/jiwigo-ws-api/src/test/java/fr/mael/jiwigo/service
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/jiwigo-ws-api/src/test/java/fr/mael/jiwigo/service/CategoryServiceTest.java

    r10089 r10505  
    11package fr.mael.jiwigo.service;
    22
    3 import java.io.IOException;
    43import java.util.Date;
    54
     
    1110import fr.mael.jiwigo.dao.impl.CategoryDaoImpl;
    1211import fr.mael.jiwigo.service.impl.CategoryServiceImpl;
     12import fr.mael.jiwigo.transverse.exception.JiwigoException;
    1313import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException;
    1414import fr.mael.jiwigo.transverse.session.SessionManager;
     
    1616
    1717public class CategoryServiceTest {
    18         private SessionManager sessionManager;
     18    private SessionManager sessionManager;
    1919
    20         @Before
    21         public void setUp() {
    22                 sessionManager = new SessionManagerImpl("mael", "motdepasse", "http://mael.piwigo.com", "Unit Test");
    23                 sessionManager.processLogin();
    24         }
     20    @Before
     21    public void setUp() throws JiwigoException {
     22        sessionManager = new SessionManagerImpl("mael", "motdepasse", "http://mael.piwigo.com", "Unit Test");
     23        sessionManager.processLogin();
     24    }
    2525
    26         /**
    27          * Test of the list method
    28          *
    29          * @throws ProxyAuthenticationException
    30          */
    31         @Test
    32         public void ListerTest() throws ProxyAuthenticationException {
    33                 try {
    34                         CategoryDaoImpl categaryDao = new CategoryDaoImpl();
    35                         categaryDao.setSessionManager(sessionManager);
    36                         categaryDao.list(true);
    37                         categaryDao.list(false);
    38                 } catch (IOException e) {
    39                         e.printStackTrace();
    40                 }
    41         }
     26    /**
     27     * Test of the list method
     28     *
     29     * @throws ProxyAuthenticationException
     30     */
     31    @Test
     32    public void ListerTest() throws JiwigoException {
     33        CategoryDaoImpl categaryDao = new CategoryDaoImpl();
     34        categaryDao.setSessionManager(sessionManager);
     35        categaryDao.list(true);
     36        categaryDao.list(false);
     37    }
    4238
    43         /**
    44         * Test of the creation method
    45         *
    46         * @throws ProxyAuthenticationException
    47         */
    48         @Test
    49         public void creerTest() throws ProxyAuthenticationException {
    50                 Date date = new Date();
    51                 CategoryServiceImpl categoryService = new CategoryServiceImpl();
    52                 CategoryDaoImpl dao = new CategoryDaoImpl();
    53                 dao.setSessionManager(sessionManager);
    54                 categoryService.setDao(dao);
    55                 Assert.assertSame(true, categoryService.create("Category" + date.getTime()));
    56         }
     39    /**
     40    * Test of the creation method
     41    *
     42    * @throws ProxyAuthenticationException
     43    */
     44    @Test
     45    public void creerTest() throws JiwigoException {
     46        Date date = new Date();
     47        CategoryServiceImpl categoryService = new CategoryServiceImpl();
     48        CategoryDaoImpl dao = new CategoryDaoImpl();
     49        dao.setSessionManager(sessionManager);
     50        categoryService.setDao(dao);
     51        Assert.assertSame(true, categoryService.create("Category" + date.getTime()));
     52    }
    5753
    5854}
  • extensions/jiwigo-ws-api/src/test/java/fr/mael/jiwigo/service/ServicesTest.java

    r10494 r10505  
    22
    33import java.io.File;
    4 import java.io.IOException;
    54import java.util.List;
    65
     
    1615import fr.mael.jiwigo.service.impl.CategoryServiceImpl;
    1716import fr.mael.jiwigo.service.impl.ImageServiceImpl;
     17import fr.mael.jiwigo.transverse.exception.JiwigoException;
    1818import fr.mael.jiwigo.transverse.session.SessionManager;
    1919import fr.mael.jiwigo.transverse.session.impl.SessionManagerImpl;
     
    2424
    2525    @Before
    26     public void setUp() {
     26    public void setUp() throws JiwigoException {
    2727        sessionManager = new SessionManagerImpl("mael", "motdepasse", "http://mael.piwigo.com", "Unit Test");
    2828        sessionManager.processLogin();
     
    7171        try {
    7272            imageService.addSimple(imageFile, categoryTest, title);
    73         } catch (IOException e) {
     73        } catch (JiwigoException e) {
    7474            Assert.fail("An exception was thrown while trying to send the pictures" + e.getMessage());
    7575        }
  • extensions/jiwigo-ws-api/src/test/java/fr/mael/jiwigo/service/TagServiceTest.java

    r10089 r10505  
    1212import fr.mael.jiwigo.dao.impl.TagDaoImpl;
    1313import fr.mael.jiwigo.service.impl.TagServiceImpl;
     14import fr.mael.jiwigo.transverse.exception.JiwigoException;
    1415import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException;
    1516import fr.mael.jiwigo.transverse.session.SessionManager;
     
    1819public class TagServiceTest {
    1920
    20         private SessionManager sessionManager;
     21    private SessionManager sessionManager;
    2122
    22         @Before
    23         public void setUp() {
    24                 sessionManager = new SessionManagerImpl("mael", "motdepasse", "http://mael.piwigo.com", "Unit Test");
    25                 sessionManager.processLogin();
    26         }
     23    @Before
     24    public void setUp() throws JiwigoException {
     25        sessionManager = new SessionManagerImpl("mael", "motdepasse", "http://mael.piwigo.com", "Unit Test");
     26        sessionManager.processLogin();
     27    }
    2728
    28         /**
    29          * Test of the listing method
    30          *
    31          * @throws ProxyAuthenticationException
    32          */
    33         @Test
    34         @Ignore
    35         public void listTest() throws ProxyAuthenticationException {
    36                 try {
    37                         TagDaoImpl tagDao = new TagDaoImpl();
    38                         tagDao.setSessionManager(sessionManager);
    39                         // TODO something weird happens here,
    40                         // java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.DeepNodeListImpl cannot be cast to
    41                         // org.w3c.dom.Element
    42                         // at fr.mael.jiwigo.dao.impl.TagDaoImpl.list(TagDaoImpl.java:58)
    43                         tagDao.list();
    44                 } catch (IOException e) {
    45                         e.printStackTrace();
    46                 }
    47         }
     29    /**
     30     * Test of the listing method
     31     * @throws JiwigoException
     32     *
     33     * @throws ProxyAuthenticationException
     34     */
     35    @Test
     36    @Ignore
     37    public void listTest() throws JiwigoException {
     38        TagDaoImpl tagDao = new TagDaoImpl();
     39        tagDao.setSessionManager(sessionManager);
     40        // TODO something weird happens here,
     41        // java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.DeepNodeListImpl cannot be cast to
     42        // org.w3c.dom.Element
     43        // at fr.mael.jiwigo.dao.impl.TagDaoImpl.list(TagDaoImpl.java:58)
     44        tagDao.list();
     45    }
    4846
    49         /**
    50          * Test of the creation method
    51          *
    52          * @throws ProxyAuthenticationException
    53          * @throws IOException
    54          */
    55         @Test
    56         public void createTest() throws ProxyAuthenticationException, IOException {
    57                 Date date = new Date();
    58                 TagServiceImpl tagService = new TagServiceImpl();
    59                 TagDaoImpl tagDao = new TagDaoImpl();
    60                 tagDao.setSessionManager(sessionManager);
    61                 tagService.setDao(tagDao);
    62                 Assert.assertSame(true, tagService.create("Tag" + date.getTime()));
    63         }
     47    /**
     48     * Test of the creation method
     49     * @throws JiwigoException
     50     *
     51     * @throws ProxyAuthenticationException
     52     * @throws IOException
     53     */
     54    @Test
     55    public void createTest() throws JiwigoException {
     56        Date date = new Date();
     57        TagServiceImpl tagService = new TagServiceImpl();
     58        TagDaoImpl tagDao = new TagDaoImpl();
     59        tagDao.setSessionManager(sessionManager);
     60        tagService.setDao(tagDao);
     61        Assert.assertSame(true, tagService.create("Tag" + date.getTime()));
     62    }
    6463
    6564}
Note: See TracChangeset for help on using the changeset viewer.