Skip to content

Commit 91a2211

Browse files
committed
Some simple regression tests to assure status maintenance after Conf's refactoring and configuration. Related to issue #109 (not finished)
1 parent e4eb312 commit 91a2211

File tree

1 file changed

+171
-0
lines changed

1 file changed

+171
-0
lines changed
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
package org.buddycloud.channelserver.channel;
2+
3+
import java.util.Date;
4+
import java.util.HashMap;
5+
import org.buddycloud.channelserver.pubsub.accessmodel.AccessModels;
6+
import org.buddycloud.channelserver.pubsub.affiliation.Affiliations;
7+
import org.junit.Test;
8+
import static org.junit.Assert.*;
9+
import org.xmpp.packet.JID;
10+
11+
/**
12+
* Simples regression test to assure refactoring changes will not break something
13+
*/
14+
public class ConfTest {
15+
16+
private JID testChannelJID = new JID("[email protected]");
17+
private JID testOwnerJID = new JID("[email protected]");
18+
19+
//@Test
20+
public void testGetPostChannelNodename() {
21+
fail("The test case is a prototype.");
22+
}
23+
24+
//@Test
25+
public void testParseDate() {
26+
fail("The test case is a prototype.");
27+
}
28+
29+
//@Test
30+
public void testFormatDate() {
31+
fail("The test case is a prototype.");
32+
}
33+
34+
@Test
35+
public void testGetDefaultChannelConf() {
36+
HashMap<String,String> result = Conf.getDefaultChannelConf(testChannelJID, testOwnerJID);
37+
assertEquals(10, result.size());
38+
assertEquals(this.testChannelJID.toBareJID()+"'s title", result.get(Conf.TITLE));
39+
assertEquals(this.testChannelJID.toBareJID()+"'s description", result.get(Conf.DESCRIPTION));
40+
assertEquals("http://www.w3.org/2005/Atom", result.get(Conf.TYPE));
41+
assertEquals("publishers",result.get(Conf.PUBLISH_MODEL));
42+
assertEquals(AccessModels.open.toString(),result.get(Conf.ACCESS_MODEL));
43+
//assertEquals(Conf.formatDate(new Date()),result.get(Conf.CREATION_DATE));
44+
assertEquals(testOwnerJID.toBareJID(),result.get(Conf.OWNER));
45+
assertEquals(Affiliations.member.toString(),result.get(Conf.DEFAULT_AFFILIATION));
46+
assertEquals("1",result.get(Conf.NUM_SUBSCRIBERS));
47+
assertEquals("1",result.get(Conf.NOTIFY_CONFIG));
48+
}
49+
50+
@Test
51+
public void testGetDefaultPostChannelConf() {
52+
HashMap<String,String> result = Conf.getDefaultPostChannelConf(testChannelJID);
53+
assertEquals(11, result.size());
54+
assertEquals(this.testChannelJID.toBareJID()+"'s very own buddycloud channel!", result.get(Conf.TITLE));
55+
assertEquals("This channel belongs to " + this.testChannelJID.toBareJID() + ". To nobody else!", result.get(Conf.DESCRIPTION));
56+
assertEquals("http://www.w3.org/2005/Atom", result.get(Conf.TYPE));
57+
assertEquals("publishers",result.get(Conf.PUBLISH_MODEL));
58+
assertEquals(AccessModels.open.toString(),result.get(Conf.ACCESS_MODEL));
59+
//assertEquals(Conf.formatDate(new Date()),result.get(Conf.CREATION_DATE));
60+
assertEquals(testChannelJID.toBareJID(),result.get(Conf.OWNER));
61+
assertEquals(Affiliations.member.toString(),result.get(Conf.DEFAULT_AFFILIATION));
62+
assertEquals("1",result.get(Conf.NUM_SUBSCRIBERS));
63+
assertEquals("1",result.get(Conf.NOTIFY_CONFIG));
64+
assertEquals("personal",result.get(Conf.CHANNEL_TYPE));
65+
}
66+
67+
@Test
68+
public void testGetStatusChannelNodename() {
69+
assertEquals("/user/" + this.testChannelJID.toBareJID() + "/status", Conf.getStatusChannelNodename(testChannelJID));
70+
}
71+
72+
@Test
73+
public void testGetDefaultStatusChannelConf() {
74+
HashMap<String,String> result = Conf.getDefaultStatusChannelConf(testChannelJID);
75+
assertEquals(10, result.size());
76+
assertEquals(this.testChannelJID.toBareJID()+"'s very own buddycloud status!", result.get(Conf.TITLE));
77+
assertEquals("This is " + this.testChannelJID.toBareJID() + "'s mood a.k.a status -channel. Depends how geek you are.", result.get(Conf.DESCRIPTION));
78+
assertEquals("http://www.w3.org/2005/Atom", result.get(Conf.TYPE));
79+
assertEquals("publishers",result.get(Conf.PUBLISH_MODEL));
80+
assertEquals(AccessModels.open.toString(),result.get(Conf.ACCESS_MODEL));
81+
//assertEquals(Conf.formatDate(new Date()),result.get(Conf.CREATION_DATE));
82+
assertEquals(testChannelJID.toBareJID(),result.get(Conf.OWNER));
83+
assertEquals(Affiliations.member.toString(),result.get(Conf.DEFAULT_AFFILIATION));
84+
assertEquals("1",result.get(Conf.NUM_SUBSCRIBERS));
85+
assertEquals("1",result.get(Conf.NOTIFY_CONFIG));
86+
}
87+
88+
@Test
89+
public void testGetGeoPreviousChannelNodename() {
90+
assertEquals("/user/" + this.testChannelJID.toBareJID() + "/geo/previous", Conf.getGeoPreviousChannelNodename(testChannelJID));
91+
}
92+
93+
@Test
94+
public void testGetDefaultGeoPreviousChannelConf() {
95+
HashMap<String,String> result = Conf.getDefaultGeoPreviousChannelConf(testChannelJID);
96+
assertEquals(10, result.size());
97+
assertEquals(this.testChannelJID.toBareJID()+"'s previous location.", result.get(Conf.TITLE));
98+
assertEquals("Where " + this.testChannelJID.toBareJID() + " has been before.", result.get(Conf.DESCRIPTION));
99+
assertEquals("http://www.w3.org/2005/Atom", result.get(Conf.TYPE));
100+
assertEquals("publishers",result.get(Conf.PUBLISH_MODEL));
101+
assertEquals(AccessModels.open.toString(),result.get(Conf.ACCESS_MODEL));
102+
//assertEquals(Conf.formatDate(new Date()),result.get(Conf.CREATION_DATE));
103+
assertEquals(testChannelJID.toBareJID(),result.get(Conf.OWNER));
104+
assertEquals(Affiliations.member.toString(),result.get(Conf.DEFAULT_AFFILIATION));
105+
assertEquals("1",result.get(Conf.NUM_SUBSCRIBERS));
106+
assertEquals("1",result.get(Conf.NOTIFY_CONFIG));
107+
}
108+
109+
@Test
110+
public void testGetGeoCurrentChannelNodename() {
111+
assertEquals("/user/" + this.testChannelJID.toBareJID() + "/geo/current", Conf.getGeoCurrentChannelNodename(testChannelJID));
112+
}
113+
114+
@Test
115+
public void testGetDefaultGeoCurrentChannelConf() {
116+
HashMap<String,String> result = Conf.getDefaultGeoCurrentChannelConf(testChannelJID);
117+
assertEquals(10, result.size());
118+
assertEquals(this.testChannelJID.toBareJID()+"'s current location.", result.get(Conf.TITLE));
119+
assertEquals("Where " + this.testChannelJID.toBareJID() + " is now.", result.get(Conf.DESCRIPTION));
120+
assertEquals("http://www.w3.org/2005/Atom", result.get(Conf.TYPE));
121+
assertEquals("publishers",result.get(Conf.PUBLISH_MODEL));
122+
assertEquals(AccessModels.open.toString(),result.get(Conf.ACCESS_MODEL));
123+
//assertEquals(Conf.formatDate(new Date()),result.get(Conf.CREATION_DATE));
124+
assertEquals(testChannelJID.toBareJID(),result.get(Conf.OWNER));
125+
assertEquals(Affiliations.member.toString(),result.get(Conf.DEFAULT_AFFILIATION));
126+
assertEquals("1",result.get(Conf.NUM_SUBSCRIBERS));
127+
assertEquals("1",result.get(Conf.NOTIFY_CONFIG));
128+
}
129+
130+
@Test
131+
public void testGetGeoNextChannelNodename() {
132+
assertEquals("/user/" + this.testChannelJID.toBareJID() + "/geo/next", Conf.getGeoNextChannelNodename(testChannelJID));
133+
}
134+
135+
@Test
136+
public void testGetDefaultGeoNextChannelConf() {
137+
HashMap<String,String> result = Conf.getDefaultGeoNextChannelConf(testChannelJID);
138+
assertEquals(10, result.size());
139+
assertEquals(this.testChannelJID.toBareJID()+"'s next location.", result.get(Conf.TITLE));
140+
assertEquals("Where " + this.testChannelJID.toBareJID() + " is going to go.", result.get(Conf.DESCRIPTION));
141+
assertEquals("http://www.w3.org/2005/Atom", result.get(Conf.TYPE));
142+
assertEquals("publishers",result.get(Conf.PUBLISH_MODEL));
143+
assertEquals(AccessModels.open.toString(),result.get(Conf.ACCESS_MODEL));
144+
//assertEquals(Conf.formatDate(new Date()),result.get(Conf.CREATION_DATE));
145+
assertEquals(testChannelJID.toBareJID(),result.get(Conf.OWNER));
146+
assertEquals(Affiliations.member.toString(),result.get(Conf.DEFAULT_AFFILIATION));
147+
assertEquals("1",result.get(Conf.NUM_SUBSCRIBERS));
148+
assertEquals("1",result.get(Conf.NOTIFY_CONFIG));
149+
}
150+
151+
@Test
152+
public void testGetSubscriptionsChannelNodename() {
153+
assertEquals("/user/" + this.testChannelJID.toBareJID() + "/subscriptions", Conf.getSubscriptionsChannelNodename(testChannelJID));
154+
}
155+
156+
@Test
157+
public void testGetDefaultSubscriptionsChannelConf() {
158+
HashMap<String,String> result = Conf.getDefaultSubscriptionsChannelConf(testChannelJID);
159+
assertEquals(10, result.size());
160+
assertEquals(this.testChannelJID.toBareJID()+"'s susbcriptions.", result.get(Conf.TITLE));
161+
assertEquals(this.testChannelJID.toBareJID() + "'s subscriptions. ", result.get(Conf.DESCRIPTION));
162+
assertEquals("http://www.w3.org/2005/Atom", result.get(Conf.TYPE));
163+
assertEquals("publishers",result.get(Conf.PUBLISH_MODEL));
164+
assertEquals(AccessModels.open.toString(),result.get(Conf.ACCESS_MODEL));
165+
//assertEquals(Conf.formatDate(new Date()),result.get(Conf.CREATION_DATE));
166+
assertEquals(testChannelJID.toBareJID(),result.get(Conf.OWNER));
167+
assertEquals(Affiliations.member.toString(),result.get(Conf.DEFAULT_AFFILIATION));
168+
assertEquals("1",result.get(Conf.NUM_SUBSCRIBERS));
169+
assertEquals("1",result.get(Conf.NOTIFY_CONFIG));
170+
}
171+
}

0 commit comments

Comments
 (0)