source: ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/RssCreatorTest.java @ 2162

Last change on this file since 2162 was 2162, checked in by olhsha, 12 years ago

# 50testing on files (functional part does work on the existing file, on the freshly written file -- null pointer exception), experimenting with the Marchaller

File size: 4.4 KB
Line 
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5package clarin.cmdi.componentregistry;
6
7import clarin.cmdi.componentregistry.components.CMDComponentSpec;
8import clarin.cmdi.componentregistry.model.AbstractDescription;
9import clarin.cmdi.componentregistry.model.ComponentDescription;
10import clarin.cmdi.componentregistry.model.ProfileDescription;
11import clarin.cmdi.componentregistry.rest.RegistryTestHelper;
12import clarin.cmdi.componentregistry.rss.RssItem;
13import java.io.IOException;
14import javax.xml.bind.JAXBException;
15import org.junit.After;
16import org.junit.AfterClass;
17import org.junit.Before;
18import org.junit.BeforeClass;
19import org.junit.Test;
20import static org.junit.Assert.*;
21
22/**
23 *
24 * @author olhsha
25 */
26public class RssCreatorTest {
27   
28    public RssCreatorTest() {
29    }
30   
31    // ????????????????
32    @BeforeClass
33    public static void setUpClass() {
34    }
35   
36    @AfterClass
37    public static void tearDownClass() {
38    }
39   
40    @Before
41    public void setUp() {
42    }
43   
44    @After
45    public void tearDown() {
46    }
47
48    /**
49     * Test of toRssItem method, of class RssCreator.
50     */
51    @Test
52    public void nullTestToRssItem() {
53       
54        RssCreator creator = new RssCreator(null);
55        RssItem result = creator.toRssItem();
56        assertEquals(null, result);
57       
58    }
59   
60   
61   
62    private ProfileDescription createTestProfileDescription(int commentcount, String creatorname, 
63    String description, String domainname, String groupname, String href, 
64    String name, boolean editorflag, String uid){
65       
66        ProfileDescription pdesc = ProfileDescription.createNewDescription();
67       
68        pdesc.setCommentsCount(commentcount);
69        pdesc.setCreatorName(creatorname);
70        pdesc.setDescription(description);
71        pdesc.setDomainName(domainname);
72        pdesc.setGroupName(groupname);
73        pdesc.setHref(href);
74        pdesc.setName(name);
75        pdesc.setShowInEditor(editorflag);
76        pdesc.setUserId(uid);
77       
78        return pdesc;
79       
80       
81    }
82   
83    private ComponentDescription createTestComponentDescription(int commentcount, String creatorname, 
84    String description, String domainname, String groupname, String href, 
85    String name, String uid){
86       
87        ComponentDescription cdesc = ComponentDescription.createNewDescription();
88       
89        cdesc.setCommentsCount(commentcount);
90        cdesc.setCreatorName(creatorname);
91        cdesc.setDescription(description);
92        cdesc.setDomainName(domainname);
93        cdesc.setGroupName(groupname);
94        cdesc.setHref(href);
95        cdesc.setName(name);
96        cdesc.setUserId(uid);
97       
98        return cdesc;
99       
100       
101    }
102   
103    private void assertEqualDescriptions(AbstractDescription desc, RssItem item){
104        assertEquals(desc.getCreatorName(), item.getAuthor());
105        assertEquals(desc.getDescription(), item.getDescription());
106        assertEquals(desc.getHref(), item.getLink());
107        assertEquals(desc.getRegistrationDate(), item.getPubDate());
108        assertEquals(desc.getName(), item.getTitle());
109    }
110   
111    @Test
112    public void profileTestToRssItem() {
113       
114        ProfileDescription pdesc=
115                createTestProfileDescription(23, "creatorname", 
116                "description", "domainname", "groupname", "href", "name", true, "uid");
117       
118        RssCreator creator = new RssCreator(pdesc);
119        RssItem result = creator.toRssItem();
120        assertEqualDescriptions(pdesc, result);
121       
122    }
123   
124    @Test
125    public void componentTestToRssItem() {
126       
127        ComponentDescription cdesc=
128                createTestComponentDescription(67, "creatorname", 
129                "description", "domainname", "groupname", "href", "name", "uid");
130       
131        RssCreator creator = new RssCreator(cdesc);
132        RssItem result = creator.toRssItem();
133        assertEqualDescriptions(cdesc, result);
134       
135    }
136   
137   
138    @Test
139      public  void fileLargeProfileTestToRssItem() throws IOException, JAXBException {
140         
141          String largeprofilestring = RegistryTestHelper.getLargeProfileContent(); // reading from the file
142          CMDComponentSpec compspec=RegistryTestHelper.getComponentFromString(largeprofilestring); // calling unmarchaller
143         
144         
145      // do not know how to get AbstractDescription from this file   
146         
147      }
148     
149}
Note: See TracBrowser for help on using the repository browser.