git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1506078 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2013-07-23 14:50:40 +00:00
parent 194c6535cd
commit 1e5dac11fa
6 changed files with 128 additions and 39 deletions

View File

@ -16,19 +16,17 @@
*/
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.X509Certificate;
import javax.net.ssl.X509TrustManager;
import org.apache.activemq.broker.BrokerService;
import org.junit.Ignore;
@Ignore("hangs atm, needs investigation")
public class AmqpSslTest extends AmqpTestSupport {
@Override
public void startBroker() throws Exception {
System.setProperty("javax.net.ssl.trustStore", "src/test/resources/client.keystore");
System.setProperty("javax.net.ssl.trustStorePassword", "password");
@ -54,12 +52,15 @@ public class AmqpSslTest extends AmqpTestSupport {
static class DefaultTrustManager implements X509TrustManager {
@Override
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
}
@Override
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}

View File

@ -22,7 +22,16 @@ import static org.junit.Assert.assertTrue;
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.qpid.amqp_1_0.jms.impl.ConnectionFactoryImpl;
@ -35,6 +44,7 @@ import org.objectweb.jtests.jms.framework.TestConfig;
*/
public class JMSClientTest extends AmqpTestSupport {
@SuppressWarnings("rawtypes")
@Test
public void testTransactions() throws Exception {
ActiveMQAdmin.enableJMSFrameTracing();
@ -65,6 +75,7 @@ public class JMSClientTest extends AmqpTestSupport {
}
@SuppressWarnings("rawtypes")
@Test
public void testSelectors() throws Exception{
ActiveMQAdmin.enableJMSFrameTracing();
@ -115,5 +126,4 @@ public class JMSClientTest extends AmqpTestSupport {
connection.start();
return connection;
}
}

View File

@ -16,29 +16,32 @@
*/
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.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.net.URI;
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 {
@ -56,9 +59,9 @@ public class ActiveMQAdmin implements Admin {
}
}
@SuppressWarnings("resource")
static public void enableJMSFrameTracing() {
try {
final SimpleFormatter formatter = new SimpleFormatter();
String outputStreamName = "amqp-trace.txt";
final PrintStream out = new PrintStream(new FileOutputStream(new File(outputStreamName)));
Handler handler = new Handler() {
@ -74,6 +77,7 @@ public class ActiveMQAdmin implements Admin {
@Override
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"));
}
@Override
public String getName() {
return getClass().getName();
}
@ -96,6 +101,7 @@ public class ActiveMQAdmin implements Admin {
static BrokerService broker;
static int port;
@Override
public void startServer() throws Exception {
if( broker!=null ) {
stopServer();
@ -105,26 +111,35 @@ public class ActiveMQAdmin implements Admin {
System.setProperty("basedir", file.getAbsolutePath());
}
broker = createBroker();
TransportConnector connector = broker.addConnector("amqp://localhost:0");
TransportConnector connector = broker.addConnector(getConnectorURI());
broker.start();
port = connector.getConnectUri().getPort();
}
protected String getConnectorURI() {
return "amqp://localhost:0";
}
@Override
public void stopServer() throws Exception {
broker.stop();
broker = null;
}
@Override
public void start() throws Exception {
}
@Override
public void stop() throws Exception {
}
@Override
public Context createContext() throws NamingException {
return context;
}
@Override
public void createQueue(String name) {
try {
context.bind(name, new QueueImpl("queue://"+name));
@ -133,6 +148,7 @@ public class ActiveMQAdmin implements Admin {
}
}
@Override
public void createTopic(String name) {
try {
context.bind(name, new TopicImpl("topic://"+name));
@ -141,6 +157,7 @@ public class ActiveMQAdmin implements Admin {
}
}
@Override
public void deleteQueue(String name) {
// BrokerTestSupport.delete_queue((Broker)base.broker, name);
try {
@ -150,6 +167,7 @@ public class ActiveMQAdmin implements Admin {
}
}
@Override
public void deleteTopic(String name) {
try {
context.unbind(name);
@ -158,6 +176,7 @@ public class ActiveMQAdmin implements Admin {
}
}
@Override
public void createConnectionFactory(String name) {
try {
final ConnectionFactory factory = new ConnectionFactoryImpl("localhost", port, null, null);
@ -167,6 +186,7 @@ public class ActiveMQAdmin implements Admin {
}
}
@Override
public void deleteConnectionFactory(String name) {
try {
context.unbind(name);
@ -175,17 +195,23 @@ public class ActiveMQAdmin implements Admin {
}
}
@Override
public void createQueueConnectionFactory(String name) {
createConnectionFactory(name);
}
@Override
public void createTopicConnectionFactory(String name) {
createConnectionFactory(name);
}
@Override
public void deleteQueueConnectionFactory(String name) {
deleteConnectionFactory(name);
}
@Override
public void deleteTopicConnectionFactory(String name) {
deleteConnectionFactory(name);
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -19,7 +19,7 @@ package org.apache.activemq.transport.amqp.joram;
import junit.framework.Test;
import junit.framework.TestCase;
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.TopicConnectionTest;
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.session.QueueSessionTest;
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.topic.TemporaryTopicTest;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
/**
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
@ -52,11 +47,9 @@ public class JoramJmsTest extends TestCase {
TestSuite suite = new TestSuite();
// TODO: Fix these tests..
if (false) {
// Fails due to
// https://issues.apache.org/jira/browse/PROTON-154
suite.addTestSuite(TopicSessionTest.class);
}
// suite.addTestSuite(TopicSessionTest.class);
// Passing tests
suite.addTestSuite(MessageHeaderTest.class);
@ -83,5 +76,4 @@ public class JoramJmsTest extends TestCase {
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
}