Archive for the ‘Java Tools’ Category

Tip Calculator For Blackberry released

Friday, September 18th, 2009

A few days ago I release a tip calculator for blackberry phones. The application is very easy to use, and I’ve gotten very positive response so far. Check the calculator out at http://www.naftulinconsulting.com/j2me/tipcalculator.htm

Integration testing with Maven

Tuesday, July 7th, 2009

If you need to run integration tests with Maven, check out FailSafe maven plug-in (http://mojo.codehaus.org/failsafe-maven-plugin/). It assumes that your integration tests are in the same directory as unit tests, but are named *IT.java. The reason you want to separate the integration tests execution from unit test integration tests, is because the integration tests take much longer and might have to have some setup before they are run and tear down after they are run.  You don’t want to run the integration tests all the time – it’s too expensive, but you do want to run them before developer checks in the code and (at least) for continuous build environment. To skip the integration tests you can use the following command:

mvn install -DskipITs

When using it, you will most probably get the following error:
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
To avoid this error add the following property in the properties part of pom.xm (after build as described by http://maven.apache.org/pom.html#Properties)
<properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

One more thing – I had problems by just putting -DskipITs=true, since the plug-in code did not check for it. So I used the following plugin configuration note the skipITs:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>failsafe-maven-plugin</artifactId>
<version>2.4.3-alpha-1</version>
<configuration>
<skipTests>${skipITs}</skipTests>
</configuration>

<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>

Plugins I usually use with Eclipse installation

Wednesday, June 3rd, 2009

Here is the list of plugins I usually use with eclipse installation – a quick way for me to upgrade eclipse and still remember the site without searching for them:
FindBugs http://findbugs.cs.umd.edu/eclipse
DBViewer http://www.ne.jp/asahi/zigen/home/plugin/dbviewer/
PHPeclipse http://phpeclipse.sourceforge.net/update/stable/1.2.x/
PERL EPIC http://e-p-i-c.sf.net/updates
EMMA http://update.eclemma.org/
Mobile Tools For Java (DSDP/MTJ) http://download.eclipse.org/dsdp/mtj/updates/0.9/stable/
Java Decompiler http://java.decompiler.free.fr/
Java Auto Documentation Plugin http://jautodoc.sourceforge.net/update/

I released Configuration Manager 1.7

Thursday, January 8th, 2009

I released configuration manager 1.7. The new release adds support for different configuration values for different environments – like production, qa and development. It also adds a couple of tutorials: Environment settings: dev, qa, etc and How to enable JMX. Here is the link to download the latest release.

How to add sources to Eclipse/Idea project generated by Maven

Friday, November 21st, 2008

Wanted to have a link here, since it takes me a while to find it: http://maven.apache.org/plugins/maven-eclipse-plugin/examples/attach-library-sources.html.

I’ve released configuration manager 1.6

Friday, November 21st, 2008

Configuration Manager 1.6 provides easy API for integrating it into your code (literally 2 lines and a small xml file), and easy Unit testing of the code that is dependent on configuration manager. Visit http://configmanager.sourceforge.net/ for more details.

Maven – fixing classpath issues for tests

Monday, November 10th, 2008

We had problems with tests not finding files that we usually package outside the jar. One of such files was log4j.xml and other files were configuration files for spring framework. We need to pass full path to the log4j file, so that we don’t have to rely on class path priorities to look it up. Given that log4j.xml is such a widely used file, it is probable that one of the dependent jar would have a copy in the archive – so we can pick up the wrong file by mistake. On the other hand, we want to have our spring framework configuration files in the class path, but outside the jar. This way we can modify the configuration on the fly if we need to. So to setup integration test case, we needed to get the full path to the log4j.xml file and adding a directory to the class path for test only.
Here is how to do that:
public static String getFullPath(Class c, String name){
     ClassLoader cl = c.getClassLoader();
     URL url = cl.getResource(name);
     return url != null ? url.getPath() : null;
}
and for adding class path:
<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-surefire-plugin</artifactId>
     <configuration>
     <additionalClasspathElements>
          <additionalClasspathElement>./src/main/config/</additionalClasspathElement>
          <additionalClasspathElement>./mymodule/src/main/config/</additionalClasspathElement>
      </additionalClasspathElements>
    </configuration>
</plugin>

Testing Struts Apps With Maven

Thursday, September 11th, 2008

While switching my configuration manager project from Maven 1 to Maven 2, I had to figure out how to add WEB-INF/web.xml located in src/main/webapp directory to the Maven test class path, so that MockStrutsTestCase would be able to access it. After a bit of digging on the net, and experimenting, I found an easy way of accomplishing it. Here is what needs to be added to your POM:
<plugins>
<
plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>${basedir}/src/main/webapp</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
</plugin>

After I’ve added this fragment, all the tests I’ve ported passed! Hurray!


Good article on Building and Deploying with Maven 2

Wednesday, September 3rd, 2008

We are using Maven 2 as part of our build/deploy/dependency management tool. It is great in dependency management, code quality reporting, deploying to repositories, as well as having a very uncomplicated build script and not having to store our Idea or Eclipse project files (since we have them generated). The biggest problem we discovered so far, was that maven is not so well suited to deploy projects into different environments – development, qa, production.  So, if you are developing reusable components – go for Maven, it will make your builds so much easier. If you have to build a product and deploy it to different servers (dev, qa, int, prod and prod_bcp) – it might not be as easy. After a long search on how other people have struggled with this problem, I found a good article The Pain of migrating from Ant to Maven and even though it does not solve my problem, it describes very well the pain points I felt when I worked with Maven.

I’ve released configuration manager 1.5

Friday, May 30th, 2008

Configuration Manager 1.5 can be controlled by using JMX. Unless otherwise instructed in the the configuration, configuration manager will register with the MBean Server. You will be able to see all the configurations and content and will also be able to reload configuration manager through the JMX console. Visit http://configmanager.sourceforge.net/ for more details.