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

File SchedulerTest.java

 

Code metrics

10
42
1
1
127
72
6
0.14
42
1
6

Classes

Class Line # Actions
SchedulerTest 39 42 0% 6 10
0.811320881.1%
 

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.scheduler.test.ui;
21   
22    import org.junit.Assert;
23    import org.junit.Rule;
24    import org.junit.Test;
25    import org.openqa.selenium.By;
26    import org.xwiki.scheduler.test.po.SchedulerHomePage;
27    import org.xwiki.scheduler.test.po.SchedulerPage;
28    import org.xwiki.scheduler.test.po.editor.SchedulerEditPage;
29    import org.xwiki.test.ui.AbstractTest;
30    import org.xwiki.test.ui.SuperAdminAuthenticationRule;
31    import org.xwiki.test.ui.browser.IgnoreBrowser;
32    import org.xwiki.test.ui.browser.IgnoreBrowsers;
33   
34    /**
35    * Tests Scheduler application features.
36    *
37    * @version $Id: 9ffd777f58848c5bb1e63fa7637d95dc6100d5b7 $
38    */
 
39    public class SchedulerTest extends AbstractTest
40    {
41    @Rule
42    public SuperAdminAuthenticationRule authenticationRule = new SuperAdminAuthenticationRule(getUtil());
43   
 
44  1 toggle @Test
45    @IgnoreBrowsers({
46    @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"),
47    @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177")
48    })
49    public void testScheduler()
50    {
51    // Make sure the job doesn't exist. Note that we don't delete the job after the test is executed (@After)
52    // because we want to remain on the same page in case of a test failure so that our TestDebugger rule can
53    // collect accurate information about the failure. It's not a problem if the job remains scheduled because it
54    // does nothing. Other tests should not rely on the number of scheduler jobs though.
55  1 getUtil().deletePage("Scheduler", "SchedulerTestJob");
56   
57    // Create Job
58  1 SchedulerHomePage schedulerHomePage = SchedulerHomePage.gotoPage();
59  1 schedulerHomePage.setJobName("SchedulerTestJob");
60  1 SchedulerEditPage schedulerEdit = schedulerHomePage.clickAdd();
61   
62  1 String jobName = "Tester problem";
63  1 schedulerEdit.setJobName(jobName);
64  1 schedulerEdit.setJobDescription(jobName);
65  1 schedulerEdit.setCron("0 15 10 ? * MON-FRI");
66  1 SchedulerPage schedulerPage = schedulerEdit.clickSaveAndView();
67  1 schedulerHomePage = schedulerPage.backToHome();
68   
69    // View Job
70  1 schedulerPage = schedulerHomePage.clickJobActionView(jobName);
71   
72    // Tests that a scheduler job page's default edit mode is Form
73    // Note: This line below will fail if the page is not edited in Form mode!
74  1 schedulerPage.edit();
75  1 new SchedulerEditPage().setJobDescription("test");
76  1 schedulerEdit.clickCancel();
77  1 schedulerHomePage = schedulerPage.backToHome();
78   
79    // Edit Job
80  1 schedulerEdit = schedulerHomePage.clickJobActionEdit(jobName);
81  1 schedulerEdit.setJobDescription("Tester problem2");
82  1 schedulerEdit.setCron("0 0/5 14 * * ?");
83  1 schedulerPage = schedulerEdit.clickSaveAndView();
84  1 schedulerHomePage = schedulerPage.backToHome();
85   
86    // Delete and Restore Job
87  1 schedulerHomePage.clickJobActionDelete(jobName).clickYes();
88  1 schedulerHomePage = SchedulerHomePage.gotoPage();
89  1 Assert.assertFalse(getDriver().hasElementWithoutWaiting(By.linkText(jobName)));
90    // Note: since the page doesn't exist, we need to disable the space redirect feature so that we end up on the
91    // terminal page that was removed.
92  1 getUtil().gotoPage("Scheduler", "SchedulerTestJob", "view", "spaceRedirect=false");
93  1 getDriver().findElement(By.linkText("Restore")).click();
94  1 schedulerPage = new SchedulerPage();
95  1 schedulerPage.backToHome();
96   
97    // Schedule Job
98  1 schedulerHomePage.clickJobActionSchedule(jobName);
99  1 if (schedulerHomePage.hasError()) {
100  0 Assert.fail("Failed to schedule job. Error [" + schedulerHomePage.getErrorMessage() + "]");
101    }
102   
103    // Trigger Job (a Job can only be triggered after it's been scheduled)
104  1 schedulerHomePage.clickJobActionTrigger(jobName);
105  1 if (schedulerHomePage.hasError()) {
106  0 Assert.fail("Failed to trigger job. Error [" + schedulerHomePage.getErrorMessage() + "]");
107    }
108   
109    // Pause Job
110  1 schedulerHomePage.clickJobActionPause(jobName);
111  1 if (schedulerHomePage.hasError()) {
112  0 Assert.fail("Failed to pause job. Error [" + schedulerHomePage.getErrorMessage() + "]");
113    }
114   
115    // Resume Job
116  1 schedulerHomePage.clickJobActionResume(jobName);
117  1 if (schedulerHomePage.hasError()) {
118  0 Assert.fail("Failed to resume job. Error [" + schedulerHomePage.getErrorMessage() + "]");
119    }
120   
121    // Unschedule Job
122  1 schedulerHomePage.clickJobActionUnschedule(jobName);
123  1 if (schedulerHomePage.hasError()) {
124  0 Assert.fail("Failed to unschedule job. Error [" + schedulerHomePage.getErrorMessage() + "]");
125    }
126    }
127    }