summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Greig <rgreig@apache.org>2007-01-11 10:53:22 +0000
committerRobert Greig <rgreig@apache.org>2007-01-11 10:53:22 +0000
commit3520a34d413c3acbb404f3af91199b73199f9795 (patch)
tree0a0337c2d700ab366ed7a3b6455b67531f4b5ca0
parent733d6182773c5bc53d1146e3f7d157ebcf2d5a6c (diff)
downloadqpid-python-3520a34d413c3acbb404f3af91199b73199f9795.tar.gz
QPID-255 : Update old_test files to work with AMQShortString
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@495189 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/client/src/old_test/java/org/apache/qpid/codec/BasicDeliverTest.java58
-rw-r--r--java/client/src/old_test/java/org/apache/qpid/framing/FieldTableTest.java14
-rw-r--r--java/client/src/old_test/java/org/apache/qpid/headers/MessageFactory.java4
3 files changed, 44 insertions, 32 deletions
diff --git a/java/client/src/old_test/java/org/apache/qpid/codec/BasicDeliverTest.java b/java/client/src/old_test/java/org/apache/qpid/codec/BasicDeliverTest.java
index 1c616f0f02..ad0a6bddae 100644
--- a/java/client/src/old_test/java/org/apache/qpid/codec/BasicDeliverTest.java
+++ b/java/client/src/old_test/java/org/apache/qpid/codec/BasicDeliverTest.java
@@ -64,15 +64,21 @@ public class BasicDeliverTest
long min = Long.MAX_VALUE;
long max = 0;
long total = 0;
- for(int i = 0; i < iterations; i++)
+ for (int i = 0; i < iterations; i++)
{
long time = decode(size, count);
total += time;
- if(time < min) min = time;
- if(time > max) max = time;
+ if (time < min)
+ {
+ min = time;
+ }
+ if (time > max)
+ {
+ max = time;
+ }
}
System.out.println("Decoded " + count + " messages of " + size +
- " bytes: avg=" + (total / iterations) + ", min=" + min + ", max=" + max) ;
+ " bytes: avg=" + (total / iterations) + ", min=" + min + ", max=" + max);
}
@@ -84,7 +90,7 @@ public class BasicDeliverTest
data.flip();
AMQDecoder decoder = new AMQDecoder(false);
long start = System.currentTimeMillis();
- for(int i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
{
decoder.decode(session, data, decoderOutput);
data.rewind();
@@ -97,15 +103,21 @@ public class BasicDeliverTest
long min = Long.MAX_VALUE;
long max = 0;
long total = 0;
- for(int i = 0; i < iterations; i++)
+ for (int i = 0; i < iterations; i++)
{
long time = encode(size, count);
total += time;
- if(time < min) min = time;
- if(time > max) max = time;
+ if (time < min)
+ {
+ min = time;
+ }
+ if (time > max)
+ {
+ max = time;
+ }
}
System.out.println("Encoded " + count + " messages of " + size +
- " bytes: avg=" + (total / iterations) + ", min=" + min + ", max=" + max) ;
+ " bytes: avg=" + (total / iterations) + ", min=" + min + ", max=" + max);
}
long encode(int size, int count) throws Exception
@@ -114,14 +126,15 @@ public class BasicDeliverTest
AMQDataBlock block = getDataBlock(size);
AMQEncoder encoder = new AMQEncoder();
long start = System.currentTimeMillis();
- for(int i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
{
encoder.encode(session, block, encoderOutput);
}
return System.currentTimeMillis() - start;
}
- private final ProtocolEncoderOutput encoderOutput = new ProtocolEncoderOutput(){
+ private final ProtocolEncoderOutput encoderOutput = new ProtocolEncoderOutput()
+ {
public void write(ByteBuffer byteBuffer)
{
@@ -137,7 +150,8 @@ public class BasicDeliverTest
}
};
- private final ProtocolDecoderOutput decoderOutput = new ProtocolDecoderOutput(){
+ private final ProtocolDecoderOutput decoderOutput = new ProtocolDecoderOutput()
+ {
public void write(Object object)
{
}
@@ -147,7 +161,8 @@ public class BasicDeliverTest
}
};
- private final IoSession session = new BaseIoSession(){
+ private final IoSession session = new BaseIoSession()
+ {
protected void updateTrafficMask()
{
@@ -216,9 +231,9 @@ public class BasicDeliverTest
{
//create a frame representing message delivery
AMQFrame[] frames = new AMQFrame[3];
- frames[0] = wrapBody( createBasicDeliverBody() );
- frames[1] = wrapBody( createContentHeaderBody() );
- frames[2] = wrapBody( createContentBody(size) );
+ frames[0] = wrapBody(createBasicDeliverBody());
+ frames[1] = wrapBody(createContentHeaderBody());
+ frames[2] = wrapBody(createContentBody(size));
return new CompositeAMQDataBlock(frames);
}
@@ -236,7 +251,7 @@ public class BasicDeliverTest
{
ContentBody body = new ContentBody();
body.payload = ByteBuffer.allocate(size);
- for(int i = 0; i < size; i++)
+ for (int i = 0; i < size; i++)
{
body.payload.put((byte) DATA[i % DATA.length]);
}
@@ -254,12 +269,9 @@ public class BasicDeliverTest
static BasicDeliverBody createBasicDeliverBody()
{
- BasicDeliverBody body = new BasicDeliverBody((byte)8, (byte)0);
- body.consumerTag = "myConsumerTag";
- body.deliveryTag = 1;
- body.exchange = "myExchange";
- body.redelivered = false;
- body.routingKey = "myRoutingKey";
+ BasicDeliverBody body = new BasicDeliverBody((byte) 8, (byte) 0, new AMQShortString("myConsumerTag"), 1,
+ new AMQShortString("myExchange"), false,
+ new AMQShortString("myRoutingKey"));
return body;
}
}
diff --git a/java/client/src/old_test/java/org/apache/qpid/framing/FieldTableTest.java b/java/client/src/old_test/java/org/apache/qpid/framing/FieldTableTest.java
index e56e38c098..955f82fab5 100644
--- a/java/client/src/old_test/java/org/apache/qpid/framing/FieldTableTest.java
+++ b/java/client/src/old_test/java/org/apache/qpid/framing/FieldTableTest.java
@@ -39,7 +39,7 @@ public class FieldTableTest extends TestCase
String key = "String";
String value = "Hello";
- table.put(key, value);
+ table.setString(key, value);
//Add one for the type encoding
int size = EncodingUtils.encodedShortStringLength(key) + 1 +
@@ -49,7 +49,7 @@ public class FieldTableTest extends TestCase
key = "Integer";
Integer number = new Integer(60);
- table.put(key, number);
+ table.setInteger(key, number);
//Add one for the type encoding
size += EncodingUtils.encodedShortStringLength(key) + 1 + 4;
@@ -93,10 +93,10 @@ public class FieldTableTest extends TestCase
public void assertEquivalent(FieldTable table1, FieldTable table2)
{
- for (Object o : table1.keySet())
+ for (String key : table1.keys())
{
- String key = (String) o;
- assertEquals("Values for " + key + " did not match", table1.get(key), table2.get(key));
+
+ assertEquals("Values for " + key + " did not match", table1.getObject(key), table2.getObject(key));
//System.out.println("Values for " + key + " matched (" + table1.get(key) + ")");
}
}
@@ -152,11 +152,11 @@ public class FieldTableTest extends TestCase
try
{
int ival = Integer.parseInt(value);
- table.put(key, (long) ival);
+ table.setLong(key, (long) ival);
}
catch (NumberFormatException e)
{
- table.put(key, value);
+ table.setObject(key, value);
}
}
return table;
diff --git a/java/client/src/old_test/java/org/apache/qpid/headers/MessageFactory.java b/java/client/src/old_test/java/org/apache/qpid/headers/MessageFactory.java
index 6f538d068c..a2d575fdd4 100644
--- a/java/client/src/old_test/java/org/apache/qpid/headers/MessageFactory.java
+++ b/java/client/src/old_test/java/org/apache/qpid/headers/MessageFactory.java
@@ -129,14 +129,14 @@ class MessageFactory
FieldTable getConsumerBinding()
{
FieldTable binding = FieldTableFactory.newFieldTable();
- binding.put("SF0000", "value");
+ binding.setString("SF0000", "value");
return binding;
}
FieldTable getControllerBinding()
{
FieldTable binding = FieldTableFactory.newFieldTable();
- binding.put("SCONTROL", "value");
+ binding.setString("SCONTROL", "value");
return binding;
}