Running Eclipse WindowTester Pro test from ant script - ant

I am using this script to launch WTP test
<ant target="ui-test" antfile="${eclipse-test-library-file}" dir="${eclipse-test-home}">
<property name="product" value="${productName}" />
<property name="application" value="${applicationName}" />
<property name="os" value="${baseos}"/>
<property name="ws" value="${basews}"/>
<property name="arch" value="${basearch}"/>
<property name="data-dir" value="${eclipse-test-home}/junit-workspace -clean" />
<property name="plugin-name" value="${pluginName}" />
<property name="classname" value="${testClassName}" />
</ant>
The workbench launched but the test did not run. Am I missing something in the ant property?

It's hard to judge what's missing in your setup, but there is an example project for running WindowTester tests from an Ant script here:
http://code.google.com/p/windowtester/downloads/detail?name=WindowTester_AntExample_v1.0.zip
If the example works for you, it should be easy to compare it to your project and find out the difference.

Related

Ant property value as parameter variable In JENKINS

I am working on Jenkins.
I have built a job1 with secret text: username and Password variable as
APP1_Dev_password
And using this variable from my ANT script by sending this variable in the predefined parameter to my other job2. I am accessing this variable using
<property name="DBPassword" value="${APP1_Dev_password}"/>
This works well.
But my ant script is a single generalized script for all my applications.
So I have get this APP1_Dev_password string constructed automatically from my ant script using
<property name="constructPasswordVariable" value="${APPLICATIONNAME}_${ENVIRON}_password"/>
<echo message= "constructPasswordVariable: ${constructPasswordVariable}" />
This clearly prints me constructPasswordVariable as APP1_Dev_password.
Now i have to use this value of the constructPasswordVariable property as a variable to fetch from the job1.
<echo message= "PasswordValue: ${${constructPasswordVariable}}" />
This statement fails. Can you guide me of how to work on this.
SOLUTION
<property name="constructPasswordVariable" value="${env.Module}_${env.Environment}_password"/>
<echo message= "constructPasswordVariable: ${constructPasswordVariable}" />
<propertycopy name="prop" from="${constructPasswordVariable}"/>
<echo message= "ENV VALUE: ${prop}" />
Output
constructPasswordVariable: APP1_Dev_password
ENV VALUE: asdhasd
Ant says nested property is not directly supported. Referring documentation from here
However, it can be achieved using library Flaka
Sample: from above reference
<project xmlns:fl="antlib:it.haefelinger.flaka">
<fl:install-property-handler/>
<property name="foo" value="foo.value"/>
<property name="var" value="foo" />
<property name="buildtype" value="test"/>
<property name="appserv_test" value="//testserver"/>
<echo>
#{${var}} = foo.value
<!-- nested property -->
#{appserv_${buildtype}}
</echo>
</project>
There is another reference here which make it possible without additional library as well.
Sample:
<project default="test">
<property name="foo" value="ABC"/>
<property name="pfoo" value="foo"/>
<target name="test">
<echo file="deref.properties">
deref: $${${pfoo}}
</echo>
<property file="deref.properties"/>
</target>

Getting error like weblogic.home env variable must be set to create osb12 config jar while executing ant script Following is the script I am using

