Skip to content

Commit 6aed2d4

Browse files
author
Marek Majkowski
committed
bug23200 merged into default
2 parents ece333e + 049e158 commit 6aed2d4

File tree

1 file changed

+32
-16
lines changed

1 file changed

+32
-16
lines changed

test/src/com/rabbitmq/client/test/functional/QueueLease.java

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class QueueLease extends BrokerTestCase {
4646

4747
// Currently the expiration timer is very responsive but this may
4848
// very well change in the future, so tweak accordingly.
49-
private final static long QUEUE_EXPIRES = 1000L; // msecs
49+
private final static int QUEUE_EXPIRES = 1000; // msecs
5050
private final static int SHOULD_EXPIRE_WITHIN = 2000;
5151

5252
/**
@@ -65,27 +65,42 @@ public void testDoesNotExpireOthers() throws IOException,
6565
verifyQueueExpires(TEST_NORMAL_QUEUE, false);
6666
}
6767

68-
/**
69-
* Verify that the server throws an error if the type of x-expires is not
70-
* long.
71-
*/
72-
public void testExpireMustBeLong() throws IOException {
68+
public void testExpireMayBeByte() throws IOException {
7369
Map<String, Object> args = new HashMap<String, Object>();
74-
args.put("x-expires", 100);
70+
args.put("x-expires", (byte)100);
7571

7672
try {
77-
channel
78-
.queueDeclare("expiresMustBeLong", false, false, false,
79-
args);
80-
fail("server accepted x-expires not of type long");
73+
channel.queueDeclare("expiresMayBeByte", false, true, false, args);
8174
} catch (IOException e) {
82-
checkShutdownSignal(AMQP.PRECONDITION_FAILED, e);
75+
fail("server did not accept x-expires of type byte");
76+
}
77+
}
78+
79+
public void testExpireMayBeShort() throws IOException {
80+
Map<String, Object> args = new HashMap<String, Object>();
81+
args.put("x-expires", (short)100);
82+
83+
try {
84+
channel.queueDeclare("expiresMayBeShort", false, true, false, args);
85+
} catch (IOException e) {
86+
fail("server did not accept x-expires of type short");
87+
}
88+
}
89+
90+
public void testExpireMayBeLong() throws IOException {
91+
Map<String, Object> args = new HashMap<String, Object>();
92+
args.put("x-expires", 100L);
93+
94+
try {
95+
channel.queueDeclare("expiresMayBeLong", false, true, false, args);
96+
} catch (IOException e) {
97+
fail("server did not accept x-expires of type long");
8398
}
8499
}
85100

86101
public void testExpireMustBeGtZero() throws IOException {
87102
Map<String, Object> args = new HashMap<String, Object>();
88-
args.put("x-expires", 0L);
103+
args.put("x-expires", 0);
89104

90105
try {
91106
channel.queueDeclare("expiresMustBeGtZero", false, false, false,
@@ -98,7 +113,7 @@ public void testExpireMustBeGtZero() throws IOException {
98113

99114
public void testExpireMustBePositive() throws IOException {
100115
Map<String, Object> args = new HashMap<String, Object>();
101-
args.put("x-expires", -10L);
116+
args.put("x-expires", -10);
102117

103118
try {
104119
channel.queueDeclare("expiresMustBePositive", false, false, false,
@@ -115,9 +130,9 @@ public void testExpireMustBePositive() throws IOException {
115130
*/
116131
public void testQueueRedeclareEquivalence() throws IOException {
117132
Map<String, Object> args1 = new HashMap<String, Object>();
118-
args1.put("x-expires", 10000L);
133+
args1.put("x-expires", 10000);
119134
Map<String, Object> args2 = new HashMap<String, Object>();
120-
args2.put("x-expires", 20000L);
135+
args2.put("x-expires", 20000);
121136

122137
channel.queueDeclare(TEST_EXPIRE_REDECLARE_QUEUE, false, false, false,
123138
args1);
@@ -145,6 +160,7 @@ void verifyQueueExpires(String name, boolean expire) throws IOException,
145160
try {
146161
channel.queueDeclarePassive(name);
147162
} catch (IOException e) {
163+
checkShutdownSignal(AMQP.NOT_FOUND, e);
148164
fail("Queue expired before deadline.");
149165
}
150166

0 commit comments

Comments
 (0)