From 1bb43f379eda76afca9df488cd9510f60ad89717 Mon Sep 17 00:00:00 2001 From: Martin Ritchie Date: Wed, 9 May 2007 15:23:33 +0000 Subject: Merged revisions 536498-536499 via svnmerge from https://svn.apache.org/repos/asf/incubator/qpid/branches/M2 ........ r536498 | ritchiem | 2007-05-09 13:15:55 +0100 (Wed, 09 May 2007) | 1 line Moved MaxChannelsTest.java to the correct package. ........ r536499 | ritchiem | 2007-05-09 13:16:17 +0100 (Wed, 09 May 2007) | 1 line Whitespace + Formatting. ........ git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@536565 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/framing/BasicContentHeaderProperties.java | 33 +++++----- .../qpid/server/channel/MaxChannelsTest.java | 75 ---------------------- .../qpid/server/protocol/MaxChannelsTest.java | 75 ++++++++++++++++++++++ 3 files changed, 90 insertions(+), 93 deletions(-) delete mode 100644 java/systests/src/main/java/org/apache/qpid/server/channel/MaxChannelsTest.java create mode 100644 java/systests/src/main/java/org/apache/qpid/server/protocol/MaxChannelsTest.java diff --git a/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java b/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java index dd872c31b0..4424fc1def 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java +++ b/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java @@ -31,26 +31,23 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti private static final AMQShortString ZERO_STRING = null; /** - * We store the encoded form when we decode the content header so that if we need to - * write it out without modifying it we can do so without incurring the expense of - * reencoding it + * We store the encoded form when we decode the content header so that if we need to write it out without modifying + * it we can do so without incurring the expense of reencoding it */ private byte[] _encodedForm; - /** - * Flag indicating whether the entire content header has been decoded yet - */ + /** Flag indicating whether the entire content header has been decoded yet */ private boolean _decoded = true; /** - * We have some optimisations for partial decoding for maximum performance. The headers are used in the broker - * for routing in some cases so we can decode that separately. + * We have some optimisations for partial decoding for maximum performance. The headers are used in the broker for + * routing in some cases so we can decode that separately. */ private boolean _decodedHeaders = true; /** - * We have some optimisations for partial decoding for maximum performance. The content type is used by all - * clients to determine the message type + * We have some optimisations for partial decoding for maximum performance. The content type is used by all clients + * to determine the message type */ private boolean _decodedContentType = true; @@ -142,9 +139,9 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti } if ((_propertyFlags & EXPIRATION_MASK) > 0) { - if(_expiration == 0L) + if (_expiration == 0L) { - size+=EncodingUtils.encodedShortStringLength(ZERO_STRING); + size += EncodingUtils.encodedShortStringLength(ZERO_STRING); } else { @@ -237,9 +234,9 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti } if ((_propertyFlags & EXPIRATION_MASK) != 0) { - if(_expiration == 0L) + if (_expiration == 0L) { - EncodingUtils.writeShortStringBytes(buffer, ZERO_STRING); + EncodingUtils.writeShortStringBytes(buffer, ZERO_STRING); } else { @@ -274,7 +271,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti } public void populatePropertiesFromBuffer(ByteBuffer buffer, int propertyFlags, int size) - throws AMQFrameDecodingException + throws AMQFrameDecodingException { _propertyFlags = propertyFlags; @@ -463,7 +460,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public String getEncodingAsString() { - + return getEncoding() == null ? null : getEncoding().toString(); } @@ -575,7 +572,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti { setReplyTo(replyTo == null ? null : new AMQShortString(replyTo)); } - + public void setReplyTo(AMQShortString replyTo) { @@ -702,7 +699,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setAppId(String appId) { - setAppId(appId == null ? null : new AMQShortString(appId)); + setAppId(appId == null ? null : new AMQShortString(appId)); } public void setAppId(AMQShortString appId) diff --git a/java/systests/src/main/java/org/apache/qpid/server/channel/MaxChannelsTest.java b/java/systests/src/main/java/org/apache/qpid/server/channel/MaxChannelsTest.java deleted file mode 100644 index 503bb28775..0000000000 --- a/java/systests/src/main/java/org/apache/qpid/server/channel/MaxChannelsTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed 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. - * - */ -package org.apache.qpid.server.protocol; - -import junit.framework.TestCase; -import org.apache.mina.common.IoSession; -import org.apache.qpid.codec.AMQCodecFactory; -import org.apache.qpid.server.AMQChannel; -import org.apache.qpid.server.virtualhost.VirtualHost; -import org.apache.qpid.server.registry.IApplicationRegistry; -import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.server.exchange.ExchangeRegistry; -import org.apache.qpid.server.queue.QueueRegistry; -import org.apache.qpid.server.queue.AMQQueue; -import org.apache.qpid.server.store.MessageStore; -import org.apache.qpid.server.store.SkeletonMessageStore; -import org.apache.qpid.AMQException; -import org.apache.qpid.protocol.AMQConstant; -import org.apache.qpid.framing.AMQShortString; - -import javax.management.JMException; - -/** Test class to test MBean operations for AMQMinaProtocolSession. */ -public class MaxChannelsTest extends TestCase -{ -// private MessageStore _messageStore = new SkeletonMessageStore(); - - public void testChannels() throws Exception - { - IApplicationRegistry appRegistry = ApplicationRegistry.getInstance(); - AMQMinaProtocolSession _protocolSession = new AMQMinaProtocolSession(new MockIoSession(), - appRegistry.getVirtualHostRegistry(), - new AMQCodecFactory(true), - null); - _protocolSession.setVirtualHost(appRegistry.getVirtualHostRegistry().getVirtualHost("test")); - - // check the channel count is correct - int channelCount = _protocolSession.getChannels().size(); - assertEquals("Initial channel count wrong", 0, channelCount); - - long maxChannels = 10L; - _protocolSession.setMaximumNumberOfChannels(maxChannels); - assertEquals("Number of channels not correctly set.", new Long(maxChannels), _protocolSession.getMaximumNumberOfChannels()); - - - try - { - for (long currentChannel = 0L; currentChannel < maxChannels; currentChannel++) - { - _protocolSession.addChannel(new AMQChannel(_protocolSession, (int) currentChannel, null, null, null)); - } - } - catch (AMQException e) - { - assertEquals("Wrong exception recevied.", e.getErrorCode(), AMQConstant.NOT_ALLOWED); - } - assertEquals("Maximum number of channels not set.", new Long(maxChannels), new Long(_protocolSession.getChannels().size())); - } - -} diff --git a/java/systests/src/main/java/org/apache/qpid/server/protocol/MaxChannelsTest.java b/java/systests/src/main/java/org/apache/qpid/server/protocol/MaxChannelsTest.java new file mode 100644 index 0000000000..5ddccb8a7b --- /dev/null +++ b/java/systests/src/main/java/org/apache/qpid/server/protocol/MaxChannelsTest.java @@ -0,0 +1,75 @@ +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed 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. + * + */ +package org.apache.qpid.server.protocol; + +import junit.framework.TestCase; +import org.apache.mina.common.IoSession; +import org.apache.qpid.codec.AMQCodecFactory; +import org.apache.qpid.server.AMQChannel; +import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.registry.IApplicationRegistry; +import org.apache.qpid.server.registry.ApplicationRegistry; +import org.apache.qpid.server.exchange.ExchangeRegistry; +import org.apache.qpid.server.queue.QueueRegistry; +import org.apache.qpid.server.queue.AMQQueue; +import org.apache.qpid.server.store.MessageStore; +import org.apache.qpid.server.store.SkeletonMessageStore; +import org.apache.qpid.AMQException; +import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.framing.AMQShortString; + +import javax.management.JMException; + +/** Test class to test MBean operations for AMQMinaProtocolSession. */ +public class MaxChannelsTest extends TestCase +{ +// private MessageStore _messageStore = new SkeletonMessageStore(); + + public void testChannels() throws Exception + { + IApplicationRegistry appRegistry = ApplicationRegistry.getInstance(); + AMQMinaProtocolSession _protocolSession = new AMQMinaProtocolSession(new MockIoSession(), + appRegistry.getVirtualHostRegistry(), + new AMQCodecFactory(true), + null); + _protocolSession.setVirtualHost(appRegistry.getVirtualHostRegistry().getVirtualHost("test")); + + // check the channel count is correct + int channelCount = _protocolSession.getChannels().size(); + assertEquals("Initial channel count wrong", 0, channelCount); + + long maxChannels = 10L; + _protocolSession.setMaximumNumberOfChannels(maxChannels); + assertEquals("Number of channels not correctly set.", new Long(maxChannels), _protocolSession.getMaximumNumberOfChannels()); + + + try + { + for (long currentChannel = 0L; currentChannel < maxChannels; currentChannel++) + { + _protocolSession.addChannel(new AMQChannel(_protocolSession, (int) currentChannel, null, null)); + } + } + catch (AMQException e) + { + assertEquals("Wrong exception recevied.", e.getErrorCode(), AMQConstant.NOT_ALLOWED); + } + assertEquals("Maximum number of channels not set.", new Long(maxChannels), new Long(_protocolSession.getChannels().size())); + } + +} -- cgit v1.2.1