Skip to content

Commit 0092d79

Browse files
committed
Merged bug21143 into default
2 parents 421a024 + 2dcc234 commit 0092d79

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

codegen.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ def printClassInterfaces():
132132
print " }"
133133

134134

135+
def printClone(c):
136+
print
137+
print """ public Object clone()
138+
throws CloneNotSupportedException
139+
{
140+
return super.clone();
141+
}""" % \
142+
{"n": java_class_name(c.name)}
143+
135144
def printReadProperties(c):
136145
print
137146
print """ public void readPropertiesFrom(ContentHeaderPropertyReader reader)
@@ -171,7 +180,7 @@ def printPropertyDebug(c):
171180

172181
def printClassProperties(c):
173182
print
174-
print " public static class %s extends AMQContentHeader {" % ( java_class_name(c.name) + 'Properties')
183+
print " public static class %s extends AMQContentHeader implements Cloneable {" % ( java_class_name(c.name) + 'Properties')
175184
#property fields
176185
for f in c.fields:
177186
print " public %s %s;" % (java_property_type(spec, f.domain),java_field_name(f.name))
@@ -196,6 +205,7 @@ def printClassProperties(c):
196205
print " public int getClassId() { return %i; }" % (c.index)
197206
print " public java.lang.String getClassName() { return \"%s\"; }" % (c.name)
198207

208+
printClone(c)
199209
printReadProperties(c)
200210
printWriteProperties(c)
201211
printPropertyDebug(c)

test/src/com/rabbitmq/client/test/AllTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public static TestSuite suite() {
4343
suite.addTest(AMQConnectionTest.suite());
4444
suite.addTest(ValueOrExceptionTest.suite());
4545
suite.addTest(BrokenFramesTest.suite());
46+
suite.addTestSuite(ClonePropertiesTest.class);
4647
return suite;
4748
}
4849
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// The contents of this file are subject to the Mozilla Public License
2+
// Version 1.1 (the "License"); you may not use this file except in
3+
// compliance with the License. You may obtain a copy of the License at
4+
// http://www.mozilla.org/MPL/
5+
//
6+
// Software distributed under the License is distributed on an "AS IS"
7+
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
8+
// License for the specific language governing rights and limitations
9+
// under the License.
10+
//
11+
// The Original Code is RabbitMQ.
12+
//
13+
// The Initial Developers of the Original Code are LShift Ltd,
14+
// Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd.
15+
//
16+
// Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
17+
// Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
18+
// are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
19+
// Technologies LLC, and Rabbit Technologies Ltd.
20+
//
21+
// Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
22+
// Ltd. Portions created by Cohesive Financial Technologies LLC are
23+
// Copyright (C) 2007-2009 Cohesive Financial Technologies
24+
// LLC. Portions created by Rabbit Technologies Ltd are Copyright
25+
// (C) 2007-2009 Rabbit Technologies Ltd.
26+
//
27+
// All Rights Reserved.
28+
//
29+
// Contributor(s): ______________________________________.
30+
//
31+
package com.rabbitmq.client.test;
32+
33+
import junit.framework.TestCase;
34+
35+
import com.rabbitmq.client.AMQP.BasicProperties;
36+
import com.rabbitmq.client.MessageProperties;
37+
38+
public class ClonePropertiesTest extends TestCase {
39+
public void testPropertyCloneIsDistinct()
40+
throws CloneNotSupportedException
41+
{
42+
assertTrue(MessageProperties.MINIMAL_PERSISTENT_BASIC !=
43+
MessageProperties.MINIMAL_PERSISTENT_BASIC.clone());
44+
}
45+
46+
public void testPropertyClonePreservesValues()
47+
throws CloneNotSupportedException
48+
{
49+
assertEquals(MessageProperties.MINIMAL_PERSISTENT_BASIC.deliveryMode,
50+
((BasicProperties) MessageProperties.MINIMAL_PERSISTENT_BASIC.clone())
51+
.deliveryMode);
52+
assertEquals((Integer) 2,
53+
((BasicProperties) MessageProperties.MINIMAL_PERSISTENT_BASIC.clone())
54+
.deliveryMode);
55+
}
56+
}

0 commit comments

Comments
 (0)