diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/FileOutboundChannelAdapterIntegrationTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/FileOutboundChannelAdapterIntegrationTests.java index 28afc8a1fb..6ae45039b7 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/FileOutboundChannelAdapterIntegrationTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/FileOutboundChannelAdapterIntegrationTests.java @@ -30,12 +30,14 @@ import org.springframework.integration.Message; import org.springframework.integration.MessageChannel; import org.springframework.integration.MessageHandlingException; import org.springframework.integration.support.MessageBuilder; +import org.springframework.integration.test.util.TestUtils; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.util.FileCopyUtils; /** * @author Gunnar Hillert + * @author Artem Bilan */ @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) @@ -43,7 +45,7 @@ public class FileOutboundChannelAdapterIntegrationTests { static final String DEFAULT_ENCODING = "UTF-8"; - static final String SAMPLE_CONTENT = "HelloWorld\nŠšŸ§"; + static final String SAMPLE_CONTENT = "HelloWorld"; static File workDir; @@ -118,7 +120,9 @@ public class FileOutboundChannelAdapterIntegrationTests { try { this.inputChannelSaveToSubDirWrongExpression.send(message); } catch (MessageHandlingException e) { - Assert.assertEquals("Destination path [target/base-directory/sub-directory/foo.txt] does not point to a directory.", e.getCause().getMessage()); + Assert.assertEquals( + TestUtils.applySystemFileSeparator("Destination path [target/base-directory/sub-directory/foo.txt] does not point to a directory."), + e.getCause().getMessage()); return; } @@ -155,7 +159,9 @@ public class FileOutboundChannelAdapterIntegrationTests { try { this.inputChannelSaveToSubDirAutoCreateOff.send(message); } catch (MessageHandlingException e) { - Assert.assertEquals("Destination directory [target/base-directory2/sub-directory2] does not exist.", e.getCause().getMessage()); + Assert.assertEquals( + TestUtils.applySystemFileSeparator("Destination directory [target/base-directory2/sub-directory2] does not exist."), + e.getCause().getMessage()); return; } @@ -215,4 +221,5 @@ public class FileOutboundChannelAdapterIntegrationTests { Assert.fail("Was expecting a MessageHandlingException to be thrown"); } -} \ No newline at end of file + +} diff --git a/spring-integration-test/src/main/java/org/springframework/integration/test/util/TestUtils.java b/spring-integration-test/src/main/java/org/springframework/integration/test/util/TestUtils.java index 02987c6263..c36e1a210c 100644 --- a/spring-integration-test/src/main/java/org/springframework/integration/test/util/TestUtils.java +++ b/spring-integration-test/src/main/java/org/springframework/integration/test/util/TestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package org.springframework.integration.test.util; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; +import java.io.File; import java.util.Properties; import java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy; @@ -52,6 +53,7 @@ import org.springframework.util.StringUtils; * @author Mark Fisher * @author Iwein Fuld * @author Oleg Zhurakousky + * @author Artem Bilan */ public abstract class TestUtils { @@ -169,4 +171,13 @@ public abstract class TestUtils { } return component; } + + /** + * Update file path by replacing any '/' with the system's file separator. + * @param s The file path containing '/'. + * @return The updated file path (if necessary). + */ + public static String applySystemFileSeparator(String s) { + return s.replaceAll("/", java.util.regex.Matcher.quoteReplacement(File.separator)); + } }