View Javadoc

1   /*
2    * Copyright 2006-2012 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  
17  package edu.samplu.krad.compview;
18  
19  import com.thoughtworks.selenium.DefaultSelenium;
20  import org.junit.After;
21  import org.junit.Before;
22  import org.junit.Test;
23  
24  import static junit.framework.Assert.assertTrue;
25  import static org.junit.Assert.assertEquals;
26  import static org.junit.Assert.assertNotSame;
27  import static org.junit.Assert.fail;
28  
29  /**
30   * tests that the parent line variable is available in a sub collection
31   *
32   * <p>configuration done in /edu/sampleu/demo/kitchensink/UifComponentsViewP7.xml on bean id="subCollection1"</p>
33   *
34   * @author Kuali Rice Team (rice.collab@kuali.org)
35   */
36  public class ParentLineIT {
37      private DefaultSelenium selenium;
38  
39      @Before
40      public void setUp() throws Exception {
41          selenium = new DefaultSelenium("localhost", 4444, "*chrome",  System.getProperty("remote.public.url"));//"http://localhost:8080/"
42          selenium.start();
43      }
44  
45      @Test
46      /**
47       * tests that the size of a sub collection is correctly displayed using the parentLine el variable
48       */
49      public void testSubCollectionSize() throws Exception {
50          selenium.open("/kr-dev/portal.do");
51          selenium.type("name=__login_user", "admin");
52          selenium.click("css=input[type=\"submit\"]");
53          selenium.waitForPageToLoad("30000");
54          selenium.click("link=KRAD");
55          selenium.waitForPageToLoad("30000");
56          selenium.click("link=Uif Components (Kitchen Sink)");
57          selenium.waitForPageToLoad("30000");
58          selenium.selectFrame("iframeportlet");
59          // click on collections page link
60          selenium.click("id=u961");
61          // Thread.sleep(30000);
62          // wait for collections page to load by checking the presence of a sub collection line item
63          for (int second = 0;; second++) {
64              if (second >= 60) fail("timeout");
65              try { if (selenium.isElementPresent("id=u1089_line0_line0_control")) break; } catch (Exception e) {}
66              Thread.sleep(1000);
67          }
68          // verify that sub collection sizes are displayed as expected
69          assertEquals("SubCollection - (3 lines)", selenium.getText("id=u1030_line0"));
70          assertEquals("SubCollection - (2 lines)", selenium.getText("id=u1030_line1"));
71      }
72  
73      @After
74      public void tearDown() throws Exception {
75          selenium.stop();
76      }
77  }