You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2006/11/07 01:56:20 UTC

svn commit: r471953 - in /tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry: integration/IntegrationTests.java internal/services/ComponentInstantiatorSourceImplTest.java

Author: hlship
Date: Mon Nov  6 16:56:20 2006
New Revision: 471953

URL: http://svn.apache.org/viewvc?view=rev&rev=471953
Log:
Changes to tests to operate properly under Mac OS X

Modified:
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImplTest.java

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?view=diff&rev=471953&r1=471952&r2=471953
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Mon Nov  6 16:56:20 2006
@@ -31,7 +31,8 @@
 { "integration" })
 public class IntegrationTests extends Assert
 {
-    private static final String BASE_URL = "http://localhost/";
+    private static final int JETTY_PORT = 9999;
+    private static final String BASE_URL = "http://localhost:9999/";
 
     /** 60 seconds */
     public static final String PAGE_LOAD_TIMEOUT = "600000";
@@ -45,14 +46,14 @@
     @BeforeClass
     public void startupBackground() throws Exception
     {
-        _jettyRunner = new JettyRunner("src/test/app1");
+        _jettyRunner = new JettyRunner("/", JETTY_PORT, "src/test/app1");
 
         _server = new SeleniumServer();
 
         _server.start();
 
         _selenium = new DefaultSelenium("localhost", SeleniumServer.DEFAULT_PORT, "*firefox",
-                "http://localhost");
+                BASE_URL);
 
         _selenium.start();
     }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImplTest.java?view=diff&rev=471953&r1=471952&r2=471953
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImplTest.java Mon Nov  6 16:56:20 2006
@@ -18,6 +18,7 @@
 import java.io.IOException;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.net.URLConnection;
 import java.util.UUID;
 
 import javassist.CannotCompileException;
@@ -47,8 +48,6 @@
  * Tests for {@link org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl}. Several
  * of these tests are more of the form of integration tests that instantiate the Tapestry IoC
  * Registry.
- * 
- * 
  */
 public class ComponentInstantiatorSourceImplTest extends InternalBaseTestCase
 {
@@ -67,6 +66,8 @@
 
     private ClassLoader _extraLoader;
 
+    private String _tempDir;
+
     @Test
     public void controlled_packages() throws Exception
     {
@@ -169,13 +170,20 @@
 
         assertEquals(named.getName(), "Original");
 
-        // Sometimes this code runs so fast that the updated file has the same timestamp as
-        // the original; this little blip seems to help. Fortunately, we now run tests in
-        // parallel.
+        String path = _tempDir + "/" + SYNTH_COMPONENT_CLASSNAME.replace('.', '/') + ".class";
+        URL url = new File(path).toURL();
 
-        Thread.sleep(250);
+        long dtm = readDTM(url);
 
-        createSynthComponentClass("Updated");
+        while (true)
+        {
+            if (readDTM(url) != dtm)
+                break;
+            
+            // Keep re-writing the file until we see the DTM change.
+            
+            createSynthComponentClass("Updated");
+        }
 
         // Detect the change and clear out the internal caches
 
@@ -192,6 +200,15 @@
         assertEquals(named.getName(), "Updated");
     }
 
+    private long readDTM(URL url) throws Exception
+    {
+        URLConnection connection = url.openConnection();
+
+        connection.connect();
+
+        return connection.getLastModified();
+    }
+
     private void createSynthComponentClass(String name) throws CannotCompileException,
             NotFoundException, IOException
     {
@@ -247,7 +264,8 @@
         String tempdir = System.getProperty("java.io.tmpdir");
         String uid = UUID.randomUUID().toString();
 
-        _extraClasspath = new File(tempdir + "/" + uid);
+        _tempDir = tempdir + "/" + uid;
+        _extraClasspath = new File(_tempDir);
 
         System.out.println("Creating dir: " + _extraClasspath);