The Apache Commons Lang library could help you to determine the running OS type. Here is an simple example.
You probably will come across the following error frequently when writing Selenium test case for a Ajax-rich website.
- Error: Element not found in the cache – perhaps the page has changed since it was looked up
This is because the Selenium WebDriver reference to your element would now be stale as the DOM has been modified by Ajax. To resolve the problem in Java, you can make us of the WebDriverWait and find the element each time before you use it.
Previously we have talked about how to package a .jar artifact with dependencies included.
An alternative solution is to put your dependencies in the src/main/resources folder and they will be copied to the target folder together with the packaged .jar file. Then we can add the class paths to these dependencies in the Manifest with the help of the maven-jar-plugin.
The following project is a real life example which i use it to test the connection between the JBoss server and the MSSQL server.
Sometimes we want to build a executable jar which contains all the dependencies. In this case we could make use of the maven-assembly-plugin which help us to package a jar-with-dependencies artifact during the Maven package phase. Let’s refer to the simple Maven project we did before.
1. First let’s introduce a dependency to our project. Say, we want to make use of the Apache Commons – Commons Lang to check the empty string. Edit the src/main/java/info/ykyuen/eureka/Addition.java as follow.
We can set the default main class in the META-INF/MANIFEST.MF. This could be configured in the maven-jar-plugin in pom.xml. Let’s use the previous example.
1. Edit the pom.xml as follow.
I would like to setup the TestNG in Maven so i take this chance to revise the Maven basics.
1. The project should have the following folder structure.
- testng-example (project root folder)
- info/ykyuen/eureka <folders for package name>
- <any resource files like .properties>
Previously we have talked about how to work with Apache Ivy and Artifactory.
The next thing i would like to share is to publish your built .jar file to Artifactory.
1. Login to Artifactory web portal and create a new repository, click on the Admin tab and select Repository on the left menu side bar.
Like Maven, we could setup a repository server for better dependency management. So instead of connecting to the public repository, we want our Apache Ivy project links to our repository server, i have already setup the Artifactory repository server in my local machine. Let’s continue with the project we created yesterday.
1. Add the ivysettings.xml location in the build.xml.
Maven is my favourite Java project management tool. But for legacy Java projects which you have to stick to use Apache Ant, you can consider Apache Ivy.
Apache Ivy installation is simple, download the binary, extract the ivy.jar to your ANT_HOME/lib.
Jenkins, previously named as Hudson, is a continuous integration tool just like CruiseControl. It has been almost 4 years since i started learning Maven which made me fall in love about best practice. Deployment and testing automation is really fun and finally i got a chance to play it again.
In this article, i would show you how to setup a simple Ant build project in Jenkins. Before we start, please refer to the simple Java project example in the post below.
1. Download and install Jenkins.