You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2017/03/03 00:03:32 UTC

qpid-proton-j git commit: PROTON-1425 Add copy constructors

Repository: qpid-proton-j
Updated Branches:
  refs/heads/master db929a053 -> f22de65ab


PROTON-1425 Add copy constructors

Adds a copy constructor to Header and Properties for ease of use


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton-j/commit/f22de65a
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton-j/tree/f22de65a
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton-j/diff/f22de65a

Branch: refs/heads/master
Commit: f22de65ab41b92486d6be36d610c9168659764f6
Parents: db929a0
Author: Timothy Bish <ta...@gmail.com>
Authored: Thu Mar 2 18:49:20 2017 -0500
Committer: Timothy Bish <ta...@gmail.com>
Committed: Thu Mar 2 19:03:12 2017 -0500

----------------------------------------------------------------------
 .../qpid/proton/amqp/messaging/Header.java      | 13 ++++
 .../qpid/proton/amqp/messaging/Properties.java  | 22 +++++++
 .../qpid/proton/amqp/messaging/HeaderTest.java  | 45 +++++++++++++
 .../proton/amqp/messaging/PropertiesTest.java   | 68 ++++++++++++++++++++
 4 files changed, 148 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/f22de65a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Header.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Header.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Header.java
index 83b1974..6f67202 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Header.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Header.java
@@ -37,6 +37,19 @@ public final class Header
     private Boolean _firstAcquirer;
     private UnsignedInteger _deliveryCount;
 
+    public Header()
+    {
+    }
+
+    public Header(Header other)
+    {
+        this._durable = other._durable;
+        this._priority = other._priority;
+        this._ttl = other._ttl;
+        this._firstAcquirer = other._firstAcquirer;
+        this._deliveryCount = other._deliveryCount;
+    }
+
     public Boolean getDurable()
     {
         return _durable;

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/f22de65a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Properties.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Properties.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Properties.java
index a8c4880..dbe8c31 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Properties.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/amqp/messaging/Properties.java
@@ -24,6 +24,7 @@
 package org.apache.qpid.proton.amqp.messaging;
 
 import java.util.Date;
+
 import org.apache.qpid.proton.amqp.Binary;
 import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.UnsignedInteger;
@@ -47,6 +48,27 @@ public final class Properties
     private UnsignedInteger _groupSequence;
     private String _replyToGroupId;
 
+    public Properties()
+    {
+    }
+
+    public Properties(Properties other)
+    {
+        this._messageId = other._messageId;
+        this._userId = other._userId;
+        this._to = other._to;
+        this._subject = other._subject;
+        this._replyTo = other._replyTo;
+        this._correlationId = other._correlationId;
+        this._contentType = other._contentType;
+        this._contentEncoding = other._contentEncoding;
+        this._absoluteExpiryTime = other._absoluteExpiryTime;
+        this._creationTime = other._creationTime;
+        this._groupId = other._groupId;
+        this._groupSequence = other._groupSequence;
+        this._replyToGroupId = other._replyToGroupId;
+    }
+
     public Object getMessageId()
     {
         return _messageId;

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/f22de65a/proton-j/src/test/java/org/apache/qpid/proton/amqp/messaging/HeaderTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/amqp/messaging/HeaderTest.java b/proton-j/src/test/java/org/apache/qpid/proton/amqp/messaging/HeaderTest.java
new file mode 100644
index 0000000..e32ced8
--- /dev/null
+++ b/proton-j/src/test/java/org/apache/qpid/proton/amqp/messaging/HeaderTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.messaging;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.qpid.proton.amqp.UnsignedByte;
+import org.apache.qpid.proton.amqp.UnsignedInteger;
+import org.junit.Test;
+
+public class HeaderTest {
+
+    @Test
+    public void testCopy() {
+        Header original = new Header();
+
+        original.setDeliveryCount(UnsignedInteger.valueOf(1));
+        original.setDurable(true);
+        original.setFirstAcquirer(true);
+        original.setPriority(UnsignedByte.valueOf((byte) 7));
+        original.setTtl(UnsignedInteger.valueOf(100));
+
+        Header copy = new Header(original);
+
+        assertEquals(original.getDeliveryCount(), copy.getDeliveryCount());
+        assertEquals(original.getDurable(), copy.getDurable());
+        assertEquals(original.getFirstAcquirer(), copy.getFirstAcquirer());
+        assertEquals(original.getPriority(), copy.getPriority());
+        assertEquals(original.getTtl(), copy.getTtl());
+    }
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/f22de65a/proton-j/src/test/java/org/apache/qpid/proton/amqp/messaging/PropertiesTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/amqp/messaging/PropertiesTest.java b/proton-j/src/test/java/org/apache/qpid/proton/amqp/messaging/PropertiesTest.java
new file mode 100644
index 0000000..970356a
--- /dev/null
+++ b/proton-j/src/test/java/org/apache/qpid/proton/amqp/messaging/PropertiesTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.messaging;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Date;
+
+import org.apache.qpid.proton.amqp.Binary;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedInteger;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class PropertiesTest {
+
+    @Test
+    public void testCopy() {
+        Properties original = new Properties();
+
+        original.setAbsoluteExpiryTime(new Date(System.currentTimeMillis()));
+        original.setContentEncoding(Symbol.valueOf("utf-8"));
+        original.setContentType(Symbol.valueOf("test/plain"));
+        original.setCorrelationId("1");
+        original.setCreationTime(new Date(System.currentTimeMillis()));
+        original.setGroupId("group-1");
+        original.setGroupSequence(UnsignedInteger.MAX_VALUE);
+        original.setMessageId("ID:1");
+        original.setReplyTo("queue");
+        original.setReplyToGroupId("3");
+        original.setSubject("subject");
+        original.setTo("to-queue");
+        original.setUserId(new Binary(new byte[1]));
+
+        Properties copy = new Properties(original);
+
+        assertEquals(original.getAbsoluteExpiryTime(), copy.getAbsoluteExpiryTime());
+        assertEquals(original.getContentEncoding(), copy.getContentEncoding());
+        assertEquals(original.getContentType(), copy.getContentType());
+        assertEquals(original.getCorrelationId(), copy.getCorrelationId());
+        assertEquals(original.getCreationTime(), copy.getCreationTime());
+        assertEquals(original.getGroupId(), copy.getGroupId());
+        assertEquals(original.getGroupSequence(), copy.getGroupSequence());
+        assertEquals(original.getMessageId(), copy.getMessageId());
+        assertEquals(original.getReplyTo(), copy.getReplyTo());
+        assertEquals(original.getReplyToGroupId(), copy.getReplyToGroupId());
+        assertEquals(original.getSubject(), copy.getSubject());
+        assertEquals(original.getTo(), copy.getTo());
+        assertEquals(original.getUserId(), copy.getUserId());
+    }
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org