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 Postal Code maintenance document, results in a final document
32   * 
33   * @author Kuali Rice Team (rice.collab@kuali.org)
34   */
35  public class LocationPostCodeBlanketAppIT {
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 testPostalCode() 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=Postal Code");
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          String docId = selenium.getText("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]");
66          assertTrue(selenium.isElementPresent("methodToCall.cancel"));
67          //selenium.setSpeed("2000");
68          selenium.type("//input[@id='document.documentHeader.documentDescription']", "Validation Test Postal Code");        
69          selenium.click("methodToCall.performLookup.(!!org.kuali.rice.location.impl.country.CountryBo!!).(((code:document.newMaintainableObject.countryCode,))).((`document.newMaintainableObject.countryCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" + remotePublicUrl + "/kr/lookup.do;::::).anchor4");
70          selenium.waitForPageToLoad("30000");
71          selenium.type("code", "US");
72          selenium.click("//input[@name='methodToCall.search' and @value='search']");
73          selenium.waitForPageToLoad("30000");
74          selenium.click("link=return value");
75          selenium.waitForPageToLoad("30000");
76          selenium.type("//input[@id='document.newMaintainableObject.code']", RandomStringUtils.randomNumeric(5));
77          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 + "/kr/lookup.do;::::).anchor4");
78          selenium.waitForPageToLoad("30000");
79          selenium.click("//input[@name='methodToCall.search' and @value='search']");
80          selenium.waitForPageToLoad("30000");
81          selenium.click("//table[@id='row']/tbody/tr[4]/td[1]/a");
82          selenium.waitForPageToLoad("30000");
83          selenium.type("//input[@id='document.newMaintainableObject.cityName']", "Validation Test Postal Code1");
84          selenium.click("methodToCall.blanketApprove");
85          selenium.waitForPageToLoad("30000");
86          selenium.selectWindow("null");
87          selenium.click("//img[@alt='doc search']");
88          selenium.waitForPageToLoad("30000");
89          assertEquals("Kuali Portal Index", selenium.getTitle());
90          selenium.selectFrame("iframeportlet");
91          selenium.click("//input[@name='methodToCall.search' and @value='search']");
92          selenium.waitForPageToLoad("30000");
93          docId= "link=" + docId;
94          
95          assertTrue(selenium.isElementPresent(docId));       
96          if(selenium.isElementPresent(docId)){            
97              assertEquals("FINAL", selenium.getText("//table[@id='row']/tbody/tr[1]/td[4]"));
98          }else{
99              assertEquals(docId, selenium.getText("//table[@id='row']/tbody/tr[1]/td[1]"));            
100             assertEquals("FINAL", selenium.getText("//table[@id='row']/tbody/tr[1]/td[4]"));
101         }
102     }
103 
104     @After
105     public void tearDown() throws Exception {
106         selenium.stop();
107     }
108 
109 }