Posted on February 15th, 2012 | Leave a Comment
My review of Programming Concurrency on the JVM: Mastering Synchronization, STM, and Actors by Venkat Subramaniam is out on LJC Book club.
Posted on July 10th, 2011 | 1 Comment
Writing tests involves typing repeatedly same things – creating test methods, writing assertions and setting up expectations. But there are a lot of keystrokes to be saved there.
Firstly, test methods. You definitely shouldn’t type them by hand. These can be generated by Eclipse using New JUnit Test Case wizard when Class under test is specified or Eclipse’s templates could be used to create them. There are two templates test and Test available by default.
No big of an issue here then if you know about them.
Now assertions and expectations, etc. I always found writing them pretty laborious task until, only one or two years ago, somebody pointed out to me that it is possible to configure Eclipse so that the content assist proposes static members even if the import is missing. You do it from Eclipse -> Preferences… and then by selecting Java -> Editor -> Content Assist -> Favorites. You can include all static member of the type (New Type…) or only specific one (New Member…).
After selecting member from the list, new static import will be automatically added at the top of the file.
Somebody might not like the fact that the content assist list is blown up a little bit by doing this.
One of the alternatives I can think of is to put static imports explicitly in each file:
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
This can work well for you or not depending on your setting for Save Actions and Organize imports in Eclipse.
I have Organize imports option configured on save so the wildcards are replaced by used members, if any, or removed completely. So it would not work for me.
Third option is to extend
junit.framework.TestCase (JUnit 3 style).
I personally like the first option (favorites static member types) best. I use it for other frequently used methods, e.g.
Posted on June 12th, 2011 | Leave a Comment
Overview of what we can expect in Java 7. Lighting talk I gave at work in 20 slides x 20 seconds per slide format. Project coin is useful but I am waiting for NIO.2 and invokedynamic + method handles.