001 /*
002 * Copyright 2005-2013 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.common;
017
018 import org.junit.Assert;
019 import org.junit.runner.RunWith;
020
021 /**
022 * SmokeTests should extend this Base class or have it in their class hierarchy.
023 *
024 * The abstract method getBookmarkUrl should be implemented to return the Bookmark URL
025 * of the page under test. The abstract method navigate should be implemented to Navigate
026 * through the UI to the page under test.
027 */
028 @RunWith(SmokeTestRunner.class)
029 public abstract class SmokeTestBase extends WebDriverLegacyITBase {
030
031 protected String testUrl = ITUtil.KRAD_PORTAL;
032
033 protected boolean shouldNavigate = false;
034
035 protected abstract String getBookmarkUrl();
036
037 protected abstract void navigate() throws Exception;
038
039 @Override
040 public String getTestUrl() {
041 // if (this.getClass().toString().contains("krad.demo") ||
042 // this.getClass().toString().contains("krad.labs")) {
043 return testUrl;
044 // } else {
045 // return ITUtil.PORTAL;
046 // }
047 }
048
049 protected void enableBookmarkMode() {
050 this.testUrl = getBookmarkUrl();
051 }
052
053 protected void enableNavigationMode() {
054 this.shouldNavigate = true;
055 String classString = this.getClass().toString();
056 if (classString.contains("krad.demo")) {
057 this.testUrl = ITUtil.KRAD_PORTAL;
058 } else if (classString.contains("krad.labs")) {
059 this.testUrl = ITUtil.LABS;
060 } else {
061 this.testUrl = ITUtil.PORTAL;
062 }
063 }
064
065 @Override
066 public void fail(String message) {
067 passed = false;
068 Assert.fail(message);
069 }
070
071 @Override
072 protected void navigateInternal() throws Exception {
073 if (this.shouldNavigate) {
074 navigate();
075 }
076 }
077 }