This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit c383b69b56d0f70a2a8358091cd776c20ddb2f7f Author: Claus Ibsen <[email protected]> AuthorDate: Tue May 28 05:45:17 2019 +0200 CAMEL-13483: Fixed CS --- .../apache/camel/component/file/FileEndpoint.java | 8 +-- .../camel/component/file/GenericFileEndpoint.java | 16 +++--- ...onsumerStartingDirectoryMustHaveAccessTest.java | 59 +++++++++++----------- 3 files changed, 42 insertions(+), 41 deletions(-) diff --git a/components/camel-file/src/main/java/org/apache/camel/component/file/FileEndpoint.java b/components/camel-file/src/main/java/org/apache/camel/component/file/FileEndpoint.java index 23e5eda..63af76d 100644 --- a/components/camel-file/src/main/java/org/apache/camel/component/file/FileEndpoint.java +++ b/components/camel-file/src/main/java/org/apache/camel/component/file/FileEndpoint.java @@ -93,11 +93,11 @@ public class FileEndpoint extends GenericFileEndpoint<File> { } } if (!isStartingDirectoryMustExist() && isStartingDirectoryMustHaveAccess()) { - throw new IllegalArgumentException("You cannot set startingDirectoryMustHaveAccess=true without setting startingDirectoryMustExist=true"); + throw new IllegalArgumentException("You cannot set startingDirectoryMustHaveAccess=true without setting startingDirectoryMustExist=true"); } else if (isStartingDirectoryMustExist() && isStartingDirectoryMustHaveAccess()) { - if (!file.canRead() || !file.canWrite()) { - throw new IOException("Starting directory permission denied: " + file); - } + if (!file.canRead() || !file.canWrite()) { + throw new IOException("Starting directory permission denied: " + file); + } } FileConsumer result = newFileConsumer(processor, operations); diff --git a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java index 7f19cfd..62c39bd 100644 --- a/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java +++ b/components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java @@ -1125,17 +1125,17 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple } public boolean isStartingDirectoryMustHaveAccess() { - return startingDirectoryMustHaveAccess; + return startingDirectoryMustHaveAccess; } - /** - * Whether the starting directory has access permissions. Mind that the - * startingDirectoryMustExist parameter must be set to true in order to verify that the - * directory exists. Will thrown an exception if the directory doesn't have - * read and write permissions. - */ + /** + * Whether the starting directory has access permissions. Mind that the + * startingDirectoryMustExist parameter must be set to true in order to verify that the + * directory exists. Will thrown an exception if the directory doesn't have + * read and write permissions. + */ public void setStartingDirectoryMustHaveAccess(boolean startingDirectoryMustHaveAccess) { - this.startingDirectoryMustHaveAccess = startingDirectoryMustHaveAccess; + this.startingDirectoryMustHaveAccess = startingDirectoryMustHaveAccess; } public boolean isDirectoryMustExist() { diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerStartingDirectoryMustHaveAccessTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerStartingDirectoryMustHaveAccessTest.java index 3e66a6f..92c04b0 100644 --- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerStartingDirectoryMustHaveAccessTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerStartingDirectoryMustHaveAccessTest.java @@ -18,6 +18,7 @@ package org.apache.camel.component.file; import java.io.File; import java.io.IOException; + import org.apache.camel.ContextTestSupport; import org.apache.camel.Endpoint; import org.apache.camel.Exchange; @@ -26,39 +27,39 @@ import org.junit.Test; public class FileConsumerStartingDirectoryMustHaveAccessTest extends ContextTestSupport { - @Override - public void setUp() throws Exception { - File file1 = new File("./target/noAccess"); - if (file1.exists()) { - file1.setReadable(true); + @Override + public void setUp() throws Exception { + File file1 = new File("./target/noAccess"); + if (file1.exists()) { + file1.setReadable(true); + } + deleteDirectory("target/noAccess"); + file1.mkdirs(); + file1.setReadable(false); + super.setUp(); } - deleteDirectory("target/noAccess"); - file1.mkdirs(); - file1.setReadable(false); - super.setUp(); - } - @Override - public void tearDown() throws Exception { - File file1 = new File("./target/noAccess"); - if (file1.exists()) { - file1.setReadable(true); + @Override + public void tearDown() throws Exception { + File file1 = new File("./target/noAccess"); + if (file1.exists()) { + file1.setReadable(true); + } + super.tearDown(); } - super.tearDown(); - } - @Test - public void testStartingDirectoryMustHaveAccess() throws Exception { - Endpoint endpoint = context.getEndpoint("file://target/noAccess?autoCreate=false&startingDirectoryMustExist=true&startingDirectoryMustHaveAccess=true"); - try { - endpoint.createConsumer(new Processor() { - public void process(Exchange exchange) throws Exception { - // noop + @Test + public void testStartingDirectoryMustHaveAccess() throws Exception { + Endpoint endpoint = context.getEndpoint("file://target/noAccess?autoCreate=false&startingDirectoryMustExist=true&startingDirectoryMustHaveAccess=true"); + try { + endpoint.createConsumer(new Processor() { + public void process(Exchange exchange) throws Exception { + // noop + } + }); + fail("Should have thrown an exception"); + } catch (IOException e) { + assertTrue(e.getMessage().startsWith("Starting directory permission denied")); } - }); - fail("Should have thrown an exception"); - } catch (IOException e) { - assertTrue(e.getMessage().startsWith("Starting directory permission denied")); } - } }
