Growing Object Oriented Software, Guided by Tests (GOOS) is a well known and respected book focusing on the design feedback provided by Test Driving software development. As discussed at [insert link], this is my first attempt at the comprehensive worked example - the Auction Sniper. Whilst the final solution is of interest, perhaps of even more value is reviewing the commit history to see how I journey from an initial failing end to end test to a working solution which communicates to remote servers, presents a Swing UI and does so with low coupling / high cohension.
This, my solution to the Auction Sniper worked example primarily consists of a Java source tree, with dependency and build implemnted using idiomatic Maven. The test and integration-test phases cover the unit testing, and end to end testing requirements of the worked example.
The Auction Sniper solution requires an XMPP server, so I've bundled a Vines instance in the poorly named vagrant submodule, as a Docker container to simplify deployment, and enable Continous Integration on CircleCi
- Java 7 / 8 JDK
- Maven or on OS X ensuring it uses correct JDK
- Docker or via homebrew on OS X
git clone git@github.com:paulspencerwilliams/auctionsniperjava.git
git submodule update --init
Build the Vines XMPP server Docker image by
docker build -t 'paulswilliams/vines' vagrant/
Once complete, run the Docker image
docker run -p 5222:5222 -t 'paulswilliams/vines'
If deploying on a Mac with Boot2Docker, in a seperate terminal window, create an ssh tunnel to enable native to Docker VM communication
boot2docker ssh -L 5222:localhost:5222
To enable the Smack XMPP client to communicate with Vines, it is essential to download, and register the Vines TLS certificate with the Auction Sniper code:
docker cp `docker ps | grep paulswilliams/vines | awk '{print $1;}'`:/localhost/conf/certs/localhost.crt certificates/
Import certificate into expected local keystore
keytool -import -alias localhost -file certificates/localhost.crt -keystore certificates/akeystore.jks
And select a password
mvn integration-test
To remove the worked example from your machine, stop and delete the Vines Docker container, and then delete the git clone.
Stop the Docker container
docker stop `docker ps | grep paulswilliams/vines | awk '{print $1;}'`
Delete the Docker container
docker rmi 'paulswilliams/vines'
anonymous classes are okay in the short term. Keep them inline until you understand sufficiently to refactor them out - remember the inline before refactor technique?
verify(auction, times(1)).bid(price + increment);
verify(sniperListener, atLeastOnce()).sniperBidding();
However, JMock has default strict mocks, so they're not that loose. Yes, allowances / when / then helps, but enough?
Although didn't fail when introducing show winning functionality
Refactoring not done in a way to allow too many small commits.
Including use of generics on collections where type is a duplication smell.
Remember that AuctionSniper bug when you were being lazy?
but I'd like to learn more, seem a useful tool to keep in the bag