Configuring Jasmine to work with Maven and JQuery Fixtures

For me unit testing Javascript has been an issue for quite a while. Our backend server usually have a lot of tests at various levels but the Javascript service and view layers have been more or less neglected in terms of automated tests. Using Selenium is one option but if your UI is subject to [...]

Tags: , , ,

Configure Morphia to work without a default constructor

In my current project we’re migrating our existing entity model to MongoDB and have turned to Morphia for mapping our Java objects to and from its MongoDB representation. Our Java entities are immutable and preferably we’d like to keep it that way. Morphia, like most other mapping frameworks, require us to have a default constructor [...]

Tags: ,

Komarro – A new interesting mock framework for Java

Mocking is a well-known and estabilished concept in our field of work as developers. There are a lot of frameworks for creating and setting up expectations on mock objects in all kinds of different languages. For me as a Java developer my introduction with mocking was through the EasyMock project. Due to the techincal limitations [...]

Tags: , , , ,

How to really fix the too many open files problem for Tomcat in Ubuntu

A couple of days ago we ran into the infamous “too many open files” when our Tomcat web server was under load. There are several blogs around the internet that tries to deal with this issue but none of them seemed to do the trick for us. Usually what you do is to set the [...]

Tags: , ,

Simple Parsing of Complex JSON and XML Documents in Java

In this blog I’m going to demonstrate how to parse and validate more complex JSON and XML documents in Java using the REST Assured framework and the XmlPath and JsonPath components available in this framework. Since REST Assured is implemented in Groovy it can be really beneficial to take advantage of Groovy’s collection API. Let’s [...]

Tags: , ,

Multipart Form Data File Uploading Made Simple with REST Assured

From a client perspective it has always seemed to me that uploading a large file or stream to a server using multi-part form data encoding in Java is overly complex. To address this I implemented support for it in REST Assured 1.3. Example Let’s say you have a simple HTML page that performs file-uploading from [...]

Tags: , ,

Is your REST assured?

A couple of months ago I introduced a new open source Java framework for simple automated testing of REST/HTTP services called REST Assured. A lot of things have happended to the framework since then and it’s now better than ever. In this blog I’m going to summarize some of the most important new features that [...]

Tags: , , ,

PowerMock for Integration Testing

A while ago I blogged about how to use the PowerMock Rule to bootstrap PowerMock without using a JUnit runner. A problem that you’ll likely run into sooner or later when using this approach in an integration test is the need to ignore certain classes or packages from being loaded by the PowerMock classloader using [...]

Tags: , , ,

PowerMock with unsupported frameworks such as JMock

Currently PowerMock builds on top of EasyMock and Mockito to provide mocking of e.g. static methods and final classes using a familiar API. What most people don’t know is that it’s pretty easy to benefit from PowerMock even for frameworks it doesn’t support. JMock is another popular mocking framework that PowerMock currently doesn’t support but [...]

Tags: , , ,

Using PowerMock with Spring integration testing

I quite often get the question if PowerMock can be used together with Spring integration testing or other frameworks that require a JUnit runner to bootstrap. The answer up until now has been somewhat ambiguous. The reason is that for the last year or so we’ve been working with a new way of bootstrapping PowerMock [...]

Tags: , ,

REST Assured – Or how to easily test REST services in Java

Testing and validating REST services in Java is harder than in dynamic languages such as Ruby and Groovy. REST Assured is a Java DSL (built on top of HTTP Builder) that brings the simplicity of these languages into the Java domain. Example 1 – JSON Assume that a GET request to http://localhost:8080/lotto returns JSON as: [...]

Tags: , , ,

Awaitility 1.3 – Scala and field support

Awaitility is a Java based DSL that allows you to easily setup expectations for asynchronous code (if you’re new to Awaitility you can read an introduction here). Version 1.3 has just been released with a couple of new interesting features. Scala support First of all we now have support for Scala! This means that you [...]

Awaitility – Java DSL for easy testing of asynchronous systems

Introduction Testing asynchronous systems is hard. Not only does it require handling threads, timeouts and concurrency issues, but the intent of the test code can be obscured by all these details. Awaility is a DSL that allows you to express expectations of a asynchronous system in a concise and easy to read manner. Simple example [...]

Tags: , , ,

Classloader Deep-Cloning without Serialization

Background In PowerMock we’re using a custom classloader to byte-code manipulate classes that are normally not mockable to make them mockable. But when running a test case there may be some cases when the user needs to byte-code manipulate a certain class (X) in the first test method but needs to have the class unmodified [...]

Tags: , , , , , , , ,

PowerMock + TestNG = True

After having it on our todo list for at least a year we’ve finally managed to integrate PowerMock with TestNG 5.11 as of PowerMock version 1.3.5. This is a big milestone of the project since we’ve now demonstrated that PowerMock is decoupled from both a specific test framework and a specific mock framework. The TestNG [...]

Tags: , , ,