1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package eu.simuline.m2latex.core;
20
21 import eu.simuline.m2latex.mojo.MavenLogWrapper;
22 import java.io.File;
23 import java.io.IOException;
24
25 import junit.framework.TestCase;
26
27 import org.apache.maven.plugin.logging.SystemStreamLog;
28
29 import static org.junit.Assert.assertEquals;
30
31 import org.junit.Test;
32 import org.junit.Ignore;
33 import org.junit.Before;
34 import org.junit.After;
35
36 public class CommandExecutorTest {
37 private final static File WORKING_DIR =
38 new File(System.getProperty("testResourcesDir"));
39
40
41
42 private static void cleanWorkingDir() {
43 assert WORKING_DIR.isDirectory() : "Expected directory. ";
44 File[] files = WORKING_DIR.listFiles();
45 assert files != null : "Working directory is not readable. ";
46 for (File file : files) {
47 if (!file.isHidden()) {
48 file.delete();
49 }
50 }
51 }
52
53 @Before public void setUp() throws IOException {
54 cleanWorkingDir();
55 }
56
57 @After public void tearDown() throws IOException {
58 cleanWorkingDir();
59 }
60
61 @Test public void testExecute() throws BuildFailureException {
62 CommandExecutor executor =
63 new CommandExecutor(new MavenLogWrapper(new SystemStreamLog()));
64 String touchFile = "cmdLineExe.touch";
65 String output = executor.execute(WORKING_DIR,
66 null,
67 "touch",
68 new String[] {touchFile},
69 new File(WORKING_DIR, touchFile));
70
71 }
72
73
74
75
76
77
78
79
80
81
82
83
84 }