I was struggling to add HtmlUnit to Grails to do some testing when I came upon this. The solution was to remove the HtmlUnit included jar, xml-apis-1.3.04. The error looked like this: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/w3c/dom/NamedNodeMap" java.lang.LinkageError: loader constraint violation: loader (instance of ) [...]
Wednesday, December 10, 2008
I gave a presentation at work a couple of months ago covering JavaScript scoping considerations for a team of Java developers new to JavaScript. During the presentation, I used Rhino to run the examples. I have seen other projects that use Rhino for unit testing, but they seemed a little heavy weight for what I [...]
Thursday, November 20, 2008
In Ganymede, the Manage Configuration option Eclipse users were used to using is gone. Help->Software Updates is for just that now. So how do you go about disabling a plugin now? Well the good news is you no longer have to wait 5 minutes for the Manage Configuration window to load! Ganymede Eclipse now provides [...]
If your project has a lot of unit testing in Java and you use continuous builds (CruiseControl) to automate, it is often difficult to automate tests which connect to Database (Dao and integration tests). For most companies, having a dedicated Oracle schema for testing is expensive. Also, sometimes, developers need their own instances of schemas [...]
I have just completed a test for a method that parses a forward-slash delimited String: private static final String PROJECTID_STR_1 = ""; private static final String PROJECTID_STR_2 = "101/103/102/104/105/106/107"; private static final String PROJECTID_STR_3 = "///103/104"; private static final String PROJECTID_STR_4 = "a/b/102/104/105/106/107"; @Test public void testParseProjectIds1() { List<integer> projectIdList1 = getViewBillingReportController().parseProjectIds(PROJECTID_STR_1); assertTrue(projectIdList1.size() == 0); [...]
This has apparently gotten a fair amount of attention over the last year or so, but I never encountered it until today- call me lucky. Here’s the situation, you’re using Spring MVC and you have a controller that extends another controller (A->B). Your unit test extends AbstractTransactionalDataSourceSpringContextTests, and makes use of autowiring. You write your [...]
Tuesday, November 13, 2007
In Java 1.5, Sun provides us with a miracle method that is long overdue: long java.lang.instrument.Instrumentation.getObjectSize (Object objectToSize) However, this is still limited in that it only returns the total size of the Object, not the details about the Object size in regard to its composition. Enter monq.jar from Whatizit. There’s a Sizeof class in [...]
I’m a fairly recent convert to unit testing, but still when I’m under pressure to get something finished, I skip right to integration tests. Despite the guilt I still use the junit framework for these integration tests… I know the unit testing purists will be rolling their eyes at this point, but this is something [...]
Sunday, December 17, 2006
This is postmodern computing at it’s finest… I’m a fairly recent convert to test driven development. I’ve always thought it seemed like the right thing to do, but have only recently bought into it whole-heartedly when I took over someone else’s code base and was told the requirement’s have changed and I needed to modify [...]
Thursday, October 26, 2006
I’ve been using EasyMock with my unit tests on a current project. Generally, it’s been useful; to configure my project to run in a test environment on my desktop is a really pain. By using EasyMock I can create a very controlled environment for my tests by faking just enough of it to run. The [...]