001 /*
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements. See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership. The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License. You may obtain a copy of the License at
010 *
011 * http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing,
014 * software distributed under the License is distributed on an
015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016 * KIND, either express or implied. See the License for the
017 * specific language governing permissions and limitations
018 * under the License.
019 *
020 */
021 package org.apache.qpid.interop.clienttestcases;
022
023 import org.apache.log4j.Logger;
024
025 import org.apache.qpid.test.framework.distributedtesting.TestClientControlledTest;
026
027 import javax.jms.JMSException;
028 import javax.jms.Message;
029 import javax.jms.Session;
030
031 /**
032 * Implements tet case 1, dummy run. This test case sends no test messages, it exists to confirm that the test harness
033 * is interacting with the coordinator correctly.
034 *
035 * <p><table id="crc"><caption>CRC Card</caption>
036 * <tr><th> Responsibilities <th> Collaborations
037 * <tr><td> Supply the name of the test case that this implements.
038 * <tr><td> Accept/Reject invites based on test parameters.
039 * <tr><td> Adapt to assigned roles.
040 * <tr><td> Perform test case actions.
041 * <tr><td> Generate test reports.
042 * </table>
043 */
044 public class TestCase1DummyRun implements TestClientControlledTest
045 {
046 /** Used for debugging. */
047 private static final Logger log = Logger.getLogger(TestCase1DummyRun.class);
048
049 /**
050 * Should provide the name of the test case that this class implements. The exact names are defined in the
051 * interop testing spec.
052 *
053 * @return The name of the test case that this implements.
054 */
055 public String getName()
056 {
057 log.debug("public String getName(): called");
058
059 return "TC1_DummyRun";
060 }
061
062 /**
063 * Determines whether the test invite that matched this test case is acceptable.
064 *
065 * @param inviteMessage The invitation to accept or reject.
066 *
067 * @return <tt>true</tt> to accept the invitation, <tt>false</tt> to reject it.
068 *
069 * @throws JMSException Any JMSException resulting from reading the message are allowed to fall through.
070 */
071 public boolean acceptInvite(Message inviteMessage) throws JMSException
072 {
073 log.debug("public boolean acceptInvite(Message inviteMessage): called");
074
075 // Test parameters don't matter, accept all invites.
076 return true;
077 }
078
079 /**
080 * Assigns the role to be played by this test case. The test parameters are fully specified in the
081 * assignment message. When this method return the test case will be ready to execute.
082 *
083 * @param role The role to be played; sender or receivers.
084 * @param assignRoleMessage The role assingment message, contains the full test parameters.
085 *
086 * @throws JMSException Any JMSException resulting from reading the message are allowed to fall through.
087 */
088 public void assignRole(Roles role, Message assignRoleMessage) throws JMSException
089 {
090 log.debug("public void assignRole(Roles role, Message assignRoleMessage): called");
091
092 // Do nothing, both roles are the same.
093 }
094
095 /**
096 * Performs the test case actions. Returning from here, indicates that the sending role has completed its test.
097 *
098 * @param numMessages The number of test messages to send.
099 */
100 public void start(int numMessages)
101 {
102 log.debug("public void start(): called");
103
104 // Do nothing.
105 }
106
107 /**
108 * Gets a report on the actions performed by the test case in its assigned role.
109 *
110 * @param session The controlSession to create the report message in.
111 *
112 * @return The report message.
113 *
114 * @throws JMSException Any JMSExceptions resulting from creating the report are allowed to fall through.
115 */
116 public Message getReport(Session session) throws JMSException
117 {
118 log.debug("public Message getReport(Session controlSession): called");
119
120 // Generate a dummy report, the coordinator expects a report but doesn't care what it is.
121 return session.createTextMessage("Dummy Run, Ok.");
122 }
123
124 /**
125 * Handles incoming test messages. Does nothing.
126 *
127 * @param message The incoming test message.
128 */
129 public void onMessage(Message message)
130 {
131 log.debug("public void onMessage(Message message = " + message + "): called");
132
133 // Ignore any messages.
134 }
135 }
|