config.xml (build file)
Ant script to create An Oracle Service Bus Config Jar from file system.
<target name="run">
<taskdef name="configjar" classname="com.bea.alsb.tools.configjar.ant.ConfigJarTask"/>
<property name="task.failonerror" value="true" />
<property name="task.errorproperty" value="" />
<property name="settingsFile" value="C:\Oracle\Middleware\Oracle_Home\osb\tools\configjar\config.xml"/>
<property name="WL_HOME" value="C:\Oracle\Middleware\Oracle_Home\wlserver" />
<property name="MW_HOME" value="C:\Oracle\Middleware\Oracle_Home\" />
<property name="OSB_HOME" value="C:\Oracle\Middleware\Oracle_Home\osb" />
<!--configjar failonerror="${task.failonerror}" errorProperty="${task.errorproperty}" settingsFile="${settingsFile}" -->
<configjar settingsFile="${settingsFile}" >
</configjar>
</target>
my settings file :
<?xml version="1.0" encoding="utf-8"?>
<configjarSettings xmlns="http://www.bea.com/alsb/tools/configjar/config">
<source>
<project dir="D:\JDeveloper\mywork\ServiceBusApplication2" />
<!--extensionMapping>
<mapping type="str1234" extensions="str1234" />
</extensionMapping-->
<!--fileset>
<include name="str1234" />
<exclude name="str1234" />
</fileset-->
</source>
<configjar jar="SBProject.jar" overwrite="false">
<projectLevel includeSystem="true">
<project>SBProject</project>
</projectLevel>
</configjar>
</configjarSettings>
I have set weblogic environment variable on command prompt , globally using environment variable section of Windows but still not luck.
I am stuck at this point.Need solution on the same.
I am using soa12c.And this is osb script for creation of configuration jar file for osb application.
Go to D:\Oracles\Middleware12c\osb\tools\configjar and run setenv.cmd. On the same cmd try running your ant script. It might ask for MW_HOME, set that also.

get property from different ant project

Is it possible to read properties from another ant project ?
I could do it with:
<ant antfile="child/build.xml" target="echoproperties">
<property name="echoproperties.file" value="${tmp}/child.properties" />
</ant>
<property prefix="child" file="${tmp}/child.properties" />
<delete file="${tmp}/child.properties" />
While in child/build.xml:
<target name="echoproperties">
<echoproperties destfile="${echoproperties.file}" />
</target>
But I would like to avoid creating temporary files.
I've found that Ant-Contrib has antfetch task although it's functionality is not that great (no prefix, no propertysets).

Ant build for multiple servers

I need suggestions for creating Ant build for multiple servers. I have about 25 servers. If possible, I would like to implement deployment war file for all the servers by running ant once. I have the following issues to consider
The configuration parameters are not the same for all servers.
Some configuration parameters I have to set server host ip on which app is deployed. With 25
servers, want some suggestions on how to deal with this.
You could hand code the logic to do this in Ant, but it might be lot of work depending on how different your server configurations are. Instead, I'd recommend looking at using a proper configuration management tool such as Chef or Puppet to automate your deployments and just use Ant to build the files that are deployed.
I had the same objectives.
You can either code a maven script in order to set up the continuous integration on Jenkins as mentionned by Jayan
or you can create an ANT script like you mentionned.
<!-- Define custom properties -->
<property name="build.dir" location="${basedir}/target" />
<property name="host.dev" value="YOUR IP" />
<property name="host.live" value="YOUR IP 2" />
<property name="ssh.timeout" value="60000" />
<property name="username.dev" value="username" />
<property name="username.live" value="username 2" />
<property name="password.dev" value="password" />
<property name="password.live" value="password 2" />
Create you own ssh macrodef task in order to use ssh commands:
<!-- Define ssh commands sshexec -->
<macrodef name="ssh_cmd">
<attribute name="host" />
<attribute name="command" />
<attribute name="usepty" default="false" />
<attribute name="username" />
<attribute name="password" />
<sequential>
<echo>Executing command : #{command} on #{username}###{host}</echo>
<sshexec host="#{host}" failonerror="true" username="#{username}" password="#{password}" timeout="${ssh.timeout}" command="#{command}" usepty="#{usepty}" trust="true" />
</sequential>
</macrodef>
Send a command to your server like :
<ssh_cmd host="${host.dev}" command="YOUR COMMAND (ex: sudo start yourservice onlinux)" username="${username.dev}" password="${password.dev}"/>
Don't forget to import sshexec / scp ant tasks with something like :
<property environment="env" />
<taskdef resource="net/jtools/classloadertask/antlib.xml">
<classpath>
<fileset dir="${ant.home}/lib" includes="ant-classloader*.jar" />
</classpath>
</taskdef>

sonar ant build.xml file for running default Sun checks on Java project

