001 // Copyright 2007, 2010 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.tapestry5.test; 016 017 import java.io.File; 018 import java.lang.reflect.Method; 019 020 import org.testng.ITestContext; 021 import org.testng.xml.XmlTest; 022 023 import com.thoughtworks.selenium.CommandProcessor; 024 import com.thoughtworks.selenium.Selenium; 025 026 public class TapestryTestConstants 027 { 028 /** 029 * The current working directory (i.e., property "user.dir"). 030 */ 031 public static final String CURRENT_DIR_PATH = System.getProperty("user.dir"); 032 033 /** 034 * The Surefire plugin sets basedir but DOES NOT change the current working directory. When 035 * building across modules, basedir changes for each module, but user.dir does not. This value should be used when 036 * referencing local files. Outside of surefire, the "basedir" property will not be set, and the current working 037 * directory will be the default. 038 */ 039 public static final String MODULE_BASE_DIR_PATH = System.getProperty("basedir", CURRENT_DIR_PATH); 040 041 /** 042 * {@link #MODULE_BASE_DIR_PATH} as a file. 043 */ 044 public static final File MODULE_BASE_DIR = new File(MODULE_BASE_DIR_PATH); 045 046 /** 047 * {@link ITestContext} attribute holding an instance of {@link Selenium}. 048 * 049 * @see SeleniumTestCase#testStartup(org.testng.ITestContext, org.testng.xml.XmlTest) 050 * @since 5.2.0 051 */ 052 public static final String SELENIUM_ATTRIBUTE = "tapestry.selenium"; 053 054 /** 055 * {@link ITestContext} attribute holding an instance of {@link ErrorReporter}. 056 * 057 * @see SeleniumTestCase#testStartup(org.testng.ITestContext, org.testng.xml.XmlTest) 058 * @since 5.2.0 059 */ 060 public static final String ERROR_REPORTER_ATTRIBUTE = "tapestry.error-reporter"; 061 062 /** 063 * {@link ITestContext} attribute holding an instance of {@link ErrorReporter}, used 064 * to shutdown Selenium and the Web Server at the end of the test. 065 * 066 * @since 5.2.2 067 */ 068 public static final String SHUTDOWN_ATTRIBUTE = "tapestry.shutdown"; 069 070 /** 071 * The {@link ITestContext} attribute holding an instance of {@link CommandProcessor}, with 072 * enhanced exception reporting control. This allows tests that wish to, to bypass the {@link Selenium} interface 073 * and execute commands directly on the Selenium RC server. 074 * 075 * @since 5.2.0 076 */ 077 public static final String COMMAND_PROCESSOR_ATTRIBUTE = "tapestry.command-processor"; 078 079 /** 080 * {@link ITestContext} attribute holding the application's base URL. 081 * @since 5.2.0 082 */ 083 public static final String BASE_URL_ATTRIBUTE = "tapestry.base-url"; 084 085 /** 086 * {@link ITestContext} attribute updated to store the current test method 087 * (as a {@link Method} instance). 088 */ 089 public static final String CURRENT_TEST_METHOD_ATTRIBUTE = "tapestry.current-test-method"; 090 091 /** 092 * {@link XmlTest} parameter holding an absolute or relative path to a web app 093 * folder. 094 */ 095 public static final String WEB_APP_FOLDER_PARAMETER = "tapestry.web-app-folder"; 096 097 /** 098 * {@link XmlTest} parameter holding the context path. 099 */ 100 public static final String CONTEXT_PATH_PARAMETER = "tapestry.context-path"; 101 102 /** 103 * {@link XmlTest} parameter holding the web server port. 104 */ 105 public static final String PORT_PARAMETER = "tapestry.port"; 106 107 /** 108 * {@link XmlTest} parameter holding the web server ssl port. 109 */ 110 public static final String SSL_PORT_PARAMETER = "tapestry.ssl-port"; 111 112 /** 113 * {@link XmlTest} parameter holding the browser command to pass to Selenium. 114 */ 115 public static final String BROWSER_START_COMMAND_PARAMETER = "tapestry.browser-start-command"; 116 117 /** 118 * {@link XmlTest} parameter holding the servlet container to run for the integration tests. 119 * @since 5.3 120 */ 121 public static final String SERVLET_CONTAINER_PARAMETER = "tapestry.servlet-container"; 122 }