From: Olivier Lamy Date: Fri, 2 Mar 2012 14:05:01 +0000 (+0000) Subject: more cleanup on it test X-Git-Tag: archiva-1.4-M3~1129 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c0296ed73911210d4d3c6200d5459cf0eca37971;p=archiva.git more cleanup on it test git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1296211 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/parent/AbstractArchivaTest.java b/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/parent/AbstractArchivaTest.java index 14f6cfbb7..27b051466 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/parent/AbstractArchivaTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/parent/AbstractArchivaTest.java @@ -34,21 +34,6 @@ public abstract class AbstractArchivaTest protected String fullname; - - @Override - @Before - public void open() - throws Exception - { - super.open(); - assertAdminCreated(); - } - - protected static String getErrorMessageText() - { - return getSelenium().getText( "//ul[@class='errorMessage']/li/span" ); - } - public String getUserEmail() { String email = getProperty( "USERROLE_EMAIL" ); diff --git a/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java b/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java index d5c8fcb91..eabe6e879 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java @@ -24,6 +24,7 @@ import com.thoughtworks.selenium.Selenium; import org.apache.archiva.web.test.tools.AfterSeleniumFailure; import org.junit.After; import org.junit.Assert; +import org.junit.Before; import java.io.File; import java.text.SimpleDateFormat; @@ -42,23 +43,30 @@ import java.util.Properties; public abstract class AbstractSeleniumTest { + public String browser = System.getProperty( "browser" ); - public static String baseUrl; + public String baseUrl = System.getProperty( "baseUrl" ); - public static String maxWaitTimeInMs; + public int maxWaitTimeInMs = Integer.getInteger( "maxWaitTimeInMs" ); - private static ThreadLocal selenium = new ThreadLocal(); + public String seleniumHost = System.getProperty( "seleniumHost", "localhost" ); + + public int seleniumPort = Integer.getInteger( "seleniumPort", 4444 ); + + private Selenium selenium = null; public Properties p; + @Before public void open() throws Exception { p = new Properties(); p.load( this.getClass().getClassLoader().getResourceAsStream( "test.properties" ) ); + open( baseUrl, browser, seleniumHost, seleniumPort, maxWaitTimeInMs ); + assertAdminCreated(); } - /** * Close selenium session. */ @@ -69,28 +77,22 @@ public abstract class AbstractSeleniumTest if ( getSelenium() != null ) { getSelenium().stop(); - selenium.set( null ); } } /** * Initialize selenium */ - public void open( String baseUrl, String browser, String seleniumHost, int seleniumPort, String maxWaitTimeInMs ) + public void open( String baseUrl, String browser, String seleniumHost, int seleniumPort, int maxWaitTimeInMs ) throws Exception { try { - AbstractSeleniumTest.baseUrl = baseUrl; - AbstractSeleniumTest.maxWaitTimeInMs = maxWaitTimeInMs; - if ( getSelenium() == null ) { - DefaultSelenium s = new DefaultSelenium( seleniumHost, seleniumPort, browser, baseUrl ); - - s.start(); - s.setTimeout( maxWaitTimeInMs ); - selenium.set( s ); + selenium = new DefaultSelenium( seleniumHost, seleniumPort, browser, baseUrl ); + selenium.start(); + selenium.setTimeout( Integer.toString( maxWaitTimeInMs ) ); } } catch ( Exception e ) @@ -104,9 +106,7 @@ public abstract class AbstractSeleniumTest public void assertAdminCreated() throws Exception { - initializeArchiva( System.getProperty( "baseUrl" ), System.getProperty( "browser" ), - Integer.getInteger( "maxWaitTimeInMs" ), System.getProperty( "seleniumHost", "localhost" ), - Integer.getInteger( "seleniumPort", 4444 ) ); + initializeArchiva( baseUrl, browser, maxWaitTimeInMs, seleniumHost, seleniumPort ); } public void initializeArchiva( String baseUrl, String browser, int maxWaitTimeInMs, String seleniumHost, @@ -114,7 +114,7 @@ public abstract class AbstractSeleniumTest throws Exception { - open( baseUrl, browser, seleniumHost, seleniumPort, Integer.toString( maxWaitTimeInMs ) ); + open( baseUrl, browser, seleniumHost, seleniumPort, maxWaitTimeInMs ); getSelenium().open( baseUrl ); @@ -144,9 +144,9 @@ public abstract class AbstractSeleniumTest } - public static Selenium getSelenium() + public Selenium getSelenium() { - return selenium == null ? null : selenium.get(); + return selenium; } protected String getProperty( String key ) @@ -431,7 +431,7 @@ public abstract class AbstractSeleniumTest try { - Thread.sleep( Long.parseLong( maxWaitTimeInMs ) ); + Thread.sleep( maxWaitTimeInMs ); } catch ( InterruptedException e ) { @@ -667,7 +667,7 @@ public abstract class AbstractSeleniumTest String className = cName.substring( cName.lastIndexOf( '.' ) + 1 ); targetPath.mkdirs(); - Selenium selenium = AbstractSeleniumTest.getSelenium(); + Selenium selenium = getSelenium(); String fileBaseName = methodName + "_" + className + ".java_" + lineNumber + "-" + time; selenium.windowMaximize();