how do I use client certitificate file for svnkit in ant? - ant

My svn admin require us to install a pfx client cert file on our windows machine to connect. I tried that and have no problem connecting to svn with TortoiseSVN.
Now I need to write an ant script and use svnkit inside to checkout/update. How do I specify the client file?
<java classname="org.tmatesoft.svn.cli.SVN" dir="src" fork="true">
<arg value="co" />
<arg value="--username" />
<arg value="xxxxx" />
<arg value="--password" />
<arg value="xxxx" />
<arg
value="https://123.456.789.123/xxx/xxx" />
<classpath>
<pathelement location="lib/antlr-runtime-3.4.jar" />
<pathelement location="lib/jna-3.4.0.jar" />
<pathelement location="lib/sequence-library-1.0.2.jar" />
<pathelement location="lib/sqljet-1.1.3.jar" />
<pathelement location="lib/svnkit-javahl16-1.7.5.jar" />
<pathelement location="lib/trilead-ssh2-1.0.0-build215.jar" />
<pathelement location="lib/svnkit-1.7.5.jar" />
<pathelement location="lib/svnkit-cli-1.7.5.jar" />
</classpath>
</java>

I don't know what a "pfx client cert file" is, but I'm assuming you're talking about a Java truststore?
Try adding the standard ssl properties to the Java program as follows:
<java classname="org.tmatesoft.svn.cli.SVN" dir="src" fork="true">
<sysproperty key="javax.net.ssl.keyStore" value="client.keystore" />
<sysproperty key="javax.net.ssl.keyStorePassword" value="123456" />
<sysproperty key="javax.net.ssl.trustStore" value="client.truststore" />
<sysproperty key="javax.net.ssl.trustStorePassword" value="123456" />
..
Reference:
JSSE Reference Guide

Related

Not able to execute testNG xml from ANT build.xml

I am using below build.xml to execute my testng xml. This build.xml is working fine for me when I required only Selenium standalone jar.
<project name="TestNGTest" default="test" basedir=".">
<!-- Define <testng> task -->
<taskdef name="testng" classname="org.testng.TestNGAntTask">
<classpath>
<pathelement location="SupportFiles/JarFiles/commons-cli-1.0.jar" />
<pathelement location="SupportFiles/JarFiles/commons-logging.jar" />
<pathelement location="SupportFiles/JarFiles/crimson.jar" />
<pathelement location="SupportFiles/JarFiles/hsqldb.jar" />
<pathelement location="SupportFiles/JarFiles/jaxp.jar" />
<pathelement location="SupportFiles/JarFiles/jconfig.jar" />
<pathelement location="SupportFiles/JarFiles/jmxri.jar" />
<pathelement location="SupportFiles/JarFiles/jxl.jar" />
<pathelement location="SupportFiles/JarFiles/mysql-connector-java-5.1.6-bin.jar" />
<pathelement location="SupportFiles/JarFiles/selenium-server-standalone-2.45.0.jar" />
<pathelement location="SupportFiles/JarFiles/xlSQL_Y8.jar" />
</classpath>
</taskdef>
<property name="testdir" location="bin" />
<property name="srcdir" location="src" />
<property name="libdir" location="SupportFiles" />
<property name="subdir" location="JarFiles" />
<property name="full-compile" value="true" />
<path id="classpath.base" />
<path id="classpath.test">
<!--pathelement location="${libdir}/testng-6.8.5.jar" /-->
<!--pathelement location="${subdir}/SeleniumTestNG.jar" /-->
<pathelement location="${subdir}/selenium-server-standalone-2.45.0.jar" />
<pathelement location="${subdir}/commons-cli-1.0.jar" />
<pathelement location="${subdir}/commons-logging.jar" />
<pathelement location="${subdir}/crimson.jar" />
<pathelement location="${subdir}/hsqldb.jar" />
<pathelement location="${subdir}/jaxp.jar" />
<pathelement location="${subdir}/jconfig.jar" />
<pathelement location="${subdir}/jmxri.jar" />
<pathelement location="${subdir}/jxl.jar" />
<pathelement location="${subdir}/mysql-connector-java-5.1.6-bin.jar" />
<pathelement location="${subdir}/xlSQL_Y8.jar" />
<!-- pathelement location="${libdir}/jxl-2.6.12.jar"/-->
<pathelement location="${testdir}" />
<fileset dir="${testdir}" includes="*.jar" />
<fileset dir="${libdir}">
<include name="**/*.jar" />
</fileset>
<pathelement location="${testdir}" />
<pathelement location="${srcdir}" />
<path refid="classpath.base" />
</path>
<target name="clean">
<delete verbose="${full-compile}">
<fileset dir="${testdir}" includes="**/*.class" />
</delete>
</target>
<target name="compile" depends="clean">
<javac srcdir="${srcdir}" destdir="${testdir}" verbose="${full-compile}" fork="yes" includeantruntime="false">
<classpath refid="classpath.test" />
</javac>
</target>
<target name="test" depends="compile">
<testng outputdir="C:\Users\A592013\.jenkins\jobs\Jenkins - Selenium\workspace\test-output" classpathref="classpath.test">
<xmlfileset dir="." includes="TestNG_Sanity.xml" />
</testng>
</target>
</project>
It is giving below message as BUILD SUCCESSFUL, however not executing the scripts. Below is the detail warning message:
[javac] C:\DurgeshProjectWork\Workspace\SeleniumWorkspace\DevOps_DIT\src\net\atos\selenium\common\XML.java:835: warning: OutputFormat is internal proprietary API and may be removed in a future release
[javac] OutputFormat format = new OutputFormat(document);
[javac] ^
[javac] C:\DurgeshProjectWork\Workspace\SeleniumWorkspace\DevOps_DIT\src\net\atos\selenium\common\XML.java:835: warning: OutputFormat is internal proprietary API and may be removed in a future release
[javac] OutputFormat format = new OutputFormat(document);
[javac]
Can anyone please tell what is wrong in my build.xml
Thanks a lit for your help on this. Just a FYI. I am reading excel data with the help of XLSQL 8 so required all these jars to execute this.
Thanks a lot for your help on this.
^

