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.ProxyAuthenticationException; |
---|
15 | import fr.mael.jiwigo.transverse.session.SessionManager; |
---|
16 | import fr.mael.jiwigo.transverse.session.impl.SessionManagerImpl; |
---|
17 | |
---|
18 | public class TagServiceTest { |
---|
19 | |
---|
20 | private SessionManager sessionManager; |
---|
21 | |
---|
22 | @Before |
---|
23 | public void setUp() { |
---|
24 | sessionManager = new SessionManagerImpl("mael", "motdepasse", "http://mael.piwigo.com", "Unit Test"); |
---|
25 | sessionManager.processLogin(); |
---|
26 | } |
---|
27 | |
---|
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 | } |
---|
48 | |
---|
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 | } |
---|
64 | |
---|
65 | } |
---|