How to run Sahi tests as part of a Hudson build? - continuous-integration

In the absence of a Maven plugin for Sahi, what's the easiest way to run Sahi tests from Hudson?

You do have a tutorial for integrating Hudson with Sahi, but it is based on a free-style project, and a Ant task (as Pascal Thivent commented)
with zkdemo.xml and other Sahi ant tasks detailed here:
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="bids" default="runfftests">
<property environment="env"/>
<property name="sahi.home" value="${env.SAHI_HOME}" location="/mnt/sda4/Sahi/sahi/" />
<property name="user.data" value="${env.SAHI_USERDATA_DIR}" location="/mnt/sda4/Sahi/sahi/userdata" />
<property name="urlbase" value="http://www.google.com/"/>
<taskdef name="sahi" classname="net.sf.sahi.ant.RunSahiTask" classpath="${sahi.home}/lib/ant-sahi.jar"/>
<target name="runfftests">
<antcall target="startsahi"/>
<sleep seconds="4"/>
<sahi suite="${user.data}/scripts/my.suite"
browser="/usr/bin/firefox"
baseurl="${urlbase}"
sahihost="localhost"
sahiport="9999"
failureproperty="sahi.failed"
haltonfailure="false"
browserProcessName="firefox"
threads="3">
</sahi>
<sleep seconds="4"/>
<antcall target="stopsahi"/>
<sleep seconds="4"/>
<antcall target="failsahi"/>
</target>
<target name="failsahi" if="sahi.failed">
<fail message="Sahi tests failed!"/>
</target>
<target name="startsahi" description="start sahi proxy">
<java classname="net.sf.sahi.Proxy" fork="true" spawn="true" dir="${sahi.home}">
<!--<env key="MOZ_NO_REMOTE" value="1"/>-->
<classpath location="${sahi.home}/lib/sahi.jar">
<fileset dir="${sahi.home}/extlib" includes="**/*.jar"/>
</classpath>
<arg value="${sahi.home}" id="basePath"/>
<arg value="${user.data}" id="userdataPath"/>
</java>
</target>
<target name="stopsahi" description="stop sahi server">
<sahi stop="true" sahihost="localhost" sahiport="9999"/>
</target>
</project>

you can use maven Surefire plugin call sahi junit test case, then integrated with Jenkin server

Related

Weblogic WsdlcTask for gradle

I am looking for the weblogic.wsee.tools.anttasks.WsdlcTask for gradle. All I could find so far was an example for Ant.
Importing the ant script with ant.importBuild "wsdlc_build.xml" works perfectly fine in my gradle build script, but I would prefer writing the task in gradle. Has someone already found a solution for this?
My ant script:
<project name="WebServices" basedir=".">
<property name="build.wls.home" value="C:\User\wls\"/>
<path id="weblogic.tools.path">
<fileset dir="${build.wls.home}/wlserver/server/lib">
<include name="weblogic.jar" />
</fileset>
</path>
<taskdef name="wsdlc" classname="weblogic.wsee.tools.anttasks.WsdlcTask" classpathref="weblogic.tools.path"/>
<target name="build_opera">
<wsdlc failOnError="true"
srcWsdl="WebContent/WEB-INF/wsdls/OperaService.wsdl"
destImplDir="src"
destJwsDir="WebContent/WEB-INF/lib"
packageName="server.opera.webservice.service"
verbose="on" debug="on"
type="JAXWS">
</wsdlc>
</target>
<target name="build_nez">
<wsdlc
failOnError="true"
srcWsdl="WebContent/WEB-INF/wsdls/NezService.wsdl"
destImplDir="src"
destJwsDir="WebContent/WEB-INF/lib"
packageName="server.nez.webservice.service"
srcPortName="NezSoapPort"
type="JAXWS">
</wsdlc>
</target>
<target name="build_nezp">
<wsdlc
failOnError="true"
srcWsdl="WebContent/WEB-INF/wsdls/NezpService.wsdl"
destImplDir="src"
destJwsDir="WebContent/WEB-INF/lib"
packageName="server.nezp.webservice.service"
srcPortName="NezPSoapPort"
type="JAXWS">
</wsdlc>
</target>

How to execute the Environment Variables (env.) from Teamcity in Nant script