ERROR: Publisher hudson.tasks.junit.JUnitResultArchiver aborted due to exception

I have performed a Junit test successfully from eclipse.
So i wanted to execute the same test cases from Jenkins.
For that i have written the build.xml (ant build).
<path id="classpath">
<pathelement location="lib\junit-4.12-javadoc.jar" />
<pathelement location="lib\junit-4.12-sources.jar" />
<pathelement location="lib\junit-4.12.jar" />
<pathelement location="lib\ojdbc14.jar" />
<pathelement location="lib\oraclejdbc.jar" />
<pathelement location="lib\testng-6.8.5.jar" />
<pathelement location="bin" />
</path>
<target name="compile">
<javac classpath="classpath" includeantruntime="false" srcdir="./src" destdir="bin" includes="**/*.java" verbose="true">
</javac>
</target>
<target name="run_tests" depends="compile">
<junit printsummary="on" haltonfailure="false" showoutput="yes">
<formatter type="xml" usefile="false" />
<test name="om.wipro.TestDbUpdates" />
<test name="om.wipro.TestExample" />
<classpath>
<pathelement location="lib\junit-4.12-javadoc.jar" />
<pathelement location="lib\junit-4.12-sources.jar" />
<pathelement location="lib\junit-4.12.jar" />
<pathelement location="lib\ojdbc14.jar" />
<pathelement location="lib\oraclejdbc.jar" />
<pathelement location="lib\testng-6.8.5.jar" />
<pathelement location="bin" />
</classpath>
</junit>
</target>
My problem is that, the execution from Jenkins is not successful. Build is successful(from both eclipse and Jenkins) though test cases are failing.
How to get rid of the following error?
ERROR: Publisher hudson.tasks.junit.JUnitResultArchiver aborted due to exception
hudson.AbortException:
Regards,
Sharon M P
There is a ticket about this error:
https://issues.jenkins-ci.org/browse/JENKINS-24946
If you are using Jenkins version "V1.582", they recommend to upgrade to the latest version to solve this issue.
You can check your jenkins version at the bottom/right of the web page.

svnant failing when trying to tag

