Sep
22
2008
adam
I was finding that test classes were somehow ending up compiled into the web application deployed onto Tomcat. I spent a fair bit of energy reading through the Eclipse ETP help files but there wasn’t any reference that I could find to reconfiguring an existing dynamic web application. In desperation I started hunting through the configuration files under the .settings folder in my project ad low and behold there i found it.
Just in case i forget or someone else has this problem the file is called org.eclipse.wst.common.component in that file are wb-resource entries for each source folder which is being compiled and/or copied into the classes directory under WEB-INF. I deleted the entries for source/test/java and source/test/resources and that took care of things.
1 comment | posted in Development, Java
Sep
20
2008
adam
I have always been a die hard Eclipse fan. Ever since the days of 2.1. A few years ago I started using the MyEclipse plugin to get hot-deploy to Tomcat. It quickly became indispensable to me and even when I started using maven and, what was then a very flaky plugin, M2Eclipse I persisted and wore the pain.
About 18 months ago I bought a Macbook Pro and my love affair with Eclipse and particularly MyEclipse plunged. I just could not seem to get a stable build. It would constantly crash…constantly. After many calls to MyEclipse and hundreds of different configurations I took the plunge an moved to IntelliJ.
Wow, what a lovely IDE. Smooth, everything just works (except the PMD plugin), but I kept feeling just a little bit dirty, just a little like I had sold out. As if forsaking Linux wasn’t enough, now I was forsaking my open source IDE! Also the use of space in IntelliJ kind of sucked. All the wasted space in margins makes it hard to use with multiple panels open unless you have a monster screen. I think most of that is due to the incredibly poor attention to detail in Java Swing UI components. Making a sexy looking Swing app is like walking over hot coals.
A little while ago I got involved in a project with a bunch of friends who were using Eclipse Ganymede without the need for MyEclipse. They were using the native functionality for hot deploy to the server. I was initially reluctant to go back to Eclipse after all the past pain but developing in different physical locations using different IDE’s really started to make some things more difficult than they needed to be so I downloaded Ganymede and gave it a go…
Rock solid on the Mac. I have been using it for the past few months without a single crash. The SWT UI is obviously a lot sexier than the IntelliJ Swing UI. The hot deploy is a bit of a pain in the arse to sort out when combined with M2Eclipse, but after a bit of tinkering around that is all working well too. The recent work on M2Eclipse has improved it out of site and integration with Maven 2 in Eclipse is now closing on what IntelliJ has had all along. The major down side is the SVN integration. Subversive is not bad, although a right pain in the arse to install, yet it is not a pinch on the IntelliJ native Subversion support. This is absolutely superb, the 3 way merge tool is brilliant, the ability to view annotations in your code to see who changed what, the constant monitoring of your repo all go to making it a pleasure to use.
I don’t have a conclusion on which is the best for me. I am back to using Eclipse almost exclusively and enjoying the experience but every now and then I really miss a feature from IntelliJ. I will download 8.0 when it gets out of Beta and have a look but it would need to provide some pretty compelling reason for me to switch back, mostly because most of the developers I work with are using Eclipse and the difference in IDEs can make some things difficult.
no comments | posted in Development
Sep
17
2008
adam
The main reason for using mock objects to write unit tests is so that they are unit tests. Without mock implementations, unit tests quickly become integration tests. There is nothing wrong with integration tests however they tend to make coverage data inaccurate, since code which is exercised incidentally rather than being directly tested gets marked as covered, and they can end up slowing down the test suite since these types of tests usually involve having to load the complete application context in a Spring application or they require a container and a JNDI instance for other J2EE apps.
My motto is keep it simple. I don’t like to think too much, particularly about my tests. When I see a red bar I don’t want to have to wonder whether it is the method under test which is broken or if it is one of its dependencies. I like to be certain that it is the method under test. It greatly reduces the time it takes me to get the green bar of goodness back.
I, personally, use EasyMock as my mock framework of choice. Combined with Unitils it takes a great deal of drudgery out of mocking out dependencies. Using the Unitils EasyMock annotations you can mark an interface as a mock using @Mock and mark the class under test which will have the mocks injected using @TestedObject. This doesn’t seem to work on classes using constructor injection, however it works fine for setter injection and means there is no need to manually setup your mocks and inject them into the class under test.
Complete details on how to use these annotations can be found here
no comments | posted in Development, Java
Sep
3
2008
adam
It has been quite a while since I posted on Eclipse plugins I am using. All the URLs have changed and so have many of the plugins I find essential for development. Here is an update on the plugins I recommended last time and the ones I’m using now:
- MyEclipse: I have ditched this as an unstable, annoying, and largely useless waste of money. Ganymede WST provides all the Sever hot deploy stuff that was good in the older MyEclipse editions out of the box, most of the rest can be found in various free plugins I will detail here. When I was working mostly in Windows or Linux this plugin was okay, but on the Mac MyEclipse crashes almost constantly and is a complete time waster. Virtually nothing interesting, which might save you money even works on the Mac, ie. UML, Javascript debug, image editing. Also the new installer is crap… I’m over these guys, $60/yr is a nice price point for a useful plugin set but really this is worse than useless if you are a Mac user.
- Spring IDE – If you are doing Spring development you cannot live without this plugin. Provides Spring configuration validation and help with code completion. URL: http://springide.org/updatesite/
- Subclipse: I have trashed this. The conflict resolution was kind of buggy and failure prone. Maybe it was operator error, but I got sick of trying to manage broken merges and migrated to Subversive.
- Subversive: This is becoming the Eclipse default SVN plugin. Why Ganymede does not have an SVN plugin out of the box is beyond me, is anyone still using CVS these days??? The only downside of Subversive is that it is slightly tricky to install as the install instruction have you jumping all over the web to get the update site urls for the connectors and the actual plugin. Here is the long and the short of it…
- Plugin site URL:http://download.eclipse.org/technology/subversive/0.7/update-site/
- Connector site URL: http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/
If you are using OS X or Linux you will need to unselect some of the windows JavaHL connectors
- M2Eclipse: This plugin has really come a long way since it was released a year or so ago. Previously the only useful thing about it was the repository search. Now it allows quite reasonable management of your Maven 2 project from within Eclipse. For those afraid of editing XML the new pom editor is really useful. I still don’t think the integration is quite as seamless as IntelliJ but it is now quite acceptable. URL: http://m2eclipse.sonatype.org/update/
- Eclemma is still the best free coverage plugin I am aware of. Again it is annoying that the IntelliJ emma integration is more seamless and intuitive but the Eclipse integration is quite workable. I had troubles installing this on Ubuntu, although it installed fine on my Mac. If you have problems it is quite simple to go to the eclemma site (www.eclemma.org) and download it. Unzip it and drop the contents of the plugin/ and features/ folders into their respective folders under your eclipse installation. URL: http://update.eclemma.org/
- PMD: This plugin is very handy for getting quick feedback on code style. We have been using PMD for a while and have a company ruleset.xml. I like the way you can prioritize problems and then filter by priority in the IDE, but I am still in 2 minds as to whether this is actually better than Checkstyle. URL: http://pmd.sourceforge.net/eclipse
1 comment | posted in Development, Java