Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Sunday, March 06, 2011

Cucumber DSL for Selenium Testing - Take 2

After poking around with Cucumber, Cuke4Duke and Selenium, I liked what I saw and started digging around for more interesting bits. I have moved from selenium 1 to Webdriver(Selenium 2).

One of the minor problems I have had so far is that the browser windows don't get closed after my tests completed.

I saw a number of attempts at solving this including having a tagged @After hook on the last scenario in the last Feature. None of them really jumped out at me until I read a question to the group and that led me to give a JVM shutdown hooks a go (equivalent to Kernel#at_exit in Ruby land). That seems to work quite well and lives well away from the features and steps making for cleaner code. It also means that we will have a clean suite of features that don't get polluted by technical detail.


Do take a look at the full thing on GitHub. Let me know what you think.


Monday, June 23, 2008

TSSJS Prague - Days 2 & 3

Days 2 and 3 have been a breeze. There have been all sorts of interesting things that have been spoken about from Groovy and Grails to JPA 2.0 new features to really cool testing in JRuby. A lot of buzz is being generated in the community by DSLs and I also think Behaviour Driven Development as epitomised by JTestr, JBehave and easyB are all things to look into. Some interesting catch phrases are that XML is deprecated (in favour of DSLs of course). All slides for the presentations are available @ the JavaSymposium Wiki.

A few more things caught my attention and I will be looking at them in more detail in the coming weeks. I will hope to share my joys or...tears as I try them out.
Scala
ServiceMix + Camel
Mule 2
etc.

I thought the JavaRebel class re-loading agent thing was quite cool and can be a productivity booster but seeing that its not free...(the freeloader that I am), I'll be giving it a miss for now.

All in all I'd say that my time in Prague was extremely interesting, especially with the chance I got to catch up with old colleagues and meet new friends that one can rub minds with. Its been well worth it and I will be headed off to the next European even next year.

Thursday, June 19, 2008

TSSJS Prague - Day 1

The TSSJS Europe conference has begun in earnest in the lovely city of Prague. Between swinging alfresco dining and lovely continental beer I have regarded the 1st day of the conference as intellectually rewarding. There were quite a few talks that stood out for me.

First of all the introductory but well thought out talk by Nati Shalom of GigaSpaces on Cloud computing. There was informative eye candy on his slides and his talk brought to the fore-front of my consciousness the fact that capacity planning and scalability are thorny issues in general. I will be investigating the GigaSpaces stack, as before now it has been on my radar but hasn't been high priority enough.

There was the double whammy of Spring talks one of which was by Costin Leau. It raised important questions in my mind on things I could be doing better. The fact that SpringSource is re-aligning, re-inventing and re-positioning itself with offerings like Spring DM (which plays quite well with OSGi), Spring Batch and Spring Integration has not gone unnoticed and personally from the capabilities demoed today, I'd advise anyone to give the new Spring stack a look in. I have already started to look into some OSGi bundling tools like aQute and will be sharing my thoughts in a while.

The SCA talk by Mike Keith of Oracle to my mind raised more question than answers. Not the least the fact that some of the issues it addresses like assembly, overlap with other product sets in the market like ESBs and even the JBI spec. I have resolved to go away from that talk and
undertake more research to see if there's more to this shining new spec.

The Grails talk was well articulated but gave very little in terms of TDD support in Grails. Issues of this nature are close to my heart and I hope improvements will be made for future talks.

With regards to organisation, I'd like to see a conference where the video content of presentation is available to attendees by close of play everyday, even if in a raw/unedited form (a-la Parleys.com and JavaPolis). This can help if you are torn between two sessions you desperately want to attend.

All in all 8 out of 10 for Day 1. Bring on day 2.

Sunday, July 15, 2007

Groovy Weblogic Migration

This is a bit of a change in direction being that I prefer to rant about football and other such easy-on-the-eye material but I thought I'd bore you a bit with techie stuff...read on.

In the past few months I have begun to re-acquaint myself with Scripting/Dynamic languages and would say that they have become quite sexy and even more expressive than I remembered. I have had cause to look at Ruby and Groovy in more detail and they each have unique selling points for me. Ruby because of its expressive nature and its wicked cohort Rails and Groovy for its near Java syntax and its inherent support for all things Java. Blessings like JSR 223 and more support in the JVM for dynamic languages (JRuby and Jython) seem to have helped.

So you can imagine that the first chance I got to make something really helpful with a scripting language I decided to give Groovy a spin. I will say that it has good documentation and is quite mature. My use case? I needed to migrate a number of system resources (DataSources and Mail Sessions) from Weblogic 8.1 to Weblogic 9.2.

I had heard from a team member on my project about WLST (Weblogic Scripting Tool) and the administrative magic you could do with it..so my head started ticking. I bet there are a number of ways I could have gone about migrating these resources (I welcome suggestions) but a notion had formed in my mind about the path I would go.

The change in configuration information structure was much between the two versions so I decided I was going to read a WLS 8.1 config.xml, then generate WLST scripts to recreate interesting elements from it in WLS 9.2. Initially I wrote the first rough sketch in Java (being a masochist :-D ) but after it became unmanageable, I had written XSLT code in lieu of JAXP or XSD and JAXB, I decided to re-implement in Groovy and I am loving every minute of it..XmlSlurper rocks! I made sure to pepper my script with closures right Groovy-newbie that I am. I have put up a copy of the code here for your viewing....free gift eh?
So without further ado here is the code. Enjoy!


class Migrator {

static void main(args) {
def domain = new XmlSlurper().parse(new File(args[0]))
def msClosure = {ms ->
new PrintWriter(new FileOutputStream("c:\\stuff\\migration\\"+ms.@Name.text().replaceAll(" ","")+".py")).withWriter {writer ->
writer.println("connect('${args[1]}','${args[2]}','${args[3]}')")
writer.println("edit()")
writer.println("startEdit()")
writer.println("myMailSession = create('${ms.@Name.text()}','MailSession')")
writer.println("myMailSession.setJNDIName('${ms.@JNDIName.text()}')")
writer.println("myMailSession.setProperties(makePropertiesObject('${ms.@Properties.text()}'))")
writer.println("myMailSession.addTarget(getMBean('Clusters/${ms.@Targets.text()}'))")
writer.println("save()")
writer.println("activate(block='true')")
writer.println("dumpStack()")
writer.println("disconnect()")
}
}
def dsClosure = {ds ->
def wlstOut = new PrintWriter(new FileOutputStream("c:\\stuff\\migration\\"+ds.@Name.text().replaceAll(" ","")+".py")).withWriter {writer ->
def poolInfo = domain.JDBCConnectionPool.find{it.@Name.text() == ds.@PoolName.text()}
def startPos = poolInfo.@Properties.text().toString().indexOf("user=")
if (startPos > -1) {
def userName = poolInfo.@Properties.text().substring(startPos+5)
writer.println("connect('${args[1]}','${args[2]}','${args[3]}')")
writer.println("edit()")
writer.println("startEdit()")
writer.println("jdbcSR = create('${ds.@Name.text()}','JDBCSystemResource')")
writer.println("theJDBCResource = jdbcSR.getJDBCResource()")
writer.println("connectionPoolParams = theJDBCResource.getJDBCConnectionPoolParams()")
writer.println("connectionPoolParams.setConnectionReserveTimeoutSeconds(25)")
writer.println("connectionPoolParams.setMaxCapacity(100)")
writer.println("connectionPoolParams.setTestTableName('SQL SELECT 1 FROM DUAL')")
writer.println("dsParams = theJDBCResource.getJDBCDataSourceParams()")
writer.println("dsParams.addJNDIName('${ds.@JNDIName.text()}')")
writer.println("driverParams = theJDBCResource.getJDBCDriverParams()")
writer.println("driverParams.setDriverName('oracle.jdbc.OracleDriver')")
writer.println("driverProperties = driverParams.getProperties()")
writer.println("proper = driverProperties.createProperty('user')")
writer.println("proper.setValue('${userName}')")
writer.println("driverParams.setPassword('${userName}')")
if (args.length > 4) {
writer.println("driverParams.setUrl('${args[3]}')")
writer.println("jdbcSR.addTarget(getMBean('Clusters/${ds.@Targets.text()}'))")
} else {
writer.println("driverParams.setUrl('${poolInfo.@URL.text()}')")
writer.println("jdbcSR.addTarget(getMBean('Clusters/${ds.@Targets.text()}'))")
}
writer.println("save()")
writer.println("activate(block='true')")
writer.println("dumpStack()")
writer.println("disconnect()")
}
}
}

domain.JDBCTxDataSource.collect dsClosure
domain.JDBCDataSource.collect dsClosure
domain.MailSession.collect msClosure
}