Archive

Archive for the ‘tool’ Category

Book Review of Arquillian Testing Guide by John D. Ament

June 2nd, 2013 No comments

Here is a review of Arquillian Testing Guide by John D. Ament published by Packt Publishing. Before I give my opinion of his book, let me first make a disclaimer. I am also a Packt Pub author. I am the author of the up and coming Java EE 7 Developer Handbook (September 2013).

Mr Ament expects you the developer to be familiar with Java EE 5 or 6, an enterprise developer in Java. I guess you should have about one or two year experience and therefore you should know how to write Java unit tests with JUnit (or TestNG), the book leans on JUnit.  In the first, chapter, The Alien Have Landed; the author covers the basics of Arquillian Framework and it is helpful for engineers to have Apache Maven knowledge. Ament explains very well how to create a Maven project with Arquillian, and you find here hints and tips to avoid dependency download meltdown. The book’s first example is about building a Java project with an embedded container (so-called container-less build). Ament is clear about to set up a test project for re-use, creating different archive, JAR, WAR and EAR; and defining Maven profiles. It is an impressive start because when I writing my own Java EE 7 book, I wish that I had this information about an easy-to-read structure about integrating Arquillian.

The second chapter, Evolution of Testing digs deep in the history of Java enterprise testing and why we engineers must perform this duty in professional work place. Ament quickly guides the reader through jumps in technology from XDoclet to Mockito to HP QuickTest Professional. He also covers the Selenium and SoapUI toolkits briefly; and to a certain degree this text can treated as a handy reference to the background in testing. He covers the reasons where and how Arquillian can help to alleviate, extend these products and solve the nagging issues with these products in testing.

The real cherry berries for the contemporary Java EE engineer starts with chapter three, Container Testing; and this where the software developer does learn how to build integration tests with Arquillian Framework. The reader learns about different deployments and archives. Ament covers the Arquillian protocols in full detail. He obviously has tested Arquillian in many application servers in different configurations from JBoss AS 7 (rebranded recently to JBoss WildFly), GlassFish, Weld, OpenEJB, Jetty, TomEE and Tomcat. He has advice for Spring Framework developer too who want to use Arquillian in their applications. Ament particular does a fine job describing the merits of embedded versus managed and remote testing with Arquillian, because not all of the application servers, EJB container or servlet container are capable of support all of the Arquillian protocols and deployment capabilities. One of the great examples is the CDIDelegateTest that really helps the reader get the picture straightaway with no fuss.

Chapter four is called: Why Did the Test Fail? This chapter pays for the book itself. There is nothing worse than having a unit test or integration test fail, with or without Arquillian framework; and it is worst if you were not responsible for writing code in the first place. Ament has a lot of advice and descriptions on what could be cause for a failing Arquillian test. The text is particular relevant when you and your team are running Arquillian in continuous integration environment where the deployment is to a managed or remote server with other dependencies such a database. To finish, the chapter Ament provides a set of Dos and Don’ts sub sections.

The fifth chapter of book: Enriching the Enterprise Test Case, is about Arquillian and Context Dependency Injection, which I am a great fan of. Ament has nice examples and there is a fine explanation of CDI and JAX-RS testing for the request scope application. He covers also popular external CDI extensions and how to test features that use them very well. He even has a section on writing CDI extensions and testing there functionality with Arquillian, which is truly great stuff and a fantastic reference for advanced Java EE software developers. In this fifth chapter, also illustrates Arquillian Persistence extension with clear code and examples. This is hard-hat stuff that I figured out for myself whilst writing my own Java EE 7 book with Gradle and Arquillian test examples, and it is nice to see that Ament supplements and enhances my knowledge of the framework. If you want to find out how to test stateless EJB then you will find it here (and also in my Java EE 7 book).

There are ten chapters in this book and unfortunately I ran out time to review the rest of the book. The remaining content covers Arquillian extensions, including in-depth coverage of the Persistence and Transaction extensions, and running the framework with Spock with Groovy; Functional Application testing with Selenium and the Warp drive extension; web services testing; Arquillian and OSGI; and finally a full chapter dedicated to the underlying and central core framework ShrinkWrap, which allows developer to create a virtual Java archives.

Ament has written great book that concentrates on JBoss Arquillian Framework purely and simply. The book was written in the Java EE 6 timeframe just before next platform edition release, however the content is highly relevant still to all Java EE 7 developers. Ament has delivered a definitive guide to the Arquillian Framework. I wish that I had this book on my desk and Kindle application much earlier in my selfish task of writing about the sumptuous changes in new Java EE 7; and most of all I learnt how Arquillian can do a lot more than I what I thought it could.

Peter A. Pilgrim

     Author of Java EE 7 Developer Handbook

Sunday, 2ndJune 2013

PS: An earlier text of this review has also been uploaded to Amazon.co.uk.

+PP+

Devoxx UK: Test-Driven Development with Java EE 7, Arquillian and Embedded Containers

March 27th, 2013 Comments off

Thank you all for attending my Devoxx UK 2013 presentation earlier today: Test-Driven Development with Java EE 7, Arquillian and Embedded Containers. It was a total honour to be at the first United Kingdom franchise. I am very proud to have served the community.

