Vanity Foul
Dedicated to the wanderings of an egotistical mind.


20090319
Thursday March 19, 2009

Parrot 1.0 It's been a long time coming, Parrot 1.0 is finally released. How far behind is Perl 6?
( Mar 19 2009, 06:27:10 AM ) Technology Permalink [Link]
Trackback: http://www.brainopolis.com/roller/trackback/lance/Weblog/parrot_1_0



20090223
Monday February 23, 2009

Epoch Time Event

Kottke notices that tomorrow, Feb 13th, at 5:31:30 PM Central Time, the unix clock (which some call "epoch time") will hit 1234567890 (that is the number of milliseconds since 'the beginning', Jan 1 1970 iirc). Some coworkers and I are celebrating at Shamrocks, stop on by and join us.
( Feb 23 2009, 10:34:52 AM ) Technology Permalink [Link]
Trackback: http://www.brainopolis.com/roller/trackback/lance/Weblog/epoch_time_event1



20090205
Thursday February 05, 2009

Warning: Zombies Ahead lighten up people

"oh noes, someone might crashed reading about scary zombies whilst driving!" I think the hazard is minimal to non-existent, and I find it ... interesting that the people interviewed are so worked up. Or perhaps the TV station only showed those who were upset, and not the interviewees ROFLMAO?
( Feb 05 2009, 12:17:44 PM ) Entertainment Permalink [Link]
Trackback: http://www.brainopolis.com/roller/trackback/lance/Weblog/warning_zombies_ahead



20090204
Wednesday February 04, 2009

Re: Re: Grails Testing Fixtures

I edited the Fixtures plugin:

class FixtureLoader implements ApplicationContextAware {
    
    def classLoader
    ApplicationContext applicationContext
    
    def createBuilder() {
        new FixtureBuilder(applicationContext, classLoader)
    }
    
    void load(String[] fixtures) {
        def bb = createBuilder()
        fixtures.each {
            bb.loadBeans("/fixtures/${it}.groovy")
        }
        applicationContext = bb.createApplicationContext()
    }
    
    void load(Closure beans) {
        def bb = createBuilder()
        bb.beans(beans)
        applicationContext = bb.createApplicationContext()
    }
    
    Object getProperty(String name) {
    	if (applicationContext.getProperty(name)) {
    		return applicationContext.getProperty(name)
    	}
    	return super.getProperty(name)
    }
}

This doesn't completely fix my complaints, but now I've direct access to the object created in the fixture:

   fixtureLoader.load("testing")
   def fooInstance = fixtureLoader.foo1
   def barInstance = fixtureLoader.bar1

I still have the instantiation/relationship issues, but that's due to Spring's BeanBuilder, not the Fixture plugin itself. Perhaps I'll look into what it would take to fix that as well.
( Feb 04 2009, 08:09:21 PM ) Groovy n Grails Permalink
Trackback: http://www.brainopolis.com/roller/trackback/lance/Weblog/re_re_grails_testing_fixtures

Re: Grails Test Fixtures

I'm less happy with Grails Test Fixtures plugin today, as I discovered that it won't do both sides of a relationship properly. If I've got class Foo which hasMany Bar's, and Bar belongsTo Foo:

testing.groovy
beans {
   foo1(Foo) {
      name = "foobar"
      bars = [/* FAILS -> ref(bar1) */]
   }

   bar1(Bar) {
      name = "barbaz"
      foo = foo1
   }
}

I can't say bars = [bar1] because bar1 won't have been instantiated yet. Even trying to use the "deferred" object references fails. And I cannot declare bar1 first, because it won't be able to set it's foo property and will fail to save. So

   fixtureLoader.load("testing")
   def foo1 = Foo.findByName("foobar")
   // foo1.bars will be empty
   def bar1 = Bar.findByName("barbaz")
   foo1.bars = [bar1]

   // now I can start testing

Which brings me to another point: Ruby fixtures would expose foo1 and bar1 as instances for me to use, no lookup necessary (as I understand it). Maybe I'm not doing it right? Will they be there in Grails Fixtures if I use the Spring Application Context?
( Feb 04 2009, 02:07:35 PM ) Groovy n Grails Permalink Comments [1]
Trackback: http://www.brainopolis.com/roller/trackback/lance/Weblog/re_grails_test_fixtures



20090203
Tuesday February 03, 2009

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.

  • $2 billion earmark to re-start FutureGen, a near-zero emissions coal power plant in Illinois that the Department of Energy defunded last year because it said the project was inefficient. Sounds like a good idea to me, but also reeks of favoritism since it is in Obama's home state.
  • A $246 million tax break for Hollywood movie producers to buy motion picture film. WHAT?!
  • $650 million for the digital television converter box coupon program. From what I hear, the FCC underfunded this program. By $650 million though?
  • $88 million for the Coast Guard to design a new polar icebreaker (arctic ship). Do we really need a new polar icebreaker? Even though the polar ice is melting faster every year?
  • $448 million for constructing the Department of Homeland Security headquarters. I'm guessing this has gone way over budget?
  • $600 million to buy hybrid vehicles for federal employees. Are these fleet or personal? Upgrading the fleet to hybrid's makes sense to me, gifting personal cars doesn't.
  • $6 billion to turn federal buildings into "green" buildings. This one only makes sense in the scope of economic stimulus, plus it should help get solar into that 'economy of scale' that's needed to tip the pricing into accessible to the populace
  • $850 million for Amtrak. Again, what?!
  • $200 million in funding for the lease of alternative energy vehicles for use on military installations. Let the military agencies pay for this out of their normal funding.

It's really tempting to comment on every line item, but I've tried to restrain myself.
( Feb 03 2009, 03:00:55 PM ) Politics Permalink [Link]
Trackback: http://www.brainopolis.com/roller/trackback/lance/Weblog/re_what_gop_leaders_deem

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....
( Feb 03 2009, 12:59:31 PM ) Groovy n Grails Permalink
Trackback: http://www.brainopolis.com/roller/trackback/lance/Weblog/grails_test_fixtures

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
Trackback: http://www.brainopolis.com/roller/trackback/lance/Weblog/groovy_grails_gpath_goodness




archives
links