You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by st...@apache.org on 2011/08/06 15:12:37 UTC

svn commit: r1154513 - /maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/ExpandTest.java

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;
     }
 
 
+
 }



Re: svn commit: r1154513 - /maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/ExpandTest.java

Posted by Stephen Connolly <st...@gmail.com>.
- 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, <st...@apache.org> 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;
> }
>
>
> +
> }
>
>

Re: svn commit: r1154513 - /maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/ExpandTest.java

Posted by Markku Saarela <ma...@iki.fi>.
https://garygregory.wordpress.com/2010/01/20/junit-tip-use-rules-to-manage-temporary-files-and-folders/

Markku

On 6.8.2011 17:20, Stephen Connolly wrote:
> i am on a phone... sorry put of luck :-P
>
> - 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 15:15, "Mark Struberg"<st...@yahoo.de>  wrote:
>> 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<st...@gmail.com>
> wrote:
>>> From: Stephen Connolly<st...@gmail.com>
>>> 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: dev@maven.apache.org
>>> Cc: commits@maven.apache.org
>>> 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,<st...@apache.org>
>>> 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: dev-unsubscribe@maven.apache.org
>> For additional commands, e-mail: dev-help@maven.apache.org
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: svn commit: r1154513 - /maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/ExpandTest.java

Posted by Stephen Connolly <st...@gmail.com>.
i am on a phone... sorry put of luck :-P

- 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 15:15, "Mark Struberg" <st...@yahoo.de> wrote:
> 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 <st...@gmail.com>
wrote:
>
>> From: Stephen Connolly <st...@gmail.com>
>> 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: dev@maven.apache.org
>> Cc: commits@maven.apache.org
>> 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, <st...@apache.org>
>> 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: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>

Re: svn commit: r1154513 - /maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/ExpandTest.java

Posted by Mark Struberg <st...@yahoo.de>.
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 <st...@gmail.com> wrote:

> From: Stephen Connolly <st...@gmail.com>
> 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: dev@maven.apache.org
> Cc: commits@maven.apache.org
> 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, <st...@apache.org>
> 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: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: svn commit: r1154513 - /maven/sandbox/trunk/plexus-utils-commons-bridge/plexus-utils-tck/src/test/java/org/codehaus/plexus/util/ExpandTest.java

Posted by Stephen Connolly <st...@gmail.com>.
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, <st...@apache.org> 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;
> }
>
>
> +
> }
>
>