diff options
author | Robert Gemmell <robbie@apache.org> | 2013-09-23 23:42:30 +0000 |
---|---|---|
committer | Robert Gemmell <robbie@apache.org> | 2013-09-23 23:42:30 +0000 |
commit | cf8dfdb4d673acee787c5e53159debd2577efded (patch) | |
tree | 4555f78461ee8b6221b1f33af590b89bac3e4257 /java | |
parent | 9324c3e5b86d7ff988cc9859016830844ae6b193 (diff) | |
download | qpid-python-cf8dfdb4d673acee787c5e53159debd2577efded.tar.gz |
QPID-5160: add a qpid-test-utils module instead of making every modules tests rely on the tests dir from the common module
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1525738 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
34 files changed, 455 insertions, 54 deletions
diff --git a/java/bdbstore/build.xml b/java/bdbstore/build.xml index 6262b24aad..975176c834 100644 --- a/java/bdbstore/build.xml +++ b/java/bdbstore/build.xml @@ -18,7 +18,7 @@ --> <project name="bdbstore" xmlns:ivy="antlib:org.apache.ivy.ant" default="build"> <property name="module.depends" value="common broker-core broker-plugins/amqp-0-8-protocol broker-plugins/amqp-0-10-protocol" /> - <property name="module.test.depends" value="client common/tests broker-core/tests management/common systests broker-plugins/management-jmx broker-plugins/memory-store broker-plugins/amqp-0-8-protocol broker-plugins/amqp-0-10-protocol broker-plugins/amqp-msg-conv-0-8-to-0-10" /> + <property name="module.test.depends" value="client qpid-test-utils broker-core/tests management/common systests broker-plugins/management-jmx broker-plugins/memory-store broker-plugins/amqp-0-8-protocol broker-plugins/amqp-0-10-protocol broker-plugins/amqp-msg-conv-0-8-to-0-10" /> <property name="module.genpom" value="true"/> <property name="module.genpom.args" value="-Sqpid-common=provided -Sqpid-broker-core=provided -Sqpid-broker-plugins-amqp-0-8-protocol=provided -Sje=provided"/> diff --git a/java/bdbstore/jmx/build.xml b/java/bdbstore/jmx/build.xml index 33e9b1e580..544cdef2fc 100644 --- a/java/bdbstore/jmx/build.xml +++ b/java/bdbstore/jmx/build.xml @@ -18,7 +18,7 @@ --> <project name="bdbstore-jmx" default="build"> <property name="module.depends" value="common broker-core broker-plugins/management-jmx management/common bdbstore" /> - <property name="module.test.depends" value="broker-core/tests common/tests management/common client systests bdbstore/tests broker-plugins/memory-store" /> + <property name="module.test.depends" value="broker-core/tests qpid-test-utils management/common client systests bdbstore/tests broker-plugins/memory-store" /> <property name="module.genpom" value="true"/> <property name="module.genpom.args" value="-Sqpid-common=provided -Sqpid-broker-core=provided -Sqpid-broker-plugins-management-jmx=provided -Sqpid-management-common=provided -Sqpid-bdbstore=provided -Sje=provided"/> diff --git a/java/broker-core/build.xml b/java/broker-core/build.xml index 2b3376c504..c8c54a6f70 100644 --- a/java/broker-core/build.xml +++ b/java/broker-core/build.xml @@ -20,7 +20,7 @@ --> <project name="AMQ Broker" default="build"> <property name="module.depends" value="management/common common"/> - <property name="module.test.depends" value="common/tests" /> + <property name="module.test.depends" value="qpid-test-utils" /> <property name="module.genpom" value="true"/> <import file="../module.xml"/> diff --git a/java/broker-plugins/access-control/build.xml b/java/broker-plugins/access-control/build.xml index ac633ab369..0e718c80c9 100644 --- a/java/broker-plugins/access-control/build.xml +++ b/java/broker-plugins/access-control/build.xml @@ -18,7 +18,7 @@ --> <project name="Qpid Broker-Plugins Access Control" default="build"> <property name="module.depends" value="common broker-core" /> - <property name="module.test.depends" value="common/tests broker-core/tests management/common" /> + <property name="module.test.depends" value="qpid-test-utils broker-core/tests management/common" /> <property name="module.genpom" value="true"/> <property name="module.genpom.args" value="-Sqpid-common=provided -Sqpid-broker-core=provided"/> diff --git a/java/broker-plugins/amqp-0-10-protocol/build.xml b/java/broker-plugins/amqp-0-10-protocol/build.xml index 5aed89f43e..3537be172d 100644 --- a/java/broker-plugins/amqp-0-10-protocol/build.xml +++ b/java/broker-plugins/amqp-0-10-protocol/build.xml @@ -18,7 +18,7 @@ --> <project name="Qpid Broker-Plugins AMQP 0-10 Protocol" default="build"> <property name="module.depends" value="common broker-core" /> - <property name="module.test.depends" value="common/tests broker-core/tests" /> + <property name="module.test.depends" value="qpid-test-utils broker-core/tests" /> <property name="module.genpom" value="true"/> <property name="module.genpom.args" value="-Sqpid-common=provided -Sqpid-broker-core=provided"/> diff --git a/java/broker-plugins/amqp-0-8-protocol/build.xml b/java/broker-plugins/amqp-0-8-protocol/build.xml index 5c8d5e3135..0ab2b0b833 100644 --- a/java/broker-plugins/amqp-0-8-protocol/build.xml +++ b/java/broker-plugins/amqp-0-8-protocol/build.xml @@ -18,7 +18,7 @@ --> <project name="Qpid Broker-Plugins AMQP 0-8 Protocol" default="build"> <property name="module.depends" value="common broker-core" /> - <property name="module.test.depends" value="common/tests broker-core/tests" /> + <property name="module.test.depends" value="qpid-test-utils broker-core/tests" /> <property name="module.genpom" value="true"/> <property name="module.genpom.args" value="-Sqpid-common=provided -Sqpid-broker-core=provided"/> diff --git a/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/InternalTestProtocolSession.java b/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/InternalTestProtocolSession.java index e8fda2bc65..5b1e5af7bd 100644 --- a/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/InternalTestProtocolSession.java +++ b/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/InternalTestProtocolSession.java @@ -20,38 +20,38 @@ */ package org.apache.qpid.server.protocol.v0_8; +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.nio.ByteBuffer; +import java.security.Principal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; + +import javax.security.auth.Subject; + import org.apache.qpid.AMQException; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.ContentHeaderBody; import org.apache.qpid.framing.abstraction.MessagePublishInfo; import org.apache.qpid.protocol.AMQConstant; -import org.apache.qpid.server.protocol.AMQSessionModel; -import org.apache.qpid.server.protocol.v0_8.AMQChannel; -import org.apache.qpid.server.protocol.v0_8.AMQMessage; import org.apache.qpid.server.message.MessageContentSource; import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.protocol.v0_8.AMQProtocolEngine; +import org.apache.qpid.server.protocol.AMQSessionModel; import org.apache.qpid.server.protocol.v0_8.output.ProtocolOutputConverter; import org.apache.qpid.server.queue.QueueEntry; import org.apache.qpid.server.security.auth.AuthenticatedPrincipal; import org.apache.qpid.server.security.auth.UsernamePrincipal; import org.apache.qpid.server.subscription.ClientDeliveryMethod; import org.apache.qpid.server.subscription.Subscription; -import org.apache.qpid.server.protocol.v0_8.SubscriptionImpl; import org.apache.qpid.server.virtualhost.VirtualHost; -import org.apache.qpid.transport.TestNetworkConnection; - -import javax.security.auth.Subject; - -import java.security.Principal; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; +import org.apache.qpid.transport.Sender; +import org.apache.qpid.transport.network.NetworkConnection; public class InternalTestProtocolSession extends AMQProtocolEngine implements ProtocolOutputConverter { @@ -266,4 +266,95 @@ public class InternalTestProtocolSession extends AMQProtocolEngine implements Pr } } } + + private static class TestNetworkConnection implements NetworkConnection + { + private String _remoteHost = "127.0.0.1"; + private String _localHost = "127.0.0.1"; + private int _port = 1; + private final Sender<ByteBuffer> _sender; + + public TestNetworkConnection() + { + _sender = new Sender<ByteBuffer>() + { + public void setIdleTimeout(int i) + { + } + + public void send(ByteBuffer msg) + { + } + + public void flush() + { + } + + public void close() + { + } + }; + } + + @Override + public SocketAddress getLocalAddress() + { + return new InetSocketAddress(_localHost, _port); + } + + @Override + public SocketAddress getRemoteAddress() + { + return new InetSocketAddress(_remoteHost, _port); + } + + @Override + public void setMaxReadIdle(int idleTime) + { + } + + @Override + public void setPeerPrincipal(Principal principal) + { + } + + @Override + public Principal getPeerPrincipal() + { + return null; + } + + @Override + public int getMaxReadIdle() + { + return 0; + } + + @Override + public int getMaxWriteIdle() + { + return 0; + } + + @Override + public void setMaxWriteIdle(int idleTime) + { + } + + @Override + public void close() + { + } + + @Override + public Sender<ByteBuffer> getSender() + { + return _sender; + } + + @Override + public void start() + { + } + } } diff --git a/java/broker-plugins/amqp-1-0-protocol/build.xml b/java/broker-plugins/amqp-1-0-protocol/build.xml index 99620905db..00926c0787 100644 --- a/java/broker-plugins/amqp-1-0-protocol/build.xml +++ b/java/broker-plugins/amqp-1-0-protocol/build.xml @@ -18,7 +18,7 @@ --> <project name="Qpid Broker-Plugins AMQP 1.0 Protocol" default="build"> <property name="module.depends" value="common broker-core amqp-1-0-common" /> - <property name="module.test.depends" value="common/tests broker-core/tests" /> + <property name="module.test.depends" value="qpid-test-utils broker-core/tests" /> <property name="module.genpom" value="true"/> <property name="module.genpom.args" value="-Sqpid-common=provided -Sqpid-broker-core=provided"/> diff --git a/java/broker-plugins/amqp-msg-conv-0-10-to-1-0/build.xml b/java/broker-plugins/amqp-msg-conv-0-10-to-1-0/build.xml index 66a08ddc31..161a4c394c 100644 --- a/java/broker-plugins/amqp-msg-conv-0-10-to-1-0/build.xml +++ b/java/broker-plugins/amqp-msg-conv-0-10-to-1-0/build.xml @@ -18,7 +18,7 @@ --> <project name="Qpid Broker-Plugins AMQP 0.8 to 1.0 MessageConversion" default="build"> <property name="module.depends" value="common broker-core amqp-1-0-common broker-plugins/amqp-1-0-protocol broker-plugins/amqp-0-10-protocol" /> - <property name="module.test.depends" value="common/tests broker-core/tests" /> + <property name="module.test.depends" value="qpid-test-utils broker-core/tests" /> <property name="module.genpom" value="true"/> <property name="module.genpom.args" value="-Sqpid-common=provided -Sqpid-broker-core=provided -Sqpid-amqp-1-0-common=provided -Sqpid-broker-plugins-amqp-0-10-protocol=provided -Sqpid-broker-plugins-amqp-1-0-protocol=provided"/> diff --git a/java/broker-plugins/amqp-msg-conv-0-8-to-0-10/build.xml b/java/broker-plugins/amqp-msg-conv-0-8-to-0-10/build.xml index 0d83e18abe..26a89bfed9 100644 --- a/java/broker-plugins/amqp-msg-conv-0-8-to-0-10/build.xml +++ b/java/broker-plugins/amqp-msg-conv-0-8-to-0-10/build.xml @@ -18,7 +18,7 @@ --> <project name="Qpid Broker-Plugins AMQP 0.8 to 0.10 MessageConversion" default="build"> <property name="module.depends" value="common broker-core broker-plugins/amqp-0-8-protocol broker-plugins/amqp-0-10-protocol" /> - <property name="module.test.depends" value="common/tests broker-core/tests" /> + <property name="module.test.depends" value="qpid-test-utils broker-core/tests" /> <property name="module.genpom" value="true"/> <property name="module.genpom.args" value="-Sqpid-common=provided -Sqpid-broker-core=provided -Sqpid-broker-plugins-amqp-0-10-protocol=provided -Sqpid-broker-plugins-amqp-0-8-protocol=provided"/> diff --git a/java/broker-plugins/amqp-msg-conv-0-8-to-1-0/build.xml b/java/broker-plugins/amqp-msg-conv-0-8-to-1-0/build.xml index 8a8a4eadfa..f28b6760e5 100644 --- a/java/broker-plugins/amqp-msg-conv-0-8-to-1-0/build.xml +++ b/java/broker-plugins/amqp-msg-conv-0-8-to-1-0/build.xml @@ -18,7 +18,7 @@ --> <project name="Qpid Broker-Plugins AMQP 0.8 to 1.0 MessageConversion" default="build"> <property name="module.depends" value="common broker-core amqp-1-0-common broker-plugins/amqp-0-8-protocol broker-plugins/amqp-1-0-protocol" /> - <property name="module.test.depends" value="common/tests broker-core/tests" /> + <property name="module.test.depends" value="qpid-test-utils broker-core/tests" /> <property name="module.genpom" value="true"/> <property name="module.genpom.args" value="-Sqpid-common=provided -Sqpid-broker-core=provided -Sqpid-amqp-1-0-common=provided -Sqpid-broker-plugins-amqp-1-0-protocol=provided -Sqpid-broker-plugins-amqp-0-8-protocol=provided"/> diff --git a/java/broker-plugins/derby-store/build.xml b/java/broker-plugins/derby-store/build.xml index c0d1bcb4b1..95d3263fbc 100644 --- a/java/broker-plugins/derby-store/build.xml +++ b/java/broker-plugins/derby-store/build.xml @@ -18,7 +18,7 @@ --> <project name="Qpid Broker-Plugins Derby Store" default="build"> <property name="module.depends" value="common broker-core" /> - <property name="module.test.depends" value="common/tests broker-core/tests" /> + <property name="module.test.depends" value="qpid-test-utils broker-core/tests" /> <property name="module.genpom" value="true"/> <property name="module.genpom.args" value="-Sqpid-common=provided -Sqpid-broker-core=provided"/> diff --git a/java/broker-plugins/jdbc-store/build.xml b/java/broker-plugins/jdbc-store/build.xml index f82c22119d..4a8e72898c 100644 --- a/java/broker-plugins/jdbc-store/build.xml +++ b/java/broker-plugins/jdbc-store/build.xml @@ -18,7 +18,7 @@ --> <project name="Qpid Broker-Plugins JDBC Store" default="build"> <property name="module.depends" value="common broker-core" /> - <property name="module.test.depends" value="common/tests broker-core/tests" /> + <property name="module.test.depends" value="qpid-test-utils broker-core/tests" /> <property name="module.genpom" value="true"/> <property name="module.genpom.args" value="-Sqpid-common=provided -Sqpid-broker-core=provided"/> diff --git a/java/broker-plugins/management-http/build.xml b/java/broker-plugins/management-http/build.xml index 188e64c885..05af45a289 100644 --- a/java/broker-plugins/management-http/build.xml +++ b/java/broker-plugins/management-http/build.xml @@ -19,7 +19,7 @@ <project name="Qpid Broker-Plugins Management HTTP" default="build"> <property name="module.depends" value="common broker-core" /> - <property name="module.test.depends" value="broker-core/tests common/tests management/common client" /> + <property name="module.test.depends" value="broker-core/tests qpid-test-utils management/common client" /> <property name="module.genpom" value="true" /> <property name="module.genpom.args" value="-Sqpid-common=provided -Sqpid-broker-core=provided" /> diff --git a/java/broker-plugins/management-jmx/build.xml b/java/broker-plugins/management-jmx/build.xml index 98c821ed5c..0209ecbd7a 100644 --- a/java/broker-plugins/management-jmx/build.xml +++ b/java/broker-plugins/management-jmx/build.xml @@ -18,7 +18,7 @@ --> <project name="Qpid Broker-Plugins Management JMX" default="build"> <property name="module.depends" value="common broker-core management/common" /> - <property name="module.test.depends" value="broker-core/tests common/tests management/common client" /> + <property name="module.test.depends" value="broker-core/tests qpid-test-utils management/common client" /> <property name="module.genpom" value="true"/> <property name="module.genpom.args" value="-Sqpid-common=provided -Sqpid-broker-core=provided -Sqpid-management-common=provided"/> diff --git a/java/broker-plugins/memory-store/build.xml b/java/broker-plugins/memory-store/build.xml index 14567ad3d5..6d107b7803 100644 --- a/java/broker-plugins/memory-store/build.xml +++ b/java/broker-plugins/memory-store/build.xml @@ -18,7 +18,7 @@ --> <project name="Qpid Broker-Plugins Memory Store" default="build"> <property name="module.depends" value="common broker-core" /> - <property name="module.test.depends" value="common/tests broker-core/tests" /> + <property name="module.test.depends" value="qpid-test-utils broker-core/tests" /> <property name="module.genpom" value="true"/> <property name="module.genpom.args" value="-Sqpid-common=provided -Sqpid-broker-core=provided"/> diff --git a/java/broker/build.xml b/java/broker/build.xml index d0c976787a..53682f2e58 100644 --- a/java/broker/build.xml +++ b/java/broker/build.xml @@ -20,7 +20,7 @@ --> <project name="Broker" default="build"> <property name="module.depends" value="broker-core common"/> - <property name="module.test.depends" value="common/tests" /> + <property name="module.test.depends" value="qpid-test-utils" /> <property name="module.main" value="org.apache.qpid.server.Main"/> <property name="module.genpom" value="true"/> diff --git a/java/build.deps b/java/build.deps index 99ca19a60b..73691b6aec 100644 --- a/java/build.deps +++ b/java/build.deps @@ -96,6 +96,7 @@ client-example.test.libs=${test.libs} tools.test.libs= systests.libs=${test.libs} perftests.test.libs=${test.libs} +qpid-test-utils.libs = ${test.libs} ${geronimo-jms} broker-plugins-access-control.test.libs=${test.libs} broker-plugins-management-http.test.libs=${test.libs} diff --git a/java/build.xml b/java/build.xml index 03c50938d0..85117b739d 100644 --- a/java/build.xml +++ b/java/build.xml @@ -34,7 +34,7 @@ <findSubProjects name="broker-plugins" dir="broker-plugins" excludes="${broker-plugins-exclude}"/> <findSubProjects name="client-plugins" dir="client-plugins"/> - <property name="modules.core" value="common management/common amqp-1-0-common broker-core broker client amqp-1-0-client amqp-1-0-client-jms tools"/> + <property name="modules.core" value="qpid-test-utils common management/common amqp-1-0-common broker-core broker client amqp-1-0-client amqp-1-0-client-jms tools"/> <property name="modules.examples" value="client/example management/example amqp-1-0-client/example amqp-1-0-client-jms/example"/> <property name="modules.tests" value="systests perftests"/> <property name="modules.plugin" value="${broker-plugins} ${client-plugins}"/> diff --git a/java/client/build.xml b/java/client/build.xml index 707bfda024..0375b83c65 100644 --- a/java/client/build.xml +++ b/java/client/build.xml @@ -21,7 +21,7 @@ <project name="AMQ Client" default="build"> <property name="module.depends" value="common"/> - <property name="module.test.depends" value="common/tests" /> + <property name="module.test.depends" value="qpid-test-utils" /> <property name="module.genpom" value="true"/> <property name="module.genpom.args" value="-Sgeronimo-jms_1.1_spec=provided"/> diff --git a/java/client/src/test/java/org/apache/qpid/client/AMQSession_0_8Test.java b/java/client/src/test/java/org/apache/qpid/client/AMQSession_0_8Test.java index d9caa68ef8..c56cf9a72b 100644 --- a/java/client/src/test/java/org/apache/qpid/client/AMQSession_0_8Test.java +++ b/java/client/src/test/java/org/apache/qpid/client/AMQSession_0_8Test.java @@ -21,10 +21,10 @@ package org.apache.qpid.client; import org.apache.qpid.AMQException; +import org.apache.qpid.client.transport.TestNetworkConnection; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.amqp_0_91.QueueDeclareOkBodyImpl; import org.apache.qpid.test.utils.QpidTestCase; -import org.apache.qpid.transport.TestNetworkConnection; import org.apache.qpid.transport.network.NetworkConnection; import org.apache.qpid.url.AMQBindingURL; diff --git a/java/client/src/test/java/org/apache/qpid/client/protocol/AMQProtocolHandlerTest.java b/java/client/src/test/java/org/apache/qpid/client/protocol/AMQProtocolHandlerTest.java index 9a5ca33174..4c9448cb39 100644 --- a/java/client/src/test/java/org/apache/qpid/client/protocol/AMQProtocolHandlerTest.java +++ b/java/client/src/test/java/org/apache/qpid/client/protocol/AMQProtocolHandlerTest.java @@ -28,12 +28,12 @@ import org.apache.qpid.AMQException; import org.apache.qpid.client.AMQAuthenticationException; import org.apache.qpid.client.MockAMQConnection; import org.apache.qpid.client.state.AMQState; +import org.apache.qpid.client.transport.TestNetworkConnection; import org.apache.qpid.framing.AMQBody; import org.apache.qpid.framing.AMQFrame; import org.apache.qpid.framing.AMQMethodBody; import org.apache.qpid.framing.amqp_8_0.BasicRecoverOkBodyImpl; import org.apache.qpid.protocol.AMQConstant; -import org.apache.qpid.transport.TestNetworkConnection; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; diff --git a/java/common/src/test/java/org/apache/qpid/transport/MockSender.java b/java/client/src/test/java/org/apache/qpid/client/transport/MockSender.java index 4b38b7318a..7c3988c19a 100644 --- a/java/common/src/test/java/org/apache/qpid/transport/MockSender.java +++ b/java/client/src/test/java/org/apache/qpid/client/transport/MockSender.java @@ -18,10 +18,12 @@ * under the License. * */ -package org.apache.qpid.transport; +package org.apache.qpid.client.transport; import java.nio.ByteBuffer; +import org.apache.qpid.transport.Sender; + public class MockSender implements Sender<ByteBuffer> { diff --git a/java/common/src/test/java/org/apache/qpid/transport/TestNetworkConnection.java b/java/client/src/test/java/org/apache/qpid/client/transport/TestNetworkConnection.java index a19c2e7e43..1ec217e468 100644 --- a/java/common/src/test/java/org/apache/qpid/transport/TestNetworkConnection.java +++ b/java/client/src/test/java/org/apache/qpid/client/transport/TestNetworkConnection.java @@ -18,11 +18,13 @@ * under the License. * */ -package org.apache.qpid.transport; +package org.apache.qpid.client.transport; import java.security.Principal; import org.apache.qpid.protocol.ProtocolEngineFactory; import org.apache.qpid.ssl.SSLContextFactory; +import org.apache.qpid.transport.NetworkTransportConfiguration; +import org.apache.qpid.transport.Sender; import org.apache.qpid.transport.network.NetworkConnection; import java.net.BindException; diff --git a/java/common/build.xml b/java/common/build.xml index 184aad1abc..1c409cfc4e 100644 --- a/java/common/build.xml +++ b/java/common/build.xml @@ -20,6 +20,7 @@ --> <project name="AMQ Common" default="build"> + <property name="module.test.depends" value="qpid-test-utils" /> <property name="module.genpom" value="true"/> <import file="../module.xml"/> diff --git a/java/perftests/build.xml b/java/perftests/build.xml index a97b33ef41..449dd7e89b 100644 --- a/java/perftests/build.xml +++ b/java/perftests/build.xml @@ -33,7 +33,7 @@ </condition> <property name="module.depends" value="client common"/> - <property name="module.test.depends" value="systests broker-core broker-plugins/memory-store broker-plugins/derby-store common/tests management/common broker-plugins/amqp-0-8-protocol broker-plugins/amqp-0-10-protocol broker-plugins/amqp-1-0-protocol ${perftests.optional.test.depends}"/> + <property name="module.test.depends" value="systests broker-core broker-plugins/memory-store broker-plugins/derby-store qpid-test-utils management/common broker-plugins/amqp-0-8-protocol broker-plugins/amqp-0-10-protocol broker-plugins/amqp-1-0-protocol ${perftests.optional.test.depends}"/> <import file="../module.xml"/> diff --git a/java/qpid-test-utils/build.xml b/java/qpid-test-utils/build.xml new file mode 100644 index 0000000000..4423c365f8 --- /dev/null +++ b/java/qpid-test-utils/build.xml @@ -0,0 +1,26 @@ +<!-- + - + - 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. + - + --> +<project name="QpidTestUtils" default="build"> + <property name="module.depends" value=""/> + <property name="module.test.depends" value="" /> + + <import file="../module.xml"/> +</project> diff --git a/java/common/src/test/java/org/apache/qpid/test/utils/PortHelper.java b/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/PortHelper.java index d3586c364f..d3586c364f 100644 --- a/java/common/src/test/java/org/apache/qpid/test/utils/PortHelper.java +++ b/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/PortHelper.java diff --git a/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java b/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java index 8f556ece5a..8f556ece5a 100644 --- a/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java +++ b/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java diff --git a/java/common/src/test/java/org/apache/qpid/test/utils/TestFileUtils.java b/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/TestFileUtils.java index 14dec8efad..d04413f06f 100644 --- a/java/common/src/test/java/org/apache/qpid/test/utils/TestFileUtils.java +++ b/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/TestFileUtils.java @@ -23,15 +23,14 @@ package org.apache.qpid.test.utils; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; import java.io.FileOutputStream; import junit.framework.TestCase; -import org.apache.qpid.util.FileUtils; - /** - * Utility methods intended to be used in unit tests that manipulate files + * Utility methods intended to be used in tests that manipulate files */ public class TestFileUtils { @@ -55,7 +54,7 @@ public class TestFileUtils File testDir = new File(SYSTEM_TMP_DIR, dirNameStem + "-" + System.currentTimeMillis()); if (testDir.exists()) { - FileUtils.delete(testDir, true); + delete(testDir, true); } testDir.mkdirs(); @@ -102,7 +101,7 @@ public class TestFileUtils InputStream in = testCase.getClass().getResourceAsStream(resourceName); try { - FileUtils.copy(in, dst); + copy(in, dst); } catch (Exception e) { @@ -150,4 +149,85 @@ public class TestFileUtils } return file; } + + /** + * Delete a given file/directory, + * A directory will always require the recursive flag to be set. + * if a directory is specified and recursive set then delete the whole tree + * + * @param file the File object to start at + * @param recursive boolean to recurse if a directory is specified. + * + * @return <code>true</code> if and only if the file or directory is + * successfully deleted; <code>false</code> otherwise + */ + public static boolean delete(File file, boolean recursive) + { + boolean success = true; + + if (file.isDirectory()) + { + if (recursive) + { + File[] files = file.listFiles(); + + // This can occur if the file is deleted outside the JVM + if (files == null) + { + return false; + } + + for (int i = 0; i < files.length; i++) + { + success = delete(files[i], true) && success; + } + + return success && file.delete(); + } + + return false; + } + + return file.delete(); + } + + /** + * Copies the specified InputStream to the specified destination file. If the destination file does not exist, + * it is created. + * + * @param in The InputStream + * @param dst The destination file name. + * @throws IOException + */ + public static void copy(InputStream in, File dst) throws IOException + { + try + { + if (!dst.exists()) + { + dst.createNewFile(); + } + + OutputStream out = new FileOutputStream(dst); + + try + { + // Transfer bytes from in to out + byte[] buf = new byte[1024]; + int len; + while ((len = in.read(buf)) > 0) + { + out.write(buf, 0, len); + } + } + finally + { + out.close(); + } + } + finally + { + in.close(); + } + } } diff --git a/java/common/src/test/java/org/apache/qpid/test/utils/TestSSLConstants.java b/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/TestSSLConstants.java index c48f164d98..c48f164d98 100644 --- a/java/common/src/test/java/org/apache/qpid/test/utils/TestSSLConstants.java +++ b/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/TestSSLConstants.java diff --git a/java/systests/build.xml b/java/systests/build.xml index 68199fbc66..78bfeaec46 100644 --- a/java/systests/build.xml +++ b/java/systests/build.xml @@ -34,7 +34,7 @@ nn - or more contributor license agreements. See the NOTICE file <!-- The jca module is unusual in that it produces a jar with the name ra rather than jca. Unfortunately this means we need to add both jca (finds jca's jar dependencies) and ra (to find the qpid-ra jar file itself). --> - <property name="module.depends" value="client management/common broker-core broker-core/tests common amqp-1-0-common common/tests jca ra broker-plugins/access-control broker-plugins/management-http broker-plugins/management-jmx broker-plugins/memory-store broker-plugins/derby-store broker-plugins/amqp-0-8-protocol broker-plugins/amqp-0-10-protocol broker-plugins/amqp-1-0-protocol broker-plugins/amqp-msg-conv-0-8-to-0-10 broker-plugins/amqp-msg-conv-0-8-to-1-0 broker-plugins/amqp-msg-conv-0-10-to-1-0 ${systests.optional.depends}"/> + <property name="module.depends" value="qpid-test-utils client management/common broker-core broker-core/tests common amqp-1-0-common common/tests jca ra broker-plugins/access-control broker-plugins/management-http broker-plugins/management-jmx broker-plugins/memory-store broker-plugins/derby-store broker-plugins/amqp-0-8-protocol broker-plugins/amqp-0-10-protocol broker-plugins/amqp-1-0-protocol broker-plugins/amqp-msg-conv-0-8-to-0-10 broker-plugins/amqp-msg-conv-0-8-to-1-0 broker-plugins/amqp-msg-conv-0-10-to-1-0 ${systests.optional.depends}"/> <property name="module.test.src" location="src/main/java"/> <property name="module.test.excludes" value="**/DropInTest.java,**/TestClientControlledTest.java"/> diff --git a/java/systests/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java b/java/systests/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java index 0d4b4ba9f8..c999be634b 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java @@ -22,7 +22,10 @@ package org.apache.qpid.server.protocol; import static org.mockito.Mockito.when; +import java.net.InetSocketAddress; +import java.net.SocketAddress; import java.nio.ByteBuffer; +import java.security.Principal; import java.util.EnumSet; import java.util.Set; @@ -32,7 +35,8 @@ import org.apache.qpid.server.util.BrokerTestHelper; import org.apache.qpid.server.virtualhost.VirtualHost; import org.apache.qpid.server.virtualhost.VirtualHostRegistry; import org.apache.qpid.test.utils.QpidTestCase; -import org.apache.qpid.transport.TestNetworkConnection; +import org.apache.qpid.transport.Sender; +import org.apache.qpid.transport.network.NetworkConnection; public class MultiVersionProtocolEngineFactoryTest extends QpidTestCase { @@ -202,4 +206,95 @@ public class MultiVersionProtocolEngineFactoryTest extends QpidTestCase //expected } } + + private static class TestNetworkConnection implements NetworkConnection + { + private String _remoteHost = "127.0.0.1"; + private String _localHost = "127.0.0.1"; + private int _port = 1; + private final Sender<ByteBuffer> _sender; + + public TestNetworkConnection() + { + _sender = new Sender<ByteBuffer>() + { + public void setIdleTimeout(int i) + { + } + + public void send(ByteBuffer msg) + { + } + + public void flush() + { + } + + public void close() + { + } + }; + } + + @Override + public SocketAddress getLocalAddress() + { + return new InetSocketAddress(_localHost, _port); + } + + @Override + public SocketAddress getRemoteAddress() + { + return new InetSocketAddress(_remoteHost, _port); + } + + @Override + public void setMaxReadIdle(int idleTime) + { + } + + @Override + public void setPeerPrincipal(Principal principal) + { + } + + @Override + public Principal getPeerPrincipal() + { + return null; + } + + @Override + public int getMaxReadIdle() + { + return 0; + } + + @Override + public int getMaxWriteIdle() + { + return 0; + } + + @Override + public void setMaxWriteIdle(int idleTime) + { + } + + @Override + public void close() + { + } + + @Override + public Sender<ByteBuffer> getSender() + { + return _sender; + } + + @Override + public void start() + { + } + } } diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java index 1a7e9dfc96..e893a58282 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java +++ b/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java @@ -20,17 +20,20 @@ */ package org.apache.qpid.test.unit.client.protocol; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.net.UnknownHostException; +import java.nio.ByteBuffer; +import java.security.Principal; + import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.protocol.AMQProtocolHandler; import org.apache.qpid.client.protocol.AMQProtocolSession; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.test.utils.QpidBrokerTestCase; -import org.apache.qpid.transport.TestNetworkConnection; - -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.SocketAddress; -import java.net.UnknownHostException; +import org.apache.qpid.transport.Sender; +import org.apache.qpid.transport.network.NetworkConnection; public class AMQProtocolSessionTest extends QpidBrokerTestCase { @@ -97,4 +100,104 @@ public class AMQProtocolSessionTest extends QpidBrokerTestCase _testSession.getNetworkConnection().setLocalAddress(address); assertEquals("Wrong queue name", queueName, _testSession.genQueueName().asString()); } + + private static class TestNetworkConnection implements NetworkConnection + { + private String _remoteHost = "127.0.0.1"; + private String _localHost = "127.0.0.1"; + private int _port = 1; + private SocketAddress _localAddress = null; + private final Sender<ByteBuffer> _sender; + + public TestNetworkConnection() + { + _sender = new Sender<ByteBuffer>() + { + + public void setIdleTimeout(int i) + { + + } + + public void send(ByteBuffer msg) + { + + } + + public void flush() + { + + } + + public void close() + { + + } + }; + } + + @Override + public SocketAddress getLocalAddress() + { + return (_localAddress != null) ? _localAddress : new InetSocketAddress(_localHost, _port); + } + + @Override + public SocketAddress getRemoteAddress() + { + return new InetSocketAddress(_remoteHost, _port); + } + + @Override + public void setMaxReadIdle(int idleTime) + { + } + + @Override + public void setPeerPrincipal(Principal principal) + { + } + + @Override + public Principal getPeerPrincipal() + { + return null; + } + + @Override + public int getMaxReadIdle() + { + return 0; + } + + @Override + public int getMaxWriteIdle() + { + return 0; + } + + @Override + public void setMaxWriteIdle(int idleTime) + { + } + + @Override + public void close() + { + } + + public void setLocalAddress(SocketAddress address) + { + _localAddress = address; + } + + public Sender<ByteBuffer> getSender() + { + return _sender; + } + + public void start() + { + } + } } |