Configuring "Cruise Control" with "Maven2" and "Subversion 1.4.6" for continuous build environment

Continous Integration build system is very useful in a software development company where members of a team integrate their work frequently. It reduces the wastage of time and at the same time it helps us to maintain all the builds up to date. Previous week we also configured a continous build flow in our R&D division using Cruise Control, Maven and Subversion.  For this what we did is, we  created our project module builds in MAVEN2 (Using the latest technology which gives us more options and easiness to handle projects). Created a new SVN environment and Configured the SVN with Cruise Control.

Here In this post I am describing about the Configuration of Cruise control with Maven and Subversion.

Versions Used:

Subversion        : 1.4.6

Maven               : 2.0

Cruise Control   : 2.7.2

What is Cruise Control?

CruiseControl is a popular open source tool for implementing Continuous Integration (CI) of Java applications. The idea behind CI is; Build, regression test, and deploy your software application to a test environment every time a code change is committed to version control. If the code change causes the build to break, the regression test to fail, or a problem with the deployment, identify and correct the problem promptly. CruiseControl is ideally suited for CI. It is a reliable tool that provides real value to Java development teams of any size.

What is Continuous Integration?

Continuous Integration is a software development practice where members of a team integrate their work frequently; usually each person integrates at least daily - leading to multiple integrations per day. Each integration is verified by an automated build (including test) to detect integration errors as quickly as possible. Many teams find that this approach leads to significantly reduced integration problems and allows a team to develop cohesive software more rapidly.

What is the goal which we want to acheive from this process?

Using maven we are maintaining a Center repository for the JARs and trying to avoid the famous Java programers error word.. “Its working in my machine but I dont know why its not in yours”. Maven will give an Object oriented way to our build system and will give a lot of plugins to make it more advanced and useful.

The cruise control will build automatically when we update any new code to the SVN and will send emails to the respective persons about the build’s  success or failures. It will give the name of the programmer who is checked in the code to SVN and also the files where the code is failing.

1. Installing and running Cruise Control

Step 1:

Download the latest version of Cruise Control from the following link. http://cruisecontrol.sourceforge.net/download.html

Step 2:

Extract the files in to a specific location where you want to install the CruiseControl. For Example: C:\CruiseControl2.7.9

Step 3:

In the Cruise control installation directory we have a batch file called cruisecontrol.bat. Double click on this will start the cruise control in port 8080. Internally a jetty Server is running… We can change the port by editing the batch file.

2. Configuring Cruise Control for Maven2 and Subversion1.4.6.

Prerequisites:

  1. Apache Maven2 should be installed in the server where we are installing and configuring CruiseControl
  2. Subversion should be installed and running on the server.

Follow the two Steps below to configure a new project in Cruise control.

  1. Configuring in config.xml file.

This is the main part of configuring a project in the cruise control. Here we are giving the necessaey informations about the project, the Scheduling the time, configuring the bootstrappers, giving the location of the local copy, Giving the SVN location, specifing the MAVEN or ANT commands which we have to run in scheduled time etc. Please find the comments written in each part for more information.

Here in this I had configured all the common parameters at the TOP of the config.xml for reusability.

<! — Project Configurations –>

<property name=”log.dir” value=”./logs/${project.name}”/>

<property name=”projects.dir” value=”./projects”/>

<property name=”projects.checkout.dir” value=”${projects.dir}”/>

<property name=”project.log.dir” value=”${projects.dir}/logs/${project.name}”/>

<! — Repository configurations for that project — >

<property name=”svn.repository” value=”< Repository URL>“/>

<property name=”svn.portal.project” value=”${svn.repository}/<Project name Here>“/>

<property name=”svn.user” value=”<username here>“/>

<property name=”svn.password” value=”<password here>“/>

<! — Build Specific Configurations –>

<property name=”maven.home” value=”E:\Apache\apache-maven-2.0.8″/>

<property name=”ant.home” value=”E:\cruisecontrol-bin-2.7.1\apache-ant-1.7.0″/>

<! — Cruise Control - Scheduler Specific Configurations–>