I am using TeamCity to build the.Net Solution using Nant script and everything works fine if I hard Code the solution path. I want to use Environment Variables from TeamCity (env.) to be used as Solution Path -->env.solution.path----- C:\a\testteamcity\Demo\deptest.sln inside Nant script test.build file:
<?xml version="1.0"?>
<project name ="first Nant file" default="compile-solution" >
<property name="bin.folder.svn" value="C:\a\testteamcity\Demo\bin123"/>
<property name="bin.folder.sln" value="C:\cicheckout\webapp\bin"/>
<target name="compile-solution">
<exec program="C:\Program Files (x86)\MSBuild\12.0\Bin\Msbuild.exe" verbose="true" >
<arg line="${environment::get-variable('env.solution.path')}" />
<arg value="/p:Configuration=Release" />
</exec>
<copy todir="${bin.folder.sln}" overwrite="true" failonerror="true">
<fileset basedir="${bin.folder.svn}">
</fileset>
</copy>
</target>
</project>
Error:Unexpected token 'Punctuation'.
Expression: ${environment::get-variable(‘env.solution.path’)}
Any Help would be great.Thanks
Create system.solution.path --> C:\a\testteamcity\demo\deptest.sln under System Properties (system.) in Teamcity and in Nant script-->
<?xml version="1.0"?>
<project name ="Build-Solution" default="build-solution" >
<property name="solution.path" value="${system.solution.path}" dynamic="true" unless="${property::exists('solution.path')}"/>
<!-- Build solution -->
<target name="build-solution">
<exec program="C:\Program Files (x86)\MSBuild\12.0\Bin\Msbuild.exe" verbose="true" >
<arg line="${solution.path}" />
<arg value="/p:Configuration=Release" />
</exec>
</target>
</project>

Maven and Ant Can't run Java - CreateProcess error=206, The filename or extension is too long

When maven via antrun executes this java code I get the dreaded error=206, The filename or extension is too long
<java classname="com.me.api" failonerror="true" fork="true" maxmemory="128m" output="${wsdlFile}.out">
<arg value="${className}" />
<arg value="${name}" />
<arg value="${wsdlFile}" />
<classpath>
<path refid="maven.test.classpath" />
</classpath>
Maven creates lengthy classpaths due to the structure and location of the local maven repo. We need to use a pathing jar.
Convert Classpath into string
Escape windows drive letter (C: = bad \C: = good)
Create manifest only jar with class path attribute
Use the pathing jar instead of the maven compile classpath
<mkdir dir="${classpath-compile.dir}"/>
<!-- Convert into usable string . -->
<pathconvert property="compile_classpath_raw" pathsep=" ">
<path refid="maven.compile.classpath"/>
</pathconvert>
<!-- escape windows drive letters (remove C: from paths -- need to wrap with a condition os.family="windows")-->
<propertyregex property="compile_classpath_prep"
input="${compile_classpath_raw}"
regexp="([A-Z]:)"
replace="\\\\\1"
casesensitive="false"
global="true"/>
<!-- Create pathing Jars -->
<jar destfile="${classpath-compile.jar}">
<manifest>
<attribute name="Class-Path" value="${compile_classpath_prep}"/>
</manifest>
</jar>
<java classname="com.me.api" failonerror="true" fork="true" maxmemory="128m" output="${wsdlFile}.out">
<arg value="${className}" />
<arg value="${name}" />
<arg value="${wsdlFile}" />
<classpath>
<pathelement location="${classpath-compile.jar}" />
</classpath>
Extending the answer provided by #user4386022: You can define (starting with Ant 1.8) this macro which can help you if you have the same problem in different places in your build process (and you cannot just copy-paste the same snippet everywhere because Ant does not allow re-defining properties, so you will get an error saying that "manifest.classpath" is already defined.)
<macrodef name="create-classpath-jar" description="Create classpath Jar, to avoid getting the error about CreateProcess error=206, The filename or extension is too long">
<attribute name="classpathjar"/>
<attribute name="classpathref"/>
<sequential>
<!-- Turn the classpath into a property formatted for inclusion in a MANIFEST.MF file -->
<local name="manifest.classpath.property"/>
<manifestclasspath property="manifest.classpath.property" jarfile="#{classpathjar}">
<classpath refid="#{classpathref}" />
</manifestclasspath>
<!-- Create the Jar -->
<jar destfile="#{classpathjar}">
<manifest>
<attribute name="Class-Path" value="${manifest.classpath.property}"/>
</manifest>
</jar>
</sequential>
</macrodef>
To use the macro in your targets or tasks, then simply use it like this:
<path id="myclasspath">
.........
</path>
<create-classpath-jar classpathjar="classpath-compile.jar" classpathref="myclasspath" />
If using Ant 1.7 or newer you can utilize the manifestclasspath task to generate a manifest file then include it in a jar for use on the javac classpath
<!-- turn the classpath into a property formatted for inclusion in a MANIFEST.MF file -->
<manifestclasspath property="manifest.classpath"
jarfile="${classpath-compile.jar}">
<classpath refid="maven.compile.classpath" />
</manifestclasspath>
<!-- Create pathing Jars -->
<jar destfile="${classpath-compile.jar}">
<manifest>
<attribute name="Class-Path" value="${manifest.classpath}"/>
</manifest>
</jar>
<java classname="com.me.api" failonerror="true" fork="true" maxmemory="128m" output="${wsdlFile}.out">
<arg value="${className}" />
<arg value="${name}" />
<arg value="${wsdlFile}" />
<classpath>
<pathelement location="${classpath-compile.jar}" />
</classpath>
Fixed problem by removing fork="true" from javac target in build.xml file. Please refer to solutions above if forking is mandatory for your build process.

