View Javadoc

1   /**
2    * Copyright 2004-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.hr.lm.leave.web;
17  
18  import junit.framework.Assert;
19  
20  import org.joda.time.DateTime;
21  import org.junit.After;
22  import org.junit.Before;
23  import org.junit.Test;
24  import org.kuali.hr.test.KPMETestCase;
25  import org.kuali.hr.time.test.HtmlUnitUtil;
26  import org.kuali.hr.time.test.TkTestConstants;
27  
28  import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
29  import com.gargoylesoftware.htmlunit.WebClient;
30  import com.gargoylesoftware.htmlunit.html.HtmlButton;
31  import com.gargoylesoftware.htmlunit.html.HtmlPage;
32  
33  import java.lang.management.MemoryManagerMXBean;
34  import java.util.Calendar;
35  
36  public class LeaveCalendarWebTest extends KPMETestCase {
37  
38  	@Before
39  	public void setUp() throws Exception {
40  		super.setUp();
41  	}
42  
43  	@After
44  	public void tearDown() throws Exception {
45  		super.tearDown();
46  	}
47  
48  	/*public void setWebClient(WebClient webClient) {
49  		webClient.setJavaScriptEnabled(true);
50  		webClient.setThrowExceptionOnScriptError(true);
51  		webClient.setAjaxController(new NicelyResynchronizingAjaxController());
52  		webClient.waitForBackgroundJavaScript(10000);
53  	}*/
54  
55  	@Test
56  	public void testLeaveCalendarPage() throws Exception {
57  		// get the page and Login
58  		HtmlPage leaveCalendarPage = HtmlUnitUtil
59  				.gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.LEAVE_CALENDAR_URL+"?documentId=1000", true);
60  		Assert.assertNotNull("Leave Request page not found" ,leaveCalendarPage);
61  
62  		//this.setWebClient(leaveCalendarPage.getWebClient());
63  
64  		Assert.assertTrue("Page does not have Current calendar ", leaveCalendarPage.asText().contains("March 2012"));
65  
66          // Check for next document
67          HtmlButton nextButton = (HtmlButton) leaveCalendarPage
68                  .getElementById("nav_next_lc");
69          Assert.assertNotNull(nextButton);
70          //TODO: click not working.  Not even getting to the 'execute' method in LeaveCalendarAction
71          HtmlPage page = nextButton.click();
72          Assert.assertNotNull(page);
73  
74  		// Check for previous document
75  		HtmlButton prevButton = (HtmlButton) page
76  				.getElementById("nav_prev_lc");
77  		Assert.assertNotNull(prevButton);
78          page = prevButton.click();
79          Assert.assertNotNull(page);
80  
81  	}
82  
83  }