MG>hopefully quick response
> From: [email protected] > Subject: Test phase for a command line tool (resend) > Date: Mon, 21 Mar 2011 09:24:27 -0400 > CC: [email protected] > To: [email protected] > > Note: I sent this on Friday (2011-03-18) but saw no response, so am resending > on the chance that it somehow got lost in transit. > > Caveat: I am new to Maven. I've read the online documentation but haven't > found a good source of sample POMs other than for very basic configurations. > > I have a POM that builds a command-line tool. I figured out how to use the > assembly plugin to build a self-contained jar, but now I need to be able to > run a series of test cases using that jar and a custom shell script to invoke > it. I have several questions: > > 1) Where do I put my custom shell script in the hierarchy? I've put the > source into src/main/bin for now. MG>anywhere you want to as long as you chmod +execute for that folder > 2) For testing I'd like to copy the shell script and self-contained jar > (jar-with-dependencies) to a test directory (similar to test-classes) and run > the jar from there. How do I do that? MG>generally in process-resources phase e.g. <build> <plugins> <plugin> <groupId>Plugin-groupId></plugin> <artifactId>plugin-artifactId</artifactId> <version>plugin-version</version> <executions> <execution> <id>process-resources</id> <phase>process-resources</phase> <configuration> <tasks> <tstamp> <format property="build.time" pattern="MMM dd, yyyy (hh:mm:ss z)" locale="en" /> </tstamp> <copy toDir="${basedir}/target/classes/" overwrite="true" filtering="on"> <!-- this will only include files with the xsl extension from ${basedir}/src --> <fileset dir="${basedir}/src/" includes="**/*.xsl" /> </copy> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build> > 3) The command-line tool analyzes compiled Java code from a jar and builds an > XML file from the analysis. What I'd like to do for my test cases is compile > a bunch of different tests into different jars, then for each jar run the > tool over it, generating an XML file, and do a diff on the XML file against > expected output. How do I do that? MG>cygwin has a nice diff tool which you can use MG>C:\maven-plugin\axis2-aar-maven-plugin\src\modules\codegen>diff --help MG>Usage: diff [OPTION]... FILES MG>-r for recursive MG>FILES are `FILE1 FILE2' or `DIR1 DIR2' or `DIR FILE...' or `FILE... DIR'. MG>If --from-file or --to-file is given, there are no restrictions on FILES. MG>If a FILE is `-', read standard input. MG>Exit status is 0 if inputs are the same, 1 if different, 2 if trouble. MG>you can use the maven-antrun-plugin and inside build.xml have a default target which runs MG>exec diff FILE1 FILE2 > 3a) Alternatively I could write a test application that used Runtime.exec() > to run the tool for each test case, then read in the resulting XML files > using an XML parser and made a bunch of assertions about each file, but > frankly I'd rather avoid writing the extra code. If I need to, however, how > would I do that? MG>maven-antrun-plugin and inside build.xml have a target which runs MG>"java -jar WhateverNameOfJarFile < input" > > I don't necessarily need the actual POMs written for me; pointers to more > complete samples doing similar tasks would be fine. Thanks in advance. > -- > Rick Genter > [email protected] > > > > ******************************************************************************* > This e-mail and any of its attachments may contain Interactions Corporation > proprietary information, which is privileged, confidential, or subject to > copyright belonging to the Interactions Corporation. This e-mail is intended > solely for the use of the individual or entity to which it is addressed. If > you > are not the intended recipient of this e-mail, you are hereby notified that > any > dissemination, distribution, copying, or action taken in relation to the > contents of and attachments to this e-mail is strictly prohibited and may be > unlawful. If you have received this e-mail in error, please notify the sender > immediately and permanently delete the original and any copy of this e-mail > and > any printout. Thank You. > ******************************************************************************* > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] >
