camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r807183 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/converter/stream/ test/java/org/apache/camel/component/file/strategy/ test/java/org/apache/camel/converter/stream/ test/java/org/apache/camel/processor/
Date Mon, 24 Aug 2009 12:27:29 GMT
Author: ningjiang
Date: Mon Aug 24 12:27:28 2009
New Revision: 807183

URL: http://svn.apache.org/viewvc?rev=807183&view=rev
Log:
CAMEL-1924 fixed unit test errors of camel-core on windows box

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategyTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/converter/stream/CachedOutputStreamTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceWithEndTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java?rev=807183&r1=807182&r2=807183&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java
Mon Aug 24 12:27:28 2009
@@ -72,6 +72,8 @@
                 try {
                     // cleanup temporary file
                     if (tempFile != null) {
+                        // close the stream first and than delete the file
+                        close();
                         boolean deleted = tempFile.delete();
                         if (!deleted) {
                             LOG.warn("Cannot delete temporary cache file: " + tempFile);

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategyTest.java?rev=807183&r1=807182&r2=807183&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategyTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategyTest.java
Mon Aug 24 12:27:28 2009
@@ -24,6 +24,7 @@
 import org.apache.camel.component.file.GenericFileEndpoint;
 import org.apache.camel.component.file.GenericFileOperationFailedException;
 import org.apache.camel.component.file.GenericFileOperations;
+import org.apache.camel.util.FileUtil;
 
 /**
  * Unit test about retrying deleting processed file, that can be a bit more tricky
@@ -49,8 +50,8 @@
 
         public boolean existsFile(String name) throws GenericFileOperationFailedException
{
             existsCounter++;
-
-            if ("target/foo/boom.txt".equals(name)) {
+            // The file name should be normalized
+            if (FileUtil.normalizePath("target/foo/boom.txt").equals(name)) {
                 // test that we can newer delete this file
                 return true;
             }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/stream/CachedOutputStreamTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/stream/CachedOutputStreamTest.java?rev=807183&r1=807182&r2=807183&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/converter/stream/CachedOutputStreamTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/converter/stream/CachedOutputStreamTest.java
Mon Aug 24 12:27:28 2009
@@ -109,10 +109,13 @@
         cache.reset();
         temp = toString((InputStream)cache);
         assertEquals("Cached a wrong file", temp, TEST_STRING);
-        
+        // windows can't delet the file which is open , so we close the stream first
+        if (System.getProperty("os.name").startsWith("Windows")) {
+            ((InputStream)cache).close();
+        }
         exchange.getUnitOfWork().done(exchange);
-
         ((InputStream)cache).close();
+        
         files = file.list();
         assertEquals("we should have no temp file", files.length, 0);       
     }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceWithEndTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceWithEndTest.java?rev=807183&r1=807182&r2=807183&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceWithEndTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceWithEndTest.java
Mon Aug 24 12:27:28 2009
@@ -21,6 +21,7 @@
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Navigate;
 import org.apache.camel.Processor;
+import org.apache.camel.Route;
 import org.apache.camel.builder.RouteBuilder;
 
 /**
@@ -30,7 +31,7 @@
 
     public void testRouteIsCorrectAtRuntime() throws Exception {
         // use navigate to find that the end works as expected
-        Navigate<Processor> nav = context.getRoutes().get(0).navigate();
+        Navigate<Processor> nav = getRoute("direct://start").navigate();
         List<Processor> node = nav.next();
         node = ((Navigate) node.get(0)).next();
 
@@ -44,6 +45,18 @@
         assertIsInstanceOf(TransformProcessor.class, unwrapChannel(node.get(2)).getNextProcessor());
         assertIsInstanceOf(SendProcessor.class, unwrapChannel(node.get(3)).getNextProcessor());
     }
+    
+    private Route getRoute(String routeEndpointURI) {
+        Route answer = null;
+        for (Route route : context.getRoutes()) {
+            if (routeEndpointURI.equals(route.getEndpoint().getEndpointUri())) {
+                answer = route;
+                break;
+            }
+        }
+        return answer;
+        
+    }
 
     public void testChoiceHello() throws Exception {
         getMockEndpoint("mock:start").expectedBodiesReceived("Hello World");



Mime
View raw message