I am a beginner to SONAR , i just need a help for a sample ant build file for running my java project name 'Hello World' with SONAR 's default Sun checks Quality profile .I have not found anywhere any proper ant guide for sonar. I am using SONAR 2.10 .
Please help me in starting with SONAR .
<project name="Example" default="Sonar" basedir=".">
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath path="C:\Program Files\Apache Software Foundation\ant\lib\sonar-ant-task-1.0.jar" />
</taskdef>
<!-- Out-of-the-box those parameters are optional -->
<property name="sonar.jdbc.url" value="jdbc:mysql://localhost:3309/sonar" />
<property name="sonar.jdbc.driverClassName" value="com.mysql.jdbc.Driver" />
<property name="sonar.jdbc.username" value="root" />
<property name="sonar.jdbc.password" value="root" />
<!-- Additional Sonar configuration (PMD need 1.5 when using annotations)-->
<property name="sonar.java.source" value="1.5"/>
<property name="sonar.java.target" value="1.5"/>
<property name="sonar.projectName" value="Example"/>
<property name="sonar.binaries" value="C:\Documents and Settings\tausif\Feature2\Example\bin"/>
<!-- SERVER ON A REMOTE HOST -->
<property name="sonar.host.url" value="http://localhost:8080/sonar" />
<target name="Sonar">
<!-- The workDir directory is used by Sonar to store temporary files -->
<sonar:sonar workDir="C:\Documents and Settings\tausif\Feature2\Sonar" key="com.example:example" xmlns:sonar="antlib:org.sonar.ant" >
<!-- source directories (required) -->
<sources>
<path location="C:\Documents and Settings\tausif\Feature2\Example" />
</sources>
</sonar:sonar>
</target>
</project>
The above two answers were realy helpful for me to create this xml file .
This is my sample build.xml . Can you please check what i am missing in it?
I have made Sun checks as default.My project name is Example.
You might find this (Sonar 2.6: Adds Continuous Inspection Support for Ant Community) or this (Analyse with Ant Task 1.0) documentation helpful.
You can refer below ant script which is specific to the sonar.
You can add it in your build.xml.
Below is the script with the details
<!-- Here you need to set the path which contains sonar specific jars required for ant e.g. path which contains sonar-ant-task-2.1.jar -->
<path id="sonar.classpath">
<fileset dir="${basedir}/sonar" includes="**/*.jar" />
</path>
<!-- This taskdef represents your ant lib for sonar you have to specify jar location along with jar name in class path no need to change the uri and resource-->
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath path="${basedir}\sonar\sonar-ant-task-2.1.jar" />
</taskdef>
<!-- This is the target we use to run sonar "depends" property is optional -->
<target name="sonar" depends="clean, compile">
<!-- specify your build version -->
<property name="build.version" value="0.0.0.1-Sonar"/>
<!-- specify your organization name its optional -->
<property name="mysonar.organizationName" value="XYZ"/>
<!-- specify your project Name -->
<property name="sonar.projectName" value="${project.name}" />
<!-- database url which is used by the sonar -->
<property name="sonar.jdbc.url" value="jdbc:mysql://<IP>:<Port>/sonar?useUnicode=true&characterEncoding=utf8" />
<!-- Driver name-->
<property name="sonar.jdbc.driverClassName" value="com.mysql.jdbc.Driver" />
<!-- database user name -->
<property name="sonar.jdbc.username" value="test" />
<!-- database password -->
<property name="sonar.jdbc.password" value="test" />
<!-- url on which sonar is running-->
<property name="sonar.host.url" value="http://<IP>:<Port>" />
<!-- project key -->
<property name="sonar.projectKey" value="${mysonar.organizationName}:${sonar.projectName}" />
<!-- project version-->
<property name="sonar.projectVersion" value="1.0" />
<!-- location source files -->
<property name="sonar.sources" value="${src.home}/main/java" />
<!-- location of binaries after compilation-->
<property name="sonar.binaries" value="${basedir}/output"/>
<!-- location of sonar library-->
<sonar:sonar xmlns:sonar="antlib:org.sonar.ant">
</sonar:sonar>
</target>
Note: Make sure that location you specify are correct you can give absolute path as well.

Resources