Here is the Slidedeck for the talk:

And you can find the entire codebase of the demonstrations exported to Github as promised: https://github.com/peterpilgrim/devoxxuk2013-tdd-javaee7.

As I said before during the presentation, actually, I am writing a JavaEE 7 Developer User Guide book for Packt Publishing. Please look out for it as it will hit the shelves in late Summer / early Autumn of 2013. Finally, don’t be afraid to get in touch to ask any question on my talk and presentation, JavaEE 7 and development testing.

See you all at ACCU 2013 in Bristol, next month or perhaps further ahead to JavaOne 2013, San Francisco.

+PP+

 

Untitled

PS: A pleasure shout out to Aslak Knutsen and David Blevins from Red Hat JBoss team for their hints and tips on this talk.

Some Captured Tweets:

Markus Eisele ‏@myfear 2h
#devoxxuk @peter_pilgrim about #Arquillian and #JavaEE7 pic.twitter.com/CSv2rb5LTr

Holly Cummins ‏@holly_cummins 3h
‘The cloud is perhaps the heaviest container there is.’ @peter_pilgrim #DevoxxUK

Aslak Knutsen ‏@aslakknutsen 3h
http://yfrog.com/od34253901j Mocks are the old way of testing EE, it’s time to move on. @peter_pilgrim #Arquillian #DevoxxUK

Steven Van Impe ‏@sipofjava 3h
Attending “Test Driven Development with Java EE 7, …” by Peter Pilgrim (@peter_pilgrim) at #Devoxx.

Dan Allen and Aslak Knutsen retweeted you
20h: 13:30PM Weds, Test Driven Development with JavaEE 7, Arquillian & Embedded Containers http://www.devoxx.com/display/UK13/Test+Driven+Development+with+Java+EE+7%2C+Arquillian+and+Enterprise+Containers … #DevoxxUK “Let’s go UK!

Dan Allen and Aslak Knutsen retweeted you
20h: 13:30PM Weds, Test Driven Development with JavaEE 7, Arquillian & Embedded Containers http://www.devoxx.com/display/UK13/Test+Driven+Development+with+Java+EE+7%2C+Arquillian+and+Enterprise+Containers … #DevoxxUK “Let’s go UK!”

adoptajsr retweeted you
20h: Thanks to @aslakknutsen and @dblevins for a very insightful #JavaEE7 discussion around the hack tables #DevoxxUK

 

A Groovy Script to Keep The Internet Cafe’s WIFI Alive

October 26th, 2012 Comments off

Have you ever been to an Internet Cafe and connected to the free WIFI? Have you found that after five minutes of activity the connection has been dropped and you have go through the License and Terms of Agreement again and again and again? Annoying isn’t.

Well after expiring this at Charlotte Airport in the USA recently, I re-concocted the script that I wrote for the half-dozenth time. This time I going to blog it and save it for all time.
Here is a simple Groovy script to keep the Internet alive.

// Hang-up to Internet Connection Groovy Script
// Useful for Internet Cafe that drop WIFI connectivity through
// perceived lack of activity e.g. Starbucks / Hotels
// Peter Pilgrim
// 28 September 2012

def maxTimeout = 30000
def minTimeout = 15000

def domainList = [
    'gmail.com', 'google.co.uk', 'google.com', 'bbc.co.uk', 'cnn.com', 'java.oracle.com',
    'facebook.com', 'twitter.com', 'oracle.com', 'zen.co.uk', 'java.net', 'www.scala-lang.org',
    'plus.google.com', 'guardian.co.uk', 'linkedin.com', 'www.typesafe.com', 'www.yahoo.com',
    'www.ibm.com', 'www.apache.org', 'www.adobe.com', 'www.microsoft.com', 'www.stackoverflow.com',
    'www.apple.com', 'groovy.codehaus.org', 'java.oracle.com', 'www.telegraph.co.uk', 'www.jroller.com',
    'www.dell.com', 'www.samsung.com', 'www.amazon.co.uk', 'docs.oracle.com', 'www.infoq.com',
    'www.devoxx.com', 'www.qconlondon.com', 'www.smashingmagazine.com', 'en.wikipedia.com' ]

def count = 1
while (true) {
    int idx = (int)( Math.random() * domainList.size )    
    println "[$count]  nslookup ${domainList[idx]}"
    def process = "nslookup ${domainList[idx]}".execute()
    println "Found text ${process.text}"
    
    def sleepTime = (int)( minTimeout + Math.random() * ( maxTimeout  - minTimeout))
    Thread.sleep( sleepTime );
    
    ++count
}

// done

The script can be improved with a much larger set of domain names, perhaps I could machine generate the domain names from the Chrome Browser history, or something like this. That is about all I would do, except to parameterise the command line arguments. On Mac or Linux I just hit the terminal and type with auto completion of course groovy ~/hangon-to-internet.groovy

Now, the only thing to write is a similar script to keep the WIFI connection to the both mobile phone and tablet alive. Answers on a post card please.

+PP+

Categories: Groovy, language, programming, tool Tags: