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.testcases;
022
023 import org.apache.log4j.Logger;
024
025 import org.apache.qpid.test.framework.FrameworkBaseCase;
026
027 import java.util.Properties;
028
029 /**
030 * Implements test case 4, from the interop test specification. This test sets up the TC2_P2PMessageSize test for 50
031 * messages, and a variety of message sizes. It checks that the sender and receivers reports both indicate that all
032 * the test messages were transmitted successfully.
033 *
034 * <p><table id="crc"><caption>CRC Card</caption>
035 * <tr><th> Responsibilities <th> Collaborations
036 * <tr><td> Setup p2p test parameters and compare with test output. <td> {@link FrameworkBaseCase}
037 * </table>
038 */
039 public class InteropTestCase4P2PMessageSize extends FrameworkBaseCase
040 {
041 /** Used for debugging. */
042 private static final Logger log = Logger.getLogger(InteropTestCase4P2PMessageSize.class);
043
044 /**
045 * Creates a new coordinating test case with the specified name.
046 *
047 * @param name The test case name.
048 */
049 public InteropTestCase4P2PMessageSize(String name)
050 {
051 super(name);
052 }
053
054 /**
055 * Performs the P2P message test case, "Test Case 4" in the specification, for messages 0K in size.
056 *
057 * @throws Exception Any exceptions are allowed to fall through and fail the test.
058 */
059 public void testP2PMessageSize0K() throws Exception
060 {
061 runTestForMessagesOfSize(0);
062 }
063
064 /**
065 * Performs the P2P message test case, "Test Case 4" in the specification, for messages 63K in size.
066 *
067 * @throws Exception Any exceptions are allowed to fall through and fail the test.
068 */
069 public void testP2PMessageSize63K() throws Exception
070 {
071 runTestForMessagesOfSize(63 * 1024);
072 }
073
074 /**
075 * Performs the P2P message test case, "Test Case 4" in the specification, for messages 64K in size.
076 *
077 * @throws Exception Any exceptions are allowed to fall through and fail the test.
078 */
079 public void testP2PMessageSize64K() throws Exception
080 {
081 runTestForMessagesOfSize(64 * 1024);
082 }
083
084 /**
085 * Performs the P2P message test case, "Test Case 4" in the specification, for messages 65K in size.
086 *
087 * @throws Exception Any exceptions are allowed to fall through and fail the test.
088 */
089 public void testP2PMessageSize65K() throws Exception
090 {
091 runTestForMessagesOfSize(65 * 1024);
092 }
093
094 /**
095 * Performs the P2P message test case, "Test Case 4" in the specification, for messages 127K in size.
096 *
097 * @throws Exception Any exceptions are allowed to fall through and fail the test.
098 */
099 public void testP2PMessageSize127K() throws Exception
100 {
101 runTestForMessagesOfSize(127 * 1024);
102 }
103
104 /**
105 * Performs the P2P message test case, "Test Case 4" in the specification, for messages 128K in size.
106 *
107 * @throws Exception Any exceptions are allowed to fall through and fail the test.
108 */
109 public void testP2PMessageSize128K() throws Exception
110 {
111 runTestForMessagesOfSize(128 * 1024);
112 }
113
114 /**
115 * Performs the P2P message test case, "Test Case 4" in the specification, for messages 129K in size.
116 *
117 * @throws Exception Any exceptions are allowed to fall through and fail the test.
118 */
119 public void testP2PMessageSize129K() throws Exception
120 {
121 runTestForMessagesOfSize(129 * 1024);
122 }
123
124 /**
125 * Performs the P2P message test case, "Test Case 4" in the specification, for messages 255K in size.
126 *
127 * @throws Exception Any exceptions are allowed to fall through and fail the test.
128 */
129 public void testP2PMessageSize255K() throws Exception
130 {
131 runTestForMessagesOfSize(255 * 1024);
132 }
133
134 /**
135 * Performs the P2P message test case, "Test Case 4" in the specification, for messages 256K in size.
136 *
137 * @throws Exception Any exceptions are allowed to fall through and fail the test.
138 */
139 public void testP2PMessageSize256K() throws Exception
140 {
141 runTestForMessagesOfSize(256 * 1024);
142 }
143
144 /**
145 * Performs the P2P message test case, "Test Case 4" in the specification, for messages 257K in size.
146 *
147 * @throws Exception Any exceptions are allowed to fall through and fail the test.
148 */
149 public void testP2PMessageSize257K() throws Exception
150 {
151 runTestForMessagesOfSize(257 * 1024);
152 }
153
154 /**
155 * Sends 50 test messages of the specified size, and asserts that all were received.
156 *
157 * @param size The size of the messages to send in bytes.
158 */
159 private void runTestForMessagesOfSize(int size)
160 {
161 Properties testConfig = new Properties();
162 testConfig.setProperty("TEST_NAME", "TC4_P2PMessageSize");
163 testConfig.setProperty("P2P_QUEUE_AND_KEY_NAME", "tc2queue");
164 testConfig.put("P2P_NUM_MESSAGES", 50);
165 testConfig.put("messageSize", size);
166
167 /*Message[] reports =*/
168 getCircuitFactory().sequenceTest(null, null, testConfig);
169
170 // Compare sender and receivers reports.
171 /*
172 int messagesSent = reports[0].getIntProperty("MESSAGE_COUNT");
173 int messagesReceived = reports[1].getIntProperty("MESSAGE_COUNT");
174
175 Assert.assertEquals("The requested number of messages were not sent.", 50, messagesSent);
176 Assert.assertEquals("Sender and receivers messages sent did not match up.", messagesSent, messagesReceived);
177 */
178 }
179
180 /**
181 * Should provide a translation from the junit method name of a test to its test case name as defined in the
182 * interop testing specification. For example the method "testP2P" might map onto the interop test case name
183 * "TC2_BasicP2P".
184 *
185 * @param methodName The name of the JUnit test method.
186 *
187 * @return The name of the corresponding interop test case.
188 */
189 public String getTestCaseNameForTestMethod(String methodName)
190 {
191 return "TC4_P2PMessageSize";
192 }
193 }
|