<property name=”schedule.interval” value=”600″/>

<property name=”quiet.period” value=”300″/>

<! — Mail configurations –>

<property name=”buildresults.url” value=”http://localhost:8080/buildresults/${project.name}”/>

<property name=”css.location” value=”E:\cruisecontrol-bin-2.7.1\docs\cruisecontrol.css”/>

<property name=”xsl.dir” value=”E:\cruisecontrol-bin-2.7.1\webapps\cruisecontrol\xsl”/>

<property name=”mail.host” value=”<mail server name>“/>

<property name=”build.url” value=”<The url where Cruise control is running>“/>

<property name=”mail.subject.prefix” value=”[Cruise Control] Project [${project.name}]“/>

<property name=”cc.mail.username” value=”<mail username here>“/>

<property name=”cc.mail.password” value=”< mail password here>“/>

<property name=”return.name” value=”Cruise Control Agent”/>

<! — Always send addresses –>

<property name=”mail.address.buildmanager” value=”<mail address here>“/>

<! — Failure addresses –>

<property name=”mail.address.ifFails” value=”<mail address here>“/>

<! — Success addresses –>

<property name=”mail.address.ifSuccess” value=”<mail address here>“/>

<! — Return Address –>

<property name=”mail.address.return” value=”<mail address here>“/>

<! — Starting the Project Specific information –>

<project name=”<Give project name here>“>

<! —Specifying the cruise control plug-ins information [It’s optional] –>

<plugin name=”svn” lassname=”net.sourceforge.cruisecontrol.sourcecontrols.SVN”/>

<plugin name=”svnbootstrapper” classname=”net.sourceforge.cruisecontrol.bootstrappers.SVNBootstrapper”/>

<! — This writes a build status snippet to the file system. –>

<listeners>

<currentbuildstatuslistener file=”logs/${project.name}/status.txt”/>

</listeners>

<! — This bootstraps resources from Subversion. –>

<bootstrappers>

<svnbootstrapper LocalWorkingCopy=”projects/${project.name}” />

<bootstrappers>

<! — A container element for a set of modifications collected from all included SourceControl elements.<modificationset> can contain multiple elements which can be useful to check only parts of a large Project rather than checking all files every time. –>

<modificationset quietperiod=”${quiet.period}”>

<svn Localworkingcopy=”projects/${project.name}” RepositoryLocation=”${svn.portal. project}”

useLocalRevision=”true”/>

<maven2snapshotdependency pomfile=”projects/${project.name}/pom.xml” user=”<SVN username here>“/>

</modificationset>

<! — This is the main part. Here the first ant task will copy the current data from the SVN to the local project folder.

The second task is doing scm update, clean and install goals of maven–>

<schedule interval=”${schedule.interval}”>

<composite>

<ant anthome=”${ant.home}” buildfile=”projects/${project.name}/cc-build.xml[l1] ” />

<maven2 mvnhome=”${maven.home}” pomfile=”projects/${project.name}/pom.xml” goal=”clean install site:site site:deploy”/>

</composite>

</schedule>

<! — In this part we are configuring the mail related information. To whom we need to send mails, what structure etc… etc –>

<publishers>

<onsuccess>

<artifactspublisher dest=”artifacts/${project.name}” file=”projects/${project.name}/target/${project.name}.jar”/>

</onsuccess>

<htmlemail mailhost=”${mail.host}” subjectprefix=”${mail.subject.prefix}” returnaddress=”${mail.address.return}”

buildresultsurl=”${build.url}/${project.name}” css=”${css.location}” xsldir=”${xsl.dir}”

xslfilelist=”header.xsl,buildresults.xsl” returnname=”${return.name}” skipusers=”false” spamwhilebroken=”false”

username=”${cc.mail.username}” password=”${cc.mail.password}” >

<always address=”${mail.address.buildmanager}”/>

</htmlemail>

</publishers>

</project>

Main points to note:

1. Schedule Time Interval : This is the time period in which cruise control is checking the SVN for updation.

