1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.sharepage.test.ui; |
21 |
|
|
22 |
|
import javax.mail.internet.MimeMessage; |
23 |
|
|
24 |
|
import org.junit.After; |
25 |
|
import org.junit.Before; |
26 |
|
import org.junit.Rule; |
27 |
|
import org.junit.Test; |
28 |
|
import org.xwiki.sharepage.test.po.ShareDialog; |
29 |
|
import org.xwiki.sharepage.test.po.ShareResultDialog; |
30 |
|
import org.xwiki.sharepage.test.po.ShareableViewPage; |
31 |
|
import org.xwiki.test.ui.AbstractTest; |
32 |
|
|
33 |
|
import org.xwiki.test.ui.SuperAdminAuthenticationRule; |
34 |
|
import org.xwiki.test.ui.po.ViewPage; |
35 |
|
|
36 |
|
import com.icegreen.greenmail.util.GreenMail; |
37 |
|
import com.icegreen.greenmail.util.ServerSetupTest; |
38 |
|
|
39 |
|
import static org.junit.Assert.assertEquals; |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
@version |
45 |
|
@since |
46 |
|
|
|
|
| 95.7% |
Uncovered Elements: 1 (23) |
Complexity: 4 |
Complexity Density: 0.22 |
|
47 |
|
public class SharePageTest extends AbstractTest |
48 |
|
{ |
49 |
|
@Rule |
50 |
|
public SuperAdminAuthenticationRule authenticationRule = new SuperAdminAuthenticationRule(getUtil()); |
51 |
|
|
52 |
|
private GreenMail mail; |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
54 |
1 |
@Before... |
55 |
|
public void startMail() |
56 |
|
{ |
57 |
1 |
this.mail = new GreenMail(ServerSetupTest.SMTP); |
58 |
1 |
this.mail.start(); |
59 |
1 |
getUtil().updateObject("Mail", "MailConfig", "Mail.SendMailConfigClass", 0, "host", "localhost", "port", |
60 |
|
"3025", "sendWaitTime", "0"); |
61 |
|
} |
62 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
63 |
1 |
@After... |
64 |
|
public void stopMail() |
65 |
|
{ |
66 |
1 |
if (this.mail != null) { |
67 |
1 |
this.mail.stop(); |
68 |
|
} |
69 |
|
} |
70 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
71 |
1 |
@Test... |
72 |
|
public void testShareByEmail() throws Exception |
73 |
|
{ |
74 |
|
|
75 |
1 |
getUtil().deletePage(getTestClassName(), getTestMethodName()); |
76 |
|
|
77 |
1 |
ViewPage vp = getUtil().createPage(getTestClassName(), getTestMethodName(), "something", "title"); |
78 |
1 |
ShareableViewPage svp = new ShareableViewPage(); |
79 |
1 |
svp.clickShareByEmail(); |
80 |
1 |
ShareDialog sd = new ShareDialog(); |
81 |
|
|
82 |
1 |
sd.setEmailField("john@doe.com"); |
83 |
1 |
sd.setMessage("test"); |
84 |
1 |
ShareResultDialog srd = sd.sendMail(); |
85 |
1 |
assertEquals("The message has been sent to john.", srd.getResultMessage()); |
86 |
1 |
srd.clickBackLink(); |
87 |
|
|
88 |
|
|
89 |
1 |
this.mail.waitForIncomingEmail(10000L, 1); |
90 |
|
|
91 |
1 |
MimeMessage mimeMessage = this.mail.getReceivedMessages()[0]; |
92 |
1 |
assertEquals("superadmin wants to share a document with you", mimeMessage.getSubject()); |
93 |
|
} |
94 |
|
} |