View Javadoc

1   /**
2    * Copyright 2005-2011 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 edu.samplu.admin.test;
17  
18  import static org.junit.Assert.assertEquals;
19  import static org.junit.Assert.assertTrue;
20  
21  import org.apache.commons.lang.RandomStringUtils;
22  import org.apache.commons.lang.StringUtils;
23  import org.junit.After;
24  import org.junit.Before;
25  import org.junit.Test;
26  
27  import com.thoughtworks.selenium.DefaultSelenium;
28  import com.thoughtworks.selenium.Selenium;
29  
30  /**
31   * tests that user 'admin', on blanket approving a new County maintenance document, results in a final document
32   * 
33   * @author Kuali Rice Team (rice.collab@kuali.org)
34   */
35  public class LocationCountyBlanketAppIT {
36      private Selenium selenium;
37      @Before
38      public void setUp() throws Exception {
39          selenium = new DefaultSelenium("localhost", 4444, "*firefox", System.getProperty("remote.public.url"));
40          selenium.start();
41      }
42  
43      @Test
44      public void testCounty() throws Exception {
45          String remotePublicUrl = System.getProperty("remote.public.url");
46          // remove the trailing slash to allow for correction concatenation in locating the lookup buttons below
47          if (StringUtils.endsWith(remotePublicUrl, "/")) {
48              remotePublicUrl = StringUtils.removeEnd(remotePublicUrl, "/");
49          }
50          selenium.open(remotePublicUrl);
51          assertEquals("Login", selenium.getTitle());
52          selenium.type("__login_user", "admin");
53          selenium.click("//input[@value='Login']");
54          selenium.waitForPageToLoad("30000");
55          assertEquals("Kuali Portal Index", selenium.getTitle());
56          selenium.click("link=Administration");
57          selenium.waitForPageToLoad("30000");
58          assertEquals("Kuali Portal Index", selenium.getTitle());
59          selenium.click("link=County");
60          selenium.waitForPageToLoad("30000");
61          assertEquals("Kuali Portal Index", selenium.getTitle());
62          selenium.selectFrame("iframeportlet");
63          selenium.click("//img[@alt='create new']");
64          selenium.waitForPageToLoad("30000");
65          //selenium.setSpeed("2000");
66          String docId = selenium.getText("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]");
67          assertTrue(selenium.isElementPresent("methodToCall.cancel"));
68          selenium.type("//input[@id='document.documentHeader.documentDescription']", "Validation Test County");
69          selenium.click("methodToCall.performLookup.(!!org.kuali.rice.location.impl.country.CountryBo!!).(((code:document.newMaintainableObject.countryCode,))).((`document.newMaintainableObject.countryCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" + remotePublicUrl
70                  + "/kr/lookup.do;::::).anchor4");
71          selenium.waitForPageToLoad("30000");
72          selenium.type("code", "US");
73          selenium.click("//input[@name='methodToCall.search' and @value='search']");
74          selenium.waitForPageToLoad("30000");
75          selenium.click("link=return value");
76          selenium.waitForPageToLoad("30000");
77          selenium.type("//input[@id='document.newMaintainableObject.code']", RandomStringUtils.randomAlphabetic(2).toUpperCase());
78          selenium.click("methodToCall.performLookup.(!!org.kuali.rice.location.impl.state.StateBo!!).(((countryCode:document.newMaintainableObject.countryCode,code:document.newMaintainableObject.stateCode,))).((`document.newMaintainableObject.countryCode:countryCode,document.newMaintainableObject.stateCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" + remotePublicUrl
79                  + "/kr/lookup.do;::::).anchor4");
80          selenium.waitForPageToLoad("30000");
81          selenium.type("code", "IN");
82          selenium.click("//input[@name='methodToCall.search' and @value='search']");
83          selenium.waitForPageToLoad("30000");
84          selenium.click("link=return value");
85          selenium.waitForPageToLoad("30000");
86          selenium.type("//input[@id='document.newMaintainableObject.name']", "Validation Test County");
87          selenium.click("//input[@id='document.newMaintainableObject.active']");
88          selenium.click("methodToCall.blanketApprove");
89          selenium.waitForPageToLoad("30000");
90          selenium.selectWindow("null");
91          selenium.click("//img[@alt='doc search']");
92          selenium.waitForPageToLoad("30000");
93          assertEquals("Kuali Portal Index", selenium.getTitle());
94          selenium.selectFrame("iframeportlet");
95          selenium.click("//input[@name='methodToCall.search' and @value='search']");
96          selenium.waitForPageToLoad("30000");
97          docId= "link=" + docId;
98          assertTrue(selenium.isElementPresent(docId));       
99          if(selenium.isElementPresent(docId)){            
100             assertEquals("FINAL", selenium.getText("//table[@id='row']/tbody/tr[1]/td[4]"));
101         }else{
102             assertEquals(docId, selenium.getText("//table[@id='row']/tbody/tr[1]/td[1]"));            
103             assertEquals("FINAL", selenium.getText("//table[@id='row']/tbody/tr[1]/td[4]"));
104         }
105     }
106 
107     @After
108     public void tearDown() throws Exception {
109         selenium.stop();
110     }
111 }