2. ANT script in schedule composite tag: Which is used to copy the SVN updated files.

3. MAVEN goals: mvn clean compile site:site site:deploy This we used to clean and compile the code. Then it will create the site related files for that project and deploy it in a server which we specified in that POM file

If you have to configure more options please refer this link: http://cruisecontrol.sourceforge.net/main/configxml.html#modificationset

2. Create a local copy of the project in the Projects folder of the Cruise Control. Follow the following steps for that.

  • Copy the entire project folder from our eclipse workspace in to the “Projects” folder.
  • Make sure that that copy contains the correct SVN information also.
  • Create a ANT build file with the following information and store it in Projects> [Current Project folder]

Name it as cc-build.xml as we mentioned in the config.xml of Cruise oontrol.

<project name=”Project” default=”update-src” basedir=”.” >

<property name=”base.dir” value=”.” />

<target name=”update-src”>

<echo>Updating source from Subversion</echo>

<exec executable=”svn” dir=”${base.dir}”>

<arg line=”up” />

</exec>

</target>

</project>


[l1]This is the ANT script which is copying all the SVN updated data in to the Local copy. So we need to copy that ANT build file in to the Local projects folder.

SpringSource Application Management Suite (AMS) Beta Released

SpringSource Application Management Suite (AMS) is a comprehensive enterprise application management tool. It is designed to manage and monitor all of your Spring-powered applications, the Spring runtime, and a variety of platforms and application servers. SpringSource AMS is built on Hyperic’s HQ Enterprise Edition, a proven systems and applications management solution. Additional features of SpringSource AMS include:

  • Automatic discovery of Spring-powered applications on deployment
  • Automatic monitoring of a variety of Spring, third party, and stereotyped components running in your application. SpringSource AMS instruments a variety of components in the Spring Framework. Simply drop the instrumented jar files into your application, and SpringSource AMS will begin monitoring your application and exposing statistics via JMX. No additional configuration steps required!
  • Automatic monitoring of components of the Spring runtime, including the application contexts and bean factories

You can read more about its features in Jennifer Hickey’s first post in Spring Team blog. This introduction part is also taken from her blog. I am only started to look into that ;)

Six Possible solutions for JDBC - SQL Server Connection problem

Here in this post I am writing about some possible solutions of JDBC - MS SQL server connection problem. During my work I had faced this problem and tried a little hard to findout the solution. In our project when we tried to connect to MSSQL Server, through its default port 1433 it thrown an exception as follows. Hope this will be helpful to you.

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host has failed.

java.net.ConnectException: Connection refused: connect

If you created the database and you are sure about your connection string then please check the following points.

  1. First Check the port which we are given is free or not. If any other connection is using this then please specify other port.
  2. Check the TCP/IP configuration in “MSSQL surface area configuration”. And if its disabled then make it enable.
  3. Check the Windows Firewall. It may obstruct the port accessing. So please disable it or allow this port accessing through the firewall using windows firewall configuration.
  4. Check if there is any antivirus software is running and it comes in between or not.
  5. Check the Dynamic port allocation of SQL Server is set or not. If it sets to ZERO or any other port then make it ‘Blank’. [making Blank is important] Give the static port number we want to the port number place. These configurations we can do in “SQL Server Configuration manager”. Give IPALL = 1433 also.  This information will set in the following part of the windows registry HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > Microsoft SQL Server> MSSQL.1 > MSSQLServer > SuperSocketNetLib > Tcp> IP1/IP2/IPALL. If it’s not changing there we can manually change it.
  6. Then also its not working then please check the Windows Registry where we sets the “SQL Instance’s port number”. If it is different then please set that to our port number. It’s in HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > Microsoft SQL Server > [Instance name] > MSSQLServer > SuperSocketNetLib > Tcp and change String value TcpPort = 1433.

Are are you reached here? Thanks for reading my full post :) becouse if u are a person who is facing this problem then I am sure you will not reach here, before itself it should solve :) And then also you are here then please check your connection string properly. I am giving an example here.

jdbc.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.url=jdbc:sqlserver://servername:1433;DatabaseName=DBName;SelectMethod=cursor

