Thursday, 26 April 2018

Overview of Spark and HTTP Testing with JUnit

TLDR: Spark is static so having it run in an @BeforeClass allows HTTP request testing to begin.

I use Spark as the embedded web server in my applications. I also run simple HTTP tests against this as part of my local maven build. And I start Spark within the JUnit tests themselves. In this post I’ll show how.

Wednesday, 25 April 2018

When would I choose basic HTTP libraries rather than using RestAssured?

TLDR: when I have a small set of HTTP use-cases, and I’m working on fast in-build HTTP integration verification then I’ll probably use HttpURLConnection

I do receive a question fairly often like:

  • “Why would you ever use basic HTTP libraries rather than Rest-Assured?”
  • “When would you choose to use basic HTTP libraries instead of Rest-Assured?”

And other variants.

I’ll try to answer that in this post.

Tuesday, 24 April 2018

Migrating from JAXB XML processing to XStream

TLDR: refactored to isolate XML processing, configured XStream in code, removed all annotations, added XML header, wrote less code

I have a small REST API application which uses Spark and GSON and JAXB. I haven’t released this to Github yet but I did release some of the example externally executed integration verification code for it.

When trying to package this for Java 1.9 I encountered the, now standard, missing JAXB, libraries. So I thought I’d investigate another XML library.

Monday, 9 April 2018

Changes to Automating a REST API code base for Java 1.9 RestAssured 3.0.7

TLDR: For Java 1.9 upgrade Rest Assured to version 3.0.6 0r 3.0.7. I also had to add some JAXB Maven Dependencies

I my book Automating and Testing a REST API I used Java 1.8 and Rest Assured version 3.0.1. This was in the days prior to Java 1.9 becoming the default.

I recently checked the code against Java 1.9 and had to make some changes to update Rest Assured.

Sunday, 8 April 2018

How to learn Java with Exploratory Programming

TLDR: Learn Java by taking advantage of code completion and JavaDoc in the IDE to explore classes with JUnit Tests

In my book Java For Testers I encourage the reader to experiment when learning Java by writing small JUnit tests to explore classes. I’m going to expand on that concept in this blog post and the associated video.