1 | package fr.mael.jiwigo.service; |
---|
2 | |
---|
3 | import java.io.IOException; |
---|
4 | import java.util.Date; |
---|
5 | |
---|
6 | import junit.framework.Assert; |
---|
7 | |
---|
8 | import org.junit.Before; |
---|
9 | import org.junit.Ignore; |
---|
10 | import org.junit.Test; |
---|
11 | |
---|
12 | import fr.mael.jiwigo.dao.impl.TagDaoImpl; |
---|
13 | import fr.mael.jiwigo.service.impl.TagServiceImpl; |
---|
14 | import fr.mael.jiwigo.transverse.exception.JiwigoException; |
---|
15 | import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException; |
---|
16 | import fr.mael.jiwigo.transverse.session.SessionManager; |
---|
17 | import fr.mael.jiwigo.transverse.session.impl.SessionManagerImpl; |
---|
18 | |
---|
19 | public class TagServiceTest { |
---|
20 | |
---|
21 | private SessionManager sessionManager; |
---|
22 | |
---|
23 | @Before |
---|
24 | public void setUp() throws JiwigoException { |
---|
25 | sessionManager = new SessionManagerImpl("mael", "motdepasse", "http://mael.piwigo.com", "Unit Test"); |
---|
26 | sessionManager.processLogin(); |
---|
27 | } |
---|
28 | |
---|
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 | } |
---|
46 | |
---|
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 | } |
---|
63 | |
---|
64 | } |
---|