Technorati Tags: ,,

Installing Subversion? Just follow this 7 Steps

During  this week I had installed and configured Subversion and Cruise Control in my office. We all know its relatively simple to configure these but then also here in this post I am just writing the installation and configuration of Subversion into some simple steps. Hope it will be helpful to any of you in future [ Surely. for me too ;) ].

Versions used here are:

Apache HTTP Server 2.2 [ Download] and Subversion 1.4.6 [Download]

1. Installing Apache HTTP server.

Download the Apache HTTP Server from Here. You can download the binary version or the Windows installer from the site. Specify a location to install, for example here Im using D:\Subversion\Apache\Server.

2. Installing Subversion.

Download the Subversion installer from Here. Just follow the steps in the instalation wizard to install the subversion. Here I am installing subversion into the root folder with a different child direcotry. D:\Subversion\Subversion

3. Configuring the Apache Server.

Okey.. So u completed two “Complex” :) steps now. But the third one is  very simple. It contains two steps

    1. Copy the files mod_authz_svn.so and mod_dav_svn.so from the [Installation path]\Subversion\bin folder to the [Installation path]\modules folder. Actually we are adding two module files into the Apache server.
    2. Go to the conf directory of Apache server [Installation path]\conf and edit the httpd.conf file. Add the following lines into the modules including part

LoadModule  dav_module             modules/mod_dav.so
LoadModule  dav_svn_module         modules/mod_dav_svn.so
LoadModule  authz_svn_module       modules/mod_authz_svn.so

3. Creating the Project repository locations.
Create a Repository Folder where you want to store all the projects. For example I am creating folders called DFRepository and SFRepository in my E drive.

E:\Repositories\DFRepository
E:\Repositories\SFRepository

These are just directories to hold our repositories, now we must create the repositories themselves, using the svnadmin utility

svnadmin create E:\Repositories\DFRepository
svnadmin create C:\Repositories\SFRepository

Then Subversion will create a folder predifined structure inside this repository folder.

4. Creating the Users authentication file
               We can create a folder called etc in the root location where we had installed Subversion and Apache server. Open the command promt and just go to the bin directory of Apache Server and run the following commands.

htpasswd -cm D:\Subversion\svn-auth-file usernameOne
New password: *****
Re-type new password: *****
Adding password for user usernameOne

htpasswd -cm D:\Subversion\svn-auth-file usernameTwo
New password: *****
Re-type new password: *****
Adding password for user usernameTwo

When using the command for the first time, add the -c option. This creates the file named D:\Subversion\svn-auth-file . The -m option instructs the htpasswd utility to use MD5 algorithm to encrypt the passwords.

5. Creating the Access - rights file 
Create a file called svn-acl in the etc folder and add the following content into it. You can modify this content as per your need.

# specifinh groups here
[groups]
DFTeam = name1, name2

# DFTeam group has a read/write access to ‘DFRepository’ repository
# all subdirectories; all others have read access only
[DFRepository:/]
@DFTeam = rw
* = r

# ‘SFRepository’ repository, only harry and sally have read-write access.
[SFRepository:/]
harry = rw
sally = rw
* = r

# ross is helping with the time zone part of the project2
[SFRepository:/timezone]
harry = rw
sally = rw
ross = rw
* = r

6. Creating the SVN Location module

Create another file called Subversion.conf in the same etc folder which contains the following data.

<Location /DFRepos>
  DAV svn
  SVNPath E:\Repositories\DFRepository

  AuthType Basic
  AuthName “Subversion Project1 repository”
  AuthUserFile c:/etc/svn-auth-file

  Require valid-user
  AuthzSVNAccessFile c:/etc/svn-acl
</Location>

<Location /SFRepos>
  DAV svn
  SVNPath E:\Repositories\SFRepository
  AuthType Basic
  AuthName “Subversion Project2 repository”
  AuthUserFile c:/etc/svn-auth-file

  Require valid-user
  AuthzSVNAccessFile c:/etc/svn-acl
