1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.sharepage.test.ui

File SharePageTest.java

 

Code metrics

2
18
3
1
94
53
4
0.22
6
3
1.33

Classes

Class Line # Actions
SharePageTest 47 18 0% 4 1
0.9565217595.7%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
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    * UI tests for the Share by Email application.
43    *
44    * @version $Id: 57fa14018b18b49e358fd0edcf039d91e3c48b5b $
45    * @since 7.0RC1
46    */
 
47    public class SharePageTest extends AbstractTest
48    {
49    @Rule
50    public SuperAdminAuthenticationRule authenticationRule = new SuperAdminAuthenticationRule(getUtil());
51   
52    private GreenMail mail;
53   
 
54  1 toggle @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   
 
63  1 toggle @After
64    public void stopMail()
65    {
66  1 if (this.mail != null) {
67  1 this.mail.stop();
68    }
69    }
70   
 
71  1 toggle @Test
72    public void testShareByEmail() throws Exception
73    {
74    // Delete any existing test page
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    // Verify we received the email and that its content is valid
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    }