Search in sources :

Example 1 with StompClientConnectionV11

use of org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionV11 in project activemq-artemis by apache.

the class StompV12Test method testConnection.

@Test
public void testConnection() throws Exception {
    server.getActiveMQServer().getConfiguration().setSecurityEnabled(true);
    StompClientConnection connection = StompClientConnectionFactory.createClientConnection(v10Uri);
    connection.connect(defUser, defPass);
    Assert.assertTrue(connection.isConnected());
    Assert.assertEquals("1.0", connection.getVersion());
    connection.disconnect();
    connection = StompClientConnectionFactory.createClientConnection(uri);
    connection.connect(defUser, defPass);
    Assert.assertTrue(connection.isConnected());
    Assert.assertEquals("1.2", connection.getVersion());
    connection.disconnect();
    connection = StompClientConnectionFactory.createClientConnection(uri);
    connection.connect();
    Assert.assertFalse(connection.isConnected());
    // new way of connection
    StompClientConnectionV11 conn = (StompClientConnectionV11) StompClientConnectionFactory.createClientConnection(v11Uri);
    conn.connect1(defUser, defPass);
    Assert.assertTrue(conn.isConnected());
    conn.disconnect();
}
Also used : StompClientConnectionV11(org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionV11) StompClientConnection(org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection) Test(org.junit.Test)

Example 2 with StompClientConnectionV11

use of org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionV11 in project activemq-artemis by apache.

the class StompV11Test method testConnection.

@Test
public void testConnection() throws Exception {
    server.getActiveMQServer().getConfiguration().setSecurityEnabled(true);
    StompClientConnection connection = StompClientConnectionFactory.createClientConnection(v10Uri);
    connection.connect(defUser, defPass);
    assertTrue(connection.isConnected());
    assertEquals("1.0", connection.getVersion());
    connection.disconnect();
    connection = StompClientConnectionFactory.createClientConnection(uri);
    connection.connect(defUser, defPass);
    assertTrue(connection.isConnected());
    assertEquals("1.1", connection.getVersion());
    connection.disconnect();
    connection = StompClientConnectionFactory.createClientConnection(uri);
    connection.connect();
    assertFalse(connection.isConnected());
    // new way of connection
    StompClientConnectionV11 conn = (StompClientConnectionV11) StompClientConnectionFactory.createClientConnection(uri);
    conn.connect1(defUser, defPass);
    assertTrue(conn.isConnected());
    conn.disconnect();
    // invalid user
    conn = (StompClientConnectionV11) StompClientConnectionFactory.createClientConnection(uri);
    ClientStompFrame frame = conn.connect("invaliduser", defPass);
    assertFalse(conn.isConnected());
    assertTrue(Stomp.Responses.ERROR.equals(frame.getCommand()));
    assertTrue(frame.getBody().contains("Security Error occurred"));
}
Also used : ClientStompFrame(org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame) StompClientConnectionV11(org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionV11) StompClientConnection(org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection) Test(org.junit.Test)

Aggregations

StompClientConnection (org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection)2 StompClientConnectionV11 (org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionV11)2 Test (org.junit.Test)2 ClientStompFrame (org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame)1