Shaun Abram
Technology and Leadership Blog
Swing, Webstart and Maven – An Example
Following my introductory rant on the subject, this post is a working example of using Swing and Webstart with a multi-module maven project.
Complete source can be downloaded from here.
Read more
Tags: helloworld, jnlp, Maven, mvn, swing, webstart
Swing, Webstart, Maven – a difficult combination
I have spent the last few weeks struggling with a Swing app that I wanted to deploy via Webstart and build using Maven, via the the Webstart Maven Plugin. It has been a hugely painful process. I found the plugin documentation difficult to follow, struggled to understand the subtle config differences in jnlp, took longer than I expected to get jar signing working, had problems with webstart caching and suffered through a plethora of vague error messages. I found this posting where the author vowed to never use Webstart again, and I can empathize. Postings of people asking for help with Webstart problems certainly aren’t difficult to find. Using maven to build the jnlp provides some conveniences, but introduces new problems too. Overall, I’d prefer to avoid using a Swing/Webstart/Maven solution again.
Read more
Tags: helloworld, jnlp, Maven, mvn, swing, webstart
Setting up multiple instances of Tomcat
With multiple tomcat instances, each can run in its own JVM, have its own configuration and can be started/stopped independently.
One approach to doing this would be to have multiple, full tomcat installations. This article instead details how to install tomcat once (in CATALINA_HOME) but have multiple independent instances (by utilizing CATALINA_BASE). This is a more streamlined approach that makes creating multiple instances easier and also simplifies upgrades/rollbacks of tomcat.
Tags: apache, appserver, tomcat
Add log4j logging for a unit test in IntelliJ
In IntelliJ
- Click: Run -> Edit Configuration
- Select your test configuration (or add a new one)
- In VM parameters, add
-Dlog4j.configuration=file:/C:/dev/config/log4j.xml
(Or wherever your log4j properties file is)
That’s it. The test should now run with log4j logging (although obviously you need to have the necessary log4j jars available).
This example uses a windows file format, but will work equally well with *nix.
I use this approach for turning on MyBatis logging for individual tests. See here for a basic setup of a log4j.xml file to enable logging with MyBatis.
Tags: intellij, JUnit, log4j, mybatis, unittesting
EasyMock
EasyMock is an open source library for creating, and defining the behavior of, mock objects as part of your unit tests. This article describes how to use EasyMock (v3.0), including its record/playback approach, after setting the context with an brief introduction to unit testing in general and the associated need for mock objects.
Read more
Tags: easymock, mocks, unittesting
Hamcrest Matcher
As a follow up to the Hamcrest post I made yesterday, I wanted to post an example of my own Hamcrest matcher implementation. This matcher tests if a string contains a specified number of substrings.
An example usage could be:
String sql = "select a,b,c from tableA";
assertThat(sql, hasNumberOfSubstrings(",", 2));
See the source code below. I have been reading up on OSS licenses recently and decided to release this using the same license as Hamcrest – the new BSD license.
I have also attached a jar which includes the associated unit tests, although you will need the hamcrest-unit-test project to compile, which can be downloaded as part of the hamcrest all-in-one jar.
Read more
Tags: Hamcrest, JUnit, Testing, unittesting
Hamcrest
Hamcrest is a framework for writing matcher objects. Matchers have a variety of uses, but are particularly useful when writing unit tests. Instead of using JUnit’s assertEquals methods, we use Hamcrest’s assertThat construct with one (or more) of the many Matchers available. For example
assertTrue(a.equalTo(b));
becomes
assertThat(a, equalTo(b));
A small change in this example, but Hamcrest’s benefits are many, enabling you to write much more flexible tests that are easier to read and have more meaningful failure messages.
Read more
Tags: Hamcrest, JUnit, Testing
Final day at JavaOne
I posted some notes about my final day at JavaOne to theServerSide. At the moment, currently on the front page. Cool 🙂
http://www.theserverside.com/news/thread.tss?thread_id=60987
Tags: javaone
OSCON Day4: WebSockets
The first talk of the day I attended at Day 4 of OSCON was from Sean Sullivan (Aravo), who gave a talk on “Programming WebSockets“.
Intro
WebSockets is a technology that enables bidirectional communication between web browsers and server side processes. It provides a persistent connection between client & Server, hence enabling ‘push’ abilities where you can push data/notification to browsers from the client. Other client communication options to compare it with would be Ajax
and Comet (basically Ajax with long polling).
Tags: ajax, comet, html, html5, oscon, websockets
OSCON Day3: Database Scalability
I spent the afternoon of Day3 at OSCON attending two interesting database scalability talks. The first was on Database Scalability Patterns; The second on Database Sharding (and Spider for MySQL).
All my notes are below…
OSCON Day3 – Google App Engine
I have seen several talks on Google App Engine before, but have still not used it in anger, so this talk, Introduction to Google App Engine, acted as a refresher. It was given by Ikai Lan, a software engineer working for the Developer Programs groups at Google.
Google App Engine is a way to run your applications on Google infrastructure. You push your code to App Engine and it gets scaled out depending on how many instances you need.
My notes from the talk are below, but you can find the full slides here or here.
Tags: cloud, google, googleAppEngine, oscon
OSCON Day3 – The Joys of Engineering Leadership
The first talk of Day 3 at OSCON was “How to Lose Friends and Alienate People: The Joys of Engineering Leadership” by Brian ‘Fitz’ Fitzpatrick and Ben Collins-Sussman, both from Google.
What is an engineering leader?
- Serves the team
- Eliminates roadblocks
- Provides advice, guidance and helps get job done
- Mutual respect/Mutual trust
- Promotes technical and social health
- Leadership is not a waste of time…
- Being a team leader is a way of scaling yourself
The speakers broke their talk on how to be a good leader down in to two sections, which were (in good coding tradition) patterns and anti-patterns…
Tags: google, leadership, oscon
OSCON Day2: Scala
I attended the Scala Summit on day 2 at OSCON.
As well as the Scala introduction classes, there were interesting talks on Akka, Simple Build Tool and Specs….
Tags: akka, sbt, scala, specs, tools
OSCON Day1: The Productive Programmer, part 2
The following are my notes from the second part of Neal Ford‘s “The Productive Programmer” talk on best practices (see here for part1 on mechanics). Again, you can get the original slides form here.
Tags: bestpractice, nealford, oscon, productivity
OSCON Day1: The Productive Programmer
I spent the afternoon of day 1 at OSCON listen to Neal Ford give his “The Productive Programmer” talk and I have to say I loved it. I have heard Neal talk before and he is an excellent speaker: clear, funny, interesting and knowledgeable.
The talk was in 2 parts: Mechanics and Practice.
Below are my notes from the first part of the talk (see here for part2), but you can also get the original slides form here. The talk is based on his book of the same name, The Productive Programmer. Which is similar in theme but not to be confused with the “The Pragmatic Programmer” book.
Tags: nealford, oscon, productivity, tools