Tuesday February 03, 2009
|
Vanity Foul Dedicated to the wanderings of an egotistical mind. |
|
Re: What GOP Leaders deem wasteful in Senate stimulus bill From CNN: "On Monday, House Republican leaders put out a list of what they call wasteful provisions in the Senate version of the nearly $900 billion stimulus bill that is being debated". I have to agree that several of these are questionable, others are defensible with "economic stimulation" in mind.
It's really tempting to comment on every line item, but I've tried to restrain myself. Grails Test Fixtures Yep, more Grails. Here's the background: in December I did some skunkworks on a Grails app, which has been thrown on the trash-heap. My next project is supposed to be in Rails, which I have not used yet. I started reading a co-workers book (the book is 3 years old), and it just wasn't feeling right - though I could definitely see where Grails was inspired by Rails. My coworker/team-lead took off for a week of vacation without checking in his work. I had already begun a project, but felt it wasn't going well. I didn't want to go too far off the rails (pardon the pun), so I restarted the project in Grails. But Grails doesn't have test fixtures (yaml), not in the core, at least. So I started searching and found a plugin that does something similar. Now I'm converting my first couple test cases, and really liking it. And I'm wondering why Test Fixtures aren't a part of the new Testing plugin that is integrated into Grails 1.1.... Groovy/Grails GPath Goodness I couldn't find any GPath references that really discussed using it on object-graphs other than those built from XML. In my case, I needed to use GPath to get a reference to an object so I could complete a Unit Test. The controller I'm testing persisted new objects build from a JSON string passed in, but when accessed didn't have the child objects in the same order. Even if the child objects were in the correct sequence, the Hibernate PersistentSet won't allow you to access objects by index number (job.actions[0].subject will error):
// this is after the controller call has been made and returned
records = service.jobsByActionSubject(testSubject)
def job = records[0]
// this actually results in the second/wrong action (of type "status")
// of the submitted json being accessed
assertEquals testSubject, job.actions.subject[0]
So I made use of
records = service.jobsByActionSubject(testSubject)
def job = records[0]
// an action has an actionType, which is named
def testAction = job.actions.find{ it.actionType.name == "pop" }
assertEquals testSubject, testAction.subject
(
Feb 03 2009, 11:52:21 AM
)
Groovy n Grails
Permalink
Sweet Sixteen Today my first child turned 16. I haven't signed her up for driver's ed, so no worries there. But my little girl is growing up. Always independent, the last several months have been all about which colleges she is going to apply. I just realized today that I'm not ready for her to leave me yet, though I've got a couple more years to get used to the idea. My mom reads this blog (or used to when I published frequently), I wonder what she will have to say. Grails: Testing JSON Output I couldn't find any resources that provided examples on how to test a Controller closure that "render[s] as JSON". Turns out it isn't terribly complicated, but I did have to root around a bit to find the right way to get ahold of the text that the controller generated.
def expectedObject = new ExpectedObject(foo: "bar")
expectedObject.save()
// Create expected JSON result
def expectedResult = expectedObject as JSON
// okay, now we call the method we're testing
controller.params.foo = "bar"
controller.getObject()
def jsonResult = controller.response.contentAsString
// did we get the job back as JSON?
assertEquals expectedResult.toString(), jsonResult
The key was discovering that Spring injected a MockHttpServletResponse, and that it has a contentAsString() method. Thanks to the following resources:
(
Feb 02 2009, 08:56:30 AM
)
Groovy n Grails
Permalink
Bad Behaviour I'm watching the inauguration live, and current-President Bush just entered: has any other President even been boo'ed while leaving office? Some people are even chanting "No More Bush". Didn't their mothers teach them to behave better than that? I'm no fan of the man (far from it), but even I consider it bad form to boo the man, especially while he still holds office.
(
Jan 20 2009, 11:49:23 AM
)
Politics
Permalink
Jingoism Last night Sean and 'friend' from Solution Design Group presented the Javascript Dependency Manager they've created, jingo at the Groovy Users of MN meeting. The presentation was very well done, including an excellent review of the existing systems. Basically, the other solutions where created ad-hoc to support the javascript framework they originate from: Dojo and YUI, primarily (Ext also?). But Jingo was purpose-built with the singular intent to create transitive javascript dependency. The Jingo guys should how easy it is to wrap Jingo around another library (unfortunately it does require modifying existing .js files) by demonstrating an RSS reader created with Ext, but using Jingo for dependancy management. The major criticism of the Ext/Jingo demo was the number of files that Jingo downloads in this case (as opposed to the ext-all.js monster). To address this Sean has already begun planning a G/JSP tag library (or other mechanisms) for a given page to dynamically condense all the dependencies into a single .js file (with caching, obviously). Also, I think the point was missed of using the appropriately sized solution to a problem: for a more modest dependency tree Jingo is a good fit, but if your going to need a monster library like Ext, perhaps ext-all.js is better I'm not a professional javascript developer, but Jingo really got me excited. Cool technology, a well thought-out design, easily extends existing libraries. +1 Update: Sean has released the slides from his presentation.
(
Jan 14 2009, 08:47:24 AM
)
Technology
Permalink
[Link]
Overheard at work I just overheard part of a conversation between two coworkers: Coworker 1: (something or other) Wondertwins? Do we need our rings? That's gotta be about the geekiest damn thing I've ever heard.
(
Nov 20 2008, 02:52:51 PM
)
Humor?
Permalink
|
|
||||