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.sustained;
022
023 import org.apache.log4j.Logger;
024
025 import org.apache.qpid.client.AMQSession;
026 import org.apache.qpid.test.framework.DropInTest;
027 import org.apache.qpid.test.framework.FrameworkBaseCase;
028
029 import javax.jms.JMSException;
030 import javax.jms.Message;
031
032 import java.util.Properties;
033
034 /**
035 * SustainedTestCase is a {@link FrameworkBaseCase} that runs the "Perf_SustainedPubSub" test case. This consists of one
036 * test client sending, and several receiving, and attempts to find the highest rate at which messages can be broadcast
037 * to the receivers. It is also a {@link DropInTest} to which more test clients may be added during a test run.
038 *
039 * <p/><table id="crc"><caption>CRC Card</caption>
040 * <tr><th> Responsibilities <th> Collaborations
041 * <tr><td>
042 * </table>
043 */
044 public class SustainedTestCase extends FrameworkBaseCase implements DropInTest
045 {
046 /** Used for debugging. */
047 Logger log = Logger.getLogger(SustainedTestCase.class);
048
049 /** Holds the root name of the topic on which to send the test messages. */
050 private static final String SUSTAINED_KEY = "Perf_SustainedPubSub";
051
052 /**
053 * Creates a new coordinating test case with the specified name.
054 *
055 * @param name The test case name.
056 */
057 public SustainedTestCase(String name)
058 {
059 super(name);
060 }
061
062 /**
063 * Performs a single test run of the sustained test.
064 *
065 * @throws Exception Any exceptions are allowed to fall through and fail the test.
066 */
067 public void testBasicPubSub() throws Exception
068 {
069 log.debug("public void testSinglePubSubCycle(): called");
070
071 Properties testConfig = new Properties();
072 testConfig.put("TEST_NAME", "Perf_SustainedPubSub");
073 testConfig.put("SUSTAINED_KEY", SUSTAINED_KEY);
074 testConfig.put("SUSTAINED_NUM_RECEIVERS", Integer.getInteger("numReceives", 2));
075 testConfig.put("SUSTAINED_UPDATE_INTERVAL", Integer.getInteger("batchSize", 1000));
076 testConfig.put("SUSTAINED_UPDATE_KEY", SUSTAINED_KEY + ".UPDATE");
077 testConfig.put("ACKNOWLEDGE_MODE", Integer.getInteger("ackMode", AMQSession.AUTO_ACKNOWLEDGE));
078
079 log.info("Created Config: " + testConfig.entrySet().toArray());
080
081 getCircuitFactory().sequenceTest(null, null, testConfig);
082 }
083
084 /**
085 * Accepts a late joining client into this test case. The client will be enlisted with a control message
086 * with the 'CONTROL_TYPE' field set to the value 'LATEJOIN'. It should also provide values for the fields:
087 *
088 * <p/><table>
089 * <tr><td> CLIENT_NAME <td> A unique name for the new client.
090 * <tr><td> CLIENT_PRIVATE_CONTROL_KEY <td> The key for the route on which the client receives its control messages.
091 * </table>
092 *
093 * @param message The late joiners join message.
094 *
095 * @throws JMSException Any JMS Exception are allowed to fall through, indicating that the join failed.
096 */
097 public void lateJoin(Message message) throws JMSException
098 {
099 throw new RuntimeException("Not implemented.");
100 /*
101 // Extract the joining clients details from its join request message.
102 TestClientDetails clientDetails = new TestClientDetails();
103 clientDetails.clientName = message.getStringProperty("CLIENT_NAME");
104 clientDetails.privateControlKey = message.getStringProperty("CLIENT_PRIVATE_CONTROL_KEY");
105
106 // Register the joining client, but do block for confirmation as cannot do a synchronous receivers during this
107 // method call, as it may have been called from an 'onMessage' method.
108 assignReceiverRole(clientDetails, new Properties(), false);
109 */
110 }
111
112 /**
113 * Should provide a translation from the junit method name of a test to its test case name as known to the test
114 * clients that will run the test. The purpose of this is to convert the JUnit method name into the correct test
115 * case name to place into the test invite. For example the method "testP2P" might map onto the interop test case
116 * name "TC2_BasicP2P".
117 *
118 * @param methodName The name of the JUnit test method.
119 *
120 * @return The name of the corresponding interop test case.
121 */
122 public String getTestCaseNameForTestMethod(String methodName)
123 {
124 return "Perf_SustainedPubSub";
125 }
126 }
|