Skip to content

Commit e4c8c60

Browse files
committed
Sort members
1 parent 9a7e27a commit e4c8c60

3 files changed

Lines changed: 99 additions & 99 deletions

File tree

src/main/java/org/apache/commons/exec/TimeoutObserver.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@
2828
*/
2929
public interface TimeoutObserver extends Consumer<Watchdog> {
3030

31-
/**
32-
* Called when the watchdog times out.
33-
*
34-
* @param w the watchdog that timed out.
35-
*/
36-
void timeoutOccured(Watchdog w);
37-
3831
/**
3932
* {@inheritDoc}
4033
*
@@ -44,4 +37,11 @@ public interface TimeoutObserver extends Consumer<Watchdog> {
4437
default void accept(final Watchdog w) {
4538
timeoutOccured(w);
4639
}
40+
41+
/**
42+
* Called when the watchdog times out.
43+
*
44+
* @param w the watchdog that timed out.
45+
*/
46+
void timeoutOccured(Watchdog w);
4747
}

src/test/java/org/apache/commons/exec/DefaultExecutorTest.java

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -92,42 +92,6 @@ public static void classSetUp() {
9292
private final Path environmentSript = TestUtil.resolveScriptPathForOS(testDir + "/environment");
9393
// private final File wrapperScript = TestUtil.resolveScriptForOS(testDir + "/wrapper");
9494

95-
/**
96-
* Start any processes in a loop to make sure that we do not leave any handles/resources open.
97-
*
98-
* @throws Exception the test failed
99-
*/
100-
@Test
101-
@Disabled
102-
void testExecuteStability() throws Exception {
103-
104-
// make a plain-vanilla test
105-
for (int i = 0; i < 100; i++) {
106-
final Map<String, String> env = new HashMap<>();
107-
env.put("TEST_ENV_VAR", Integer.toString(i));
108-
final CommandLine cl = new CommandLine(testScript);
109-
final int exitValue = exec.execute(cl, env);
110-
assertFalse(exec.isFailure(exitValue));
111-
assertEquals("FOO." + i + ".", baos.toString().trim());
112-
baos.reset();
113-
}
114-
115-
// now be nasty and use the watchdog to kill out sub-processes
116-
for (int i = 0; i < 100; i++) {
117-
final Map<String, String> env = new HashMap<>();
118-
env.put("TEST_ENV_VAR", Integer.toString(i));
119-
final DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
120-
final CommandLine cl = new CommandLine(foreverTestScript);
121-
final ExecuteWatchdog watchdog = new ExecuteWatchdog(500);
122-
exec.setWatchdog(watchdog);
123-
exec.execute(cl, env, resultHandler);
124-
resultHandler.waitFor(WAITFOR_TIMEOUT);
125-
assertTrue(resultHandler.hasResult(), "ResultHandler received a result");
126-
assertNotNull(resultHandler.getException());
127-
baos.reset();
128-
}
129-
}
130-
13195
private int getOccurrences(final String data, final char c) {
13296

13397
int result = 0;
@@ -419,6 +383,42 @@ void testExecuteNonExistingApplicationWithWatchDog() throws Exception {
419383
assertThrows(IOException.class, () -> executor.execute(cl));
420384
}
421385

386+
/**
387+
* Start any processes in a loop to make sure that we do not leave any handles/resources open.
388+
*
389+
* @throws Exception the test failed
390+
*/
391+
@Test
392+
@Disabled
393+
void testExecuteStability() throws Exception {
394+
395+
// make a plain-vanilla test
396+
for (int i = 0; i < 100; i++) {
397+
final Map<String, String> env = new HashMap<>();
398+
env.put("TEST_ENV_VAR", Integer.toString(i));
399+
final CommandLine cl = new CommandLine(testScript);
400+
final int exitValue = exec.execute(cl, env);
401+
assertFalse(exec.isFailure(exitValue));
402+
assertEquals("FOO." + i + ".", baos.toString().trim());
403+
baos.reset();
404+
}
405+
406+
// now be nasty and use the watchdog to kill out sub-processes
407+
for (int i = 0; i < 100; i++) {
408+
final Map<String, String> env = new HashMap<>();
409+
env.put("TEST_ENV_VAR", Integer.toString(i));
410+
final DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
411+
final CommandLine cl = new CommandLine(foreverTestScript);
412+
final ExecuteWatchdog watchdog = new ExecuteWatchdog(500);
413+
exec.setWatchdog(watchdog);
414+
exec.execute(cl, env, resultHandler);
415+
resultHandler.waitFor(WAITFOR_TIMEOUT);
416+
assertTrue(resultHandler.hasResult(), "ResultHandler received a result");
417+
assertNotNull(resultHandler.getException());
418+
baos.reset();
419+
}
420+
}
421+
422422
/**
423423
* Start a script looping forever (asynchronously) and check if the ExecuteWatchdog kicks in killing the runaway process. To make killing a process more
424424
* testable the "forever" scripts write each second a '.' into "./target/forever.txt" (a marker file). After a test run we should have a few dots in there.

src/test/java/org/apache/commons/exec/issues/Exec36Test.java

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -51,62 +51,6 @@ class Exec36Test {
5151

5252
private ByteArrayOutputStream baos;
5353

54-
/**
55-
* Some complex real-life command line from https://blogs.msdn.com/b/astebner/archive/2005/12/13/503471.aspx
56-
*/
57-
@Test
58-
@Disabled
59-
void testExec36Part4() throws Exception {
60-
CommandLine cmdl;
61-
final String line = "./script/jrake cruise:publish_installers INSTALLER_VERSION=unstable_2_1 "
62-
+ "INSTALLER_PATH=\"/var/lib/cruise-agent/installers\" INSTALLER_DOWNLOAD_SERVER='something'WITHOUT_HELP_DOC=true";
63-
cmdl = CommandLine.parse(line);
64-
final String[] args = cmdl.toStrings();
65-
assertEquals("./script/jrake", args[0]);
66-
assertEquals("cruise:publish_installers", args[1]);
67-
assertEquals("INSTALLER_VERSION=unstable_2_1", args[2]);
68-
assertEquals("INSTALLER_PATH=\"/var/lib/cruise-agent/installers\"", args[3]);
69-
assertEquals("INSTALLER_DOWNLOAD_SERVER='something'", args[4]);
70-
assertEquals("WITHOUT_HELP_DOC=true", args[5]);
71-
}
72-
73-
/**
74-
* Some complex real-life command line from https://blogs.msdn.com/b/astebner/archive/2005/12/13/503471.aspx
75-
*/
76-
@Test
77-
@Disabled
78-
void testExec36Part5() {
79-
80-
CommandLine cmdl;
81-
82-
final String line = "dotnetfx.exe /q:a "
83-
+ "/c:\"install.exe /l \"\"c:\\Documents and Settings\\myusername\\Local Settings\\Temp\\netfx.log\"\" /q\"";
84-
85-
cmdl = CommandLine.parse(line);
86-
final String[] args = cmdl.toStrings();
87-
assertEquals("dotnetfx.exe", args[0]);
88-
assertEquals("/q:a", args[1]);
89-
assertEquals("/c:\"install.exe /l \"\"c:\\Documents and Settings\\myusername\\Local Settings\\Temp\\netfx.log\"\" /q\"", args[2]);
90-
}
91-
92-
/**
93-
* Test the following command line
94-
*
95-
* C:\CVS_DB\WeightsEngine /f WeightsEngine.mak CFG="WeightsEngine - Win32Release"
96-
*/
97-
@Test
98-
@Disabled
99-
void testExec36Part6() {
100-
101-
final String commandLine = "C:\\CVS_DB\\WeightsEngine /f WeightsEngine.mak CFG=\"WeightsEngine - Win32Release\"";
102-
103-
final CommandLine cmdl = CommandLine.parse(commandLine);
104-
final String[] args = cmdl.getArguments();
105-
assertEquals("/f", args[0]);
106-
assertEquals("WeightsEngine.mak", args[1]);
107-
assertEquals("CFG=\"WeightsEngine - Win32Release\"", args[2]);
108-
}
109-
11054
@BeforeEach
11155
public void setUp() throws Exception {
11256
// prepare a ready to Executor
@@ -209,4 +153,60 @@ void testExec36Part2() throws Exception {
209153
assertEquals(expected, result);
210154
}
211155
}
156+
157+
/**
158+
* Some complex real-life command line from https://blogs.msdn.com/b/astebner/archive/2005/12/13/503471.aspx
159+
*/
160+
@Test
161+
@Disabled
162+
void testExec36Part4() throws Exception {
163+
CommandLine cmdl;
164+
final String line = "./script/jrake cruise:publish_installers INSTALLER_VERSION=unstable_2_1 "
165+
+ "INSTALLER_PATH=\"/var/lib/cruise-agent/installers\" INSTALLER_DOWNLOAD_SERVER='something'WITHOUT_HELP_DOC=true";
166+
cmdl = CommandLine.parse(line);
167+
final String[] args = cmdl.toStrings();
168+
assertEquals("./script/jrake", args[0]);
169+
assertEquals("cruise:publish_installers", args[1]);
170+
assertEquals("INSTALLER_VERSION=unstable_2_1", args[2]);
171+
assertEquals("INSTALLER_PATH=\"/var/lib/cruise-agent/installers\"", args[3]);
172+
assertEquals("INSTALLER_DOWNLOAD_SERVER='something'", args[4]);
173+
assertEquals("WITHOUT_HELP_DOC=true", args[5]);
174+
}
175+
176+
/**
177+
* Some complex real-life command line from https://blogs.msdn.com/b/astebner/archive/2005/12/13/503471.aspx
178+
*/
179+
@Test
180+
@Disabled
181+
void testExec36Part5() {
182+
183+
CommandLine cmdl;
184+
185+
final String line = "dotnetfx.exe /q:a "
186+
+ "/c:\"install.exe /l \"\"c:\\Documents and Settings\\myusername\\Local Settings\\Temp\\netfx.log\"\" /q\"";
187+
188+
cmdl = CommandLine.parse(line);
189+
final String[] args = cmdl.toStrings();
190+
assertEquals("dotnetfx.exe", args[0]);
191+
assertEquals("/q:a", args[1]);
192+
assertEquals("/c:\"install.exe /l \"\"c:\\Documents and Settings\\myusername\\Local Settings\\Temp\\netfx.log\"\" /q\"", args[2]);
193+
}
194+
195+
/**
196+
* Test the following command line
197+
*
198+
* C:\CVS_DB\WeightsEngine /f WeightsEngine.mak CFG="WeightsEngine - Win32Release"
199+
*/
200+
@Test
201+
@Disabled
202+
void testExec36Part6() {
203+
204+
final String commandLine = "C:\\CVS_DB\\WeightsEngine /f WeightsEngine.mak CFG=\"WeightsEngine - Win32Release\"";
205+
206+
final CommandLine cmdl = CommandLine.parse(commandLine);
207+
final String[] args = cmdl.getArguments();
208+
assertEquals("/f", args[0]);
209+
assertEquals("WeightsEngine.mak", args[1]);
210+
assertEquals("CFG=\"WeightsEngine - Win32Release\"", args[2]);
211+
}
212212
}

0 commit comments

Comments
 (0)