mirror of https://github.com/apache/archiva.git
more cleanup on it test
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1296211 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b143434569
commit
c0296ed739
|
@ -34,21 +34,6 @@ public abstract class AbstractArchivaTest
|
||||||
|
|
||||||
protected String fullname;
|
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()
|
public String getUserEmail()
|
||||||
{
|
{
|
||||||
String email = getProperty( "USERROLE_EMAIL" );
|
String email = getProperty( "USERROLE_EMAIL" );
|
||||||
|
|
|
@ -24,6 +24,7 @@ import com.thoughtworks.selenium.Selenium;
|
||||||
import org.apache.archiva.web.test.tools.AfterSeleniumFailure;
|
import org.apache.archiva.web.test.tools.AfterSeleniumFailure;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
import org.junit.Before;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
@ -42,23 +43,30 @@ import java.util.Properties;
|
||||||
|
|
||||||
public abstract class AbstractSeleniumTest
|
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> selenium = new ThreadLocal<Selenium>();
|
public String seleniumHost = System.getProperty( "seleniumHost", "localhost" );
|
||||||
|
|
||||||
|
public int seleniumPort = Integer.getInteger( "seleniumPort", 4444 );
|
||||||
|
|
||||||
|
private Selenium selenium = null;
|
||||||
|
|
||||||
public Properties p;
|
public Properties p;
|
||||||
|
|
||||||
|
@Before
|
||||||
public void open()
|
public void open()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
p = new Properties();
|
p = new Properties();
|
||||||
p.load( this.getClass().getClassLoader().getResourceAsStream( "test.properties" ) );
|
p.load( this.getClass().getClassLoader().getResourceAsStream( "test.properties" ) );
|
||||||
|
open( baseUrl, browser, seleniumHost, seleniumPort, maxWaitTimeInMs );
|
||||||
|
assertAdminCreated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close selenium session.
|
* Close selenium session.
|
||||||
*/
|
*/
|
||||||
|
@ -69,28 +77,22 @@ public abstract class AbstractSeleniumTest
|
||||||
if ( getSelenium() != null )
|
if ( getSelenium() != null )
|
||||||
{
|
{
|
||||||
getSelenium().stop();
|
getSelenium().stop();
|
||||||
selenium.set( null );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize selenium
|
* 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
|
throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AbstractSeleniumTest.baseUrl = baseUrl;
|
|
||||||
AbstractSeleniumTest.maxWaitTimeInMs = maxWaitTimeInMs;
|
|
||||||
|
|
||||||
if ( getSelenium() == null )
|
if ( getSelenium() == null )
|
||||||
{
|
{
|
||||||
DefaultSelenium s = new DefaultSelenium( seleniumHost, seleniumPort, browser, baseUrl );
|
selenium = new DefaultSelenium( seleniumHost, seleniumPort, browser, baseUrl );
|
||||||
|
selenium.start();
|
||||||
s.start();
|
selenium.setTimeout( Integer.toString( maxWaitTimeInMs ) );
|
||||||
s.setTimeout( maxWaitTimeInMs );
|
|
||||||
selenium.set( s );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
|
@ -104,9 +106,7 @@ public abstract class AbstractSeleniumTest
|
||||||
public void assertAdminCreated()
|
public void assertAdminCreated()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
initializeArchiva( System.getProperty( "baseUrl" ), System.getProperty( "browser" ),
|
initializeArchiva( baseUrl, browser, maxWaitTimeInMs, seleniumHost, seleniumPort );
|
||||||
Integer.getInteger( "maxWaitTimeInMs" ), System.getProperty( "seleniumHost", "localhost" ),
|
|
||||||
Integer.getInteger( "seleniumPort", 4444 ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initializeArchiva( String baseUrl, String browser, int maxWaitTimeInMs, String seleniumHost,
|
public void initializeArchiva( String baseUrl, String browser, int maxWaitTimeInMs, String seleniumHost,
|
||||||
|
@ -114,7 +114,7 @@ public abstract class AbstractSeleniumTest
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
open( baseUrl, browser, seleniumHost, seleniumPort, Integer.toString( maxWaitTimeInMs ) );
|
open( baseUrl, browser, seleniumHost, seleniumPort, maxWaitTimeInMs );
|
||||||
|
|
||||||
getSelenium().open( baseUrl );
|
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 )
|
protected String getProperty( String key )
|
||||||
|
@ -431,7 +431,7 @@ public abstract class AbstractSeleniumTest
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Thread.sleep( Long.parseLong( maxWaitTimeInMs ) );
|
Thread.sleep( maxWaitTimeInMs );
|
||||||
}
|
}
|
||||||
catch ( InterruptedException e )
|
catch ( InterruptedException e )
|
||||||
{
|
{
|
||||||
|
@ -667,7 +667,7 @@ public abstract class AbstractSeleniumTest
|
||||||
|
|
||||||
String className = cName.substring( cName.lastIndexOf( '.' ) + 1 );
|
String className = cName.substring( cName.lastIndexOf( '.' ) + 1 );
|
||||||
targetPath.mkdirs();
|
targetPath.mkdirs();
|
||||||
Selenium selenium = AbstractSeleniumTest.getSelenium();
|
Selenium selenium = getSelenium();
|
||||||
String fileBaseName = methodName + "_" + className + ".java_" + lineNumber + "-" + time;
|
String fileBaseName = methodName + "_" + className + ".java_" + lineNumber + "-" + time;
|
||||||
|
|
||||||
selenium.windowMaximize();
|
selenium.windowMaximize();
|
||||||
|
|
Loading…
Reference in New Issue