Wednesday, December 20, 2006

Groovy in Action

The book "Groovy in Action" is finally out! Have a look, it's worth reading it!

URL:

http://groovy.canoo.com/gina

Description:

Groovy in Action is a comprehensive description of the Groovy programming language, its libraries, and its everyday use. With the release of JSR 241, Groovy has become the second standard language for the Java platform. The book introduces Java developers to the new dynamic features that Groovy brings to this platform.

Enjoy!

Groovy in Action

The book "Groovy in Action" is finally out! Have a look, it's worth reading it!

URL:

http://groovy.canoo.com/gina

Description:

Groovy in Action is a comprehensive description of the Groovy programming language, its libraries, and its everyday use. With the release of JSR 241, Groovy has become the second standard language for the Java platform. The book introduces Java developers to the new dynamic features that Groovy brings to this platform.

Enjoy!

Monday, September 25, 2006

groovy articles on del.icio.us

Since I'm using Groovy in the current project (thanks to Dierk and Marc) I'll start collect articles about groovy...

This might help some other beginners to start with a steeper learning curve as well :)Enjoy!

Read more at del.icio.us/TomiSchuetz...

Monday, August 28, 2006

Groovy: Parsing an XML file with Groovy

Groovy comes with a handy XML parser. With this parser you can load an XML file quickly and navigate it easy.

Currently I'm working with WebTest (http://webtest.canoo.com/) for testing functional aspects of an web application.

WebTest comes with a nice overview to present the results of the test runs. The report itself is transformed out of an XML file. For statistics reason, I'm using this XML file to extract specific data. This extraction is done with a little Groovy script.

To get an idea of the WebTest report XML file, have a look a the fragment below:

WebTestReport.xml:








...










name="resultFilename" value="response_1156746643278_invoke.html"/>
















...



This file can be parsed with the following code:


import java.text.SimpleDateFormat

FormatUS = new SimpleDateFormat('EEE MMM dd hh:mm:ss z yyyy', Locale.US)
FormatDE = new SimpleDateFormat('dd.MM.yyyy hh:mm:ss', Locale.GERMAN)

def folder = args?.size() ? args[0] : "data"
println "reading files from directory '$folder'"
def basedir = new File(folder)

// result files of the current run
files = basedir.listFiles().grep(~/.*xml$/)

