mirror of https://github.com/apache/activemq.git
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1506078 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
194c6535cd
commit
1e5dac11fa
|
@ -16,19 +16,17 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.transport.amqp;
|
package org.apache.activemq.transport.amqp;
|
||||||
|
|
||||||
import org.apache.activemq.broker.BrokerService;
|
|
||||||
import org.junit.Ignore;
|
|
||||||
|
|
||||||
import javax.net.ssl.KeyManager;
|
|
||||||
import javax.net.ssl.SSLContext;
|
|
||||||
import javax.net.ssl.TrustManager;
|
|
||||||
import javax.net.ssl.X509TrustManager;
|
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
|
|
||||||
|
import javax.net.ssl.X509TrustManager;
|
||||||
|
|
||||||
|
import org.apache.activemq.broker.BrokerService;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
@Ignore("hangs atm, needs investigation")
|
@Ignore("hangs atm, needs investigation")
|
||||||
public class AmqpSslTest extends AmqpTestSupport {
|
public class AmqpSslTest extends AmqpTestSupport {
|
||||||
|
@Override
|
||||||
public void startBroker() throws Exception {
|
public void startBroker() throws Exception {
|
||||||
System.setProperty("javax.net.ssl.trustStore", "src/test/resources/client.keystore");
|
System.setProperty("javax.net.ssl.trustStore", "src/test/resources/client.keystore");
|
||||||
System.setProperty("javax.net.ssl.trustStorePassword", "password");
|
System.setProperty("javax.net.ssl.trustStorePassword", "password");
|
||||||
|
@ -54,12 +52,15 @@ public class AmqpSslTest extends AmqpTestSupport {
|
||||||
|
|
||||||
static class DefaultTrustManager implements X509TrustManager {
|
static class DefaultTrustManager implements X509TrustManager {
|
||||||
|
|
||||||
|
@Override
|
||||||
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public X509Certificate[] getAcceptedIssuers() {
|
public X509Certificate[] getAcceptedIssuers() {
|
||||||
return new X509Certificate[0];
|
return new X509Certificate[0];
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,16 @@ import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
|
||||||
import javax.jms.*;
|
import javax.jms.Connection;
|
||||||
|
import javax.jms.DeliveryMode;
|
||||||
|
import javax.jms.ExceptionListener;
|
||||||
|
import javax.jms.JMSException;
|
||||||
|
import javax.jms.Message;
|
||||||
|
import javax.jms.MessageConsumer;
|
||||||
|
import javax.jms.MessageProducer;
|
||||||
|
import javax.jms.QueueBrowser;
|
||||||
|
import javax.jms.Session;
|
||||||
|
import javax.jms.TextMessage;
|
||||||
|
|
||||||
import org.apache.activemq.transport.amqp.joram.ActiveMQAdmin;
|
import org.apache.activemq.transport.amqp.joram.ActiveMQAdmin;
|
||||||
import org.apache.qpid.amqp_1_0.jms.impl.ConnectionFactoryImpl;
|
import org.apache.qpid.amqp_1_0.jms.impl.ConnectionFactoryImpl;
|
||||||
|
@ -35,6 +44,7 @@ import org.objectweb.jtests.jms.framework.TestConfig;
|
||||||
*/
|
*/
|
||||||
public class JMSClientTest extends AmqpTestSupport {
|
public class JMSClientTest extends AmqpTestSupport {
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
@Test
|
@Test
|
||||||
public void testTransactions() throws Exception {
|
public void testTransactions() throws Exception {
|
||||||
ActiveMQAdmin.enableJMSFrameTracing();
|
ActiveMQAdmin.enableJMSFrameTracing();
|
||||||
|
@ -65,6 +75,7 @@ public class JMSClientTest extends AmqpTestSupport {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
@Test
|
@Test
|
||||||
public void testSelectors() throws Exception{
|
public void testSelectors() throws Exception{
|
||||||
ActiveMQAdmin.enableJMSFrameTracing();
|
ActiveMQAdmin.enableJMSFrameTracing();
|
||||||
|
@ -115,5 +126,4 @@ public class JMSClientTest extends AmqpTestSupport {
|
||||||
connection.start();
|
connection.start();
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,29 +16,32 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.transport.amqp.joram;
|
package org.apache.activemq.transport.amqp.joram;
|
||||||
|
|
||||||
import org.apache.activemq.broker.BrokerFactory;
|
|
||||||
import org.apache.activemq.broker.BrokerService;
|
|
||||||
import org.apache.activemq.broker.TransportConnector;
|
|
||||||
import org.objectweb.jtests.jms.admin.Admin;
|
|
||||||
import org.apache.qpid.amqp_1_0.jms.impl.ConnectionFactoryImpl;
|
|
||||||
import org.apache.qpid.amqp_1_0.jms.impl.QueueImpl;
|
|
||||||
import org.apache.qpid.amqp_1_0.jms.impl.TopicImpl;
|
|
||||||
|
|
||||||
import javax.jms.ConnectionFactory;
|
|
||||||
import javax.naming.Context;
|
|
||||||
import javax.naming.InitialContext;
|
|
||||||
import javax.naming.NamingException;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.logging.*;
|
import java.util.logging.Handler;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.LogRecord;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.jms.ConnectionFactory;
|
||||||
|
import javax.naming.Context;
|
||||||
|
import javax.naming.InitialContext;
|
||||||
|
import javax.naming.NamingException;
|
||||||
|
|
||||||
|
import org.apache.activemq.broker.BrokerFactory;
|
||||||
|
import org.apache.activemq.broker.BrokerService;
|
||||||
|
import org.apache.activemq.broker.TransportConnector;
|
||||||
|
import org.apache.qpid.amqp_1_0.jms.impl.ConnectionFactoryImpl;
|
||||||
|
import org.apache.qpid.amqp_1_0.jms.impl.QueueImpl;
|
||||||
|
import org.apache.qpid.amqp_1_0.jms.impl.TopicImpl;
|
||||||
|
import org.objectweb.jtests.jms.admin.Admin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
|
|
||||||
*/
|
*/
|
||||||
public class ActiveMQAdmin implements Admin {
|
public class ActiveMQAdmin implements Admin {
|
||||||
|
|
||||||
|
@ -56,9 +59,9 @@ public class ActiveMQAdmin implements Admin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("resource")
|
||||||
static public void enableJMSFrameTracing() {
|
static public void enableJMSFrameTracing() {
|
||||||
try {
|
try {
|
||||||
final SimpleFormatter formatter = new SimpleFormatter();
|
|
||||||
String outputStreamName = "amqp-trace.txt";
|
String outputStreamName = "amqp-trace.txt";
|
||||||
final PrintStream out = new PrintStream(new FileOutputStream(new File(outputStreamName)));
|
final PrintStream out = new PrintStream(new FileOutputStream(new File(outputStreamName)));
|
||||||
Handler handler = new Handler() {
|
Handler handler = new Handler() {
|
||||||
|
@ -74,6 +77,7 @@ public class ActiveMQAdmin implements Admin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws SecurityException {
|
public void close() throws SecurityException {
|
||||||
|
out.close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -89,6 +93,7 @@ public class ActiveMQAdmin implements Admin {
|
||||||
return BrokerFactory.createBroker(new URI("broker://()/localhost?persistent=false"));
|
return BrokerFactory.createBroker(new URI("broker://()/localhost?persistent=false"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return getClass().getName();
|
return getClass().getName();
|
||||||
}
|
}
|
||||||
|
@ -96,6 +101,7 @@ public class ActiveMQAdmin implements Admin {
|
||||||
static BrokerService broker;
|
static BrokerService broker;
|
||||||
static int port;
|
static int port;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void startServer() throws Exception {
|
public void startServer() throws Exception {
|
||||||
if( broker!=null ) {
|
if( broker!=null ) {
|
||||||
stopServer();
|
stopServer();
|
||||||
|
@ -105,26 +111,35 @@ public class ActiveMQAdmin implements Admin {
|
||||||
System.setProperty("basedir", file.getAbsolutePath());
|
System.setProperty("basedir", file.getAbsolutePath());
|
||||||
}
|
}
|
||||||
broker = createBroker();
|
broker = createBroker();
|
||||||
TransportConnector connector = broker.addConnector("amqp://localhost:0");
|
TransportConnector connector = broker.addConnector(getConnectorURI());
|
||||||
broker.start();
|
broker.start();
|
||||||
port = connector.getConnectUri().getPort();
|
port = connector.getConnectUri().getPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getConnectorURI() {
|
||||||
|
return "amqp://localhost:0";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void stopServer() throws Exception {
|
public void stopServer() throws Exception {
|
||||||
broker.stop();
|
broker.stop();
|
||||||
broker = null;
|
broker = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void start() throws Exception {
|
public void start() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void stop() throws Exception {
|
public void stop() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Context createContext() throws NamingException {
|
public Context createContext() throws NamingException {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void createQueue(String name) {
|
public void createQueue(String name) {
|
||||||
try {
|
try {
|
||||||
context.bind(name, new QueueImpl("queue://"+name));
|
context.bind(name, new QueueImpl("queue://"+name));
|
||||||
|
@ -133,6 +148,7 @@ public class ActiveMQAdmin implements Admin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void createTopic(String name) {
|
public void createTopic(String name) {
|
||||||
try {
|
try {
|
||||||
context.bind(name, new TopicImpl("topic://"+name));
|
context.bind(name, new TopicImpl("topic://"+name));
|
||||||
|
@ -141,6 +157,7 @@ public class ActiveMQAdmin implements Admin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void deleteQueue(String name) {
|
public void deleteQueue(String name) {
|
||||||
// BrokerTestSupport.delete_queue((Broker)base.broker, name);
|
// BrokerTestSupport.delete_queue((Broker)base.broker, name);
|
||||||
try {
|
try {
|
||||||
|
@ -150,6 +167,7 @@ public class ActiveMQAdmin implements Admin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void deleteTopic(String name) {
|
public void deleteTopic(String name) {
|
||||||
try {
|
try {
|
||||||
context.unbind(name);
|
context.unbind(name);
|
||||||
|
@ -158,6 +176,7 @@ public class ActiveMQAdmin implements Admin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void createConnectionFactory(String name) {
|
public void createConnectionFactory(String name) {
|
||||||
try {
|
try {
|
||||||
final ConnectionFactory factory = new ConnectionFactoryImpl("localhost", port, null, null);
|
final ConnectionFactory factory = new ConnectionFactoryImpl("localhost", port, null, null);
|
||||||
|
@ -167,6 +186,7 @@ public class ActiveMQAdmin implements Admin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void deleteConnectionFactory(String name) {
|
public void deleteConnectionFactory(String name) {
|
||||||
try {
|
try {
|
||||||
context.unbind(name);
|
context.unbind(name);
|
||||||
|
@ -175,17 +195,23 @@ public class ActiveMQAdmin implements Admin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void createQueueConnectionFactory(String name) {
|
public void createQueueConnectionFactory(String name) {
|
||||||
createConnectionFactory(name);
|
createConnectionFactory(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void createTopicConnectionFactory(String name) {
|
public void createTopicConnectionFactory(String name) {
|
||||||
createConnectionFactory(name);
|
createConnectionFactory(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void deleteQueueConnectionFactory(String name) {
|
public void deleteQueueConnectionFactory(String name) {
|
||||||
deleteConnectionFactory(name);
|
deleteConnectionFactory(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void deleteTopicConnectionFactory(String name) {
|
public void deleteTopicConnectionFactory(String name) {
|
||||||
deleteConnectionFactory(name);
|
deleteConnectionFactory(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.activemq.transport.amqp.joram;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Kevin Earls
|
||||||
|
*/
|
||||||
|
public class ActiveMQNIOAdmin extends ActiveMQAdmin {
|
||||||
|
private static final String AMQP_NIO_URI = "amqp+nio://localhost:0";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getConnectorURI() {
|
||||||
|
return AMQP_NIO_URI;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.activemq.transport.amqp.joram;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the JoramJmsTests using amqp+nio
|
||||||
|
*/
|
||||||
|
public class JoramJmsNioTest extends JoramJmsTest {
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
System.setProperty("joram.jms.test.file", "providerNIO.properties");
|
||||||
|
Test suite = JoramJmsTest.suite();
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,7 +19,7 @@ package org.apache.activemq.transport.amqp.joram;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import org.apache.qpid.amqp_1_0.jms.impl.ConnectionFactoryImpl;
|
|
||||||
import org.objectweb.jtests.jms.conform.connection.ConnectionTest;
|
import org.objectweb.jtests.jms.conform.connection.ConnectionTest;
|
||||||
import org.objectweb.jtests.jms.conform.connection.TopicConnectionTest;
|
import org.objectweb.jtests.jms.conform.connection.TopicConnectionTest;
|
||||||
import org.objectweb.jtests.jms.conform.message.MessageBodyTest;
|
import org.objectweb.jtests.jms.conform.message.MessageBodyTest;
|
||||||
|
@ -35,14 +35,9 @@ import org.objectweb.jtests.jms.conform.selector.SelectorSyntaxTest;
|
||||||
import org.objectweb.jtests.jms.conform.selector.SelectorTest;
|
import org.objectweb.jtests.jms.conform.selector.SelectorTest;
|
||||||
import org.objectweb.jtests.jms.conform.session.QueueSessionTest;
|
import org.objectweb.jtests.jms.conform.session.QueueSessionTest;
|
||||||
import org.objectweb.jtests.jms.conform.session.SessionTest;
|
import org.objectweb.jtests.jms.conform.session.SessionTest;
|
||||||
import org.objectweb.jtests.jms.conform.session.TopicSessionTest;
|
|
||||||
import org.objectweb.jtests.jms.conform.session.UnifiedSessionTest;
|
import org.objectweb.jtests.jms.conform.session.UnifiedSessionTest;
|
||||||
import org.objectweb.jtests.jms.conform.topic.TemporaryTopicTest;
|
import org.objectweb.jtests.jms.conform.topic.TemporaryTopicTest;
|
||||||
|
|
||||||
import javax.jms.Connection;
|
|
||||||
import javax.jms.ConnectionFactory;
|
|
||||||
import javax.jms.JMSException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
|
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
|
||||||
*/
|
*/
|
||||||
|
@ -52,11 +47,9 @@ public class JoramJmsTest extends TestCase {
|
||||||
TestSuite suite = new TestSuite();
|
TestSuite suite = new TestSuite();
|
||||||
|
|
||||||
// TODO: Fix these tests..
|
// TODO: Fix these tests..
|
||||||
if (false) {
|
// Fails due to
|
||||||
// Fails due to
|
// https://issues.apache.org/jira/browse/PROTON-154
|
||||||
// https://issues.apache.org/jira/browse/PROTON-154
|
// suite.addTestSuite(TopicSessionTest.class);
|
||||||
suite.addTestSuite(TopicSessionTest.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Passing tests
|
// Passing tests
|
||||||
suite.addTestSuite(MessageHeaderTest.class);
|
suite.addTestSuite(MessageHeaderTest.class);
|
||||||
|
@ -83,5 +76,4 @@ public class JoramJmsTest extends TestCase {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
junit.textui.TestRunner.run(suite());
|
junit.textui.TestRunner.run(suite());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue