You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Daniel Kulp <dk...@apache.org> on 2008/12/05 17:54:47 UTC

Re: svn commit: r723778 - in /cxf/trunk/common/common/src: main/java/org/apache/cxf/helpers/FileUtils.java test/java/org/apache/cxf/helpers/FileUtilsTest.java

Sean,


On Friday 05 December 2008 11:02:52 am seanoc@apache.org wrote:
> +public class FileUtilsTest extends Assert {
> +
> +
> +    @Test
> +    public void testTempIODirExists() throws Exception {
> +
> +        try {
> +            System.setProperty("java.io.tmpdir", "dummy");
> +            FileUtils.createTempFile("foo", "bar");
> +        } catch (RuntimeException e) {
> +            assertTrue(e.toString().contains("please set java.io.tempdir
> to an existing directory")); +        }
> +    }
> +}

Most likely, you should get the original java.io.tmpdir value and restore it 
in a finally block.   I'm not sure what would happen if your test runs before 
other tests as the tmpdir value would then point to a non-existent location.   
Restoring it to the previous value should prevent any strange issues.


-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

RE: svn commit: r723778 - in /cxf/trunk/common/common/src: main/java/org/apache/cxf/helpers/FileUtils.java test/java/org/apache/cxf/helpers/FileUtilsTest.java

Posted by Sean O'Callaghan <SE...@progress.com>.
Good point Dan, will do so.
thanks,

Seán.



> -----Original Message-----
> From: Daniel Kulp [mailto:dkulp@apache.org]
> Sent: 05 December 2008 16:55
> To: dev@cxf.apache.org
> Cc: Sean O'Callaghan
> Subject: Re: svn commit: r723778 - in /cxf/trunk/common/common/src:
> main/java/org/apache/cxf/helpers/FileUtils.java
> test/java/org/apache/cxf/helpers/FileUtilsTest.java
> 
> 
> 
> Sean,
> 
> 
> On Friday 05 December 2008 11:02:52 am seanoc@apache.org wrote:
> > +public class FileUtilsTest extends Assert {
> > +
> > +
> > +    @Test
> > +    public void testTempIODirExists() throws Exception {
> > +
> > +        try {
> > +            System.setProperty("java.io.tmpdir", "dummy");
> > +            FileUtils.createTempFile("foo", "bar");
> > +        } catch (RuntimeException e) {
> > +            assertTrue(e.toString().contains("please set 
> java.io.tempdir
> > to an existing directory")); +        }
> > +    }
> > +}
> 
> Most likely, you should get the original java.io.tmpdir value 
> and restore it 
> in a finally block.   I'm not sure what would happen if your 
> test runs before 
> other tests as the tmpdir value would then point to a 
> non-existent location.   
> Restoring it to the previous value should prevent any strange issues.
> 
> 
> -- 
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
>