This repository was archived by the owner on Sep 22, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed
src/test/java/ut/com/comsysto/poc/ao/service Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -36,18 +36,13 @@ public void getOwnersWhoHavePets() throws Exception {
36
36
//
37
37
38
38
protected static void setUpDockerContainer (String dockerRunCommand ) {
39
- CmdLineExecutionResult result = CmdLineTestHelper
40
- .executeCommand (dockerRunCommand );
41
- assertEquals (new Integer (0 ), result .exitCode );
42
- assertEquals (null , result .exception );
39
+ CmdLineTestHelper .executeAndFailIfNotValidStatusCode (dockerRunCommand , 0 );
43
40
}
44
41
45
42
protected static void tearDownDockerContainer (String dockerGetIdCommand ) {
46
43
CmdLineExecutionResult result = CmdLineTestHelper
47
- .executeCommand (dockerGetIdCommand );
48
- assertEquals (new Integer (0 ), result .exitCode );
49
- assertEquals (null , result .exception );
44
+ .executeAndFailIfNotValidStatusCode (dockerGetIdCommand , 0 );
50
45
String dockerId = result .stdout .trim ();
51
- CmdLineTestHelper .executeCommand ("docker kill " + dockerId );
46
+ CmdLineTestHelper .executeAndFailIfNotValidStatusCode ("docker kill " + dockerId , 0 );
52
47
}
53
48
}
Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ public static CmdLineExecutionResult executeCommand(String command) {
14
14
//
15
15
// EXECUTE DOCKER COMMAND AND RETURN RESULT
16
16
//
17
+ System .out .println ("====================" );
18
+ System .out .println (command );
19
+ System .out .println ("====================" );
17
20
ByteArrayOutputStream stdout = new ByteArrayOutputStream ();
18
21
PumpStreamHandler psh = new PumpStreamHandler (stdout );
19
22
CommandLine cmdLine = CommandLine .parse (command );
@@ -34,4 +37,12 @@ public static CmdLineExecutionResult executeCommand(String command) {
34
37
}
35
38
return res ;
36
39
}
40
+
41
+ public static CmdLineExecutionResult executeAndFailIfNotValidStatusCode (String command , Integer expectedExitCode ) {
42
+ CmdLineExecutionResult result = executeCommand (command .toString ());
43
+ if (! result .exitCode .equals (expectedExitCode )) {
44
+ throw new RuntimeException ("Exec of cmd failed with exit code: " + result .exitCode + " - " + command + " ---- EXCEPTION: " + result .exception );
45
+ }
46
+ return result ;
47
+ }
37
48
}
You can’t perform that action at this time.
0 commit comments