001 /** 002 * Copyright 2005-2011 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 edu.samplu.admin.test; 017 018 import static org.junit.Assert.assertEquals; 019 import static org.junit.Assert.assertTrue; 020 021 import org.apache.commons.lang.RandomStringUtils; 022 import org.apache.commons.lang.StringUtils; 023 import org.junit.After; 024 import org.junit.Before; 025 import org.junit.Test; 026 027 import com.thoughtworks.selenium.DefaultSelenium; 028 import com.thoughtworks.selenium.Selenium; 029 030 /** 031 * tests that user 'admin', on blanket approving a new Postal Code maintenance document, results in a final document 032 * 033 * @author Kuali Rice Team (rice.collab@kuali.org) 034 */ 035 public class LocationPostCodeBlanketAppIT { 036 private Selenium selenium; 037 @Before 038 public void setUp() throws Exception { 039 selenium = new DefaultSelenium("localhost", 4444, "*firefox", System.getProperty("remote.public.url")); 040 selenium.start(); 041 } 042 043 @Test 044 public void testPostalCode() throws Exception { 045 String remotePublicUrl = System.getProperty("remote.public.url"); 046 // remove the trailing slash to allow for correction concatenation in locating the lookup buttons below 047 if (StringUtils.endsWith(remotePublicUrl, "/")) { 048 remotePublicUrl = StringUtils.removeEnd(remotePublicUrl, "/"); 049 } 050 selenium.open(remotePublicUrl); 051 assertEquals("Login", selenium.getTitle()); 052 selenium.type("__login_user", "admin"); 053 selenium.click("//input[@value='Login']"); 054 selenium.waitForPageToLoad("30000"); 055 assertEquals("Kuali Portal Index", selenium.getTitle()); 056 selenium.click("link=Administration"); 057 selenium.waitForPageToLoad("30000"); 058 assertEquals("Kuali Portal Index", selenium.getTitle()); 059 selenium.click("link=Postal Code"); 060 selenium.waitForPageToLoad("30000"); 061 assertEquals("Kuali Portal Index", selenium.getTitle()); 062 selenium.selectFrame("iframeportlet"); 063 selenium.click("//img[@alt='create new']"); 064 selenium.waitForPageToLoad("30000"); 065 String docId = selenium.getText("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]"); 066 assertTrue(selenium.isElementPresent("methodToCall.cancel")); 067 //selenium.setSpeed("2000"); 068 selenium.type("//input[@id='document.documentHeader.documentDescription']", "Validation Test Postal Code"); 069 selenium.click("methodToCall.performLookup.(!!org.kuali.rice.location.impl.country.CountryBo!!).(((code:document.newMaintainableObject.countryCode,))).((`document.newMaintainableObject.countryCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" + remotePublicUrl + "/kr/lookup.do;::::).anchor4"); 070 selenium.waitForPageToLoad("30000"); 071 selenium.type("code", "US"); 072 selenium.click("//input[@name='methodToCall.search' and @value='search']"); 073 selenium.waitForPageToLoad("30000"); 074 selenium.click("link=return value"); 075 selenium.waitForPageToLoad("30000"); 076 selenium.type("//input[@id='document.newMaintainableObject.code']", RandomStringUtils.randomNumeric(5)); 077 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"); 078 selenium.waitForPageToLoad("30000"); 079 selenium.click("//input[@name='methodToCall.search' and @value='search']"); 080 selenium.waitForPageToLoad("30000"); 081 selenium.click("//table[@id='row']/tbody/tr[4]/td[1]/a"); 082 selenium.waitForPageToLoad("30000"); 083 selenium.type("//input[@id='document.newMaintainableObject.cityName']", "Validation Test Postal Code1"); 084 selenium.click("methodToCall.blanketApprove"); 085 selenium.waitForPageToLoad("30000"); 086 selenium.selectWindow("null"); 087 selenium.click("//img[@alt='doc search']"); 088 selenium.waitForPageToLoad("30000"); 089 assertEquals("Kuali Portal Index", selenium.getTitle()); 090 selenium.selectFrame("iframeportlet"); 091 selenium.click("//input[@name='methodToCall.search' and @value='search']"); 092 selenium.waitForPageToLoad("30000"); 093 docId= "link=" + docId; 094 095 assertTrue(selenium.isElementPresent(docId)); 096 if(selenium.isElementPresent(docId)){ 097 assertEquals("FINAL", selenium.getText("//table[@id='row']/tbody/tr[1]/td[4]")); 098 }else{ 099 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 }