1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 package name.angoca.zemucan.tools.messages.executer;
30
31 import java.io.IOException;
32
33 import name.angoca.zemucan.executer.api.ExecutingCommandException;
34 import name.angoca.zemucan.executer.impl.CommandNotFoundException;
35 import name.angoca.zemucan.tools.test.RandomTestRunner;
36
37 import org.junit.Assert;
38 import org.junit.Test;
39 import org.junit.runner.RunWith;
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 @RunWith(RandomTestRunner.class)
58 public class ExecuterMessagesTest {
59
60
61
62 public ExecuterMessagesTest() {
63
64 }
65
66
67
68
69 @Test
70 public final void testCommandNotFoundException() {
71 final String expectedCommand = "db2 create database";
72 final CommandNotFoundException exception = new CommandNotFoundException(
73 expectedCommand);
74
75 final String actual = exception.getMessage();
76
77 final String expected = "EXEC1 - Command not found: " + expectedCommand;
78
79 Assert.assertEquals("CommandNotFoundException", expected, actual);
80
81 final String actualCommand = exception.getCommand();
82
83 Assert.assertEquals("CommandNotFoundException getCommand",
84 expectedCommand, actualCommand);
85 }
86
87
88
89
90 @Test(expected = AssertionError.class)
91 public final void testCommandNotFoundExceptionNull() {
92 new CommandNotFoundException(null);
93 }
94
95
96
97
98 @Test
99 public final void testExecutingCommandException() {
100 final IOException io = new IOException();
101 final Exception exception = new ExecutingCommandException(io);
102
103 final String actual = exception.getMessage();
104
105 final String expected = "EXEC2 - There was a problem while executing the command.";
106
107 Assert.assertEquals("ExecutingCommandException", expected, actual);
108 }
109
110
111
112
113 @Test(expected = AssertionError.class)
114 public final void testExecutingCommandExceptionNull() {
115 new ExecutingCommandException(null);
116 }
117 }