Selenium running headless Firefox browser in Windows

Is it possible to configure Selenium to use Firefox driver and run the browser headlessly within Windows?
I am aware of other drivers working so within Windows or under Linux but not in the particular case mentioned above. Any reference information (ad-hoc ways to achieve it, limitations, etc.) to read upon is highly appreaciated.
Regards,
It is possible to run browsers (Firefox, IE, ...) via dedicated virtual desktop which supported by OS Windows. One such known helper utility for that task is Headless Selenium for Windows.
Here is the way we are running selenium using firefox driver in headless mode on windows.
Create a windows task schedule, you can either do this using the UI
http://windows.microsoft.com/en-US/windows/schedule-task#1TC=windows-7
or with a command like this :
schtasks /Create /TN Automation /TR C:\automation\automated_regression.bat /SC ONSTART /RU Administrator /RP password /F /V1
in our case, the automation is ant driven, so the automated_regression.bat has something like this
:myLoop
cd c:\automation
call ant_env.bat
call ant -f regression.xml
GOTO myLoop
where the regression.xml has a the typical junit targets of a selenium java project
<property name="main.dir" location="./selweb" />
<property name="src.dir" location="${main.dir}/src" />
<property name="lib.dir" location="${main.dir}/lib" />
<property name="build.dir" location="${main.dir}/build" />
<property name="test.report" location="${main.dir}/testreport">
</property>
<path id="build.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${test.report}" />
</target>
<target name="make dir" depends="clean">
<mkdir dir="${build.dir}" />
<mkdir dir="${test.report}" />
</target>
<target name="compile" depends="clean, make dir">
<javac srcdir="${src.dir}" destdir="${build.dir}" debug="true">
<classpath refid="build.classpath" />
</javac>
</target>
<target name="junit" depends="clean, make dir,compile">
<loadfile property="LATEST" srcFile="LATEST" />
<junit printsummary="no" fork="true" haltonfailure="false" dir="${main.dir}">
<classpath>
<pathelement path="${build.dir}" />
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</classpath>
<formatter type="xml" />
<batchtest todir="${test.report}">
<fileset dir="${build.dir}">
<include name="**/tests/**/*.class" />
</fileset>
</batchtest>
</junit>
<junitreport todir="${test.report}">
<fileset dir="${test.report}">
<include name="**/*.xml"/>
</fileset>
<report format="noframes" todir="${test.report}/html" styledir="${main.dir}/style">
<param name="TITLE" expression="Selenium Test Results for build ${LATEST}"/>
</report>
<report format="frames" todir="${test.report}/html" styledir="${main.dir}/style"/>
</junitreport>
</target>
you can use a logger to record your ant runtime eg.
<record name="log\automation_${timestamp}.log" loglevel="verbose" append="false" />
using this you can follow what is going on in your headless automation.
The ' characters around the executable and arguments are
not part of the command.
[junit] Test com.yourtests ... FAILED
[junit] Implicitly adding C:\automation\dep\apache-ant-1.8.4\lib\ant-launcher.jar;C:\automation\dep\apache-ant-1.8.4\lib\ant.jar;C:\automation\dep\apache-ant-1.8.4\lib\ant-junit.jar;C:\automation\dep\apache-ant-1.8.4\lib\ant-junit4.jar to CLASSPATH
.....
'org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner'
'com.yourtests'
'filtertrace=true'
'haltOnError=false'
'haltOnFailure=false'
'showoutput=false'
'outputtoformatters=true'
'logfailedtests=true'
'logtestlistenerevents=false'
'formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,c:\automation\selweb\testreport\TEST-com.yourtests'
'crashfile=c:\automation\junitvmwatcher2114698975676150832.properties'
'propsfile=c:\automation\junit4190343520192991051.properties'
We have followed this approach and it's working, even screen shots are being taken and inserted in the ant-junit html report.
So the essence is that you need to run your selenium through windows Tasks Scheduler and it will run in headless mode. I think something similar can be done under linux using the cron, but i haven't tried it out to see if it works.

