Oh JBehave, Baby! Behaviour Driven Development using JBehave

Behaviour Driven Development is the keyword when we’re talking about test scenarios written in an ubiquitous language, strong interaction with stakeholders, product owners or testers and well described, common understandable test scenarios. The popular JBehave framework is our tool of choice here and allows us to decouple our test stories from the test classes, offers an integration for web tests using Selenium and finally there’s a helpful Maven plugin for JBehave, too. ...

May 31, 2011 · 14 min · 2849 words · Micha Kops

Creating a sample Java EE 6 Blog Application with JPA, EJB, CDI, JSF and Primefaces on GlassFish

Java EE 6 is out and it indeed offers an interesting stack of technologies. So in today’s tutorial we are going to build a small sample web application that builds on this stack using Enterprise JavaBeans, Java Persistence API, Bean Validation, CDI and finally Java Server Faces and PrimeFaces. The application we’re going to develop is a simple blog app that allows us to create new articles, list them and – finally delete them. We’re also covering some additional topics like JSF navigation, i18n, Ajax-enabled components and the deployment on the GlassFish application server. ...

February 8, 2011 · 17 min · 3575 words · Micha Kops

Enterprise Java Bean EJB 3.1 Testing using Maven and embedded Glassfish

Are you playing around with the shiny new 3.1 EJB API? Using Maven for your Java projects? Need an easy way to write and execute tests for your EJBs that depends on an Java Application Server? No problem using Maven Archetypes, the Maven EJB Plugin and the GlassFish embedded Application Container.. Prerequisites For the following tutorial we’re going to need an installation of Maven and of course – the Java Development Kit! ...

January 1, 2011 · 5 min · 969 words · Micha Kops

Bean Validation with JSR-303 and Hibernate Validator

You want to add some validation logic to your Java beans? You want to achieve this with some shiny extendable annotations? Then give the Java Bean Validation standard aka JSR-303 a try.. We’re going to use the reference implementation for bean validation, Hibernate Validator in this tutorial but there are also links to other alternatives like Oval or Apache Bean Validation. So let’s begin and validate some stuff .. Prerequisites JDK >=6 Maven >=2 An IDE or text editor of choice ...

December 14, 2010 · 5 min · 1041 words · Micha Kops

Creating a REST Client Step-by-Step using JAX-RS, JAX-B and Jersey

Often in a developer’s life there is a REST service to deal with and nowadays one wants a fast and clean solution to create a client for such a service. The following tutorial shows a quick approach using JAX-RS with its reference implementation, Jersey in combination with JAX-B for annotation driven marshalling between XML or JSON structures and our Java-Beans. Prerequisites The following stuff is needed to run the following examples and code samples ...

November 25, 2010 · 8 min · 1630 words · Micha Kops

Using PrimeFaces to pimp up existing Java Server Faces / JSF 2 Applications

In this tutorial we’re going to modify an existing Java Server Faces / JSF 2 web application by adding rich UI components to the existing layout. Our tool of choice here is the PrimeFaces framework. It offers a wide range of interesting, customizable and (several) Ajax-enabled components that blend very well with JSF1+2 and also a solid documentation that allows a quick integration into existing projects. Project setup For this tutorial we’re going to reuse the web application from my JSF2 Tutorial “Java Server Faces/JSF 2 Tutorial – Step 1: Project setup, Maven and the first Facelet” – the source code is available at GitHub.org. ...

November 14, 2010 · 6 min · 1197 words · Micha Kops

How to create a Confluence SOAP Component in 5 Minutes

You’re using the popular Confluence wiki? You’re using its RPC/SOAP API and missing a function you really need? Just extend the capabilities of the Confluence RPC API by programming a custom web service component – it is really easy and also well documented. In this tutorial we’re going to take a look on how to quickly implement a SOAP service, securing it and putting its methods in a transactional context. Prerequisites Maven >=2 JDK >= 5 Confluence Wiki >= 3.0 (for a quick installation guide take a look at this article) SoapUI for Testing ...

October 24, 2010 · 7 min · 1309 words · Micha Kops

Object-relational Mapping using Java Persistence API JPA 2

Today we’re going to take a look at the world of object-relational Mapping and how it is done using the Java Persistence API by creating some basic examples, mapping some relations and querying objects using JPQL or the Criteria API.. Prerequisites Java 6 JDK Maven >= 2 If you’d like to take a look behind the scenes e.g. how entities are mapped in your database you could install a RDBMS of your choice .. or just use Derby/JavaDB that is bundled with the JDK 6 ...

October 11, 2010 · 13 min · 2668 words · Micha Kops

Playing around with the Android Animation Framework

Animations add some spice to our Android applications and the offered animation framework makes it easy to create custom animations and tweens. So lets dance around and create some animations ;) .. About There are two ways to create animations – via XML declaration or in a Java class. We’re going to focus on XML declaration – if you’re interested in java based declaration – take a look at the Android JavaDocs and the subclasses of android.view.animation.Animation. ...

September 27, 2010 · 4 min · 820 words · Micha Kops

Creating a SOAP Service using JAX-WS Annotations

It is possible to create SOAP webservices with only a few lines of code using the JAX-WS annotations. In a productivity environment you might prefer using contract-first instead of code-first to create your webservice but for now we’re going to use the fast method and that means code-first and annotations olé! Creating the SOAP Service Create a class SampleService with two public methods Annotate this class with @WebService (javax.jws.WebService) – now all public methods of this class are exported for our SOAP service To change the name of an exported method, annotate the method with @WebMethod(operationName = “theDesiredName”) (javax.jws.WebMethod) Finally the service class could look like this package com.hascode.tutorial.soap; import javax.jws.WebMethod; import javax.jws.WebService; @WebService public class SampleService { @WebMethod(operationName = "getInfo") public String getInformation() { return "hasCode.com"; } public String doubleString(String inString) { return inString + inString; } } ...

September 23, 2010 · 2 min · 400 words · Micha Kops