Implementaed handlig of publish notification on the client
This commit is contained in:
@@ -4,7 +4,10 @@ import java.io.IOException;
|
||||
import org.apache.mina.core.service.IoConnector;
|
||||
import org.dna.mqtt.moquette.client.Client;
|
||||
import org.dna.mqtt.moquette.client.IPublishCallback;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -13,26 +16,46 @@ import org.junit.Test;
|
||||
public class ServerIntegrationTest {
|
||||
|
||||
IoConnector connector;
|
||||
boolean received;
|
||||
Server server;
|
||||
|
||||
protected void startServer() throws IOException {
|
||||
new Server().startServer();
|
||||
server = new Server();
|
||||
server.startServer();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws IOException {
|
||||
startServer();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
server.stopServer();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSubscribe() throws IOException, InterruptedException {
|
||||
startServer();
|
||||
// startServer();
|
||||
Client client = new Client("localhost", Server.PORT);
|
||||
client.connect();
|
||||
|
||||
client.publish("/topic", "Test my payload".getBytes());
|
||||
|
||||
client.subscribe("/topic", new IPublishCallback() {
|
||||
|
||||
public void published(String topic, byte[] message) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
received = true;
|
||||
}
|
||||
});
|
||||
|
||||
client.publish("/topic", "Test my payload".getBytes());
|
||||
|
||||
|
||||
client.close();
|
||||
|
||||
|
||||
assertTrue(received);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user