001 /** 002 * Copyright 2004-2013 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.hr.lm.leave.web; 017 018 import junit.framework.Assert; 019 020 import org.joda.time.DateTime; 021 import org.junit.After; 022 import org.junit.Before; 023 import org.junit.Test; 024 import org.kuali.hr.test.KPMETestCase; 025 import org.kuali.hr.time.test.HtmlUnitUtil; 026 import org.kuali.hr.time.test.TkTestConstants; 027 028 import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController; 029 import com.gargoylesoftware.htmlunit.WebClient; 030 import com.gargoylesoftware.htmlunit.html.HtmlButton; 031 import com.gargoylesoftware.htmlunit.html.HtmlPage; 032 033 import java.lang.management.MemoryManagerMXBean; 034 import java.util.Calendar; 035 036 public class LeaveCalendarWebTest extends KPMETestCase { 037 038 @Before 039 public void setUp() throws Exception { 040 super.setUp(); 041 } 042 043 @After 044 public void tearDown() throws Exception { 045 super.tearDown(); 046 } 047 048 /*public void setWebClient(WebClient webClient) { 049 webClient.setJavaScriptEnabled(true); 050 webClient.setThrowExceptionOnScriptError(true); 051 webClient.setAjaxController(new NicelyResynchronizingAjaxController()); 052 webClient.waitForBackgroundJavaScript(10000); 053 }*/ 054 055 @Test 056 public void testLeaveCalendarPage() throws Exception { 057 // get the page and Login 058 HtmlPage leaveCalendarPage = HtmlUnitUtil 059 .gotoPageAndLogin(TkTestConstants.Urls.LEAVE_CALENDAR_URL+"?documentId=1000", true); 060 Assert.assertNotNull("Leave Request page not found" ,leaveCalendarPage); 061 062 //this.setWebClient(leaveCalendarPage.getWebClient()); 063 064 DateTime dt = new DateTime(); 065 Assert.assertTrue("Page does not have Current calendar ", leaveCalendarPage.asText().contains("March 2012")); 066 067 // Check for next document 068 HtmlButton nextButton = (HtmlButton) leaveCalendarPage 069 .getElementById("nav_next_lc"); 070 Assert.assertNotNull(nextButton); 071 //TODO: click not working. Not even getting to the 'execute' method in LeaveCalendarAction 072 HtmlPage page = nextButton.click(); 073 Assert.assertNotNull(page); 074 075 // Check for previous document 076 HtmlButton prevButton = (HtmlButton) page 077 .getElementById("nav_prev_lc"); 078 Assert.assertNotNull(prevButton); 079 page = prevButton.click(); 080 Assert.assertNotNull(page); 081 082 } 083 084 }