File tree Expand file tree Collapse file tree 3 files changed +33
-7
lines changed
src/test/java/com/rabbitmq Expand file tree Collapse file tree 3 files changed +33
-7
lines changed Original file line number Diff line number Diff line change 20
20
import com .rabbitmq .client .impl .nio .NioParams ;
21
21
import com .rabbitmq .tools .Host ;
22
22
import org .junit .After ;
23
+ import org .junit .Assume ;
23
24
import org .junit .Before ;
24
25
import org .junit .Rule ;
25
26
import org .junit .rules .TestRule ;
37
38
import java .util .concurrent .TimeoutException ;
38
39
39
40
import static org .junit .Assert .*;
41
+ import static org .junit .Assume .*;
40
42
41
43
public class BrokerTestCase {
42
44
@@ -81,6 +83,7 @@ protected boolean isAutomaticRecoveryEnabled() {
81
83
82
84
@ Before public void setUp ()
83
85
throws IOException , TimeoutException {
86
+ assumeTrue (shouldRun ());
84
87
openConnection ();
85
88
openChannel ();
86
89
@@ -89,14 +92,26 @@ protected boolean isAutomaticRecoveryEnabled() {
89
92
90
93
@ After public void tearDown ()
91
94
throws IOException , TimeoutException {
92
- closeChannel ();
93
- closeConnection ();
95
+ if (shouldRun ()) {
96
+ closeChannel ();
97
+ closeConnection ();
98
+
99
+ openConnection ();
100
+ openChannel ();
101
+ releaseResources ();
102
+ closeChannel ();
103
+ closeConnection ();
104
+ }
105
+ }
94
106
95
- openConnection ();
96
- openChannel ();
97
- releaseResources ();
98
- closeChannel ();
99
- closeConnection ();
107
+ /**
108
+ * Whether to run the test or not.
109
+ * Subclasses can check whether some broker features
110
+ * are available or not, and choose not to run the test.
111
+ * @return
112
+ */
113
+ protected boolean shouldRun () throws IOException {
114
+ return true ;
100
115
}
101
116
102
117
/**
Original file line number Diff line number Diff line change @@ -34,6 +34,11 @@ public class TopicPermissions extends BrokerTestCase {
34
34
String notProtectedTopic = "not.protected.topic" ;
35
35
String noneTopicExchange = "not.a.topic" ;
36
36
37
+ @ Override
38
+ protected boolean shouldRun () throws IOException {
39
+ return Host .isRabbitMqCtlCommandAvailable ("set_topic_permissions" );
40
+ }
41
+
37
42
@ Override
38
43
protected void createResources () throws IOException , TimeoutException {
39
44
channel .exchangeDeclare (protectedTopic , BuiltinExchangeType .TOPIC );
Original file line number Diff line number Diff line change @@ -91,6 +91,12 @@ private static Process executeCommandProcess(String command) throws IOException
91
91
return Runtime .getRuntime ().exec (finalCommand );
92
92
}
93
93
94
+ public static boolean isRabbitMqCtlCommandAvailable (String command ) throws IOException {
95
+ Process process = rabbitmqctl ("help" );
96
+ String stdout = capture (process .getInputStream ());
97
+ return stdout .contains (command );
98
+ }
99
+
94
100
public static Process rabbitmqctl (String command ) throws IOException {
95
101
return executeCommand (rabbitmqctlCommand () +
96
102
" -n \' " + nodenameA () + "\' " +
You can’t perform that action at this time.
0 commit comments