Skip to content

Commit 33c5131

Browse files
author
Alexandru Scvortov
committed
abstracted fail
1 parent d671583 commit 33c5131

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

test/src/com/rabbitmq/client/test/server/Permissions.java

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -269,65 +269,66 @@ public void testNoAccess()
269269
expectExceptionRun(AMQP.ACCESS_REFUSED, new WithName() {
270270
public void with(String _) throws IOException {
271271
noAccessCh.queueDeclare("justaqueue", false, false, true, null);
272-
fail("user noaccess should not be able to declare a queue");
273-
}
274-
});
272+
}},
273+
"user noaccess should not be able to declare a queue"
274+
);
275275
expectExceptionRun(AMQP.ACCESS_REFUSED, new WithName() {
276276
public void with(String _) throws IOException {
277277
noAccessCh.queueDelete("configure");
278-
fail("user noaccess should not be able to delete a queue");
279-
}
280-
});
278+
}}
279+
, "user noaccess should not be able to delete a queue"
280+
);
281281
expectExceptionRun(AMQP.ACCESS_REFUSED, new WithName() {
282282
public void with(String _) throws IOException {
283283
noAccessCh.queueBind("write", "write", "write");
284-
fail("user noaccess should not be able to bind a queue");
285-
}
286-
});
284+
}},
285+
"user noaccess should not be able to bind a queue"
286+
);
287287
expectExceptionRun(AMQP.ACCESS_REFUSED, new WithName() {
288288
public void with(String _) throws IOException {
289289
noAccessCh.queuePurge("read");
290-
fail("user noaccess should not be able to purge a queue");
291-
}
292-
});
290+
}},
291+
"user noaccess should not be able to purge a queue"
292+
);
293293
expectExceptionRun(AMQP.ACCESS_REFUSED, new WithName() {
294294
public void with(String _) throws IOException {
295295
noAccessCh.exchangeDeclare("justanexchange", "direct");
296-
fail("user noaccess should not be able to declare an exchange");
297-
}
298-
});
296+
}},
297+
"user noaccess should not be able to declare an exchange"
298+
);
299299
expectExceptionRun(AMQP.ACCESS_REFUSED, new WithName() {
300300
public void with(String _) throws IOException {
301301
noAccessCh.exchangeDeclare("configure", "direct");
302-
fail("user noaccess should not be able to delete an exchange");
303-
}
304-
});
302+
}},
303+
"user noaccess should not be able to delete an exchange"
304+
);
305305
expectExceptionRun(AMQP.ACCESS_REFUSED, new WithName() {
306306
public void with(String _) throws IOException {
307307
noAccessCh.basicPublish("write", "", null, "foo".getBytes());
308308
noAccessCh.queueDeclare();
309-
fail("user noaccess should not be able to publish");
310-
}
311-
});
309+
}},
310+
"user noaccess should not be able to publish"
311+
);
312312
expectExceptionRun(AMQP.ACCESS_REFUSED, new WithName() {
313313
public void with(String _) throws IOException {
314314
noAccessCh.basicGet("read", false);
315-
fail("user noaccess should not be able to get");
316-
}
317-
});
315+
}},
316+
"user noaccess should not be able to get"
317+
);
318318
expectExceptionRun(AMQP.ACCESS_REFUSED, new WithName() {
319319
public void with(String _) throws IOException {
320320
noAccessCh.basicConsume("read", null);
321-
fail("user noaccess should not be able to consume");
322-
}
323-
});
321+
}},
322+
"user noaccess should not be able to consume"
323+
);
324324
}
325325

326-
protected void expectExceptionRun(int exceptionCode, WithName action)
326+
protected void expectExceptionRun(int exceptionCode, WithName action, String failMsg)
327327
throws IOException
328328
{
329329
try {
330330
action.with("");
331+
fail(failMsg);
331332
} catch (IOException e) {
332333
noAccessCh = noAccessConn.createChannel();
333334
checkShutdownSignal(exceptionCode, e);

0 commit comments

Comments
 (0)