Skip to content
Permalink
Browse files
FLUME-3218 fixing executable permission in test case in a more portab…
… way

This closes #199

Reviewers: Denes Arvay

(Ferenc Szabo via Ferenc Szabo)
  • Loading branch information
szaboferee committed Feb 23, 2018
1 parent beb11e5 commit d1f24f56ce9714bb3e1edc671da290c75a17dead
Showing 2 changed files with 6 additions and 43 deletions.
@@ -44,46 +44,4 @@ limitations under the License.
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<!-- workaround fro test resource permission errors -->
<profile>
<id>unix</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>fix-resource-permissions</id>
<goals>
<goal>exec</goal>
</goals>
<phase>process-test-resources</phase>
<configuration>
<executable>/bin/sh</executable>
<arguments>
<argument>-c</argument>
<argument>
set -x

SRC="${basedir}/src/test/resources"
DST="${project.build.directory}/test-classes"

find "$$SRC" -printf "%P\0" | xargs -0 -I {} chmod --reference="$$SRC/{}" -f "$$DST/{}"
</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
@@ -22,6 +22,7 @@
import org.junit.Before;
import org.junit.Test;

import java.io.File;
import java.util.HashMap;

import static org.junit.Assert.assertEquals;
@@ -45,20 +46,24 @@ public void filterOk() {
String file = Thread.currentThread().getContextClassLoader()
.getResource("test.sh").getFile();

File testExecutable = new File(file);
testExecutable.setExecutable(true);

HashMap<String, String> configuration = new HashMap<>();
configuration.put("command", file);
configFilter.initializeWithConfiguration(configuration);
assertEquals(FILTERED, configFilter.filter(MY_PASSWORD_KEY));
assertEquals(FILTERED_2, configFilter.filter(MY_PASSWORD_KEY_2));

}

@Test
public void filterError() {
String file = Thread.currentThread().getContextClassLoader()
.getResource("test_error.sh").getFile();

File testExecutable = new File(file);
testExecutable.setExecutable(true);

HashMap<String, String> configuration = new HashMap<>();
configuration.put("command", file);
configFilter.initializeWithConfiguration(configuration);

0 comments on commit d1f24f5

Please sign in to comment.