webspehere 6.1.0.25 base with RAD 7.0.0.9 wsInstallApp task problem

Hi All,
I am trying to run wsInstallApp task to deploy my war file into
websphere.
I am getting the error "Unable to parse setupCmdLine:
null\bin\setupCmdLine.bat (The system cannot find the path specified.)"
<property name="ear.file" value="../archive/DocProcessing.war" />
There is no attribute for war
Here is the code SNIPPET:
<target name="init">
<path id="lib.ref">
<fileset dir="${env.classpath.WAS_HOME}\lib">
<include name="*.*jar" />
</fileset>
<fileset dir="${env.classpath.WAS_HOME}\bin">
<include name="*.*bat" />
</fileset>
<fileset dir="${env.classpath.WAS_HOME}\plugins">
<include name="*.*jar" />
</fileset>
<fileset dir="${env.classpath.WAS_HOME}\java\lib">
<include name="*.*jar" />
</fileset>
<fileset dir="${env.classpath.WAS_HOME}\deploytool\itp\plugins">
<include name="*.*jar" />
</fileset>
<fileset dir="${env.classpath.WAS_HOME}">
<include name="*.*jar" />
</fileset>
</path>
<taskdef name="wsStartServer" classpathref="lib.ref"
classname="com.ibm.websphere.ant.tasks.StartServer" />
<taskdef name="wsInstallApp" classpathref="lib.ref"
classname="com.ibm.websphere.ant.tasks.InstallApplication" />
</target>
<target name="StartServer" depends="init">
<exec dir="${env.classpath.WAS_HOME}\bin" executable="cmd">
<arg line="/c startServer.bat server1 -profileName AppSrv01" />
</exec>
</target>
<target name="installEar" depends="StartServer">
<echo message="EAR File located: ${ear.file}" />
<wsInstallApp ear="${ear.file}" wasHome="${env.classpath.WAS_HOME}"
conntype="${remoteConnType}" host="${remoteHostName}" user="${remoteUserId}"
password="${remotePassword}" />
</target>
properties set are:
<property name="remoteHostName" value="localhost" />
<property name="remoteConnType" value="SOAP" />
<property name="remotePort" value="8880" />
<property name="remoteUserId" value="wasadmin" />
<property name="remotePassword" value="wasadmin" />
path set for wasHome ="C:\Program Files\IBM\WebSphere\AppServer"
I could
not findout what is wrong in this .Though i am new to websphere i am
trying to find out the solution to install application and start
application using ant script .Please kindly provide me the solution to
get it set right .
Thanx in advance
You have to set 'user.install.root' property, here is an example:
<property name="user.install.root" value="${env.classpath.WAS_HOME}/profiles/was60profile1" />
Yes, we needed to add the following:
<property name="user.install.root" value="${was.path}/profiles/AppSrv01" />
where was.path would be the location where your was application is installed.
I had this error today. And found the answer!!!
Add profileName="[name of the profile]", in my case profileName="wp_profile", And it works!
This process most probably runs ws_ant.bat which in turn calls setupcmdline to initialise all the variables. In my installation the line is like this:
#echo off
#setlocal
call "%~dp0setupCmdLine.bat" %*
Could it be something to do with your server/RAD configuration being invalid, or the project not having a default server assigned to it?
What happens when you run it outside of RAD through the command line, does it still fail in the same way?
More information from IBM Support here:
http://www-01.ibm.com/support/docview.wss?rs=180&uid=swg1PK23265

Resources