Added: incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/localcircuit/LocalCircuitImpl.csx URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/localcircuit/LocalCircuitImpl.csx?rev=612874&view=auto ============================================================================== --- incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/localcircuit/LocalCircuitImpl.csx (added) +++ incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/localcircuit/LocalCircuitImpl.csx Thu Jan 17 09:13:11 2008 @@ -0,0 +1,290 @@ +/* + * + * 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. + * + */ +using log4net; + +using Apache.Qpid.Integration.Tests.framework.*; + +using uk.co.thebadgerset.junit.extensions.util.ParsedProperties; + +using javax.jms.*; + +using System.Collections.Generic.LinkedList; +using System.Collections.Generic.IList; + +namespace Apache.Qpid.Integration.Tests.framework.localcircuit +{ + /// <summary> + /// LocalCircuitImpl provides an implementation of the test circuit. This is a local only circuit implementation that + /// supports a single producer/consumer on each end of the circuit, with both ends of the circuit on the same JVM. + /// + /// <p/><table id="crc"><caption>CRC Card</caption> + /// <tr><th> Responsibilities <th> Collaborations + /// <tr><td> Supply the publishing and receiving ends of a test messaging circuit. + /// <td> <see cref="LocalPublisherImpl"/>, <see cref="LocalReceiverImpl"/> + /// <tr><td> Start the circuit running. + /// <tr><td> Close the circuit down. + /// <tr><td> Take a reading of the circuits state. + /// <tr><td> Apply assertions against the circuits state. <td> <see cref="Assertion"/> + /// <tr><td> Send test messages over the circuit. + /// <tr><td> Perform the default test procedure on the circuit. + /// <tr><td> Provide access to connection and controlSession exception monitors. <td> <see cref="ExceptionMonitor"/> + /// </table> + /// </summary> + public class LocalCircuitImpl : Circuit + { + /// <summary> Used for debugging. </summary> + private static ILog log = LogManager.GetLogger(typeof(LocalCircuitImpl)); + + /// <summary> Holds the test configuration for the circuit. </summary> + private ParsedProperties testProps; + + /// <summary> Holds the publishing end of the circuit. </summary> + private LocalPublisherImpl publisher; + + /// <summary> Holds the receiving end of the circuit. </summary> + private LocalReceiverImpl receiver; + + /// <summary> Holds the connection for the publishing end of the circuit. </summary> + private Connection connection; + + /// <summary> Holds the exception listener for the connection on the publishing end of the circuit. </summary> + private ExceptionMonitor connectionExceptionMonitor; + + /// <summary> Holds the exception listener for the controlSession on the publishing end of the circuit. </summary> + private ExceptionMonitor exceptionMonitor; + + /// <summary> + /// Creates a test circuit using the specified test parameters. The publisher, receivers, connection and + /// connection monitor must already have been created, to assemble the circuit. + /// </summary> + /// <param name="testProps"> The test parameters. </param> + /// <param name="publisher"> The test publisher. </param> + /// <param name="receiver"> The test receivers. </param> + /// <param name="connection"> The connection. </param> + /// <param name="connectionExceptionMonitor"> The connection exception monitor. </param> + public LocalCircuitImpl(ParsedProperties testProps, LocalPublisherImpl publisher, LocalReceiverImpl receiver, + Connection connection, ExceptionMonitor connectionExceptionMonitor) + { + this.testProps = testProps; + this.publisher = publisher; + this.receiver = receiver; + this.connection = connection; + this.connectionExceptionMonitor = connectionExceptionMonitor; + this.exceptionMonitor = new ExceptionMonitor(); + + // Set this as the parent circuit on the publisher and receivers. + publisher.setCircuit(this); + receiver.setCircuit(this); + } + + /// <summary> + /// Gets the interface on the publishing end of the circuit. + /// </summary> + /// <return> The publishing end of the circuit. </return> + public Publisher getPublisher() + { + return publisher; + } + + /// <summary> + /// Gets the local publishing circuit end, for direct manipulation. + /// </summary> + /// <return> The local publishing circuit end. </return> + public CircuitEnd getLocalPublisherCircuitEnd() + { + return publisher; + } + + /// <summary> + /// Gets the interface on the receiving end of the circuit. + /// </summary> + /// <return> The receiving end of the circuit. </return> + public Receiver getReceiver() + { + return receiver; + } + + /// <summary> + /// Gets the local receiving circuit end, for direct manipulation. + /// </summary> + /// <return> The local receiving circuit end. </return> + public CircuitEnd getLocalReceiverCircuitEnd() + { + return receiver; + } + + /// <summary> + /// Checks the test circuit. The effect of this is to gather the circuits state, for both ends of the circuit, + /// into a report, against which assertions may be checked. + /// </summary> + public void check() + { } + + /// <summary> + /// Applied a list of assertions against the test circuit. The <see cref="#check()"/> method should be called before doing + /// this, to ensure that the circuit has gathered its state into a report to assert against. + /// </summary> + /// <param name="assertions"> The list of assertions to apply. </param> + /// <return> Any assertions that failed. </return> + public IList<Assertion> applyAssertions(List<Assertion> assertions) + { + IList<Assertion> failures = new LinkedList<Assertion>(); + + for (Assertion assertion : assertions) + { + if (!assertion.apply()) + { + failures.add(assertion); + } + } + + return failures; + } + + /// <summary> Connects and starts the circuit. After this method is called the circuit is ready to send messages. </summary> + public void start() + { } + + /// <summary> Closes the circuit. All associated resources are closed. </summary> + public void close() + { + try + { + publisher.close(); + receiver.close(); + connection.close(); + } + catch (JMSException e) + { + throw new RuntimeException("Got JMSException during close:" + e.getMessage(), e); + } + } + + /// <summary> Sends a message on the test circuit. The exact nature of the message sent is controlled by the test parameters. </summary> + protected void send() + { + // Cast the test properties into a typed interface for convenience. + MessagingTestConfigProperties props = new MessagingTestConfigProperties(testProps); + + bool transactional = props.getPublisherTransacted(); + bool rollback = props.getRollbackPublisher(); + + // Send a message through the publisher and log any exceptions raised. + try + { + CircuitEnd end = getLocalPublisherCircuitEnd(); + + end.send(createTestMessage(end)); + + if (rollback) + { + end.getSession().rollback(); + } + else if (transactional) + { + end.getSession().commit(); + } + } + catch (JMSException e) + { + exceptionMonitor.onException(e); + } + } + + /// <summary> + /// Runs the default test procedure against the circuit, and checks that all of the specified assertions hold. The + /// outline of the default test procedure is: + /// + /// <p/><pre> + /// Start the circuit. + /// Send test messages. + /// Request a status report. + /// Assert conditions on the publishing end of the circuit. + /// Assert conditions on the receiving end of the circuit. + /// Close the circuit. + /// Pass with no failed assertions or fail with a list of failed assertions. + /// </pre> + /// </summary> + /// <param name="numMessages"> The number of messages to send using the default test procedure. </param> + /// <param name="assertions"> The list of assertions to apply. </param> + /// <return> Any assertions that failed. </return> + public IList<Assertion> test(int numMessages, List<Assertion> assertions) + { + // Start the test circuit. + start(); + + // Send the requested number of test messages. + for (int i = 0; i < numMessages; i++) + { + send(); + } + + // Inject a short pause to allow time for exceptions to come back asynchronously. + TestUtils.pause(500L); + + // Request a status report. + check(); + + // Clean up the publisher/receivers/controlSession/connections. + close(); + + // Apply all of the requested assertions, keeping record of any that fail. + IList<Assertion> failures = applyAssertions(assertions); + + // Return any failed assertions to the caller. + return failures; + } + + /// <summary> + /// Creates a message with the properties defined as per the test parameters. + /// </summary> + /// <param name="client"> The circuit end to create the message on. </param> + /// + /// <return> The test message. </return> + /// + /// <exception cref="JMSException"> Any JMSException occurring during creation of the message is allowed to fall through. </exception> + private Message createTestMessage(CircuitEnd client) throws JMSException + { + // Cast the test properties into a typed interface for convenience. + MessagingTestConfigProperties props = new MessagingTestConfigProperties(testProps); + + return TestUtils.createTestMessageOfSize(client.getSession(), props.getMessageSize()); + } + + /// <summary> + /// Gets the exception monitor for the publishing ends connection. + /// </summary> + /// <return> The exception monitor for the publishing ends connection. </return> + public ExceptionMonitor getConnectionExceptionMonitor() + { + return connectionExceptionMonitor; + } + + /// <summary> + /// Gets the exception monitor for the publishing ends controlSession. + /// </summary> + /// <return> The exception monitor for the publishing ends controlSession. </return> + public ExceptionMonitor getExceptionMonitor() + { + return exceptionMonitor; + } + } +}
Added: incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/localcircuit/LocalPublisherImpl.csx URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/localcircuit/LocalPublisherImpl.csx?rev=612874&view=auto ============================================================================== --- incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/localcircuit/LocalPublisherImpl.csx (added) +++ incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/localcircuit/LocalPublisherImpl.csx Thu Jan 17 09:13:11 2008 @@ -0,0 +1,164 @@ +/* + * + * 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. + * + */ +using Apache.Qpid.Integration.Tests.framework.*; + +using uk.co.thebadgerset.junit.extensions.util.ParsedProperties; + +using javax.jms.MessageConsumer; +using javax.jms.MessageProducer; +using javax.jms.Session; + +namespace Apache.Qpid.Integration.Tests.framework.localcircuit +{ + /// <summary> + /// Provides an implementation of the <see cref="Publisher"/> interface and wraps a single message producer and consumer on + /// a single controlSession, as a <see cref="CircuitEnd"/>. A local publisher also acts as a circuit end, because for a locally + /// located circuit the assertions may be applied directly, there does not need to be any inter-process messaging + /// between the publisher and its single circuit end, in order to ascertain its status. + /// + /// <p/><table id="crc"><caption>CRC Card</caption> + /// <tr><th> Responsibilities <th> Collaborations + /// <tr><td> Provide a message producer for sending messages. + /// <tr><td> Provide a message consumer for receiving messages. + /// <tr><td> Provide assertion that the publisher received no exceptions. + /// <tr><td> Provide assertion that the publisher received a no consumers error code. + /// <tr><td> Provide assertion that the publisher received a no route error code. + /// </table> + /// </summary> + public class LocalPublisherImpl extends CircuitEndBase : Publisher + { + /// <summary> Holds a reference to the containing circuit. </summary> + protected LocalCircuitImpl circuit; + + /// <summary> + /// Creates a circuit end point on the specified producer, consumer and controlSession. Monitors are also configured + /// for messages and exceptions received by the circuit end. + /// </summary> + /// <param name="producer"> The message producer for the circuit end point. </param> + /// <param name="consumer"> The message consumer for the circuit end point. </param> + /// <param name="session"> The controlSession for the circuit end point. </param> + /// <param name="messageMonitor"> The monitor to notify of all messages received by the circuit end. </param> + /// <param name="exceptionMonitor"> The monitor to notify of all exceptions received by the circuit end. </param> + public LocalPublisherImpl(MessageProducer producer, MessageConsumer consumer, Session session, + MessageMonitor messageMonitor, ExceptionMonitor exceptionMonitor) + { + super(producer, consumer, session, messageMonitor, exceptionMonitor); + } + + /// <summary> + /// Creates a circuit end point from the producer, consumer and controlSession in a circuit end base implementation. + /// </summary> + /// <param name="end"> The circuit end base implementation to take producers and consumers from. </param> + public LocalPublisherImpl(CircuitEndBase end) + { + super(end.getProducer(), end.getConsumer(), end.getSession(), end.getMessageMonitor(), end.getExceptionMonitor()); + } + + /// <summary> Provides an assertion that the publisher encountered no exceptions. </summary> + /// + /// <param name="testProps"> The test configuration properties. </param> + /// + /// <return> An assertion that the publisher encountered no exceptions. </return> + public Assertion noExceptionsAssertion(ParsedProperties testProps) + { + return new AssertionBase() + { + public bool apply() + { + bool passed = true; + ExceptionMonitor sessionExceptionMonitor = circuit.getExceptionMonitor(); + ExceptionMonitor connectionExceptionMonitor = circuit.getConnectionExceptionMonitor(); + + if (!connectionExceptionMonitor.assertNoExceptions()) + { + passed = false; + + addError("Was expecting no exceptions.\n"); + addError("Got the following exceptions on the connection, " + + circuit.getConnectionExceptionMonitor()); + } + + if (!sessionExceptionMonitor.assertNoExceptions()) + { + passed = false; + + addError("Was expecting no exceptions.\n"); + addError("Got the following exceptions on the producer, " + circuit.getExceptionMonitor()); + } + + return passed; + } + }; + } + + /// <summary> + /// Provides an assertion that the AMQP channel was forcibly closed by an error condition. + /// </summary> + /// <param name="testProps"> The test configuration properties. </param> + /// + /// <return> An assertion that the AMQP channel was forcibly closed by an error condition. </return> + public Assertion channelClosedAssertion(ParsedProperties testProps) + { + return new NotApplicableAssertion(testProps); + } + + /// <summary> + /// Provides an assertion that the publisher got a given exception during the test. + /// </summary> + /// <param name="testProps"> The test configuration properties. </param> + /// <param name="exceptionClass"> The exception class to check for. </param> + /// + /// <return> An assertion that the publisher got a given exception during the test. </return> + public Assertion exceptionAssertion(ParsedProperties testProps, final Class<? extends Exception> exceptionClass) + { + return new AssertionBase() + { + public bool apply() + { + bool passed = true; + ExceptionMonitor connectionExceptionMonitor = circuit.getConnectionExceptionMonitor(); + + if (!connectionExceptionMonitor.assertExceptionOfType(exceptionClass)) + { + passed = false; + + addError("Was expecting linked exception type " + exceptionClass.getName() + + " on the connection.\n"); + addError((connectionExceptionMonitor.size() > 0) + ? ("Actually got the following exceptions on the connection, " + connectionExceptionMonitor) + : "Got no exceptions on the connection."); + } + + return passed; + } + }; + } + + /// <summary> + /// Sets the contianing circuit. + /// </summary> + /// <param name="circuit"> The containing circuit. </param> + public void setCircuit(LocalCircuitImpl circuit) + { + this.circuit = circuit; + } + } +} \ No newline at end of file Added: incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/localcircuit/LocalReceiverImpl.csx URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/localcircuit/LocalReceiverImpl.csx?rev=612874&view=auto ============================================================================== --- incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/localcircuit/LocalReceiverImpl.csx (added) +++ incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/localcircuit/LocalReceiverImpl.csx Thu Jan 17 09:13:11 2008 @@ -0,0 +1,137 @@ +/* + * + * 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. + * + */ +using Apache.Qpid.Integration.Tests.framework.*; + +using uk.co.thebadgerset.junit.extensions.util.ParsedProperties; + +using javax.jms.MessageConsumer; +using javax.jms.MessageProducer; +using javax.jms.Session; + +namespace Apache.Qpid.Integration.Tests.framework.localcircuit +{ + /// <summary> + /// Provides an implementation of the <see cref="Receiver"/> interface that wraps a single message producer and consumer on + /// a single controlSession, as a <see cref="CircuitEnd"/>. A local receiver also acts as a circuit end, because for a locally + /// located circuit the assertions may be applied directly, there does not need to be any inter process messaging + /// between the publisher and its single circuit end, in order to ascertain its status. + /// + /// <p/><table id="crc"><caption>CRC Card</caption> + /// <tr><th> Responsibilities <th> Collaborations + /// <tr><td> Provide a message producer for sending messages. + /// <tr><td> Provide a message consumer for receiving messages. + /// <tr><td> Provide assertion that the receivers received no exceptions. + /// <tr><td> Provide assertion that the receivers received all test messages sent to it. + /// </table> + /// </summary> + public class LocalReceiverImpl extends CircuitEndBase : Receiver + { + /// <summary> Holds a reference to the containing circuit. </summary> + private LocalCircuitImpl circuit; + + /// <summary> + /// Creates a circuit end point on the specified producer, consumer and controlSession. Monitors are also configured + /// for messages and exceptions received by the circuit end. + /// </summary> + /// <param name="producer"> The message producer for the circuit end point. </param> + /// <param name="consumer"> The message consumer for the circuit end point. </param> + /// <param name="session"> The controlSession for the circuit end point. </param> + /// <param name="messageMonitor"> The monitor to notify of all messages received by the circuit end. </param> + /// <param name="exceptionMonitor"> The monitor to notify of all exceptions received by the circuit end. </param> + public LocalReceiverImpl(MessageProducer producer, MessageConsumer consumer, Session session, + MessageMonitor messageMonitor, ExceptionMonitor exceptionMonitor) + { + super(producer, consumer, session, messageMonitor, exceptionMonitor); + } + + /// <summary> + /// Creates a circuit end point from the producer, consumer and controlSession in a circuit end base implementation. + /// </summary> + /// <param name="end"> The circuit end base implementation to take producers and consumers from. </param> + public LocalReceiverImpl(CircuitEndBase end) + { + super(end.getProducer(), end.getConsumer(), end.getSession(), end.getMessageMonitor(), end.getExceptionMonitor()); + } + + /// <summary> + /// Provides an assertion that the receivers encountered no exceptions. + /// </summary> + /// <param name="testProps"> The test configuration properties. </param> + /// + /// <return> An assertion that the receivers encountered no exceptions. </return> + public Assertion noExceptionsAssertion(ParsedProperties testProps) + { + return new NotApplicableAssertion(testProps); + } + + /// <summary> + /// Provides an assertion that the AMQP channel was forcibly closed by an error condition. + /// </summary> + /// <param name="testProps"> The test configuration properties. </param> + /// + /// <return> An assertion that the AMQP channel was forcibly closed by an error condition. </return> + public Assertion channelClosedAssertion(ParsedProperties testProps) + { + return new NotApplicableAssertion(testProps); + } + + /// <summary> + /// Provides an assertion that the receivers got all messages that were sent to it. + /// </summary> + /// <param name="testProps"> The test configuration properties. </param> + /// + /// <return> An assertion that the receivers got all messages that were sent to it. </return> + public Assertion allMessagesReceivedAssertion(ParsedProperties testProps) + { + return new NotApplicableAssertion(testProps); + } + + /// <summary> + /// Provides an assertion that the receivers got none of the messages that were sent to it. + /// </summary> + /// <param name="testProps"> The test configuration properties. </param> + /// + /// <return> An assertion that the receivers got none of the messages that were sent to it. </return> + public Assertion noMessagesReceivedAssertion(ParsedProperties testProps) + { + return new NotApplicableAssertion(testProps); + } + + /// <summary> + /// Provides an assertion that the receiver got a given exception during the test. + /// </summary> + /// <param name="testProps"> The test configuration properties. </param> + /// <param name="exceptionClass"> The exception class to check for. <return> An assertion that the receiver got a given exception during the test. </return> </param> + public Assertion exceptionAssertion(ParsedProperties testProps, Class<? extends Exception> exceptionClass) + { + return new NotApplicableAssertion(testProps); + } + + /// <summary> + /// Sets the contianing circuit. + /// </summary> + /// <param name="circuit"> The containing circuit. </param> + public void setCircuit(LocalCircuitImpl circuit) + { + this.circuit = circuit; + } + } +} \ No newline at end of file Added: incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/sequencers/BaseCircuitFactory.csx URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/sequencers/BaseCircuitFactory.csx?rev=612874&view=auto ============================================================================== --- incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/sequencers/BaseCircuitFactory.csx (added) +++ incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/sequencers/BaseCircuitFactory.csx Thu Jan 17 09:13:11 2008 @@ -0,0 +1,128 @@ +/* + * + * 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. + * + */ +using log4net; + +using Apache.Qpid.Integration.Tests.framework.Circuit; +using Apache.Qpid.Integration.Tests.framework.TestClientDetails; +using org.apache.qpid.util.ConversationFactory; + +using System.Collections.Generic.LinkedList; +using System.Collections.Generic.IList; +using java.util.Properties; + +namespace Apache.Qpid.Integration.Tests.framework.sequencers +{ + /// <summary> + /// BaseCircuitFactory provides some functionality common to all <see cref="CircuitFactory"/>s, such as the details of + /// all <see cref="Apache.Qpid.Integration.Tests.framework.distributedtesting.TestClient"/>s that make up the end-points of + /// the circuits that the factory creates, and an active <see cref="ConversationFactory"/> that can be used to generate + /// control conversations with those circuit end-points. + /// + /// <p/><table id="crc"><caption>CRC Card</caption> + /// <tr><th> Responsibilities <th> Collaborations + /// <tr><td> Hold the details of the sending and receiving end-points to create circuits from. + /// <tr><td> Provide a conversation factory to create control conversations with the end-points. + /// </table> + /// </summary> + public abstract class BaseCircuitFactory : CircuitFactory + { + /// <summary> Used for debugging. </summary> + private static ILog log = LogManager.GetLogger(typeof(BaseCircuitFactory)); + + /// <summary> Holds the contact details for the sending test client. </summary> + protected TestClientDetails sender; + + /// <summary> Holds the contact details for the receving test client. </summary> + protected IList<TestClientDetails> receivers = new LinkedList<TestClientDetails>(); + + /// <summary> Holds the conversation factory over which to coordinate the test. </summary> + protected ConversationFactory conversationFactory; + + /// <summary> + /// Creates a test circuit for the test, configered by the test parameters specified. + /// </summary> + /// <param name="testProperties"> The test parameters. </param> + /// <return> A test circuit. </return> + public Circuit createCircuit(Properties testProperties) + { + throw new RuntimeException("Not implemented."); + } + + /// <summary> + /// Sets the sender test client to coordinate the test with. + /// </summary> + /// <param name="sender"> The contact details of the sending client in the test. </param> + public void setSender(TestClientDetails sender) + { + log.debug("public void setSender(TestClientDetails sender = " + sender + "): called"); + + this.sender = sender; + } + + /// <summary> + /// Sets the receiving test client to coordinate the test with. + /// </summary> + /// <param name="receiver"> The contact details of the sending client in the test. </param> + public void setReceiver(TestClientDetails receiver) + { + log.debug("public void setReceiver(TestClientDetails receivers = " + receiver + "): called"); + + this.receivers.add(receiver); + } + + /// <summary> + /// Supplies the sending test client. + /// </summary> + /// <return> The sending test client. </return> + public TestClientDetails getSender() + { + return sender; + } + + /// <summary> + /// Supplies the receiving test client. + /// </summary> + /// <return> The receiving test client. </return> + public IList<TestClientDetails> getReceivers() + { + return receivers; + } + + /// <summary> + /// Accepts the conversation factory over which to hold the test coordinating conversation. + /// </summary> + /// <param name="conversationFactory"> The conversation factory to coordinate the test over. </param> + public void setConversationFactory(ConversationFactory conversationFactory) + { + this.conversationFactory = conversationFactory; + } + + /// <summary> + /// Provides the conversation factory for providing the distributed test sequencing conversations over the test + /// connection. + /// </summary> + /// <return> The conversation factory to create test sequencing conversations with. </return> + public ConversationFactory getConversationFactory() + { + return conversationFactory; + } + } +} \ No newline at end of file Added: incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/sequencers/CircuitFactory.csx URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/sequencers/CircuitFactory.csx?rev=612874&view=auto ============================================================================== --- incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/sequencers/CircuitFactory.csx (added) +++ incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/framework/sequencers/CircuitFactory.csx Thu Jan 17 09:13:11 2008 @@ -0,0 +1,99 @@ +/* + * + * 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. + * + */ +using Apache.Qpid.Integration.Tests.framework.Assertion; +using Apache.Qpid.Integration.Tests.framework.Circuit; +using Apache.Qpid.Integration.Tests.framework.TestClientDetails; +using org.apache.qpid.util.ConversationFactory; + +using uk.co.thebadgerset.junit.extensions.util.ParsedProperties; + +using javax.jms.JMSException; +using javax.jms.Message; + +using System.Collections.Generic.IList; +using System.Collections.Generic.IDictionary; +using java.util.Properties; + +namespace Apache.Qpid.Integration.Tests.framework.sequencers +{ + /// <summary> + /// A CircuitFactory is responsibile for creating test circuits appropriate to the context that a test case is + /// running in, and providing an implementation of a standard test procedure over a test circuit. + /// + /// <p/><table id="crc"><caption>CRC Card</caption> + /// <tr><th> Responsibilities + /// <tr><td> Provide a standard test procedure over a test circuit. + /// <tr><td> Construct test circuits appropriate to a tests context. + /// </table> + /// </summary> + public interface CircuitFactory + { + /// <summary> + /// Holds a test coordinating conversation with the test clients. This should consist of assigning the test roles, + /// begining the test, gathering the test reports from the participants, and checking for assertion failures against + /// the test reports. + /// </summary> + /// <param name="testCircuit"> The test circuit. </param> + /// <param name="assertions"> The list of assertions to apply to the test circuit. </param> + /// <param name="testProperties"> The test case definition. </param> + /// + /// @deprecated Use test circuits and Circuit.test instead. + public void sequenceTest(Circuit testCircuit, IList<Assertion> assertions, Properties testProperties); + + /// <summary> + /// Creates a test circuit for the test, configered by the test parameters specified. + /// </summary> + /// <param name="testProperties"> The test parameters. </param> + /// + /// <return> A test circuit. </return> + public Circuit createCircuit(ParsedProperties testProperties); + + /// <summary> + /// Sets the sender test client to coordinate the test with. + /// </summary> + /// <param name="sender"> The contact details of the sending client in the test. </param> + public void setSender(TestClientDetails sender); + + /// <summary> + /// Sets the receiving test client to coordinate the test with. + /// </summary> + /// <param name="receiver"> The contact details of the sending client in the test. </param> + public void setReceiver(TestClientDetails receiver); + + /// <summary> + /// Supplies the sending test client. + /// </summary> + /// <return> The sending test client. </return> + public TestClientDetails getSender(); + + /// <summary> + /// Supplies the receiving test client. + /// </summary> + /// <return> The receiving test client. </return> + public IList<TestClientDetails> getReceivers(); + + /// <summary> + /// Accepts the conversation factory over which to hold the test coordinating conversation. + /// </summary> + /// <param name="conversationFactory"> The conversation factory to coordinate the test over. </param> + public void setConversationFactory(ConversationFactory conversationFactory); + } +} \ No newline at end of file Modified: incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/testcases/BaseMessagingTestFixture.cs URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/testcases/BaseMessagingTestFixture.cs?rev=612874&r1=612873&r2=612874&view=diff ============================================================================== --- incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/testcases/BaseMessagingTestFixture.cs (original) +++ incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/testcases/BaseMessagingTestFixture.cs Thu Jan 17 09:13:11 2008 @@ -74,5 +74,43 @@ log.Debug("Connection disposed."); } } + + /// <summary> + /// Consumes n messages, checking that the n+1th is not available within a timeout, and that the consumed messages + /// are text messages with contents equal to the specified message body. + /// </summary> + /// + /// <param name="n">The number of messages to consume.</param> + /// <param name="body">The body text to match against all messages.</param> + /// <param name="consumer">The message consumer to recieve the messages on.</param> + public static void ConsumeNMessagesOnly(int n, string body, IMessageConsumer consumer) + { + ConsumeNMessages(n, body, consumer); + + // Check that one more than n cannot be received. + IMessage msg = consumer.Receive(500); + Assert.IsNull(msg, "Consumer got more messages than the number requested (" + n + ")."); + } + + /// <summary> + /// Consumes n messages, checking that the n+1th is not available within a timeout, and that the consumed messages + /// are text messages with contents equal to the specified message body. + /// </summary> + /// + /// <param name="n">The number of messages to consume.</param> + /// <param name="body">The body text to match against all messages.</param> + /// <param name="consumer">The message consumer to recieve the messages on.</param> + public static void ConsumeNMessages(int n, string body, IMessageConsumer consumer) + { + IMessage msg; + + // Try to receive n messages. + for (int i = 0; i < n; i++) + { + msg = consumer.Receive(500); + Assert.IsNotNull(msg, "Consumer did not receive message number " + i); + Assert.AreEqual(body, ((ITextMessage)msg).Text, "Incorrect Message recevied on consumer1."); + } + } } } Modified: incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/testcases/DurableSubscriptionTest.cs URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/testcases/DurableSubscriptionTest.cs?rev=612874&r1=612873&r2=612874&view=diff ============================================================================== --- incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/testcases/DurableSubscriptionTest.cs (original) +++ incubator/qpid/branches/M2.1/dotnet/Qpid.Integration.Tests/testcases/DurableSubscriptionTest.cs Thu Jan 17 09:13:11 2008 @@ -118,9 +118,6 @@ // Re-attach consumer, check that it gets the messages that it missed. IChannel channel3 = _connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge, 1); - //string topicQueueName3 = channe3.GenerateUniqueName(); - //channe3.DeclareQueue(topicQueueName3, false, true, true); - //channe3.Bind(topicQueueName3, ExchangeNameDefaults.TOPIC, TEST_ROUTING_KEY); IMessageConsumer consumer3 = channel3.CreateConsumerBuilder(topicQueueName2) .WithSubscriptionName("TestSubscription") .WithDurable(true) @@ -131,24 +128,6 @@ // Clean up any open consumers at the end of the test. consumer1.Dispose(); consumer3.Dispose(); - } - - /// Consumes n messages, checking that the n+1th is not available within a timeout. - private void ConsumeNMessagesOnly(int n, string body, IMessageConsumer consumer) - { - IMessage msg; - - // Try to receive n messages. - for (int i = 0; i < n; i++) - { - msg = consumer.Receive(500); - Assert.IsNotNull(msg, "Consumer did not receive message number " + i); - Assert.AreEqual(body, ((ITextMessage)msg).Text, "Incorrect Message recevied on consumer1."); - } - - // Check that one more than n cannot be received. - msg = consumer.Receive(500); - Assert.IsNull(msg, "Consumer got more messages than the number requested (" + n + ")."); } } } Modified: incubator/qpid/branches/M2.1/dotnet/Qpid.Messaging/Properties/AssemblyInfo.cs URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/dotnet/Qpid.Messaging/Properties/AssemblyInfo.cs?rev=612874&r1=612873&r2=612874&view=diff ============================================================================== --- incubator/qpid/branches/M2.1/dotnet/Qpid.Messaging/Properties/AssemblyInfo.cs (original) +++ incubator/qpid/branches/M2.1/dotnet/Qpid.Messaging/Properties/AssemblyInfo.cs Thu Jan 17 09:13:11 2008 @@ -25,7 +25,7 @@ // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Apache.Qpid.Messaging")] -[assembly: AssemblyDescription("Built from svn revision number: 612420:612430M")] +[assembly: AssemblyDescription("Built from svn revision number: 612518:612870M")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("Apache.Qpid.Messaging")] Modified: incubator/qpid/branches/M2.1/dotnet/Qpid.Sasl.Tests/Properties/AssemblyInfo.cs URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/dotnet/Qpid.Sasl.Tests/Properties/AssemblyInfo.cs?rev=612874&r1=612873&r2=612874&view=diff ============================================================================== --- incubator/qpid/branches/M2.1/dotnet/Qpid.Sasl.Tests/Properties/AssemblyInfo.cs (original) +++ incubator/qpid/branches/M2.1/dotnet/Qpid.Sasl.Tests/Properties/AssemblyInfo.cs Thu Jan 17 09:13:11 2008 @@ -6,7 +6,7 @@ // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Apache.Qpid.Sasl.Tests")] -[assembly: AssemblyDescription("Built from svn revision number: 612420:612430M")] +[assembly: AssemblyDescription("Built from svn revision number: 612518:612870M")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("Apache.Qpid.Sasl.Tests")] Modified: incubator/qpid/branches/M2.1/dotnet/Qpid.Sasl/Properties/AssemblyInfo.cs URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/dotnet/Qpid.Sasl/Properties/AssemblyInfo.cs?rev=612874&r1=612873&r2=612874&view=diff ============================================================================== --- incubator/qpid/branches/M2.1/dotnet/Qpid.Sasl/Properties/AssemblyInfo.cs (original) +++ incubator/qpid/branches/M2.1/dotnet/Qpid.Sasl/Properties/AssemblyInfo.cs Thu Jan 17 09:13:11 2008 @@ -7,7 +7,7 @@ // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Apache.Qpid.Sasl")] -[assembly: AssemblyDescription("Built from svn revision number: 612420:612430M")] +[assembly: AssemblyDescription("Built from svn revision number: 612518:612870M")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("Apache.Qpid.Sasl")] Modified: incubator/qpid/branches/M2.1/dotnet/TestClient/Properties/AssemblyInfo.cs URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/dotnet/TestClient/Properties/AssemblyInfo.cs?rev=612874&r1=612873&r2=612874&view=diff ============================================================================== --- incubator/qpid/branches/M2.1/dotnet/TestClient/Properties/AssemblyInfo.cs (original) +++ incubator/qpid/branches/M2.1/dotnet/TestClient/Properties/AssemblyInfo.cs Thu Jan 17 09:13:11 2008 @@ -6,7 +6,7 @@ // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("TestClient")] -[assembly: AssemblyDescription("Built from svn revision number: 612420:612430M")] +[assembly: AssemblyDescription("Built from svn revision number: 612518:612870M")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("TestClient")] Modified: incubator/qpid/branches/M2.1/dotnet/TopicListener/Properties/AssemblyInfo.cs URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/dotnet/TopicListener/Properties/AssemblyInfo.cs?rev=612874&r1=612873&r2=612874&view=diff ============================================================================== --- incubator/qpid/branches/M2.1/dotnet/TopicListener/Properties/AssemblyInfo.cs (original) +++ incubator/qpid/branches/M2.1/dotnet/TopicListener/Properties/AssemblyInfo.cs Thu Jan 17 09:13:11 2008 @@ -6,7 +6,7 @@ // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("TopicListener")] -[assembly: AssemblyDescription("Built from svn revision number: 612420:612430M")] +[assembly: AssemblyDescription("Built from svn revision number: 612518:612870M")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("TopicListener")] Modified: incubator/qpid/branches/M2.1/dotnet/TopicPublisher/Properties/AssemblyInfo.cs URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/dotnet/TopicPublisher/Properties/AssemblyInfo.cs?rev=612874&r1=612873&r2=612874&view=diff ============================================================================== --- incubator/qpid/branches/M2.1/dotnet/TopicPublisher/Properties/AssemblyInfo.cs (original) +++ incubator/qpid/branches/M2.1/dotnet/TopicPublisher/Properties/AssemblyInfo.cs Thu Jan 17 09:13:11 2008 @@ -6,7 +6,7 @@ // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("TopicPublisher")] -[assembly: AssemblyDescription("Built from svn revision number: 612420:612430M")] +[assembly: AssemblyDescription("Built from svn revision number: 612518:612870M")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("TopicPublisher")]
