This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit a4148675e309e18a3f2479c3bc7f0631c494c21a
Author: Anton Goncharov <[email protected]>
AuthorDate: Tue Nov 7 20:45:38 2023 +0100

     Fix TestSupport code that resolved fileUri and fix ResourceLoaderTest
---
 .../apache/camel/spring/file/SpringSimpleFileNameWithQuoteTest.java | 2 +-
 .../java/org/apache/camel/spring/processor/SpringTestHelper.java    | 2 +-
 core/camel-core/src/test/java/org/apache/camel/TestSupport.java     | 2 +-
 .../src/test/java/org/apache/camel/util/ResourceLoaderTest.java     | 6 +++---
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/components/camel-spring-xml/src/test/java/org/apache/camel/spring/file/SpringSimpleFileNameWithQuoteTest.java
 
b/components/camel-spring-xml/src/test/java/org/apache/camel/spring/file/SpringSimpleFileNameWithQuoteTest.java
index 9d7491ee4a1..6da35580391 100644
--- 
a/components/camel-spring-xml/src/test/java/org/apache/camel/spring/file/SpringSimpleFileNameWithQuoteTest.java
+++ 
b/components/camel-spring-xml/src/test/java/org/apache/camel/spring/file/SpringSimpleFileNameWithQuoteTest.java
@@ -46,7 +46,7 @@ public class SpringSimpleFileNameWithQuoteTest extends 
SpringRunWithTestSupport
         result.expectedBodiesReceived(expectedBody);
         result.expectedHeaderReceived("foo", "\"hello.txt\" abc");
 
-        template.sendBodyAndHeader(fileUri(), expectedBody, 
Exchange.FILE_NAME, "hello.txt");
+        template.sendBodyAndHeader(fileUri(tempDir, ""), expectedBody, 
Exchange.FILE_NAME, "hello.txt");
 
         result.assertIsSatisfied();
     }
diff --git 
a/components/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringTestHelper.java
 
b/components/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringTestHelper.java
index a57b10e124a..77966561679 100644
--- 
a/components/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringTestHelper.java
+++ 
b/components/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringTestHelper.java
@@ -48,7 +48,7 @@ public final class SpringTestHelper {
             DefaultCamelContext.setNoStart(true);
             applicationContext = new ClassPathXmlApplicationContext(new 
String[] { classpathUri }, false);
             applicationContext.getEnvironment().getSystemProperties().put(
-                PROPERTY_TEST_DIR, test.testDirectory().toString());
+                    PROPERTY_TEST_DIR, test.testDirectory().toString());
             applicationContext.refresh();
         } finally {
             DefaultCamelContext.setNoStart(isNoStart);
diff --git a/core/camel-core/src/test/java/org/apache/camel/TestSupport.java 
b/core/camel-core/src/test/java/org/apache/camel/TestSupport.java
index 29604c205f3..fc53971b7b3 100644
--- a/core/camel-core/src/test/java/org/apache/camel/TestSupport.java
+++ b/core/camel-core/src/test/java/org/apache/camel/TestSupport.java
@@ -125,7 +125,7 @@ public abstract class TestSupport {
     }
 
     protected String fileUri(Path directory, String query) {
-        return "file:" + directory + (query.startsWith("?") ? "" : "/") + 
query;
+        return "file:" + testDirectory().resolve(directory) + 
(query.startsWith("?") ? "" : "/") + query;
     }
 
     protected boolean canRunOnThisPlatform() {
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/util/ResourceLoaderTest.java 
b/core/camel-core/src/test/java/org/apache/camel/util/ResourceLoaderTest.java
index fc999690339..4ac6bc041ae 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/util/ResourceLoaderTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/util/ResourceLoaderTest.java
@@ -63,11 +63,11 @@ public class ResourceLoaderTest extends TestSupport {
     @Test
     public void testLoadFileWithSpace() throws Exception {
         testDirectory("target/data/my space", true);
-        copyFile(new File("src/test/resources/log4j2.properties"), new 
File("target/data/my space/log4j2.properties"));
+        copyFile(new File("src/test/resources/log4j2.properties"), 
testFile("target/data/my space/log4j2.properties").toFile());
 
         DefaultCamelContext context = new DefaultCamelContext();
-        Resource resource
-                = 
PluginHelper.getResourceLoader(context).resolveResource("file:target/data/my%20space/log4j2.properties");
+        Resource resource = 
PluginHelper.getResourceLoader(context).resolveResource(
+                "file:" + testDirectory().toString() + 
"/target/data/my%20space/log4j2.properties");
 
         try (InputStream is = resource.getInputStream()) {
             assertNotNull(is);

Reply via email to