Search in sources :

Example 1 with StompFrameHandlerV11

use of org.apache.activemq.artemis.core.protocol.stomp.v11.StompFrameHandlerV11 in project activemq-artemis by apache.

the class StompV11Test method testHeartBeat3.

@Test
public void testHeartBeat3() throws Exception {
    connection.close();
    ClientStompFrame frame = conn.createFrame("CONNECT");
    frame.addHeader("host", "127.0.0.1");
    frame.addHeader("login", this.defUser);
    frame.addHeader("passcode", this.defPass);
    frame.addHeader("heart-beat", "500,500");
    frame.addHeader("accept-version", "1.0,1.1");
    ClientStompFrame reply = conn.sendFrame(frame);
    assertEquals("CONNECTED", reply.getCommand());
    assertEquals("500,500", reply.getHeader("heart-beat"));
    System.out.println("========== start pinger!");
    conn.startPinger(100);
    Assert.assertEquals(1, server.getActiveMQServer().getRemotingService().getConnections().size());
    StompConnection stompConnection = (StompConnection) server.getActiveMQServer().getRemotingService().getConnections().iterator().next();
    StompFrameHandlerV11 stompFrameHandler = (StompFrameHandlerV11) stompConnection.getStompVersionHandler();
    Thread.sleep(1000);
    // now check the frame size
    int size = conn.getServerPingNumber();
    conn.stopPinger();
    // ((AbstractStompClientConnection)conn).killReaderThread();
    Wait.waitFor(() -> {
        return server.getActiveMQServer().getRemotingService().getConnections().size() == 0;
    });
    Assert.assertFalse(stompFrameHandler.getHeartBeater().isStarted());
}
Also used : ClientStompFrame(org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame) StompConnection(org.apache.activemq.artemis.core.protocol.stomp.StompConnection) StompFrameHandlerV11(org.apache.activemq.artemis.core.protocol.stomp.v11.StompFrameHandlerV11) Test(org.junit.Test)

Aggregations

StompConnection (org.apache.activemq.artemis.core.protocol.stomp.StompConnection)1 StompFrameHandlerV11 (org.apache.activemq.artemis.core.protocol.stomp.v11.StompFrameHandlerV11)1 ClientStompFrame (org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame)1 Test (org.junit.Test)1