Sunday, January 29, 2006

Finding a good solution to do a simple task

I wrote some in-container automation tests which needs to be driven by some outside container client applications. This series of automation tests each would create some test data based on a XML file, wait till the client application finish executing the tests, then move onto its next series. The client application, use this same XML file to generate a property file as its input.

Basically I need to automation the entire test execution process. And one way I can think of is the following. Use some scripting language to perform the following tasks

1. Take this XML file, generate the client property file.
2. Start the client application with the property file generated above as the input.
3. Start the in-container automation tests.
4. Check if the in-container automation tests finish, if so, move to 5, otherwise loop in 4.
5. Stop the client application started in 2.
6. Repeat these step with the next test series.

So far this seems a practical solution, but the efforts involved in creating these trival tasks for a non-shell programmer (like myself) is much more than creating this set of in-container automation programs.

If somehow the in-container programs can trigger out-side containers processes, the above tasks can be much simpler, at least all can be done in Java.

Tuesday, January 17, 2006

Deciphering XML in Day One

SAX – Simple API for XML processing, it is based on event-model.
DOM – based on object model.

JAXP – Java API for XML Processing

SAX and DOM are two different parsing APIs most widely used. Other parsing APIs are JDOM, dom4j etc. JAXP is a set of APIs that’s designed on top of SAX, DOM and other parsing APIs, and acts as a layer of abstraction to handle some (parser) vendor-specific tasks in a vendor-neutral way. JAXP provides a means of getting to these parsers and the data that they expose, but doesn't offer a new way to parse an XML document.
Most popular XML parsers will be supported through JAXP. When it is installed and supporting a particular parser, JAXP can be used to select it. The main value of JAXP is to act as the adaptor between the JAXP API and the vendor specific parsers.
With JDK 1.4, Sun has included JAXP in the standard distribution of the JDK, and therefore is available out of the box. Even more, JDK 1.4+ comes with Apache’s Crimson XML parser, so you don’t have to worry about that either.

Some JAXP pointers
http://java.sun.com/xml/downloads/jaxp.html - Specification
http://java.sun.com/webservices/docs/1.6/api/index.html - JAVADOC API
http://www-128.ibm.com/developerworks/xml/library/x-jaxp/
http://www.devarticles.com/c/a/XML/Java-and-XML-Basics-1/
http://www.devarticles.com/c/a/XML/Java-and-XML-Basics-2/
http://www.devarticles.com/c/a/XML/Java-and-XML-Basics-3/

JDOM
JDOM is a set of API based on the DOM model, it uses “new” operator to initiate parsers rather than using the factory pattern which are considered complicated by many. Both SAX and DOM parsers can be plugged in. SAXBuilder listens for the SAX events and builds a corresponding Document in memory. That approach is very fast (basically as fast as SAX), and it is the approach we recommend. It provides API more intuitive to the Java programmers to traverse the XML tree. JDOM uses the JAXP to select parsers.

Some JDOM pointers
http://www.javaworld.com/javaworld/jw-05-2000/jw-0518-jdom.html
http://www-128.ibm.com/developerworks/java/library/j-jdom/index.html
http://www.oracle.com/technology/oramag/oracle/02-sep/o52jdom.html
http://www.oracle.com/technology/oramag/oracle/02-nov/o62odev_jdom.html

DOM4J

DOM,SAX,JDOM,JAXP的关系
http://searchwebservices.techtarget.com.cn/askexperts/139/2229139.shtml?ticket=ST-10519-EEGFnBSpDJQhMWMu4uA9

Jakarta Common Digester
http://www.javaworld.com/javaworld/jw-10-2002/jw-1025-opensourceprofile.html
http://www-128.ibm.com/developerworks/java/library/j-lucene/

http://www.devx.com/Java/Article/21832/0/page/1

XML in general
http://www.informit.com/guides/guide.asp?g=xml

XML for the Novice

I have been running into several basic XML terms lately and with the spirit to seriously treat the technologies in my daily life, I start my very late, and long aimed catching up learning.

The first set of items I am trying to get my foot wet includes DOM, SAX, XPath and JDOM.

Here are the good links that I googled to acquire the basic knowledge.

Monday, January 09, 2006

Getting Started with Shell

I am finally tired of wasting so much time on fixing trival shell errors and decided to spend an hour or two to kill the basics of it.

1. Formatting Issues - Spaces do matter.
I haven't found any summaries online about this, but just from personal experiences, first, if you are assigning values to variables, you need to elimate all spaces around the equal sign. E.g. You have to write something like
var="string"
instead of
var = "string" or var= "string" or var ="string".

On the contrary, spaces are necessary to separate other operators. When using if [], you have to use space to separate [ or ] from the operator it uses inside. E.g. you have to write
if [ -z $string ]; then ... ; fi
instead of
if [-z $string ]; string ... ; fi etc.

2. Just as some convenient links, here are all the comparison operators
http://www.tldp.org/LDP/abs/html/comparison-ops.html
and file operators
http://www.tldp.org/LDP/abs/html/fto.html


And for more information here are some quick starts and references http://quong.best.vwh.net/shellin20/; http://www.tldp.org/LDP/abs/html/ and http://linux.org.mt/article/terminal

3. To test whether a variable is a string or not in shell, there is no straightforward way to do it, the closest i found is

if [ -z `echo $var tr -d "[:digit:]"` ]; then ... ; fi

New Year Resolution

New Year Resolutions

Back from an extended vacation to step into another year, time to write down some new year resolutions before time flies away quickly.

1. Work Out --- I'd like to keep the muscle I gained over the winter break, maybe a feasible goal would be 2 serious workout session each week.

2. Get up early --- To keep my youth, I think it is better to go to bed early and get up early. And hopefully this will make the day more productive as well. I am sure I will feel totally accomplished if I can do it persistently.

3. 2 hours each day to keep life on track --- half hour in the morning to plan out the list of the day, one hour investment in related tech stuff, half hour preparation and reflection for the next day. Hopefully a more regular schedule can free me up to have more fun with family and friends.

4. Tactic and lay back --- I'd like to be the opposite of intense. I want to feel accomplished but I don't like to go through life with high stress daily. Even though lay back or intense might come from the gene, I'd like to learn to tune my life toward more relaxations.