You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by lq...@apache.org on 2017/09/28 13:36:03 UTC
[06/12] qpid-broker-j git commit: QPID-7932: [Java Broker,
AMQP 1.0] Improve error handling when deserializing composite types
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/6a267175/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/EndConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/EndConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/EndConstructor.java
deleted file mode 100644
index 6bc3958..0000000
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/EndConstructor.java
+++ /dev/null
@@ -1,99 +0,0 @@
-
-/*
-*
-* 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.
-*
-*/
-
-
-package org.apache.qpid.server.protocol.v1_0.type.transport.codec;
-
-import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeConstructor;
-import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
-import org.apache.qpid.server.protocol.v1_0.type.*;
-import org.apache.qpid.server.protocol.v1_0.type.transport.*;
-
-
-import java.util.List;
-
-public class EndConstructor extends AbstractDescribedTypeConstructor<End>
-{
- private static final Object[] DESCRIPTORS =
- {
- Symbol.valueOf("amqp:end:list"),UnsignedLong.valueOf(0x0000000000000017L),
- };
-
- private static final EndConstructor INSTANCE = new EndConstructor();
-
- public static void register(DescribedTypeConstructorRegistry registry)
- {
- for(Object descriptor : DESCRIPTORS)
- {
- registry.register(descriptor, INSTANCE);
- }
- }
-
- @Override
- public End construct(Object underlying)
- {
- if(underlying instanceof List)
- {
- List list = (List) underlying;
- End obj = new End();
- int position = 0;
- final int size = list.size();
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setError( (org.apache.qpid.server.protocol.v1_0.type.transport.Error) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
-
- return obj;
- }
- else
- {
- // TODO - error
- return null;
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/6a267175/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/ErrorConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/ErrorConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/ErrorConstructor.java
deleted file mode 100644
index cbbbf78..0000000
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/ErrorConstructor.java
+++ /dev/null
@@ -1,224 +0,0 @@
-
-/*
-*
-* 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.
-*
-*/
-
-
-package org.apache.qpid.server.protocol.v1_0.type.transport.codec;
-
-import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeConstructor;
-import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
-import org.apache.qpid.server.protocol.v1_0.type.*;
-import org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionErrors;
-import org.apache.qpid.server.protocol.v1_0.type.transport.*;
-import org.apache.qpid.server.protocol.v1_0.type.transport.Error;
-
-
-import java.util.List;
-import java.util.Map;
-
-public class ErrorConstructor extends AbstractDescribedTypeConstructor<Error>
-{
- private static final Object[] DESCRIPTORS =
- {
- Symbol.valueOf("amqp:error:list"),UnsignedLong.valueOf(0x000000000000001dL),
- };
-
- private static final ErrorConstructor INSTANCE = new ErrorConstructor();
-
- public static void register(DescribedTypeConstructorRegistry registry)
- {
- for(Object descriptor : DESCRIPTORS)
- {
- registry.register(descriptor, INSTANCE);
- }
- }
-
- @Override
- public org.apache.qpid.server.protocol.v1_0.type.transport.Error construct(Object underlying)
- {
- if(underlying instanceof List)
- {
- List list = (List) underlying;
- org.apache.qpid.server.protocol.v1_0.type.transport.Error obj = new org.apache.qpid.server.protocol.v1_0.type.transport.Error();
- int position = 0;
- final int size = list.size();
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
- if(val instanceof ErrorCondition)
- {
- obj.setCondition( (ErrorCondition) val );
- }
- else if(val instanceof Symbol)
- {
- ErrorCondition condition = null;
- condition = AmqpError.valueOf(val);
- if(condition == null)
- {
- condition = ConnectionError.valueOf(val);
- if(condition == null)
- {
- condition = SessionError.valueOf(val);
- if(condition == null)
- {
- condition = LinkError.valueOf(val);
- if(condition == null)
- {
- condition = TransactionErrors.valueOf(val);
- if(condition == null)
- {
- condition = new UnknownErrorCondition((Symbol)val);
- }
- }
- }
- }
- }
- obj.setCondition(condition);
- }
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setDescription( (String) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setInfo( (Map) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
-
- return obj;
- }
- else
- {
- // TODO - error
- return null;
- }
- }
-
-
- private static final class UnknownErrorCondition implements ErrorCondition
- {
- private final Symbol _value;
-
- public UnknownErrorCondition(final Symbol value)
- {
- _value = value;
- }
-
- @Override
- public Symbol getValue()
- {
- return _value;
- }
-
- @Override
- public boolean equals(final Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- final UnknownErrorCondition that = (UnknownErrorCondition) o;
-
- if (!_value.equals(that._value))
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- return _value.hashCode();
- }
-
- @Override
- public String toString()
- {
- return _value.toString();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/6a267175/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/FlowConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/FlowConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/FlowConstructor.java
deleted file mode 100644
index 6031f11..0000000
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/FlowConstructor.java
+++ /dev/null
@@ -1,370 +0,0 @@
-
-/*
-*
-* 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.
-*
-*/
-
-
-package org.apache.qpid.server.protocol.v1_0.type.transport.codec;
-
-import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeConstructor;
-import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
-import org.apache.qpid.server.protocol.v1_0.type.*;
-import org.apache.qpid.server.protocol.v1_0.type.transport.*;
-
-
-import java.util.List;
-import java.util.Map;
-
-public class FlowConstructor extends AbstractDescribedTypeConstructor<Flow>
-{
- private static final Object[] DESCRIPTORS =
- {
- Symbol.valueOf("amqp:flow:list"),UnsignedLong.valueOf(0x0000000000000013L),
- };
-
- private static final FlowConstructor INSTANCE = new FlowConstructor();
-
- public static void register(DescribedTypeConstructorRegistry registry)
- {
- for(Object descriptor : DESCRIPTORS)
- {
- registry.register(descriptor, INSTANCE);
- }
- }
-
- @Override
- public Flow construct(Object underlying)
- {
- if(underlying instanceof List)
- {
- List list = (List) underlying;
- Flow obj = new Flow();
- int position = 0;
- final int size = list.size();
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setNextIncomingId( (UnsignedInteger) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setIncomingWindow( (UnsignedInteger) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setNextOutgoingId( (UnsignedInteger) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setOutgoingWindow( (UnsignedInteger) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setHandle( (UnsignedInteger) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setDeliveryCount( (UnsignedInteger) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setLinkCredit( (UnsignedInteger) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setAvailable( (UnsignedInteger) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setDrain( (Boolean) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setEcho( (Boolean) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setProperties( (Map) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
-
- return obj;
- }
- else
- {
- // TODO - error
- return null;
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/6a267175/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/OpenConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/OpenConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/OpenConstructor.java
deleted file mode 100644
index 3716690..0000000
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/OpenConstructor.java
+++ /dev/null
@@ -1,373 +0,0 @@
-
-/*
-*
-* 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.
-*
-*/
-
-
-package org.apache.qpid.server.protocol.v1_0.type.transport.codec;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeConstructor;
-import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
-import org.apache.qpid.server.protocol.v1_0.type.Symbol;
-import org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger;
-import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;
-import org.apache.qpid.server.protocol.v1_0.type.UnsignedShort;
-import org.apache.qpid.server.protocol.v1_0.type.transport.Open;
-
-public class OpenConstructor extends AbstractDescribedTypeConstructor<Open>
-{
- private static final Object[] DESCRIPTORS =
- {
- Symbol.valueOf("amqp:open:list"),UnsignedLong.valueOf(0x0000000000000010L),
- };
-
- private static final OpenConstructor INSTANCE = new OpenConstructor();
-
- public static void register(DescribedTypeConstructorRegistry registry)
- {
- for(Object descriptor : DESCRIPTORS)
- {
- registry.register(descriptor, INSTANCE);
- }
- }
-
- @Override
- public Open construct(Object underlying)
- {
- if(underlying instanceof List)
- {
- List list = (List) underlying;
- Open obj = new Open();
- int position = 0;
- final int size = list.size();
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setContainerId( (String) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setHostname( (String) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setMaxFrameSize( (UnsignedInteger) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setChannelMax( (UnsignedShort) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setIdleTimeOut( (UnsignedInteger) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
-
- if (val instanceof Symbol[] )
- {
- obj.setOutgoingLocales( (Symbol[]) val );
- }
- else
- {
- try
- {
- obj.setOutgoingLocales( new Symbol[] { (Symbol) val } );
- }
- catch(ClassCastException e)
- {
- // TODO Error
- }
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
-
- if (val instanceof Symbol[] )
- {
- obj.setIncomingLocales( (Symbol[]) val );
- }
- else
- {
- try
- {
- obj.setIncomingLocales( new Symbol[] { (Symbol) val } );
- }
- catch(ClassCastException e)
- {
- // TODO Error
- }
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
-
- if (val instanceof Symbol[] )
- {
- obj.setOfferedCapabilities( (Symbol[]) val );
- }
- else
- {
- try
- {
- obj.setOfferedCapabilities( new Symbol[] { (Symbol) val } );
- }
- catch(ClassCastException e)
- {
- // TODO Error
- }
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
-
- if (val instanceof Symbol[] )
- {
- obj.setDesiredCapabilities( (Symbol[]) val );
- }
- else
- {
- try
- {
- obj.setDesiredCapabilities( new Symbol[] { (Symbol) val } );
- }
- catch(ClassCastException e)
- {
- // TODO Error
- }
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setProperties( (Map) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
-
- return obj;
- }
- else
- {
- // TODO - error
- return null;
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/6a267175/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/TransferConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/TransferConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/TransferConstructor.java
deleted file mode 100644
index cfe641c..0000000
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/TransferConstructor.java
+++ /dev/null
@@ -1,369 +0,0 @@
-
-/*
-*
-* 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.
-*
-*/
-
-
-package org.apache.qpid.server.protocol.v1_0.type.transport.codec;
-
-import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeConstructor;
-import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
-import org.apache.qpid.server.protocol.v1_0.type.*;
-import org.apache.qpid.server.protocol.v1_0.type.transport.*;
-
-
-import java.util.List;
-
-public class TransferConstructor extends AbstractDescribedTypeConstructor<Transfer>
-{
- private static final Object[] DESCRIPTORS =
- {
- Symbol.valueOf("amqp:transfer:list"),UnsignedLong.valueOf(0x0000000000000014L),
- };
-
- private static final TransferConstructor INSTANCE = new TransferConstructor();
-
- public static void register(DescribedTypeConstructorRegistry registry)
- {
- for(Object descriptor : DESCRIPTORS)
- {
- registry.register(descriptor, INSTANCE);
- }
- }
-
- @Override
- public Transfer construct(Object underlying)
- {
- if(underlying instanceof List)
- {
- List list = (List) underlying;
- Transfer obj = new Transfer();
- int position = 0;
- final int size = list.size();
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setHandle( (UnsignedInteger) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setDeliveryId( (UnsignedInteger) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setDeliveryTag( (Binary) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setMessageFormat( (UnsignedInteger) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setSettled( (Boolean) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setMore( (Boolean) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setRcvSettleMode( ReceiverSettleMode.valueOf( val ) );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setState( (DeliveryState) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setResume( (Boolean) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setAborted( (Boolean) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
- if(position < size)
- {
- Object val = list.get(position);
- position++;
-
- if(val != null)
- {
-
- try
- {
- obj.setBatchable( (Boolean) val );
- }
- catch(ClassCastException e)
- {
-
- // TODO Error
- }
-
- }
-
-
- }
- else
- {
- return obj;
- }
-
-
- return obj;
- }
- else
- {
- // TODO - error
- return null;
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/6a267175/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreTestCase.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreTestCase.java b/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreTestCase.java
index 2f0e1db..06e058e 100644
--- a/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreTestCase.java
+++ b/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/store/LinkStoreTestCase.java
@@ -64,7 +64,7 @@ public abstract class LinkStoreTestCase extends QpidTestCase
_source.setDurable(TerminusDurability.UNSETTLED_STATE);
_source.setDynamic(Boolean.TRUE);
_source.setExpiryPolicy(TerminusExpiryPolicy.CONNECTION_CLOSE);
- _source.setFilter(Collections.singletonMap("foo", NoLocalFilter.INSTANCE));
+ _source.setFilter(Collections.singletonMap(Symbol.valueOf("foo"), NoLocalFilter.INSTANCE));
_source.setOutcomes(new Accepted().getSymbol());
_source.setDynamicNodeProperties(Collections.singletonMap(Symbol.valueOf("dynamicProperty"),
"dynamicPropertyValue"));
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/6a267175/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/DecodeErrorTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/DecodeErrorTest.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/DecodeErrorTest.java
new file mode 100644
index 0000000..8cc6f92
--- /dev/null
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/DecodeErrorTest.java
@@ -0,0 +1,196 @@
+/*
+ * 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.
+ *
+ */
+
+package org.apache.qpid.tests.protocol.v1_0;
+
+import static org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError.DECODE_ERROR;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.fail;
+
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.codec.StringWriter;
+import org.apache.qpid.server.protocol.v1_0.type.Symbol;
+import org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger;
+import org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations;
+import org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotationsSection;
+import org.apache.qpid.server.protocol.v1_0.type.messaging.Header;
+import org.apache.qpid.server.protocol.v1_0.type.messaging.HeaderSection;
+import org.apache.qpid.server.protocol.v1_0.type.messaging.Source;
+import org.apache.qpid.server.protocol.v1_0.type.messaging.Target;
+import org.apache.qpid.server.protocol.v1_0.type.transport.Attach;
+import org.apache.qpid.server.protocol.v1_0.type.transport.Begin;
+import org.apache.qpid.server.protocol.v1_0.type.transport.Close;
+import org.apache.qpid.server.protocol.v1_0.type.transport.Detach;
+import org.apache.qpid.server.protocol.v1_0.type.transport.End;
+import org.apache.qpid.server.protocol.v1_0.type.transport.Error;
+import org.apache.qpid.server.protocol.v1_0.type.transport.Flow;
+import org.apache.qpid.server.protocol.v1_0.type.transport.Open;
+import org.apache.qpid.server.protocol.v1_0.type.transport.Role;
+import org.apache.qpid.tests.utils.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
+
+public class DecodeErrorTest extends BrokerAdminUsingTestBase
+{
+ private InetSocketAddress _brokerAddress;
+
+ @Before
+ public void setUp()
+ {
+ _brokerAddress = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
+ getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
+ }
+
+ @Test
+ @SpecificationTest(section = "3.2",
+ description = "Altogether a message consists of the following sections: Zero or one header,"
+ + " Zero or one delivery-annotations, [...]")
+ public void illegalMessageFormatPayload() throws Exception
+ {
+ try (FrameTransport transport = new FrameTransport(_brokerAddress).connect())
+ {
+
+ List<QpidByteBuffer> combinedPayload = new ArrayList<>();
+ final HeaderSection headerSection = new Header().createEncodingRetainingSection();
+ combinedPayload.addAll(headerSection.getEncodedForm());
+ headerSection.dispose();
+ final StringWriter stringWriter = new StringWriter("string in between annotation sections");
+ QpidByteBuffer encodedString = QpidByteBuffer.allocate(stringWriter.getEncodedSize());
+ stringWriter.writeToBuffer(encodedString);
+ encodedString.flip();
+ combinedPayload.add(encodedString);
+ final DeliveryAnnotationsSection
+ deliveryAnnotationsSection =
+ new DeliveryAnnotations(Collections.emptyMap()).createEncodingRetainingSection();
+ combinedPayload.addAll(deliveryAnnotationsSection.getEncodedForm());
+ deliveryAnnotationsSection.dispose();
+
+ final Detach detachResponse = transport.newInteraction()
+ .negotiateProtocol().consumeResponse()
+ .open().consumeResponse(Open.class)
+ .begin().consumeResponse(Begin.class)
+ .attachRole(Role.SENDER)
+ .attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME)
+ .attach().consumeResponse(Attach.class)
+ .consumeResponse(Flow.class)
+ .transferMessageFormat(UnsignedInteger.ZERO)
+ .transferPayload(combinedPayload)
+ .transfer()
+ .consumeResponse()
+ .getLatestResponse(Detach.class);
+ assertThat(detachResponse.getError(), is(notNullValue()));
+ assertThat(detachResponse.getError().getCondition(), is(equalTo(DECODE_ERROR)));
+ }
+ }
+
+ @Test
+ @SpecificationTest(section = "3.5.9",
+ description = "The value of this entry MUST be of a type which provides the lifetime-policy archetype.")
+ public void nodePropertiesLifetimePolicy() throws Exception
+ {
+ try (FrameTransport transport = new FrameTransport(_brokerAddress).connect())
+ {
+ final Source source = new Source();
+ source.setDynamic(Boolean.TRUE);
+ source.setDynamicNodeProperties(Collections.singletonMap(Symbol.valueOf("lifetime-policy"),
+ UnsignedInteger.MAX_VALUE));
+ final Response<?> latestResponse = transport.newInteraction()
+ .negotiateProtocol().consumeResponse()
+ .open().consumeResponse(Open.class)
+ .begin().consumeResponse(Begin.class)
+ .attachSource(source)
+ .attachRole(Role.SENDER)
+ .attach().consumeResponse()
+ .getLatestResponse();
+
+ assertThat(latestResponse, is(notNullValue()));
+ final Object responseBody = latestResponse.getBody();
+ final Error error;
+ if (responseBody instanceof End)
+ {
+ error = ((End) responseBody).getError();
+ }
+ else if (responseBody instanceof Close)
+ {
+ error = ((Close) responseBody).getError();
+ }
+ else
+ {
+ fail(String.format("Expected response of either Detach, End, or Close. Got '%s'", responseBody));
+ error = null;
+ }
+
+ assertThat(error, is(notNullValue()));
+ assertThat(error.getCondition(), is(equalTo(DECODE_ERROR)));
+ }
+ }
+
+ @Test
+ @SpecificationTest(section = "3.5.9",
+ description = "The value of this entry MUST be of a type which provides the lifetime-policy archetype.")
+ public void nodePropertiesSupportedDistributionModes() throws Exception
+ {
+ try (FrameTransport transport = new FrameTransport(_brokerAddress).connect())
+ {
+ final Target target = new Target();
+ target.setDynamic(Boolean.TRUE);
+ target.setDynamicNodeProperties(Collections.singletonMap(Symbol.valueOf("supported-dist-modes"),
+ UnsignedInteger.ZERO));
+ final Response<?> latestResponse = transport.newInteraction()
+ .negotiateProtocol().consumeResponse()
+ .open().consumeResponse(Open.class)
+ .begin().consumeResponse(Begin.class)
+ .attachTarget(target)
+ .attachRole(Role.SENDER)
+ .attach().consumeResponse()
+ .getLatestResponse();
+
+ assertThat(latestResponse, is(notNullValue()));
+ final Object responseBody = latestResponse.getBody();
+ final Error error;
+ if (responseBody instanceof End)
+ {
+ error = ((End) responseBody).getError();
+ }
+ else if (responseBody instanceof Close)
+ {
+ error = ((Close) responseBody).getError();
+ }
+ else
+ {
+ fail(String.format("Expected response of either Detach, End, or Close. Got '%s'", responseBody));
+ error = null;
+ }
+
+ assertThat(error, is(notNullValue()));
+ assertThat(error.getCondition(), is(equalTo(DECODE_ERROR)));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/6a267175/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/MessageFormat.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/MessageFormat.java b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/MessageFormat.java
index b9148aa..6a373d1 100644
--- a/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/MessageFormat.java
+++ b/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/messaging/MessageFormat.java
@@ -20,28 +20,19 @@
package org.apache.qpid.tests.protocol.v1_0.messaging;
-import static org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError.DECODE_ERROR;
-import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.fail;
import java.net.InetSocketAddress;
-import java.util.ArrayList;
import java.util.Collections;
-import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
-import org.apache.qpid.server.protocol.v1_0.codec.StringWriter;
import org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger;
-import org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations;
-import org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotationsSection;
-import org.apache.qpid.server.protocol.v1_0.type.messaging.Header;
-import org.apache.qpid.server.protocol.v1_0.type.messaging.HeaderSection;
import org.apache.qpid.server.protocol.v1_0.type.transport.Attach;
import org.apache.qpid.server.protocol.v1_0.type.transport.Begin;
import org.apache.qpid.server.protocol.v1_0.type.transport.Close;
@@ -128,44 +119,4 @@ public class MessageFormat extends BrokerAdminUsingTestBase
assertThat(error, is(notNullValue()));
}
}
-
- @Test
- @SpecificationTest(section = "3.2",
- description = "Altogether a message consists of the following sections: Zero or one header,"
- + " Zero or one delivery-annotations, [...]")
- public void illegalMessageFormatPayload() throws Exception
- {
- try (FrameTransport transport = new FrameTransport(_brokerAddress).connect())
- {
-
- List<QpidByteBuffer> combinedPayload = new ArrayList<>();
- final HeaderSection headerSection = new Header().createEncodingRetainingSection();
- combinedPayload.addAll(headerSection.getEncodedForm());
- headerSection.dispose();
- final StringWriter stringWriter = new StringWriter("string in between annotation sections");
- QpidByteBuffer encodedString = QpidByteBuffer.allocate(stringWriter.getEncodedSize());
- stringWriter.writeToBuffer(encodedString);
- encodedString.flip();
- combinedPayload.add(encodedString);
- final DeliveryAnnotationsSection deliveryAnnotationsSection = new DeliveryAnnotations(Collections.emptyMap()).createEncodingRetainingSection();
- combinedPayload.addAll(deliveryAnnotationsSection.getEncodedForm());
- deliveryAnnotationsSection.dispose();
-
- final Detach detachResponse = transport.newInteraction()
- .negotiateProtocol().consumeResponse()
- .open().consumeResponse(Open.class)
- .begin().consumeResponse(Begin.class)
- .attachRole(Role.SENDER)
- .attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME)
- .attach().consumeResponse(Attach.class)
- .consumeResponse(Flow.class)
- .transferMessageFormat(UnsignedInteger.ZERO)
- .transferPayload(combinedPayload)
- .transfer()
- .consumeResponse()
- .getLatestResponse(Detach.class);
- assertThat(detachResponse.getError(), is(notNullValue()));
- assertThat(detachResponse.getError().getCondition(), is(equalTo(DECODE_ERROR)));
- }
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org