You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2016/11/25 21:01:20 UTC
[24/48] qpid-proton git commit: PROTON-1352,
PROTON-1353: Added message annotations to the String visualization of
AMQP message Refactored ReceiverSettleMode and SenderSettleMode for having
trivial casting from/to UnsignedByte and added unit tests
PROTON-1352,PROTON-1353: Added message annotations to the String visualization of AMQP message
Refactored ReceiverSettleMode and SenderSettleMode for having trivial casting from/to UnsignedByte and added unit tests
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/fec0bc8c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/fec0bc8c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/fec0bc8c
Branch: refs/heads/go1
Commit: fec0bc8c82ad6eb705757fd2df87cef67c28f930
Parents: eac0bb6
Author: ppatierno <pp...@live.com>
Authored: Wed Nov 16 11:03:35 2016 +0100
Committer: ppatierno <pp...@live.com>
Committed: Wed Nov 16 18:42:35 2016 +0100
----------------------------------------------------------------------
.../amqp/transport/ReceiverSettleMode.java | 25 ++++++--
.../proton/amqp/transport/SenderSettleMode.java | 29 +++++++--
.../qpid/proton/message/impl/MessageImpl.java | 4 ++
.../amqp/transport/ReceiverSettleModeTest.java | 61 ++++++++++++++++++
.../amqp/transport/SenderSettleModeTest.java | 67 ++++++++++++++++++++
5 files changed, 178 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fec0bc8c/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleMode.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleMode.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleMode.java
index 1062e39..c2621e6 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleMode.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleMode.java
@@ -27,11 +27,28 @@ import org.apache.qpid.proton.amqp.UnsignedByte;
public enum ReceiverSettleMode
{
- FIRST, SECOND;
+ FIRST(0),
+ SECOND(1);
- public UnsignedByte getValue()
- {
- return UnsignedByte.valueOf((byte)ordinal());
+ private UnsignedByte value;
+
+ private ReceiverSettleMode(int value) {
+ this.value = UnsignedByte.valueOf((byte)value);
}
+ public static ReceiverSettleMode valueOf(UnsignedByte value) {
+
+ switch (value.intValue()) {
+ case 0:
+ return ReceiverSettleMode.FIRST;
+ case 1:
+ return ReceiverSettleMode.SECOND;
+ default:
+ throw new IllegalArgumentException("The value can be only 0 (for FIRST) and 1 (for SECOND)");
+ }
+ }
+
+ public UnsignedByte getValue() {
+ return this.value;
+ }
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fec0bc8c/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SenderSettleMode.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SenderSettleMode.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SenderSettleMode.java
index e3ed0b2..6dae3f4 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SenderSettleMode.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/amqp/transport/SenderSettleMode.java
@@ -27,11 +27,32 @@ import org.apache.qpid.proton.amqp.UnsignedByte;
public enum SenderSettleMode
{
- UNSETTLED, SETTLED, MIXED;
+ UNSETTLED(0),
+ SETTLED(1),
+ MIXED(2);
- public UnsignedByte getValue()
- {
- return UnsignedByte.valueOf((byte)ordinal());
+ private UnsignedByte value;
+
+ private SenderSettleMode(int value) {
+ this.value = UnsignedByte.valueOf((byte)value);
+ }
+
+ public static SenderSettleMode valueOf(UnsignedByte value) {
+
+ switch (value.intValue()) {
+
+ case 0:
+ return SenderSettleMode.UNSETTLED;
+ case 1:
+ return SenderSettleMode.SETTLED;
+ case 2:
+ return SenderSettleMode.MIXED;
+ default:
+ throw new IllegalArgumentException("The value can be only 0 (for UNSETTLED), 1 (for SETTLED) and 2 (for MIXED)");
+ }
}
+ public UnsignedByte getValue() {
+ return this.value;
+ }
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fec0bc8c/proton-j/src/main/java/org/apache/qpid/proton/message/impl/MessageImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/message/impl/MessageImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/message/impl/MessageImpl.java
index b0204f3..df6373f 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/message/impl/MessageImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/message/impl/MessageImpl.java
@@ -769,6 +769,10 @@ public class MessageImpl implements ProtonJMessage
sb.append("properties=");
sb.append(_properties);
}
+ if (_messageAnnotations != null) {
+ sb.append("message_annotations=");
+ sb.append(_messageAnnotations);
+ }
if (_body != null) {
sb.append("body=");
sb.append(_body);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fec0bc8c/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleModeTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleModeTest.java b/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleModeTest.java
new file mode 100644
index 0000000..eb8472b
--- /dev/null
+++ b/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/ReceiverSettleModeTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.proton.amqp.transport;
+
+import org.apache.qpid.proton.amqp.UnsignedByte;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+public class ReceiverSettleModeTest {
+
+ @Test
+ public void testEquality() {
+
+ ReceiverSettleMode first = ReceiverSettleMode.FIRST;
+ ReceiverSettleMode second = ReceiverSettleMode.SECOND;
+
+ assertEquals(first, ReceiverSettleMode.valueOf(UnsignedByte.valueOf((byte)0)));
+ assertEquals(second, ReceiverSettleMode.valueOf(UnsignedByte.valueOf((byte)1)));
+
+ assertEquals(first.getValue(), UnsignedByte.valueOf((byte)0));
+ assertEquals(second.getValue(), UnsignedByte.valueOf((byte)1));
+ }
+
+ @Test
+ public void testNotEquality() {
+
+ ReceiverSettleMode first = ReceiverSettleMode.FIRST;
+ ReceiverSettleMode second = ReceiverSettleMode.SECOND;
+
+ assertNotEquals(first, ReceiverSettleMode.valueOf(UnsignedByte.valueOf((byte)1)));
+ assertNotEquals(second, ReceiverSettleMode.valueOf(UnsignedByte.valueOf((byte)0)));
+
+ assertNotEquals(first.getValue(), UnsignedByte.valueOf((byte)1));
+ assertNotEquals(second.getValue(), UnsignedByte.valueOf((byte)0));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testIllegalArgument() {
+
+ ReceiverSettleMode.valueOf(UnsignedByte.valueOf((byte)2));
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fec0bc8c/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/SenderSettleModeTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/SenderSettleModeTest.java b/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/SenderSettleModeTest.java
new file mode 100644
index 0000000..1ef5da1
--- /dev/null
+++ b/proton-j/src/test/java/org/apache/qpid/proton/amqp/transport/SenderSettleModeTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.proton.amqp.transport;
+
+import org.apache.qpid.proton.amqp.UnsignedByte;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+public class SenderSettleModeTest {
+
+ @Test
+ public void testEquality() {
+
+ SenderSettleMode unsettled = SenderSettleMode.UNSETTLED;
+ SenderSettleMode settled = SenderSettleMode.SETTLED;
+ SenderSettleMode mixed = SenderSettleMode.MIXED;
+
+ assertEquals(unsettled, SenderSettleMode.valueOf(UnsignedByte.valueOf((byte)0)));
+ assertEquals(settled, SenderSettleMode.valueOf(UnsignedByte.valueOf((byte)1)));
+ assertEquals(mixed, SenderSettleMode.valueOf(UnsignedByte.valueOf((byte)2)));
+
+ assertEquals(unsettled.getValue(), UnsignedByte.valueOf((byte)0));
+ assertEquals(settled.getValue(), UnsignedByte.valueOf((byte)1));
+ assertEquals(mixed.getValue(), UnsignedByte.valueOf((byte)2));
+ }
+
+ @Test
+ public void testNotEquality() {
+
+ SenderSettleMode unsettled = SenderSettleMode.UNSETTLED;
+ SenderSettleMode settled = SenderSettleMode.SETTLED;
+ SenderSettleMode mixed = SenderSettleMode.MIXED;
+
+ assertNotEquals(unsettled, SenderSettleMode.valueOf(UnsignedByte.valueOf((byte)2)));
+ assertNotEquals(settled, SenderSettleMode.valueOf(UnsignedByte.valueOf((byte)0)));
+ assertNotEquals(mixed, SenderSettleMode.valueOf(UnsignedByte.valueOf((byte)1)));
+
+ assertNotEquals(unsettled.getValue(), UnsignedByte.valueOf((byte)2));
+ assertNotEquals(settled.getValue(), UnsignedByte.valueOf((byte)0));
+ assertNotEquals(mixed.getValue(), UnsignedByte.valueOf((byte)1));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testIllegalArgument() {
+
+ SenderSettleMode.valueOf(UnsignedByte.valueOf((byte)3));
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org