Micro Benchmarking your Tests using JUnit and JUnitBenchmarks

I recently stumbled upon a nice framework that allows to convert simple JUnit tests into micro benchmarks named JUnitBenchmarks. It allows to set basic benchmark options and and to generate charts by adding some simple annotations and a test rule to your tests. One might argue if it is wise to mix the aspects, testing and benchmarking and I’d agree for sure – nevertheless I think this framework can be handy sometimes so let’s create some benchmarks using JUnit and JUnitBenchmarks.. ...

March 10, 2013 · 8 min · 1508 words · Micha Kops

Running categorized Tests using JUnit, Maven and Annotated-Test Suites

Sometimes we need to classify the tests in a project and a possible solution to achieve this goal is to assign different categories to the tests. Often we’re doing this to separate the execution of fast-running and long-running tests or to run a specific set of tests that is only applicable in special situations. To run a specific set of categorized tests there are different options and in the following tutorial we’ll be covering two of them: by configuring the Maven Surefire Plug-in or by using a JUnit Test Suite and the JUnit annotations. ...

December 6, 2012 · 4 min · 748 words · Micha Kops

Content Detection, Metadata and Content Extraction with Apache Tika

Encountering the situation that you want to extract meta-data or content from a file – might it be an office document, a spreadsheet or even a mp3 or an image – or you’d like to detect the content type for a given file then Apache Tika might be a helpful tool for you. Apache Tika supports a variety of document formats and has a nice, extendable parser and detection API with a lot of built-in parsers available. ...

December 2, 2012 · 11 min · 2222 words · Micha Kops

New features in JUnit 4.11

JUnit is one of the most popular testing frameworks out there. Version 4.11 has just been released and offers some nice improvements that you shouldn’t miss. Dependencies In older versions of JUnit there were two dependencies .. junit:junit contained an old version of hamcrest and could cause some nasty trouble .. junit:junit-dep just referenced hamcrest the maven way. Now with version 4.11 there is just junit:junit with clean references to hamcrest and junit:junit-dep is relocated to junit:junit. ...

November 18, 2012 · 4 min · 850 words · Micha Kops

Lucene Snippets: Faceting Search

The latest snippet from my Lucene examples demonstrates how to achieve a facet search using the Lucene 4.0 API and how easy it is to define multiple category paths to aggregate search results for different possible facets. In the following example we’re indexing some books as a classical example and create multiple category paths for author, publication date and category afterwards .. Lucene Dependencies We simply need two dependencies here .. lucene-core of course and in addition the lucene-facet library .. I’ve added the declarations needed for Maven and SBT here .. if you’re using Gradle or Buildr you should’t have a problem to transfer the information needed ;) ...

August 28, 2012 · 4 min · 837 words · Micha Kops

Creating a Windows Executable from a Jar using Maven

Often in the life of a developer there is the need to create a windows executable for a Java application that is build and packaged in a Jar file. The following short example shows how to create an executable Jar first and a windows executable containing vendor information, a nice icon and other stuff afterwards by using a combination of the Maven Shade Plugin and the launch4j Plugin for Maven. ...

August 7, 2012 · 3 min · 542 words · Micha Kops

Integration Testing IMAP, SMTP and POP3 with GreenMail

Having written some e-mail handling, sending or receiving library you’d like to run some integration tests against a real mail server? Then GreenMail might help you out here .. the framework is not quite new on the market but it is really easy to setup IMAP,SMTP or POP3 services with it and it comes with some helpful libraries making your life a bit easier here. That’s why I’ve come to the idea to share some examples for setting up different server instances, creating user accounts and – at last – fetching and validating e-mails… ...

July 30, 2012 · 9 min · 1833 words · Micha Kops

Aspects of Functional Programming in Java

Functional programming is a trending topic these days and a lot of Java programmers are hot for the features that modern functional programming languages might offer. Waiting for Java 8 and native closure support is a nice thing but for now we’re going to take a look at several Java frameworks that are trying to implement typical structures from those functional languages where possible using the capabilities of the Java language to emulate elements like higher-order-functions, closures, options and others … ...

July 16, 2012 · 16 min · 3233 words · Micha Kops

Task Scheduling in Java EE 6 on GlassFish using the Timer Service

Creating cronjobs or scheduled service executions is made really easy in Java EE 6. Scheduled tasks may be created in a programmatic style or simply by adding some annotations to an EJB. In the following tutorial we’re creating some simple scheduled tasks and let them run on an embedded GlassFish instance using the Maven Embedded GlassFish plugin.. Java EE 6 Maven Project from Archetype First of all we’re creating a new maven-ized project using one of the appropriate jee6 Maven archetypes ...

June 22, 2012 · 5 min · 956 words · Micha Kops

Creating updatable Java Applications using Getdown and the Getdown Maven Plugin

Many programmers have suffered when trying to setup an environment to handle updates for their application without much effort. Some tried Java Web Start for this purpose and many encountered difficulties with this approach. Now there is getdown that aims to replace Java Web Start by offering a simple architecture to handle updates that is fast, realiable and the only thing you need is a normal http server. Though getdown lets us handle our updates really easy it is possible to make this process even easier with the getdown maven plugin. ...

May 27, 2012 · 5 min · 885 words · Micha Kops