You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2012/11/12 13:50:02 UTC

svn commit: r1408269 - in /camel/trunk/camel-core/src/test/java/org/apache/camel: management/JmxInstrumentationWithConnectorTest.java processor/FileRollbackOnCompletionTest.java

Author: davsclaus
Date: Mon Nov 12 12:50:01 2012
New Revision: 1408269

URL: http://svn.apache.org/viewvc?rev=1408269&view=rev
Log:
Fixed tests

Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationWithConnectorTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FileRollbackOnCompletionTest.java

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationWithConnectorTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationWithConnectorTest.java?rev=1408269&r1=1408268&r2=1408269&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationWithConnectorTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationWithConnectorTest.java Mon Nov 12 12:50:01 2012
@@ -42,9 +42,14 @@ public class JmxInstrumentationWithConne
     @Override
     protected boolean canRunOnThisPlatform() {
         String os = System.getProperty("os.name");
+        boolean aix = os.toLowerCase(Locale.ENGLISH).contains("aix");
+        boolean windows = os.toLowerCase(Locale.ENGLISH).contains("windows");
+
         // Does not work on AIX and the problem is hard to identify, could be issues not allowing to use a custom port
         // java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.NameNotFoundException: jmxrmi/camel
-        return !os.toLowerCase(Locale.ENGLISH).contains("aix");
+
+        // windows CI servers is often slow/tricky so skip as well
+        return !aix && !windows;
     }
 
     @Override

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FileRollbackOnCompletionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FileRollbackOnCompletionTest.java?rev=1408269&r1=1408268&r2=1408269&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FileRollbackOnCompletionTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FileRollbackOnCompletionTest.java Mon Nov 12 12:50:01 2012
@@ -17,6 +17,8 @@
 package org.apache.camel.processor;
 
 import java.io.File;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.ContextTestSupport;
@@ -31,6 +33,8 @@ import org.apache.camel.util.FileUtil;
  */
 public class FileRollbackOnCompletionTest extends ContextTestSupport {
 
+    private static final CountDownLatch LATCH = new CountDownLatch(1);
+
     public static final class FileRollback implements Synchronization {
 
         public void onComplete(Exchange exchange) {
@@ -41,6 +45,9 @@ public class FileRollbackOnCompletionTes
             // delete the file
             String name = exchange.getIn().getHeader(Exchange.FILE_NAME_PRODUCED, String.class);
             FileUtil.deleteFile(new File(name));
+
+            // signal we have deleted the file
+            LATCH.countDown();
         }
 
     }
@@ -56,13 +63,6 @@ public class FileRollbackOnCompletionTes
             if (to.equals("FATAL")) {
                 throw new IllegalArgumentException("Simulated fatal error");
             }
-
-            // simulate CPU processing of the order by sleeping a bit
-            try {
-                Thread.sleep(250);
-            } catch (InterruptedException e) {
-                // ignore
-            }
         }
 
     }
@@ -93,7 +93,7 @@ public class FileRollbackOnCompletionTes
         oneExchangeDone.matchesMockWaitTime();
 
         // onCompletion is async so we gotta wait a bit for the file to be deleted
-        Thread.sleep(250);
+        assertTrue("Should countdown the latch", LATCH.await(5, TimeUnit.SECONDS));
 
         File file = new File("target/mail/backup/");
         String[] files = file.list();