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 [...]
How to really fix the too many open files problem for Tomcat in Ubuntu
February 11th, 2012 by Johan Haleby — Tips & Tricks
Simple Parsing of Complex JSON and XML Documents in Java
October 9th, 2011 by Johan Haleby — Java, Testing, Tips & Tricks
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 [...]
Multipart Form Data File Uploading Made Simple with REST Assured
September 15th, 2011 by Johan Haleby — Java, Testing, Tips & Tricks
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: automated testing, http, rest
Is your REST assured?
June 4th, 2011 by Johan Haleby — Java, Testing, Tips & Tricks
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: automated testing, Java, rest, test
PowerMock for Integration Testing
May 19th, 2011 by Johan Haleby — Java, 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: automated testing, junit, powermock, testng
PowerMock with unsupported frameworks such as JMock
December 28th, 2010 by Johan Haleby — Java, Testing, Tips & Tricks
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: automated testing, Java, jmock, powermock
Using PowerMock with Spring integration testing
December 28th, 2010 by Johan Haleby — Java, 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: automated testing, frameworks, powermock
REST Assured – Or how to easily test REST services in Java
December 27th, 2010 by Johan Haleby — Java, Testing
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: automated testing, frameworks, Java, rest
Awaitility 1.3 – Scala and field support
October 20th, 2010 by Johan Haleby — Java, Testing
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
July 20th, 2010 by Johan Haleby — Java, Testing
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: automated testing, concurrency, Java, open source
Classloader Deep-Cloning without Serialization
December 23rd, 2009 by Johan Haleby — Java, Testing
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: classloader, deep-cloning, frameworks, junit, manipulate, open source, powermock, serialization, tools
PowerMock + TestNG = True
December 14th, 2009 by Johan Haleby — Java, Testing
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: frameworks, open source, powermock, testng
Untestable code with Mockito and PowerMock
October 28th, 2009 by Johan Haleby — Testing
With the new release of PowerMock 1.3 we’ve focused a lot on getting the Mockito support up to par with the EasyMock support allowing mocking of e.g. final classes, static methods and new object construction using a Mockito-like syntax. Below you’ll find some examples of how to use the Mockito extension API, aka PowerMockito. Hopefully [...]
Getting Android SDK working on Ubuntu 64
October 21st, 2009 by Johan Haleby — Android
Today I was trying to setup the Android SDK (version 1.6_r1) on the 64 bit version of Ubuntu 9.04 (Jaunty Jackalope). After having installed the ADT Eclipse plugin and pointed out the Android SDK directory in the settings I immediately ran into the following error: Failed to get the adb version: Cannot run program “/home/johan/devtools/android/android-sdk-linux_x86-1.6_r1/tools/adb”: [...]
Tags: linux, open source, tools, ubuntu
Mocking static methods in Java system classes
May 17th, 2009 by Johan Haleby — Java, Testing
As you may already know PowerMock can be used to easily mock static methods which is normally not possible with standard mock frameworks such as EasyMock, JMock or Mockito. All you have to do is to use mockStatic in one of the PowerMock extension API’s as well as telling PowerMock to enable the class for [...]
Tags: frameworks, open source, powermock, tdd, tools
