June 30, 2006
Several reasons convinced me to move cintoo Messages from jMock to EasyMock 2. The main reason is that jMock has no static importable methods for mock creation and verification. The way to do this in jMock is to extend a jMock TestCase class. Unfortunately this class depends on JUnit, so when moving to TestNG I still had to keep the JUnit jar around. Also TestNG promotes a no-inheritance test structure where jMock just doesn’t fit in. The second reason is that I was bitten by method name refactorings several times. As some methods were equal in different classes, IDEA wrongfully replaced the methods strings in jMock which broke lots of tests. Another minor reason is that jMock doesn’t seem to move very fast.
The transition has been made easier by EasyMock as that framework adopted a lot of ideas from jMock in version 2.x (I think :-). I still hope to use the jMock spinoff assertion DSL though with assertThat( eq(5), …).
In the last years since the first jMock release I’ve been convincing clients to use jMock for their unit testing. I still think jMock is great for JUnit, but it just doesn’t work with TestNG in the current version.
The funniest quote I’ve read for some time is “Lower-level languages that don’t support associative arrays (such as C++ or Java) are not as good for implementing tag clouds, because you will end up writing considerably more code.” on an ORA site. Later on in the comments the author says he really meant syntax support with “don’t support”, but well I can’t see why a language is not suited for a problem because it has no syntax support for maps. It’s nice to have, see Groovy, but 95% of the time when I use syntax sugar to create maps is when writing unit test. I very very rarely construct maps not dynamically in my applications.
June 27, 2006
Due to the help by Alex with TestNG I finalized the Messages 1.0 release.
Messages is a free framework to make internationalization easier for Java
applications. It adds several features compared to default Java internation-
alization and support locales for threads and different bundles for different
packages. This allows the usage of different bundles for different parts of
the application like plugins, the installer or logging.
Key features:
- a lot less code than standard internationalization in Java
- easier to use for developers
- supports bundle refactorings
- bundles associated with Java packages
- hierarchies of bundles,
e.g. one bundle for com.corp and one for com.corp.accounting
- Low intrusive code, e.g. $(this, “FILE_NOT_FOUND”, fileName)
- Locales per thread or global
- Apache license
http://cintoo.org
Downloads http://cintoo.org/dist/messages/
Documentation http://docs.cintoo.org/messages/
June 26, 2006
Thanks to the help from Alex (from the TestNG project, great support) I managed to move Messages from JUnit 3 to TestNG. TestNG is more flexible and seems to move faster. JUnit 4 was released after I started moving projects to TestNG, so my default now is TestNG and I only use JUnit 4 on demand from customers. Also works great with pulse integration server, just point pulse to the xml file generated by TestNG and use the JUnit task in pulse.
I switched several projects from JUnit 3 to TestNG. After some minor problems with the fact that TestNG doesn’t seperate tests as JUnit does per default, everything works in IDEA and Maven. But whatever I tried, I can’t get TestNG to work with Ant. The TestNG Ant task just doesn’t find any tests. I used testjar, dir, includes and it also doesn’t help that the TestNG documentation is sparse and misleading. I moved Messages to TestNG too, but without Ant support this will not be released. Everything works fine, just Ant doesn’t. If I can’t get it working, I’ll give Junit 4 a try.
June 16, 2006
Just made the last version the RC1 version without changes. Everythings seems to be working, no complaints. If everything moves along as planned, this will become 1.0 final. After that I’ll have some ideas on 1.1. Thanks to all users for their feedback.
http://messages.cintoo.org
June 6, 2006
When formatting messages with Messages.format code becomes quite noisy. So I thought why not use a special char for the method name? I used “_” which seems to be unintrusive.
Messages.format( “FILES_WRITTEN”, files);
then becomes
Messages._( “FILES_WRITTEN”, files );
combining this with the new static import feature from Java 1.5 (great timing :-) this becomes
import static api.cintoo.messages.Messages.*;
_( “FILES_WRITTEN”, files);
which looks shorter and less noisy than the first and as the default Sun solution for i18n.
I think about using “$” for the method name,
$( “FILES_WRITTEN”, files);
looks perhaps more familiar with Prototype.js using $ and this also looks like templating engines as Velocity/ JSP.
June 5, 2006
I’ve released nother alpha, which looks quite final, so the next one will be a beta version.
Changes since the last version:
- Added support for hierarchies, if a key is not found in one context (e.g. my.package)
Messages now looks in the parent context (e.g. my)
- Added support for language hierarchies,if a key is not found in one language (de_de) then
Messages looks in the less specific language (de)
- Added much more unit tests (more than 90% coverage, thanks cenqua :-)
- Added unintrusive method names. _() now mirrors the format() methods
I wish you less i18n problems with the usage of Messages