neat, do you have a pointer for me where I can copy&paste that stuff from? :) (as an excuse: I'm a long time testng user and didn't use junit-4 much yet)
LieGrue, strub --- On Sat, 8/6/11, Stephen Connolly <[email protected]> wrote: > From: Stephen Connolly <[email protected]> > Subject: Re: svn commit: r1154513 - > /maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/ExpandTest.java > To: [email protected] > Cc: [email protected] > Date: Saturday, August 6, 2011, 2:08 PM > fyi there is a handy temporary folder > rule in junit. > > - Stephen > > --- > Sent from my Android phone, so random spelling mistakes, > random nonsense > words and other nonsense are a direct result of using swype > to type on the > screen > On 6 Aug 2011 14:13, <[email protected]> > wrote: > > Author: struberg > > Date: Sat Aug 6 13:12:37 2011 > > New Revision: 1154513 > > > > URL: http://svn.apache.org/viewvc?rev=1154513&view=rev > > Log: > > MSANDBOX-51 ExpandTest continued > > > > Modified: > > > maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/ExpandTest.java > > > > Modified: > maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/ExpandTest.java > > URL: > http://svn.apache.org/viewvc/maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/ExpandTest.java?rev=1154513&r1=1154512&r2=1154513&view=diff > > > ============================================================================== > > --- > maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/ExpandTest.java > (original) > > +++ > maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/ExpandTest.java > Sat Aug 6 13:12:37 2011 > > @@ -25,6 +25,7 @@ import org.junit.Test; > > import org.junit.Assert; > > > > import java.io.File; > > +import java.io.FileNotFoundException; > > import java.io.IOException; > > import java.net.URL; > > import java.util.logging.Logger; > > @@ -117,11 +118,58 @@ public class ExpandTest extends > Assert > > > > expand.execute(); > > > > - verifyExpandedContent( targetDir ); > > + verifyExpandedFileAndContent( targetDir, > TEST_UNZIPPED_CONTENT ); > > } > > > > + @Test > > + public void testExecuteIntoNonexistingDirectory() > throws Exception > > + { > > + Expand expand = new Expand(); > > + > > + File source = getSourceFile(); > > + expand.setSrc( source ); > > + > > + File nonexisingDir = new File( getTestTargetDir(), > "nonexisting_dir" ); > > + > > + if ( nonexisingDir.exists() ) > > + { > > + FileUtils.deleteDirectory( nonexisingDir ); > > + } > > + > > + expand.setDest( nonexisingDir ); > > > > - private void verifyExpandedContent( File targetDir > ) > > + expand.execute(); > > + > > + verifyExpandedFileAndContent( nonexisingDir, > TEST_UNZIPPED_CONTENT ); > > + } > > + > > + @Test > > + public void testExecuteNonexistingSource() throws > Exception > > + { > > + Expand expand = new Expand(); > > + > > + File nonexistingSource = new File( > "target/expand_test_target/nonexisting_source_file.nixda" > ); > > + expand.setSrc( nonexistingSource ); > > + > > + File targetDir = getTestTargetDir(); > > + expand.setDest( targetDir ); > > + > > + try > > + { > > + > > + expand.execute(); > > + fail( "expand with notexiting source must throw > Exception!" ); > > + } > > + catch ( Exception e ) > > + { > > + Throwable cause = ExceptionUtils.getCause( e ); > > + > > + assertTrue( "cause must be a FileNotFoundException", > cause instanceof > FileNotFoundException ); > > + } > > + > > + } > > + > > + private File verifyExpandedFile( File targetDir ) > > { > > assertThat( "target directory must exist" > > , targetDir.exists() > > @@ -132,7 +180,27 @@ public class ExpandTest extends > Assert > > assertThat( "expanded file must exist: " + > expandedFile.getAbsolutePath() > > , expandedFile.exists() > > , is( true) ); > > + > > + return expandedFile; > > + } > > + > > + private File verifyExpandedFileAndContent( File > targetDir, String > expectedContent ) > > + throws FileNotFoundException > > + { > > + File expandedFile = verifyExpandedFile( targetDir > ); > > + > > + assertNotNull(expandedFile); > > + > > + java.util.Scanner scanner = new java.util.Scanner( > expandedFile > ).useDelimiter("\n"); > > + String text = scanner.next(); > > + > > + assertThat( "expanded file content must match" > > + , text > > + , is( expectedContent) ); > > + > > + return expandedFile; > > } > > > > > > + > > } > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
