tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r411856 - /tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java
Date Mon, 05 Jun 2006 16:55:00 GMT
Author: hlship
Date: Mon Jun  5 09:54:59 2006
New Revision: 411856

URL: http://svn.apache.org/viewvc?rev=411856&view=rev
Log:
Make the touch() method wait until a real timestamp change is observed (needed for faster
machines).

Modified:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java?rev=411856&r1=411855&r2=411856&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java
Mon Jun  5 09:54:59 2006
@@ -15,9 +15,7 @@
 package org.apache.tapestry.test;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
-import java.io.IOException;
 import java.io.OutputStream;
 import java.lang.annotation.Annotation;
 import java.net.MalformedURLException;
@@ -28,13 +26,13 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.hivemind.Resource;
-import org.apache.hivemind.util.ClasspathResource;
 import org.apache.tapestry.internal.InternalComponentResources;
 import org.apache.tapestry.internal.annotations.SuppressNullCheck;
 import org.apache.tapestry.internal.parser.ComponentTemplate;
 import org.apache.tapestry.model.MutableComponentModel;
 import org.apache.tapestry.transform.ClassTransformation;
 
+import static java.lang.Thread.sleep;
 import static org.apache.tapestry.util.CollectionFactory.newList;
 
 /**
@@ -101,14 +99,26 @@
         setReturnValue(fieldNames);
     }
 
-
-
     /** Writes a change to a file. */
-    protected final void touch(File f) throws FileNotFoundException, IOException
+    protected final void touch(File f) throws Exception
     {
-        OutputStream o = new FileOutputStream(f);
-        o.write(0);
-        o.close();
+        long startModified = f.lastModified();
+
+        while (true)
+        {
+            OutputStream o = new FileOutputStream(f);
+            o.write(0);
+            o.close();
+
+            long newModified = f.lastModified();
+
+            if (newModified != startModified)
+                return;
+
+            // Sleep 1/4 second and try again
+
+            sleep(250);
+        }
     }
 
     /**
@@ -117,12 +127,13 @@
      * 
      * @see #createClasspathRoot()
      */
-    protected final URLClassLoader newLoaderWithClasspathRoot(File rootDir) throws MalformedURLException
+    protected final URLClassLoader newLoaderWithClasspathRoot(File rootDir)
+            throws MalformedURLException
     {
         String urlPath = rootDir.toURL().toString();
         // URLs for folders must end with a slash to make URLClassLoader happy.
         URL url = new URL(urlPath + "/");
-    
+
         return new URLClassLoader(new URL[]
         { url }, Thread.currentThread().getContextClassLoader());
     }
@@ -136,7 +147,7 @@
     {
         String temp = System.getProperty("java.io.tmpdir");
         String rootDirPath = temp + "/" + UUID.randomUUID().toString();
-    
+
         return new File(rootDirPath);
     }
 



Mime
View raw message