Repository: activemq Updated Branches: refs/heads/master 9f50ce3d0 -> 04ee70a16
http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-ra/pom.xml ---------------------------------------------------------------------- diff --git a/activemq-ra/pom.xml b/activemq-ra/pom.xml index 16a6006..0650c61 100755 --- a/activemq-ra/pom.xml +++ b/activemq-ra/pom.xml @@ -169,6 +169,27 @@ </plugins> </build> </profile> + <profile> + <id>activemq.tests-autoTransport</id> + <activation> + <property> + <name>activemq.tests</name> + <value>autoTransport</value> + </property> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <excludes> + <exclude>**</exclude> + </excludes> + </configuration> + </plugin> + </plugins> + </build> + </profile> </profiles> </project> http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-runtime-config/pom.xml ---------------------------------------------------------------------- diff --git a/activemq-runtime-config/pom.xml b/activemq-runtime-config/pom.xml index 90b68a5..b5f129a 100755 --- a/activemq-runtime-config/pom.xml +++ b/activemq-runtime-config/pom.xml @@ -208,6 +208,27 @@ </plugins> </build> </profile> + <profile> + <id>activemq.tests-autoTransport</id> + <activation> + <property> + <name>activemq.tests</name> + <value>autoTransport</value> + </property> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <excludes> + <exclude>**</exclude> + </excludes> + </configuration> + </plugin> + </plugins> + </build> + </profile> </profiles> http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-spring/pom.xml ---------------------------------------------------------------------- diff --git a/activemq-spring/pom.xml b/activemq-spring/pom.xml index b98f9c7..1a12d27 100755 --- a/activemq-spring/pom.xml +++ b/activemq-spring/pom.xml @@ -323,6 +323,27 @@ </plugins> </build> </profile> + <profile> + <id>activemq.tests-autoTransport</id> + <activation> + <property> + <name>activemq.tests</name> + <value>autoTransport</value> + </property> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <excludes> + <exclude>**</exclude> + </excludes> + </configuration> + </plugin> + </plugins> + </build> + </profile> <profile> <id>activemq.tests.windows.excludes</id> http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-stomp/pom.xml ---------------------------------------------------------------------- diff --git a/activemq-stomp/pom.xml b/activemq-stomp/pom.xml index 7acd71a..c51ff70 100755 --- a/activemq-stomp/pom.xml +++ b/activemq-stomp/pom.xml @@ -164,6 +164,27 @@ </plugins> </build> </profile> + <profile> + <id>activemq.tests-autoTransport</id> + <activation> + <property> + <name>activemq.tests</name> + <value>autoTransport</value> + </property> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <includes> + <include>**/auto/*Test.java</include> + </includes> + </configuration> + </plugin> + </plugins> + </build> + </profile> <profile> <id>activemq.tests.windows.excludes</id> http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOSSLTransport.java ---------------------------------------------------------------------- diff --git a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOSSLTransport.java b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOSSLTransport.java index 4562141..f583533 100644 --- a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOSSLTransport.java +++ b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOSSLTransport.java @@ -25,6 +25,7 @@ import java.nio.ByteBuffer; import java.security.cert.X509Certificate; import javax.net.SocketFactory; +import javax.net.ssl.SSLEngine; import org.apache.activemq.transport.nio.NIOSSLTransport; import org.apache.activemq.wireformat.WireFormat; @@ -40,7 +41,14 @@ public class StompNIOSSLTransport extends NIOSSLTransport { } public StompNIOSSLTransport(WireFormat wireFormat, Socket socket) throws IOException { - super(wireFormat, socket); + super(wireFormat, socket, null, null, null); + } + + + + public StompNIOSSLTransport(WireFormat wireFormat, Socket socket, + SSLEngine engine, InitBuffer initBuffer, ByteBuffer inputBuffer) throws IOException { + super(wireFormat, socket, engine, initBuffer, inputBuffer); } @Override @@ -71,4 +79,18 @@ public class StompNIOSSLTransport extends NIOSSLTransport { super.doConsume(command); } + + /* (non-Javadoc) + * @see org.apache.activemq.transport.nio.NIOSSLTransport#doInit() + */ + @Override + protected void doInit() throws Exception { + if (initBuffer != null) { + nextFrameSize = -1; + // System.out.println("length1: " + initBuffer.array().length); + receiveCounter += initBuffer.readSize; + initBuffer.buffer.flip(); + processCommand(initBuffer.buffer); + } + } } http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOSSLTransportFactory.java ---------------------------------------------------------------------- diff --git a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOSSLTransportFactory.java b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOSSLTransportFactory.java index 94fb559..27a8712 100644 --- a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOSSLTransportFactory.java +++ b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOSSLTransportFactory.java @@ -21,16 +21,19 @@ import java.net.Socket; import java.net.URI; import java.net.URISyntaxException; import java.net.UnknownHostException; +import java.nio.ByteBuffer; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLEngine; import org.apache.activemq.broker.SslContext; import org.apache.activemq.transport.Transport; import org.apache.activemq.transport.TransportServer; import org.apache.activemq.transport.nio.NIOSSLTransportServer; import org.apache.activemq.transport.tcp.TcpTransport; +import org.apache.activemq.transport.tcp.TcpTransport.InitBuffer; import org.apache.activemq.transport.tcp.TcpTransportServer; import org.apache.activemq.wireformat.WireFormat; @@ -63,6 +66,13 @@ public class StompNIOSSLTransportFactory extends StompNIOTransportFactory { } @Override + public TcpTransport createTransport(WireFormat wireFormat, Socket socket, + SSLEngine engine, InitBuffer initBuffer, ByteBuffer inputBuffer) + throws IOException { + return new StompNIOSSLTransport(wireFormat, socket, engine, initBuffer, inputBuffer); + } + + @Override public TransportServer doBind(URI location) throws IOException { if (SslContext.getCurrentSslContext() != null) { try { http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransport.java ---------------------------------------------------------------------- diff --git a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransport.java b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransport.java index e2be9f9..d11a5c1 100644 --- a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransport.java +++ b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransport.java @@ -57,6 +57,10 @@ public class StompNIOTransport extends TcpTransport { super(wireFormat, socket); } + public StompNIOTransport(WireFormat wireFormat, Socket socket, InitBuffer initBuffer) throws IOException { + super(wireFormat, socket, initBuffer); + } + @Override protected void initializeStreams() throws IOException { channel = socket.getChannel(); @@ -84,14 +88,24 @@ public class StompNIOTransport extends TcpTransport { this.dataOut = new DataOutputStream(outPutStream); this.buffOut = outPutStream; codec = new StompCodec(this); + + try { + if (initBuffer != null) { + processBuffer(initBuffer.buffer, initBuffer.readSize); + } + } catch (IOException e) { + onException(e); + } catch (Throwable e) { + onException(IOExceptionSupport.create(e)); + } } private void serviceRead() { try { - while (true) { // read channel int readSize = channel.read(inputBuffer); + // channel is closed, cleanup if (readSize == -1) { onException(new EOFException()); @@ -104,15 +118,7 @@ public class StompNIOTransport extends TcpTransport { break; } - receiveCounter += readSize; - - inputBuffer.flip(); - - ByteArrayInputStream input = new ByteArrayInputStream(inputBuffer.array()); - codec.parse(input, readSize); - - // clear the buffer - inputBuffer.clear(); + processBuffer(inputBuffer, readSize); } } catch (IOException e) { onException(e); @@ -121,6 +127,18 @@ public class StompNIOTransport extends TcpTransport { } } + protected void processBuffer(ByteBuffer buffer, int readSize) throws Exception { + receiveCounter += readSize; + + buffer.flip(); + + ByteArrayInputStream input = new ByteArrayInputStream(buffer.array()); + codec.parse(input, readSize); + + // clear the buffer + buffer.clear(); + } + @Override protected void doStart() throws Exception { connect(); http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransportFactory.java ---------------------------------------------------------------------- diff --git a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransportFactory.java b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransportFactory.java index 4f20df3..be6768d 100644 --- a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransportFactory.java +++ b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransportFactory.java @@ -34,6 +34,7 @@ import org.apache.activemq.transport.MutexTransport; import org.apache.activemq.transport.Transport; import org.apache.activemq.transport.nio.NIOTransportFactory; import org.apache.activemq.transport.tcp.TcpTransport; +import org.apache.activemq.transport.tcp.TcpTransport.InitBuffer; import org.apache.activemq.transport.tcp.TcpTransportServer; import org.apache.activemq.util.IntrospectionSupport; import org.apache.activemq.wireformat.WireFormat; @@ -47,22 +48,32 @@ public class StompNIOTransportFactory extends NIOTransportFactory implements Bro private BrokerContext brokerContext = null; + @Override protected String getDefaultWireFormatType() { return "stomp"; } + @Override protected TcpTransportServer createTcpTransportServer(URI location, ServerSocketFactory serverSocketFactory) throws IOException, URISyntaxException { return new TcpTransportServer(this, location, serverSocketFactory) { + @Override protected Transport createTransport(Socket socket, WireFormat format) throws IOException { return new StompNIOTransport(format, socket); } }; } + @Override protected TcpTransport createTcpTransport(WireFormat wf, SocketFactory socketFactory, URI location, URI localLocation) throws UnknownHostException, IOException { return new StompNIOTransport(wf, socketFactory, location, localLocation); } + @Override + public TcpTransport createTransport(WireFormat wireFormat, Socket socket, + InitBuffer initBuffer) throws IOException { + return new StompNIOTransport(wireFormat, socket, initBuffer); + } + @SuppressWarnings("rawtypes") @Override public Transport serverConfigure(Transport transport, WireFormat format, HashMap options) throws Exception { @@ -76,6 +87,7 @@ public class StompNIOTransportFactory extends NIOTransportFactory implements Bro return transport; } + @Override @SuppressWarnings("rawtypes") public Transport compositeConfigure(Transport transport, WireFormat format, Map options) { transport = new StompTransportFilter(transport, format, brokerContext); @@ -83,6 +95,7 @@ public class StompNIOTransportFactory extends NIOTransportFactory implements Bro return super.compositeConfigure(transport, format, options); } + @Override public void setBrokerService(BrokerService brokerService) { this.brokerContext = brokerService.getBrokerContext(); } http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompTestSupport.java ---------------------------------------------------------------------- diff --git a/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompTestSupport.java b/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompTestSupport.java index 0bf1928..e0db6d9 100644 --- a/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompTestSupport.java +++ b/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompTestSupport.java @@ -62,6 +62,10 @@ public class StompTestSupport { protected int sslPort; protected int nioPort; protected int nioSslPort; + protected int autoPort; + protected int autoSslPort; + protected int autoNioPort; + protected int autoNioSslPort; protected String jmsUri = "vm://localhost"; protected StompConnection stompConnection; protected ActiveMQConnectionFactory cf; @@ -81,6 +85,10 @@ public class StompTestSupport { s.port = 5676; s.nioPort = 5677; s.nioSslPort = 5678; + s.autoPort = 5679; + s.autoSslPort = 5680; + s.autoNioPort = 5681; + s.autoNioSslPort = 5682; s.startBroker(); while(true) { @@ -288,25 +296,49 @@ public class StompTestSupport { connector = brokerService.addConnector( "stomp://0.0.0.0:" + port + getAdditionalConfig()); port = connector.getConnectUri().getPort(); - LOG.debug("Using amqp port " + port); + LOG.debug("Using stomp port " + port); } if (isUseSslConnector()) { connector = brokerService.addConnector( "stomp+ssl://0.0.0.0:" + sslPort + getAdditionalConfig()); sslPort = connector.getConnectUri().getPort(); - LOG.debug("Using amqp+ssl port " + sslPort); + LOG.debug("Using stomp+ssl port " + sslPort); } if (isUseNioConnector()) { connector = brokerService.addConnector( "stomp+nio://0.0.0.0:" + nioPort + getAdditionalConfig()); nioPort = connector.getConnectUri().getPort(); - LOG.debug("Using amqp+nio port " + nioPort); + LOG.debug("Using stomp+nio port " + nioPort); } if (isUseNioPlusSslConnector()) { connector = brokerService.addConnector( "stomp+nio+ssl://0.0.0.0:" + nioSslPort + getAdditionalConfig()); nioSslPort = connector.getConnectUri().getPort(); - LOG.debug("Using amqp+nio+ssl port " + nioSslPort); + LOG.debug("Using stomp+nio+ssl port " + nioSslPort); + } + if (isUseAutoConnector()) { + connector = brokerService.addConnector( + "auto://0.0.0.0:" + autoPort + getAdditionalConfig()); + autoPort = connector.getConnectUri().getPort(); + LOG.debug("Using auto port " + autoPort); + } + if (isUseAutoSslConnector()) { + connector = brokerService.addConnector( + "auto+ssl://0.0.0.0:" + autoSslPort + getAdditionalConfig()); + autoSslPort = connector.getConnectUri().getPort(); + LOG.debug("Using auto+ssl port " + autoSslPort); + } + if (isUseAutoNioConnector()) { + connector = brokerService.addConnector( + "auto+nio://0.0.0.0:" + autoNioPort + getAdditionalConfig()); + autoNioPort = connector.getConnectUri().getPort(); + LOG.debug("Using auto+nio port " + autoNioPort); + } + if (isUseAutoNioPlusSslConnector()) { + connector = brokerService.addConnector( + "auto+nio+ssl://0.0.0.0:" + autoNioSslPort + getAdditionalConfig()); + autoNioSslPort = connector.getConnectUri().getPort(); + LOG.debug("Using auto+nio+ssl port " + autoNioSslPort); } } @@ -334,6 +366,22 @@ public class StompTestSupport { return false; } + protected boolean isUseAutoConnector() { + return false; + } + + protected boolean isUseAutoSslConnector() { + return false; + } + + protected boolean isUseAutoNioConnector() { + return false; + } + + protected boolean isUseAutoNioPlusSslConnector() { + return false; + } + protected String getAdditionalConfig() { return ""; } http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/auto/StompAutoNioSslTest.java ---------------------------------------------------------------------- diff --git a/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/auto/StompAutoNioSslTest.java b/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/auto/StompAutoNioSslTest.java new file mode 100644 index 0000000..90fc18c --- /dev/null +++ b/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/auto/StompAutoNioSslTest.java @@ -0,0 +1,44 @@ +/** + * 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.stomp.auto; + +import java.io.IOException; +import java.net.Socket; + +import javax.net.SocketFactory; +import javax.net.ssl.SSLSocketFactory; + +import org.apache.activemq.transport.stomp.StompTest; + +public class StompAutoNioSslTest extends StompTest { + + @Override + protected boolean isUseTcpConnector() { + return false; + } + + @Override + protected boolean isUseAutoNioPlusSslConnector() { + return true; + } + + @Override + protected Socket createSocket() throws IOException { + SocketFactory factory = SSLSocketFactory.getDefault(); + return factory.createSocket("127.0.0.1", this.autoNioSslPort); + } +} http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/auto/StompAutoNioTest.java ---------------------------------------------------------------------- diff --git a/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/auto/StompAutoNioTest.java b/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/auto/StompAutoNioTest.java new file mode 100644 index 0000000..782d7a1 --- /dev/null +++ b/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/auto/StompAutoNioTest.java @@ -0,0 +1,40 @@ +/** + * 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.stomp.auto; + +import java.io.IOException; +import java.net.Socket; + +import org.apache.activemq.transport.stomp.StompTest; + +public class StompAutoNioTest extends StompTest { + + @Override + protected boolean isUseTcpConnector() { + return false; + } + + @Override + protected boolean isUseAutoNioConnector() { + return true; + } + + @Override + protected Socket createSocket() throws IOException { + return new Socket("127.0.0.1", this.autoNioPort); + } +} http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/auto/StompAutoSslTest.java ---------------------------------------------------------------------- diff --git a/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/auto/StompAutoSslTest.java b/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/auto/StompAutoSslTest.java new file mode 100644 index 0000000..c4ac5c2 --- /dev/null +++ b/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/auto/StompAutoSslTest.java @@ -0,0 +1,44 @@ +/** + * 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.stomp.auto; + +import java.io.IOException; +import java.net.Socket; + +import javax.net.SocketFactory; +import javax.net.ssl.SSLSocketFactory; + +import org.apache.activemq.transport.stomp.StompTest; + +public class StompAutoSslTest extends StompTest { + + @Override + protected boolean isUseTcpConnector() { + return false; + } + + @Override + protected boolean isUseAutoSslConnector() { + return true; + } + + @Override + protected Socket createSocket() throws IOException { + SocketFactory factory = SSLSocketFactory.getDefault(); + return factory.createSocket("127.0.0.1", this.autoSslPort); + } +} http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/auto/StompAutoTest.java ---------------------------------------------------------------------- diff --git a/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/auto/StompAutoTest.java b/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/auto/StompAutoTest.java new file mode 100644 index 0000000..d90eb91 --- /dev/null +++ b/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/auto/StompAutoTest.java @@ -0,0 +1,40 @@ +/** + * 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.stomp.auto; + +import java.io.IOException; +import java.net.Socket; + +import org.apache.activemq.transport.stomp.StompTest; + +public class StompAutoTest extends StompTest { + + @Override + protected boolean isUseTcpConnector() { + return false; + } + + @Override + protected boolean isUseAutoConnector() { + return true; + } + + @Override + protected Socket createSocket() throws IOException { + return new Socket("127.0.0.1", this.autoPort); + } +} http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-unit-tests/pom.xml ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/pom.xml b/activemq-unit-tests/pom.xml index 76ed735..5df7fcf 100755 --- a/activemq-unit-tests/pom.xml +++ b/activemq-unit-tests/pom.xml @@ -580,6 +580,27 @@ </build> </profile> <profile> + <id>activemq.tests-autoTransport</id> + <activation> + <property> + <name>activemq.tests</name> + <value>autoTransport</value> + </property> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <includes> + <include>**/transport/auto/**/*Test.java</include> + </includes> + </configuration> + </plugin> + </plugins> + </build> + </profile> + <profile> <id>activemq.exclude-broken-tests</id> <activation> <activeByDefault>true</activeByDefault> http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoNIOSslTransportBrokerTest.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoNIOSslTransportBrokerTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoNIOSslTransportBrokerTest.java new file mode 100644 index 0000000..496ccf7 --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoNIOSslTransportBrokerTest.java @@ -0,0 +1,67 @@ +/** + * 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.auto; + +import java.net.URI; +import java.net.URISyntaxException; + +import junit.framework.Test; +import junit.textui.TestRunner; + +import org.apache.activemq.transport.TransportBrokerTestSupport; + +public class AutoNIOSslTransportBrokerTest extends TransportBrokerTestSupport { + + public static final String KEYSTORE_TYPE = "jks"; + public static final String PASSWORD = "password"; + public static final String SERVER_KEYSTORE = "src/test/resources/server.keystore"; + public static final String TRUST_KEYSTORE = "src/test/resources/client.keystore"; + + @Override + protected String getBindLocation() { + return "auto+nio+ssl://localhost:0?transport.soWriteTimeout=20000"; + } + + @Override + protected URI getBindURI() throws URISyntaxException { + return new URI("auto+nio+ssl://localhost:0?soWriteTimeout=20000"); + } + + @Override + protected void setUp() throws Exception { + System.setProperty("javax.net.ssl.trustStore", TRUST_KEYSTORE); + System.setProperty("javax.net.ssl.trustStorePassword", PASSWORD); + System.setProperty("javax.net.ssl.trustStoreType", KEYSTORE_TYPE); + System.setProperty("javax.net.ssl.keyStore", SERVER_KEYSTORE); + System.setProperty("javax.net.ssl.keyStorePassword", PASSWORD); + System.setProperty("javax.net.ssl.keyStoreType", KEYSTORE_TYPE); + //System.setProperty("javax.net.debug", "ssl,handshake,data,trustmanager"); + + maxWait = 10000; + super.setUp(); + } + + public static Test suite() { + return suite(AutoNIOSslTransportBrokerTest.class); + } + + public static void main(String[] args) { + TestRunner.run(suite()); + } + + +} http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoNIOTransportBrokerTest.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoNIOTransportBrokerTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoNIOTransportBrokerTest.java new file mode 100644 index 0000000..0281043 --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoNIOTransportBrokerTest.java @@ -0,0 +1,38 @@ +/** + * 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.auto; + +import junit.framework.Test; +import junit.textui.TestRunner; +import org.apache.activemq.transport.TransportBrokerTestSupport; + +public class AutoNIOTransportBrokerTest extends TransportBrokerTestSupport { + + @Override + protected String getBindLocation() { + return "auto+nio://localhost:0"; + } + + public static Test suite() { + return suite(AutoNIOTransportBrokerTest.class); + } + + public static void main(String[] args) { + TestRunner.run(suite()); + } + +} http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoSslTransportBrokerTest.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoSslTransportBrokerTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoSslTransportBrokerTest.java new file mode 100755 index 0000000..203f6ee --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoSslTransportBrokerTest.java @@ -0,0 +1,64 @@ +/** + * 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.auto; + +import java.net.URI; +import java.net.URISyntaxException; +import junit.framework.Test; +import junit.textui.TestRunner; +import org.apache.activemq.transport.TransportBrokerTestSupport; + +public class AutoSslTransportBrokerTest extends TransportBrokerTestSupport { + + public static final String KEYSTORE_TYPE = "jks"; + public static final String PASSWORD = "password"; + public static final String SERVER_KEYSTORE = "src/test/resources/server.keystore"; + public static final String TRUST_KEYSTORE = "src/test/resources/client.keystore"; + + @Override + protected String getBindLocation() { + return "auto+ssl://localhost:0?transport.soWriteTimeout=20000"; + } + + @Override + protected URI getBindURI() throws URISyntaxException { + return new URI("auto+ssl://localhost:0?soWriteTimeout=20000"); + } + + @Override + protected void setUp() throws Exception { + System.setProperty("javax.net.ssl.trustStore", TRUST_KEYSTORE); + System.setProperty("javax.net.ssl.trustStorePassword", PASSWORD); + System.setProperty("javax.net.ssl.trustStoreType", KEYSTORE_TYPE); + System.setProperty("javax.net.ssl.keyStore", SERVER_KEYSTORE); + System.setProperty("javax.net.ssl.keyStorePassword", PASSWORD); + System.setProperty("javax.net.ssl.keyStoreType", KEYSTORE_TYPE); + //System.setProperty("javax.net.debug", "ssl,handshake,data,trustmanager"); + + maxWait = 10000; + super.setUp(); + } + + public static Test suite() { + return suite(AutoSslTransportBrokerTest.class); + } + + public static void main(String[] args) { + TestRunner.run(suite()); + } + +} http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoTransportBrokerTest.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoTransportBrokerTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoTransportBrokerTest.java new file mode 100644 index 0000000..e3f3349 --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoTransportBrokerTest.java @@ -0,0 +1,38 @@ +/** + * 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.auto; + +import junit.framework.Test; +import junit.textui.TestRunner; +import org.apache.activemq.transport.TransportBrokerTestSupport; + +public class AutoTransportBrokerTest extends TransportBrokerTestSupport { + + @Override + protected String getBindLocation() { + return "auto://localhost:0"; + } + + public static Test suite() { + return suite(AutoTransportBrokerTest.class); + } + + public static void main(String[] args) { + TestRunner.run(suite()); + } + +} http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoTransportConfigureTest.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoTransportConfigureTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoTransportConfigureTest.java new file mode 100644 index 0000000..9054e1a --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoTransportConfigureTest.java @@ -0,0 +1,156 @@ +/** + * 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.auto; + +import java.util.Arrays; + +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.JMSException; +import javax.jms.MessageProducer; +import javax.jms.Session; + +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.command.ActiveMQQueue; +import org.apache.activemq.command.ActiveMQTextMessage; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + + +@RunWith(Parameterized.class) +public class AutoTransportConfigureTest { + + public static final String KEYSTORE_TYPE = "jks"; + public static final String PASSWORD = "password"; + public static final String SERVER_KEYSTORE = "src/test/resources/server.keystore"; + public static final String TRUST_KEYSTORE = "src/test/resources/client.keystore"; + + private BrokerService brokerService; + private String url; + + @Parameters + public static Iterable<Object[]> parameters() { + return Arrays.asList(new Object[][]{ + {"auto"}, + {"auto+nio"}, + {"auto+ssl"}, + {"auto+nio+ssl"} + }); + } + + private String transportType; + + public AutoTransportConfigureTest(String transportType) { + super(); + this.transportType = transportType; + } + + @Before + public void setUp() throws Exception { + System.setProperty("javax.net.ssl.trustStore", TRUST_KEYSTORE); + System.setProperty("javax.net.ssl.trustStorePassword", PASSWORD); + System.setProperty("javax.net.ssl.trustStoreType", KEYSTORE_TYPE); + System.setProperty("javax.net.ssl.keyStore", SERVER_KEYSTORE); + System.setProperty("javax.net.ssl.keyStorePassword", PASSWORD); + System.setProperty("javax.net.ssl.keyStoreType", KEYSTORE_TYPE); + + } + + @After + public void tearDown() throws Exception{ + if (this.brokerService != null) { + this.brokerService.stop(); + this.brokerService.waitUntilStopped(); + } + } + + protected void createBroker(String uriConfig) throws Exception { + brokerService = new BrokerService(); + brokerService.setPersistent(false); + url = brokerService.addConnector(uriConfig).getPublishableConnectString(); + brokerService.start(); + brokerService.waitUntilStarted(); + + } + + @Test(expected=JMSException.class) + public void testUrlConfiguration() throws Exception { + createBroker(transportType + "://localhost:0?wireFormat.maxFrameSize=10"); + + ConnectionFactory factory = new ActiveMQConnectionFactory(url); + sendMessage(factory.createConnection()); + } + + @Test(expected=JMSException.class) + public void testUrlConfigurationOpenWireFail() throws Exception { + createBroker(transportType + "://localhost:0?wireFormat.default.maxFrameSize=10"); + + ConnectionFactory factory = new ActiveMQConnectionFactory(url); + sendMessage(factory.createConnection()); + } + + @Test + public void testUrlConfigurationOpenWireSuccess() throws Exception { + //Will work because max frame size only applies to amqp + createBroker(transportType + "://localhost:0?wireFormat.amqp.maxFrameSize=10"); + + ConnectionFactory factory = new ActiveMQConnectionFactory(url); + sendMessage(factory.createConnection()); + } + + @Test(expected=JMSException.class) + public void testUrlConfigurationOpenWireNotAvailable() throws Exception { + //only amqp is available so should fail + createBroker(transportType + "://localhost:0?auto.protocols=amqp"); + + ConnectionFactory factory = new ActiveMQConnectionFactory(url); + sendMessage(factory.createConnection()); + } + + @Test + public void testUrlConfigurationOpenWireAvailable() throws Exception { + //only open wire is available + createBroker(transportType + "://localhost:0?auto.protocols=default"); + + ConnectionFactory factory = new ActiveMQConnectionFactory(url); + sendMessage(factory.createConnection()); + } + + @Test + public void testUrlConfigurationOpenWireAndAmqpAvailable() throws Exception { + createBroker(transportType + "://localhost:0?auto.protocols=default,amqp"); + + ConnectionFactory factory = new ActiveMQConnectionFactory(url); + sendMessage(factory.createConnection()); + } + + + protected void sendMessage(Connection connection) throws JMSException { + connection.start(); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageProducer producer = session.createProducer(new ActiveMQQueue("test")); + ActiveMQTextMessage message = new ActiveMQTextMessage(); + message.setText("this is a test"); + producer.send(message); + } + +} http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/failover/AutoFailoverClusterTest.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/failover/AutoFailoverClusterTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/failover/AutoFailoverClusterTest.java new file mode 100644 index 0000000..a612e22 --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/failover/AutoFailoverClusterTest.java @@ -0,0 +1,27 @@ +/** + * 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.auto.failover; + +import org.apache.activemq.transport.failover.FailoverClusterTest; + +public class AutoFailoverClusterTest extends FailoverClusterTest { + + @Override + protected String getBindAddress() { + return "auto://0.0.0.0:0"; + } +} http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/failover/AutoFailoverTimeoutTest.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/failover/AutoFailoverTimeoutTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/failover/AutoFailoverTimeoutTest.java new file mode 100644 index 0000000..b62c245 --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/failover/AutoFailoverTimeoutTest.java @@ -0,0 +1,27 @@ +/** + * 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.auto.failover; + +import org.apache.activemq.transport.failover.FailoverTimeoutTest; + +public class AutoFailoverTimeoutTest extends FailoverTimeoutTest { + + @Override + protected String getTransportUri() { + return "auto://localhost:0"; + } +} http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/failover/FailoverAutoRandomTest.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/failover/FailoverAutoRandomTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/failover/FailoverAutoRandomTest.java new file mode 100644 index 0000000..05da980 --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/failover/FailoverAutoRandomTest.java @@ -0,0 +1,28 @@ +/** + * 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.auto.failover; + +import org.apache.activemq.transport.failover.FailoverRandomTest; + +public class FailoverAutoRandomTest extends FailoverRandomTest { + + @Override + protected String getBrokerUrl() { + return "auto://localhost:0"; + } +} http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/failover/FailoverAutoTransportBrokerTest.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/failover/FailoverAutoTransportBrokerTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/failover/FailoverAutoTransportBrokerTest.java new file mode 100755 index 0000000..808f72d --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/failover/FailoverAutoTransportBrokerTest.java @@ -0,0 +1,43 @@ +/** + * 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.auto.failover; + +import junit.framework.Test; + +import org.apache.activemq.transport.failover.FailoverTransportBrokerTest; + +public class FailoverAutoTransportBrokerTest extends FailoverTransportBrokerTest { + + @Override + protected String getLocalURI() { + return "auto://localhost:0?wireFormat.tcpNoDelayEnabled=true"; + } + + @Override + protected String getRemoteURI() { + return "auto://localhost:0?wireFormat.tcpNoDelayEnabled=true"; + } + + public static Test suite() { + return suite(FailoverAutoTransportBrokerTest.class); + } + + public static void main(String[] args) { + junit.textui.TestRunner.run(suite()); + } + +} http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/nio/AutoNIOJmsDurableTopicSendReceiveTest.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/nio/AutoNIOJmsDurableTopicSendReceiveTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/nio/AutoNIOJmsDurableTopicSendReceiveTest.java new file mode 100644 index 0000000..869b10e --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/nio/AutoNIOJmsDurableTopicSendReceiveTest.java @@ -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.auto.nio; + +import org.apache.activemq.transport.nio.NIOJmsDurableTopicSendReceiveTest; + +public class AutoNIOJmsDurableTopicSendReceiveTest extends NIOJmsDurableTopicSendReceiveTest { + + @Override + protected String getBrokerURL() { + return "auto+nio://localhost:61616"; + } + + +} http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/nio/AutoNIOJmsSendAndReceiveTest.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/nio/AutoNIOJmsSendAndReceiveTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/nio/AutoNIOJmsSendAndReceiveTest.java new file mode 100644 index 0000000..7f0b72d --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/nio/AutoNIOJmsSendAndReceiveTest.java @@ -0,0 +1,32 @@ +/** + * 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.auto.nio; + +import org.apache.activemq.transport.nio.NIOJmsSendAndReceiveTest; + +/** + * + */ +public class AutoNIOJmsSendAndReceiveTest extends NIOJmsSendAndReceiveTest { + + @Override + protected String getBrokerURL() { + return "auto+nio://localhost:61616"; + } + + +} http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/nio/AutoNIOPersistentSendAndReceiveTest.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/nio/AutoNIOPersistentSendAndReceiveTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/nio/AutoNIOPersistentSendAndReceiveTest.java new file mode 100644 index 0000000..defe191 --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/nio/AutoNIOPersistentSendAndReceiveTest.java @@ -0,0 +1,27 @@ +/** + * 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.auto.nio; + +import org.apache.activemq.transport.nio.NIOPersistentSendAndReceiveTest; + +public class AutoNIOPersistentSendAndReceiveTest extends NIOPersistentSendAndReceiveTest { + + @Override + protected String getBrokerURL() { + return "auto+nio://localhost:61616"; + } +} http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/nio/AutoNIOSSLBasicTest.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/nio/AutoNIOSSLBasicTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/nio/AutoNIOSSLBasicTest.java new file mode 100644 index 0000000..3ab93fa --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/nio/AutoNIOSSLBasicTest.java @@ -0,0 +1,27 @@ +/** + * 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.auto.nio; + +import org.apache.activemq.transport.nio.NIOSSLBasicTest; + +public class AutoNIOSSLBasicTest extends NIOSSLBasicTest { + + @Override + protected String getTransportType() { + return "auto+nio+ssl"; + } +} http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java index 417516f..86a251c 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java @@ -44,10 +44,14 @@ public class FailoverClusterTest extends TestCase { private final List<ActiveMQConnection> connections = new ArrayList<ActiveMQConnection>(); + protected String getBindAddress() { + return BROKER_BIND_ADDRESS; + } + public void testClusterConnectedAfterClients() throws Exception { createClients(); if (brokerB == null) { - brokerB = createBrokerB(BROKER_BIND_ADDRESS); + brokerB = createBrokerB(getBindAddress()); } Thread.sleep(3000); Set<String> set = new HashSet<String>(); @@ -61,7 +65,7 @@ public class FailoverClusterTest extends TestCase { createClients(); if (brokerB == null) { // add in server side only url param, should not be propagated - brokerB = createBrokerB(BROKER_BIND_ADDRESS + "?transport.closeAsync=false"); + brokerB = createBrokerB(getBindAddress() + "?transport.closeAsync=false"); } Thread.sleep(3000); Set<String> set = new HashSet<String>(); @@ -74,7 +78,7 @@ public class FailoverClusterTest extends TestCase { public void testClusterConnectedBeforeClients() throws Exception { if (brokerB == null) { - brokerB = createBrokerB(BROKER_BIND_ADDRESS); + brokerB = createBrokerB(getBindAddress()); } Thread.sleep(5000); createClients(); @@ -92,7 +96,7 @@ public class FailoverClusterTest extends TestCase { @Override protected void setUp() throws Exception { if (brokerA == null) { - brokerA = createBrokerA(BROKER_BIND_ADDRESS + "?transport.closeAsync=false"); + brokerA = createBrokerA(getBindAddress() + "?transport.closeAsync=false"); clientUrl = "failover://(" + brokerA.getTransportConnectors().get(0).getPublishableConnectString() + ")"; } } http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRandomTest.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRandomTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRandomTest.java index 8998fe7..4edd67a 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRandomTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRandomTest.java @@ -24,23 +24,29 @@ import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; public class FailoverRandomTest extends TestCase { - + BrokerService brokerA, brokerB; - + + @Override public void setUp() throws Exception { brokerA = createBroker("A"); brokerB = createBroker("B"); } - + + @Override public void tearDown() throws Exception { brokerA.stop(); brokerB.stop(); } - + + protected String getBrokerUrl() { + return "tcp://localhost:0"; + } + private BrokerService createBroker(String name) throws Exception { BrokerService broker = new BrokerService(); broker.setBrokerName("Broker"+ name); - broker.addConnector("tcp://localhost:0"); + broker.addConnector(getBrokerUrl()); broker.getManagementContext().setCreateConnector(false); broker.setPersistent(false); broker.setUseJmx(false); @@ -55,14 +61,14 @@ public class FailoverRandomTest extends TestCase { + brokerB.getTransportConnectors().get(0).getConnectUri() + ")"; ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(failoverUrl); - - + + ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection(); connection.start(); String brokerName1 = connection.getBrokerName(); assertNotNull(brokerName1); connection.close(); - + String brokerName2 = brokerName1; int attempts = 40; while (brokerName1.equals(brokerName2) && attempts-- > 0) { http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTimeoutTest.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTimeoutTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTimeoutTest.java index 9ef6e28..865d7c9 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTimeoutTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTimeoutTest.java @@ -61,6 +61,10 @@ public class FailoverTimeoutTest { } } + protected String getTransportUri() { + return "tcp://localhost:0"; + } + @Test public void testTimoutDoesNotFailConnectionAttempts() throws Exception { bs.stop(); http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLBasicTest.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLBasicTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLBasicTest.java index 885446d..473d785 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLBasicTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLBasicTest.java @@ -78,21 +78,21 @@ public class NIOSSLBasicTest { @Test public void basicConnector() throws Exception { - BrokerService broker = createBroker("nio+ssl", "nio+ssl://localhost:0?transport.needClientAuth=true"); + BrokerService broker = createBroker("nio+ssl", getTransportType() + "://localhost:0?transport.needClientAuth=true"); basicSendReceive("ssl://localhost:" + broker.getConnectorByName("nio+ssl").getConnectUri().getPort()); stopBroker(broker); } @Test public void enabledCipherSuites() throws Exception { - BrokerService broker = createBroker("nio+ssl", "nio+ssl://localhost:0?transport.needClientAuth=true&transport.enabledCipherSuites=SSL_RSA_WITH_RC4_128_SHA,SSL_DH_anon_WITH_3DES_EDE_CBC_SHA"); + BrokerService broker = createBroker("nio+ssl", getTransportType() + "://localhost:0?transport.needClientAuth=true&transport.enabledCipherSuites=SSL_RSA_WITH_RC4_128_SHA,SSL_DH_anon_WITH_3DES_EDE_CBC_SHA"); basicSendReceive("ssl://localhost:" + broker.getConnectorByName("nio+ssl").getConnectUri().getPort()); stopBroker(broker); } @Test public void enabledProtocols() throws Exception { - BrokerService broker = createBroker("nio+ssl", "nio+ssl://localhost:61616?transport.needClientAuth=true&transport.enabledProtocols=TLSv1,TLSv1.1,TLSv1.2"); + BrokerService broker = createBroker("nio+ssl", getTransportType() + "://localhost:61616?transport.needClientAuth=true&transport.enabledProtocols=TLSv1,TLSv1.1,TLSv1.2"); basicSendReceive("ssl://localhost:" + broker.getConnectorByName("nio+ssl").getConnectUri().getPort()); stopBroker(broker); } @@ -112,4 +112,8 @@ public class NIOSSLBasicTest { Message received = consumer.receive(2000); TestCase.assertEquals(body, ((TextMessage)received).getText()); } + + protected String getTransportType() { + return "nio+ssl"; + } } http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLTransportBrokerTest.java ---------------------------------------------------------------------- diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLTransportBrokerTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLTransportBrokerTest.java index 3373540..2d6d13e 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLTransportBrokerTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/nio/NIOSSLTransportBrokerTest.java @@ -29,6 +29,7 @@ public class NIOSSLTransportBrokerTest extends TransportBrokerTestSupport { public static final String SERVER_KEYSTORE = "src/test/resources/server.keystore"; public static final String TRUST_KEYSTORE = "src/test/resources/client.keystore"; + @Override protected String getBindLocation() { return "nio+ssl://localhost:0?transport.soWriteTimeout=20000"; } @@ -38,10 +39,11 @@ public class NIOSSLTransportBrokerTest extends TransportBrokerTestSupport { return new URI("nio+ssl://localhost:0?soWriteTimeout=20000"); } + @Override protected void setUp() throws Exception { System.setProperty("javax.net.ssl.trustStore", TRUST_KEYSTORE); System.setProperty("javax.net.ssl.trustStorePassword", PASSWORD); - System.setProperty("javax.net.ssl.trustStoreType", KEYSTORE_TYPE); + System.setProperty("javax.net.ssl.trustStoreType", KEYSTORE_TYPE); System.setProperty("javax.net.ssl.keyStore", SERVER_KEYSTORE); System.setProperty("javax.net.ssl.keyStoreType", KEYSTORE_TYPE); System.setProperty("javax.net.ssl.keyStorePassword", PASSWORD); http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-web-demo/pom.xml ---------------------------------------------------------------------- diff --git a/activemq-web-demo/pom.xml b/activemq-web-demo/pom.xml index 8812340..58aa3b1 100755 --- a/activemq-web-demo/pom.xml +++ b/activemq-web-demo/pom.xml @@ -258,5 +258,26 @@ </plugins> </build> </profile> + <profile> + <id>activemq.tests-autoTransport</id> + <activation> + <property> + <name>activemq.tests</name> + <value>autoTransport</value> + </property> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <excludes> + <exclude>**</exclude> + </excludes> + </configuration> + </plugin> + </plugins> + </build> + </profile> </profiles> </project> http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/activemq-web/pom.xml ---------------------------------------------------------------------- diff --git a/activemq-web/pom.xml b/activemq-web/pom.xml index 8b5776d..e349f9e 100755 --- a/activemq-web/pom.xml +++ b/activemq-web/pom.xml @@ -161,5 +161,26 @@ </plugins> </build> </profile> + <profile> + <id>activemq.tests-autoTransport</id> + <activation> + <property> + <name>activemq.tests</name> + <value>autoTransport</value> + </property> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <excludes> + <exclude>**</exclude> + </excludes> + </configuration> + </plugin> + </plugins> + </build> + </profile> </profiles> </project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq/blob/04ee70a1/assembly/pom.xml ---------------------------------------------------------------------- diff --git a/assembly/pom.xml b/assembly/pom.xml index 71a6a6f..d7aa25a 100755 --- a/assembly/pom.xml +++ b/assembly/pom.xml @@ -575,5 +575,26 @@ </plugins> </build> </profile> + <profile> + <id>activemq.tests-autoTransport</id> + <activation> + <property> + <name>activemq.tests</name> + <value>autoTransport</value> + </property> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <excludes> + <exclude>**</exclude> + </excludes> + </configuration> + </plugin> + </plugins> + </build> + </profile> </profiles> </project>