use of org.apache.qpid.jms.JmsConnectionFactory in project activemq-artemis by apache.
the class JMSSaslExternalTest method testConnection.
@Test(timeout = 600000)
public void testConnection() throws Exception {
final String keystore = this.getClass().getClassLoader().getResource("client_not_revoked.jks").getFile();
final String truststore = this.getClass().getClassLoader().getResource("truststore.jks").getFile();
String connOptions = "?amqp.saslMechanisms=EXTERNAL" + "&" + "transport.trustStoreLocation=" + truststore + "&" + "transport.trustStorePassword=changeit" + "&" + "transport.keyStoreLocation=" + keystore + "&" + "transport.keyStorePassword=changeit" + "&" + "transport.verifyHost=false";
JmsConnectionFactory factory = new JmsConnectionFactory(new URI("amqps://localhost:" + 61616 + connOptions));
Connection connection = factory.createConnection("client", null);
connection.start();
try {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
javax.jms.Queue queue = session.createQueue("TEST");
MessageConsumer consumer = session.createConsumer(queue);
MessageProducer producer = session.createProducer(queue);
final String text = RandomUtil.randomString();
producer.send(session.createTextMessage(text));
TextMessage m = (TextMessage) consumer.receive(1000);
assertNotNull(m);
assertEquals(text, m.getText());
} finally {
connection.close();
}
}
use of org.apache.qpid.jms.JmsConnectionFactory in project activemq-artemis by apache.
the class JMSSaslGssapiTest method testSaslPlainConnectionDenied.
@Test(timeout = 600000)
public void testSaslPlainConnectionDenied() throws Exception {
JmsConnectionFactory factory = new JmsConnectionFactory(new URI("amqp://localhost:" + AMQP_PORT + "?amqp.saslMechanisms=PLAIN"));
try {
factory.createConnection("plain", "secret");
fail("Expect sasl failure");
} catch (JMSSecurityException expected) {
assertTrue(expected.getMessage().contains("SASL"));
}
}
use of org.apache.qpid.jms.JmsConnectionFactory in project activemq-artemis by apache.
the class JMSTopicConsumerTest method testSendAndReceiveOnAutoCreatedTopicJMS2.
@Test(timeout = 60000)
public void testSendAndReceiveOnAutoCreatedTopicJMS2() throws Exception {
ConnectionFactory cf = new JmsConnectionFactory(getBrokerQpidJMSConnectionURI());
JMSContext context = cf.createContext();
String topicName = UUID.randomUUID().toString();
SimpleString simpleTopicName = SimpleString.toSimpleString(topicName);
try {
Topic topic = context.createTopic(topicName);
JMSProducer producer = context.createProducer();
TextMessage message = context.createTextMessage("test-message");
// this will auto-create the address, but not the subscription queue
producer.send(topic, message);
assertNotNull(server.getAddressInfo(simpleTopicName));
assertEquals(RoutingType.MULTICAST, server.getAddressInfo(simpleTopicName).getRoutingType());
assertTrue(server.getAddressInfo(simpleTopicName).isAutoCreated());
assertTrue(server.getPostOffice().getBindingsForAddress(simpleTopicName).getBindings().isEmpty());
// this will auto-create the subscription queue
JMSConsumer consumer = context.createConsumer(topic);
assertFalse(server.getPostOffice().getBindingsForAddress(simpleTopicName).getBindings().isEmpty());
producer.send(topic, message);
context.start();
message = (TextMessage) consumer.receive(1000);
assertNotNull(message);
assertNotNull(message.getText());
assertEquals("test-message", message.getText());
consumer.close();
assertTrue(server.getPostOffice().getBindingsForAddress(simpleTopicName).getBindings().isEmpty());
} finally {
context.close();
}
}
use of org.apache.qpid.jms.JmsConnectionFactory in project activemq-artemis by apache.
the class JMSWebSocketConnectionTest method testSendLargeMessageToClientFromOpenWire.
@Test(timeout = 30000)
public void testSendLargeMessageToClientFromOpenWire() throws Exception {
JmsConnectionFactory factory = new JmsConnectionFactory(getBrokerQpidJMSConnectionURI());
JmsConnection connection = (JmsConnection) factory.createConnection();
sendLargeMessageViaOpenWire();
try {
Session session = connection.createSession();
Queue queue = session.createQueue(getQueueName());
connection.start();
MessageConsumer consumer = session.createConsumer(queue);
Message message = consumer.receive(1000);
assertNotNull(message);
assertTrue(message instanceof BytesMessage);
} finally {
connection.close();
}
}
use of org.apache.qpid.jms.JmsConnectionFactory in project activemq-artemis by apache.
the class JMSWebSocketConnectionTest method testCreateConnectionAndStart.
@Test(timeout = 30000)
public void testCreateConnectionAndStart() throws Exception {
JmsConnectionFactory factory = new JmsConnectionFactory(getBrokerQpidJMSConnectionURI());
JmsConnection connection = (JmsConnection) factory.createConnection();
assertNotNull(connection);
connection.start();
connection.close();
}
Aggregations