public class ExampleWebTestCase extends WebTestCase {
public void setUp ( ) {
super . setUp ( ) ;
setBaseUrl ( " localhost : 8080 / test" ) ;
}
public void test1 ( ) {
beginAt ( "/ home" ) ;
clickLink ( "login" ) ;
assertTitleEquals ( "Login" ) ;
setTextField ( "username" , "test" ) ;
setTextField ( "password" , "test123" ) ;
submit ( ) ;
assertTitleEquals ( “Welcome, test!” ) ;
}
}
Deployable war = new WAR ( "path / to / simple.war" ) ;
LocalConfiguration configuration =
new Resin3xStandaloneLocalConfiguration ( "target / myresin3x" ) ;
configuration. addDeployable ( war ) ;
InstalledLocalContainer container =
new Resin3xInstalledLocalContainer ( configuration ) ;
container. setHome ( "c: /apps/resin-3.0.18" ) ;
container. start ( ) ;
// Here you are assured the container is started.
container. stop ( ) ;
// Here you are assured the container is stopped.
<property name = "cargolib.dir" value = "$ {basedir} / cargolib" />
<property name = "cargo-uberjar" value = "$ {cargolib.dir} /cargo-core-uberjar-0.7.jar" />
<property name = "cargo-antjar" value = "$ {cargolib.dir} /cargo-ant-0.7.jar" />
<taskdef resource = "cargo.tasks" >
<classpath >
<pathelement location = "$ {cargo-uberjar}" />
<pathelement location = "$ {cargo-antjar}" />
</ classpath >
</ taskdef >
<target name = "cargostart" depends = "war" >
<delete dir = "$ {tomcatconfig.dir}" />
<mkdir dir = "$ {tomcatlog.dir}" />
<mkdir dir = "$ {tomcatconfig.dir}" />
<echo message = "Starting Cargo ..." />
<echo message = "Using tomcat.home = $ {tomcat.home}" />
<echo message = "Using war = $ {mywarfile}" />
<echo message = "Jars used = $ {cargo-uberjar}, $ {cargo-antjar}" />
<cargo containerId = "tomcat5x" home = "$ {tomcat.home}" output = "$ {tomcatlog.dir} /output.log"
log = "$ {tomcatlog.dir} /cargo.log" action = "start" >
<configuration home = "$ {tomcatconfig.dir}" >
<property name = "cargo.servlet.port" value = "8080" />
<property name = "cargo.logging" value = "high" />
<deployable type = "war" file = "$ {mywarfile}" />
</ configuration >
</ cargo >
<! - here you can do anything, such as tests ->
<! - it is necessary to slow down the server in the same way, just specify another action ->
</ target >
Source: https://habr.com/ru/post/70739/
All Articles