I want create an ant build that creates a reference tag to a given project, but I'm getting an error:
Cannot find javahl, svnkit nor command line svn client
My build.xml:
<property name="tag.name" value="...." />
<path id="path.svnant">
<pathelement location="${basedir}/svnant.jar" />
<pathelement location="${basedir}/svnClientAdapter.jar" />
</path>
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="..." />
<path id="svnant.classpath">
<fileset dir="${svnant.lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<target name="svntag" description="tags individual project using svnant task">
<property name="svn.tag.message" value="Tagging Project ${project.name} with tag name ${tag.name} from trunk " />
<property name="src.url" value="${svn.base.url}/${project.name}/trunk/" />
<property name="dest.url" value="${svn.base.url}/${project.name}/tags/${tag.name}" />
<echo message="${svn.project.base.path}" />
<echo message="${svn.tag.message}" />
<echo message="${src.url}" />
<echo message="${dest.url}" />
<svnSetting javahl="false" svnkit="true" username="...." password="...." id="svn.settings" />
<svn>
<copy srcUrl="${src.url}" destUrl="${dest.url}" message="${svn.tag.message}" />
</svn>
</target>
See another question for details Cannot find javahl, svnkit nor command line svn client
I recommend you to use SVNKit (http://svnkit.com/kb/user-guide-svnant.html) because it's pure java SVN implementation so can be run on platforms where java exists.

Invoking FindBugs from Ant: passing a space-separated list of files to java

I'm trying to invoke FindBugs from inside Ant. In order to control the amount of memory available to FindBugs, I've chosen not to use the ant-task. The problem I have now is that I want to pass a number of jars on the command-line to FindBugs:
java -jar .../findbugs.jar foo.jar bar.jar fie.jar
However, since these jars actually are Eclipse plugins, I don't know the exact name of the jars so I need a way to use a wildcard to obtain the list. This is what I've come up with:
<target name="findbugs">
<property name="findbugs.home" location="${user.home}/eclipse/findbugs" />
<path id="findbugs.input">
<fileset dir="${testDirectory}/eclipse/plugins">
<include name="my.plugins.*.jar" />
</fileset>
</path>
<path id="findbugs.auxinput">
<fileset dir="${testDirectory}/eclipse/plugins">
<include name="*.jar" />
<include name="**/*.jar" />
</fileset>
</path>
<java jar="${findbugs.home}/lib/findbugs.jar" fork="true">
<jvmarg value="-Xmx1048m" />
<arg value="-textui" />
<arg value="-output" />
<arg value="findbugs.xml" />
<arg value="-xml" />
<arg value="-exclude" />
<arg value="${basedir}/findbugsExclude.xml" />
<arg value="-auxclasspath" />
<arg pathref="findbugs.auxinput"/>
<arg pathref="findbugs.input" />
</java>
</target>
However, the findbugs.input pathref is a comma-separated list of jars, and not space-separated as FindBugs wants it. How do I get the list of jars as a space-separated list?
(Is this perhaps easier to do with the FindBugs ant-task. I can't really tell from the documentation.)
Use pathconvert, like this:
<pathconvert pathsep="," property="findbugs.input.csv" refid="findbugs.input"/>
Implementing in the target that you provided, I changed the reference from <arg pathref="findbugs.input" />
to <arg value="${findbugs.input.csv}" />
<target name="findbugs">
<property name="findbugs.home" location="${user.home}/eclipse/findbugs" />
<path id="findbugs.input">
<fileset dir="${testDirectory}/eclipse/plugins">
<include name="my.plugins.*.jar" />
</fileset>
</path>
<pathconvert pathsep="," property="findbugs.input.csv"
refid="findbugs.input"/>
<path id="findbugs.auxinput">
<fileset dir="${testDirectory}/eclipse/plugins">
<include name="*.jar" />
<include name="**/*.jar" />
</fileset>
</path>
<echo message="${findbugs.input.csv}" />
<java jar="${findbugs.home}/lib/findbugs.jar" fork="true">
<jvmarg value="-Xmx1048m" />
<arg value="-textui" />
<arg value="-output" />
<arg value="findbugs.xml" />
<arg value="-xml" />
<arg value="-exclude" />
<arg value="${basedir}/findbugsExclude.xml" />
<arg value="-auxclasspath" />
<arg pathref="findbugs.auxinput"/>
<arg value="${findbugs.input.csv}" />
</java>
</target>
Use <pathconvert> to convert the path into the proper format, storing it into a property then use <arg value...> instead of <arg pathref...>
You can control the memory from the ant task:
<findbugs jvmargs="-Xms512m -Xmx512m" ...>
...
</findbugs>

How do I generate Emma code coverage reports using Ant?

How do I setup an Ant task to generate Emma code coverage reports?
To answer questions about where the source and instrumented directories are (these can be switched to whatever your standard directory structure is):
<property file="build.properties" />
<property name="source" location="src/main/java" />
<property name="test.source" location="src/test/java" />
<property name="target.dir" location="target" />
<property name="target" location="${target.dir}/classes" />
<property name="test.target" location="${target.dir}/test-classes" />
<property name="instr.target" location="${target.dir}/instr-classes" />
Classpaths:
<path id="compile.classpath">
<fileset dir="lib/main">
<include name="*.jar" />
</fileset>
</path>
<path id="test.compile.classpath">
<path refid="compile.classpath" />
<pathelement location="lib/test/junit-4.6.jar" />
<pathelement location="${target}" />
</path>
<path id="junit.classpath">
<path refid="test.compile.classpath" />
<pathelement location="${test.target}" />
</path>
First you need to setup where Ant can find the Emma libraries:
<path id="emma.lib" >
<pathelement location="${emma.dir}/emma.jar" />
<pathelement location="${emma.dir}/emma_ant.jar" />
</path>
Then import the task:
<taskdef resource="emma_ant.properties" classpathref="emma.lib" />
Then instrument the code:
<target name="coverage.instrumentation">
<mkdir dir="${instr.target}"/>
<mkdir dir="${coverage}"/>
<emma>
<instr instrpath="${target}" destdir="${instr.target}" metadatafile="${coverage}/metadata.emma" mode="copy">
<filter excludes="*Test*"/>
</instr>
</emma>
<!-- Update the that will run the instrumented code -->
<path id="test.classpath">
<pathelement location="${instr.target}"/>
<path refid="junit.classpath"/>
<pathelement location="${emma.dir}/emma.jar"/>
</path>
</target>
Then run a target with the proper VM arguments like:
<jvmarg value="-Demma.coverage.out.file=${coverage}/coverage.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
Finally generate your report:
<target name="coverage.report" depends="coverage.instrumentation">
<emma>
<report sourcepath="${source}" depth="method">
<fileset dir="${coverage}" >
<include name="*.emma" />
</fileset>
<html outfile="${coverage}/coverage.html" />
</report>
</emma>
</target>
The User Guide has a good example of how to set up your build script so that you not only seperate the instrumented code from the execution, but it's also all contained in the same <target> so that you don't have to run a series of different targets, but instead you can just do something like ant emma tests (if ant tests was how you normally ran your unit tests, for example).
Here's their example:
<target name="emma" description="turns on EMMA instrumentation/reporting" >
<property name="emma.enabled" value="true" />
<!-- EMMA instr class output directory: -->
<property name="out.instr.dir" value="${basedir}/outinstr" />
<mkdir dir="${out.instr.dir}" />
</target>
<target name="run" depends="init, compile" description="runs the examples" >
<emma enabled="${emma.enabled}" >
<instr instrpathref="run.classpath"
destdir="${out.instr.dir}"
metadatafile="${coverage.dir}/metadata.emma"
merge="true"
/>
</emma>
<!-- note from matt b: you could just as easily have a <junit> task here! -->
<java classname="Main" fork="true" >
<classpath>
<pathelement location="${out.instr.dir}" />
<path refid="run.classpath" />
<path refid="emma.lib" />
</classpath>
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
</java>
<emma enabled="${emma.enabled}" >
<report sourcepath="${src.dir}" >
<fileset dir="${coverage.dir}" >
<include name="*.emma" />
</fileset>
<txt outfile="${coverage.dir}/coverage.txt" />
<html outfile="${coverage.dir}/coverage.html" />
</report>
</emma>
</target>
Emma 2.1 introduces another way of obtaining runtime coverage information (.ec file). One can remotely request the data from the given port of the computer where an instrumented application is runnig. So there's no need to stop VM.
To get the file with runtime coverage data you need to insert the following snippet in your Ant script between running of your tests and generating coverage report:
<emma>
<ctl connect="${emma.rt.host}:${emma.rt.port}" >
<command name="coverage.get" args="${emma.ec.file}" />
<command name="coverage.reset" />
</ctl>
</emma>
Other steps are similar to Emma 2.0. They are perfectly described in previous post
More information on Emma 2.1 features: http://sourceforge.net/project/shownotes.php?group_id=108932&release_id=336859

Resources