View Javadoc
1   /*
2    * Copyright 2005-2013 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.common;
17  
18  import org.junit.Assert;
19  import org.junit.runner.RunWith;
20  
21  /**
22   * SmokeTests should extend this Base class or have it in their class hierarchy.
23   *
24   * The abstract method getBookmarkUrl should be implemented to return the Bookmark URL
25   * of the page under test.  The abstract method navigate should be implemented to Navigate
26   * through the UI to the page under test.
27   */
28  @RunWith(SmokeTestRunner.class)
29  public abstract class SmokeTestBase extends WebDriverLegacyITBase {
30  
31      protected String testUrl = ITUtil.KRAD_PORTAL;
32  
33      protected boolean shouldNavigate = false;
34  
35      protected abstract String getBookmarkUrl();
36  
37      protected abstract void navigate() throws Exception;
38  
39      @Override
40      public String getTestUrl() {
41  //        if (this.getClass().toString().contains("krad.demo") ||
42  //            this.getClass().toString().contains("krad.labs")) {
43              return testUrl;
44  //        } else {
45  //            return ITUtil.PORTAL;
46  //        }
47      }
48  
49      protected void enableBookmarkMode() {
50          this.testUrl = getBookmarkUrl();
51      }
52  
53      protected void enableNavigationMode() {
54          this.shouldNavigate = true;
55          String classString = this.getClass().toString();
56          if (classString.contains("krad.demo") || classString.contains("library")) {
57              this.testUrl = ITUtil.KRAD_PORTAL;
58          } else if (classString.contains("krad.library")) {
59              this.testUrl = ITUtil.KRAD_PORTAL;
60          } else if (classString.contains("krad.labs")) {
61              this.testUrl = ITUtil.LABS;
62          } else {
63              this.testUrl = ITUtil.PORTAL;
64          }
65      }
66  
67      @Override
68      public void fail(String message) {
69          passed = false;
70          Assert.fail(message);
71      }
72  
73      @Override
74      protected void navigateInternal() throws Exception {
75          if (this.shouldNavigate) {
76              navigate();
77          }
78      }
79  }