8000 Merge pull request #181 from rabbitmq/rabbitmq-java-client-108 · CassOnMars/rabbitmq-java-client@8898c00 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8898c00

Browse files
Merge pull request rabbitmq#181 from rabbitmq/rabbitmq-java-client-108
Refactor tests in TestMain
2 parents bac5a3f + a745b1b commit 8898c00

File tree

5 files changed

+53
-534
lines changed

5 files changed

+53
-534
lines changed

pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@
385385
<include>**/SSLTests.*</include>
386386
<include>**/ServerTests.*</include>
387387
<include>**/HATests.*</include>
388-
<include>**/TestMain.*</include>
389388
</includes>
390389
</configuration>
391390
<executions>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.rabbitmq.client.test.functional;
2+
3+
import com.rabbitmq.client.AMQP;
4+
import com.rabbitmq.client.Channel;
5+
import com.rabbitmq.client.DefaultConsumer;
6+
import com.rabbitmq.client.Envelope;
7+
import com.rabbitmq.client.test.BrokerTestCase;
8+
import org.junit.Test;
9+
10+
import java.io.IOException;
11+
import java.util.concurrent.CountDownLatch;
12+
import java.util.concurrent.TimeUnit;
13+
14+
import static org.junit.Assert.assertTrue;
15+
16+
/**
17+
*
18+
*/
19+
public class BasicConsume extends BrokerTestCase {
20+
21+
@Test public void basicConsumeOk() throws IOException, InterruptedException {
22+
String q = channel.queueDeclare().getQueue();
23+
basicPublishPersistent("msg".getBytes("UTF-8"), q);
24+
basicPublishPersistent("msg".getBytes("UTF-8"), q);
25+
26+
CountDownLatch latch = new CountDownLatch(2);
27+
channel.basicConsume(q, new CountDownLatchConsumer(channel, latch));
28+
29+
boolean nbOfExpectedMessagesHasBeenConsumed = latch.await(1, TimeUnit.SECONDS);
30+
assertTrue("Not all the messages have been received", nbOfExpectedMessagesHasBeenConsumed);
31+
}
32+
33+
static class CountDownLatchConsumer extends DefaultConsumer {
34+
35+
private final CountDownLatch latch;
36+
37+
public CountDownLatchConsumer(Channel channel, CountDownLatch latch) {
38+
super(channel);
39+
this.latch = latch;
40+
}
41+
42+
@Override
43+
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
44+
latch.countDown();
45+
}
46+
}
47+
48+
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.rabbitmq.client.test.functional;
1818

19+
import static org.junit.Assert.assertEquals;
1920
import static org.junit.Assert.fail;
2021

2122
import java.io.IOException;
@@ -50,6 +51,10 @@ public FrameMax() {
5051
connectionFactory.setRequestedFrameMax(FRAME_MAX);
5152
}
5253

54+
@Test public void negotiationOk() {
55+
assertEquals(FRAME_MAX, connection.getFrameMax());
56+
}
57+
5358
/* Publish a message of size FRAME_MAX. The broker should split
5459
* this into two frames before sending back. Frame content should
5560
* be less or equal to frame-max - 8. */

0 commit comments

Comments
 (0)
0