</Location>
 

If u dont want to include the access defenitions file and just want to check the user is valid or not the just change the Subversion.conf as follows.

<Location /SFRepos>
  DAV svn
  SVNPath E:\Repositories\SFRepository
  AuthType Basic
  AuthName “Subversion Project2 repository”
  AuthUserFile c:/etc/svn-auth-file

  <LimitExcept GET PROPFIND OPTIONS REPORT>  Require valid-user  </LimitExcept>
       </Location>

7. Configuring Location in httpd.conf file

This is very simple step. Just add this Subversion.conf file to the end of httpd.conf file as follows

Include D:\Subversion\etc\subversion.conf

Restart the Apache Server :). Finished…

Reference: This link helped me a lot to configure the repository

TestNG 5.6 and Junit 4.4 : which framework you will choose for unit testing?

As we all know JUnit is the most famous unit testing framework. Nobody needs any type of introduction for this small and easy framework. Most of the developers are using this as their unit testing framework in their day to day development life. And can I ask one question? Do you know TestNG? a unit testing framework which is named as ‘Next Generation test ing tool’. Here is a small comparison on these two unit testing frameworks.

  TestNG Version 5.6   JUnit  Version 4.4
1 Extensive annotation support 1 Supports Annotations but not that much rich as TestNG
2 Flexible test configuration in an external XML file. 2 Configuration is less and no XML file configuration at all.
3 External configuration gives more flexibility. 3 Less configuration makes it more easy and really fast to create :)
4 Support for data-driven testing (with @DataProvider). 4 We have to integrate with EasyMock for Mock object testing
5 Support for parameters using @Parameters 5 No such type of annotations
6 Allows distribution of tests on slave machines. 6 NA
7 Supported by a variety of tools and plug-ins (Eclipse, IDEA, Maven, etc…). 7 Cant defeat JUnit in this matter. It has a lot of supporting tools and plugins.
8 Embeds BeanShell (scripting)  for further flexibility. 8 JUnit dont have this feature at all.
9 Default JDK functions for runtime and logging (no dependencies). 9 I dont aware of logging support in JUnit.
10 Dependent methods for application server testing. 10 NA
11 Creates a small HTML report at eash time of testing. Which will display the passed/failed tests and errors. It gives the XML output for testing also. 11 JUnit also creates the test report in XML form. But it will not create an HTML form with passed/failed testnames at each test run. But we can create a very useful JavaDoc Style report for entire JUnit testing
12 We dont need a specific name for setup and tearDown. We can make any method/ any number of methods that works on start up 12 Same in Junit also.
13 Here we can create Groups, Suites, etc and it also gives more annotations like
@After/BeforeSuite.
@After/BeforeGroup.
@After/BeforeClass.
@After/BeforeMethod
etc
13 @After/Before works in methods and @After/BeforeClass will work with classes. But no groups or suites.
14 No annotation like @Ignore. But we can ignore through XML congiurations. 14 @Ignore annotation is there for ignoring a method.
15 Dependancy of previous methods can be managed easily 15 Methods dependancy handling between each test methods is not possible easily.
16 Option to run failed tests only/ last test only in the IDE 16 We have to select and run each methods which are failed
17 No AssertThat method support 17 It gives a method AssertThat that is very much flexible for giving a Business type result message for the tests.
18 Using ‘ExpectedExceptions in @Test Annotation’ we can expect some exceptions in the test methods and thus the method will be success. 18 We can use (expected = Exception.class) in the @Test annotation

Conclusion

If you are a very busy programmer and want very little time to spend on testing the code then go for JUnit. It is giving enough support for that. But you need a good testing and more configurable options for each test cases then choose TestNG. The depeneded methods are also can make work on TestNG very easily.

Next Page »


View Lijin Joseji's profile on LinkedIn

Disclaimer

The information on this site is for informational purposes only. The use of any Trademark or Copyrighted material is not intended to infringe Copyright. This blog is intended to be used under a policy of personal and non commercial use.

Adds

Add to Google

Blog Stats

  • 105,957 hits

Categories