List resultLines() {
List result = []
for (currentFile in files) {
println " processing $currentFile"
def summary = new XmlParser().parse(currentFile)

// List with all 'testresult' elements
def testresults = summary.testresult


testresults.each { testcase ->
def entry = [:]
entry.name = testcase.'@testspecname'.split(/\W/)[0]
entry.time = testcase.'@starttime'
entry.time = FormatUS.parse(entry.time)
entry.time = FormatDE.format(entry.time)
entry.ok = testcase.'@successful'

def rt = testcase.depthFirst().findAll { element ->
if (element.name() != 'parameter') return false
if (element.'@name' != 'taskName') return false
def roundtripTags = 'clickLink clickButton clickElement'
roundtripTags.tokenize().contains(element.'@value')
}
entry.roundtrips = rt.size()

def fields = testcase.depthFirst().findAll { element ->
if (element.name() != 'parameter') return false
if (element.'@name' != 'taskName') return false
def fieldsTags = 'selectForm setCheckbox setFileField setInputField setRadioButton'
fieldsTags.tokenize().contains(element.'@value')
}
entry.fields = fields.size()

def verifies = testcase.depthFirst().findAll { element ->
if (element.name() != 'parameter') return false
if (element.'@name' != 'taskName') return false
def fieldsTags = 'verifyCheckbox verifyCookie verifyDocumentURL verifyElement'
fieldsTags.tokenize().contains(element.'@value')
}
entry.verifies = verifies.size()

if (testcase.results.error) {
entry.resultsError = testcase.results.error.'@exception'[0]
} else {
entry.resultsError = ''
}

/*
if (testcase.results.failure) {
entry.resultsFailure = testcase.results.failure.'@message'[0].replaceAll(/\W/, " ")
println "####" + entry.resultsFailure
} else {
entry.resultsFailure = ''
}
*/

def groupSteps = testcase.results.step.findAll { step ->
step.parameter.any { param ->
param.'@name' == 'taskName' && param.'@value' == 'group'
}
}

def goodSteps = groupSteps.findAll{ it.result?.completed }

// assumed: there is always at least one group step, size() never 0
if (groupSteps.size() != 0) {
entry.complete_pct = goodSteps.size() / groupSteps.size()
} else {
entry.complete_pct = 0
}

if (goodSteps) {
entry.description = goodSteps[-1].parameter.findAll{it.'@name'=='description'}.'@value'[0]
} else {
entry.description = ''
}

result <<>
writer <<
"Testfall\t" <<
"Datum\t" <<
"Erfolgreich\t" <<
"Prozent\t" <<
"Error\t" <<
"Server Roundtrips\t" <<
"Number of Fields\t" <<
"Verifications\t" <<
"Beschreibung\n"
for (entry in resultLines()) {
writer <<
entry.name << "\t" <<
entry.time << "\t" <<
entry.ok << "\t" <<
entry.complete_pct << "\t" <<
entry.resultsError << "\t" <<
entry.roundtrips << "\t" <<
entry.fields << "\t" <<
entry.verifies << "\t" <<
entry.description << "\n"
}
}


Now you get a tab seperated file with the content of your result files from the web testing runs. I
import this file into Excel and create a pivot table to understand the results better.

I hope this helps :)

Friday, August 25, 2006

Groovy: Get all XML files from a directory tree

Currently I'm working in a project, where Groovy (a dynamic scripting language for the JVM) is used. One of the project members is Dierk König, which is a Groovy commiter and the author of Groovy in Action. This gives a real insight in the beauty of Groovy :)

Below you can see a nice solution for finding all XML files in a directory tree:


// pass a directory or use the current directory
def folder = args?.size() ? args[0] : "."
println "reading files from directory '$folder'"
def basedir = new File(folder)

// result files of the current run
files = basedir.listFiles().grep(~/.*xml$/)

List resultLines() {
List result = []
for (currentFile in files) {
println " processing $currentFile"
}
return result
}

Monday, August 14, 2006

GWT Widget Library

Google released a new version of GWT today, version 1.1.0. There were some API changes made that broke a few things in the GWT-WL, namely the FormPanel and SVG support. This release is to make the GWT-WL compatible with the latest GWT release. Below are a list of changes...

[from the site]

Read more at gwt-widget.sourceforge....

Friday, August 11, 2006

Eclipse Summit Europe 2006

The Eclipse Summit Europe will take place in Esslingen, Germany from October 11-12, 2006

Read more at www.eclipsecon.org/summ...

Eclipse 3.3 M1 - New and Noteworthy

It's amazing, how fast the Eclipse people work! Thanks to all of them :)

Read more at download.eclipse.org/ec...

Tuesday, August 08, 2006

Lint4j Maven Plugin - Lint4j

Lint4j comes with a Maven Plugin that simplifies generation of reports significantly.

I'll have to check this plugin with WebTestClipse ...

Read more at www.jutils.com/maven-pl...

dzone.com

An interesting site for developers. It's similar to del.icio.us and stumbleupon , but more focused on developers.

I like these community driven sites, because it allows me to find high quality sites.

Read more at www.dzone.com/

Thursday, August 03, 2006

SourceForge.net: WebTestClipse

I added WebTestClipse as a project to Sourceforge.net ( http://sourceforge.net/projects/webtestclipse/ ). The idea is, to use Sourceforge.net as a portal and to redirect to http://webtestclipse.canoo.com/ where the project is hosted and developed...

Read more at sourceforge.net/project...

Friday, July 28, 2006

Setting up the master Maven 2 project for WebTestClipse - Install Maven 2

I'm setting up the master Maven 2 project for WebTestClipse . You can follow these steps to set up any kind of project.In this post I'll descripe the installation of Maven 2, based on links and some minor notes. It's not to be considered to be a complete installation guide.

1.) Download Maven 2

Download Maven 2 from http://maven.apache.org/download.html and chose the right distribution. I'm using http://www.apache.org/dyn/closer.cgi/maven/binaries/maven-2.0.4-bin.zip .

2.) Unpack Maven into a local directory

I've chosen C:\dev\maven-2.0.4 as my Maven 2 home directory.

3.) Environment Variable

Define a %MAVEN_HOME% variable and extend the %PATH% variable. This will make it possible to call Maven 2 commands from the command line

4.) Test your Installation

Testing the installation is fairly simple. Just call a Maven 2 command from the command shell:

mvn -v

As a result you should see:

Maven version: 2.0.4

Joined WebTestClipse

I joined the WebTestClipse project. The goal of the project is to provide a set of Eclipse features and plugins to develop tests for WebTest .

Read more at webtestclipse.canoo.com...

Daily IT Thoughts...

I'll start making daily notes about my work, this shall be a collection of impressions but also of small code fragments which help me on my daily projects...

Monday, January 09, 2006

Eclipse and Java on USB Memory Stick

I bought myself a memory stick a few days ago, mainly to store data which I download in a internet coffee shops. I find it quite annoying to transport my laptop every time I just would like to read some mails...

Somehow I found portableapps.com which has a nice collection of tools (Firefox, Thunderbird, etc.) which can be copied on the USB memory stick and started from there. This makes it easy to use my favorite browser and mail client...

For me the next question was: can I install Eclipse and Java on the memory stick and use it? Yes, you can :)

Here a short description on what I did:

1.) Copy a current installation of Java to the memory stick. I really copied it, I didn't install it!
2.) Copy Eclipse on the memory stick.
3.) Write a simple batch file to start Eclipse.

that's it!

My directory structure on the memory stick looks like this:

%USB_MEMORY_STICK_ROOT%
| Eclipse.bat
+---Applications
+---jdk1.5.0_05
| \---bin
| \---javaw.exe
|
+---eclipse
\---eclipse.exe

Eclipse.bat looks like this:

.\Applications\eclipse\eclipse.exe
-data .\Projects
-vm .\Applications\jdk1.5.0_05\bin\javaw.exe
-vmargs -Xmx256M



Enjoy :)