Author: rgreig
Date: Thu Jan 11 02:53:22 2007
New Revision: 495189
URL: http://svn.apache.org/viewvc?view=rev&rev=495189
Log:
QPID-255 : Update old_test files to work with AMQShortString
Modified:
incubator/qpid/trunk/qpid/java/client/src/old_test/java/org/apache/qpid/codec/BasicDeliverTest.java
incubator/qpid/trunk/qpid/java/client/src/old_test/java/org/apache/qpid/framing/FieldTableTest.java
incubator/qpid/trunk/qpid/java/client/src/old_test/java/org/apache/qpid/headers/MessageFactory.java
Modified:
incubator/qpid/trunk/qpid/java/client/src/old_test/java/org/apache/qpid/codec/BasicDeliverTest.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/old_test/java/org/apache/qpid/codec/BasicDeliverTest.java?view=diff&rev=495189&r1=495188&r2=495189
==============================================================================
---
incubator/qpid/trunk/qpid/java/client/src/old_test/java/org/apache/qpid/codec/BasicDeliverTest.java
(original)
+++
incubator/qpid/trunk/qpid/java/client/src/old_test/java/org/apache/qpid/codec/BasicDeliverTest.java
Thu Jan 11 02:53:22 2007
@@ -64,15 +64,21 @@
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 @@
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 @@
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 @@
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 @@
}
};
- private final ProtocolDecoderOutput decoderOutput = new
ProtocolDecoderOutput(){
+ private final ProtocolDecoderOutput decoderOutput = new
ProtocolDecoderOutput()
+ {
public void write(Object object)
{
}
@@ -147,7 +161,8 @@
}
};
- private final IoSession session = new BaseIoSession(){
+ private final IoSession session = new BaseIoSession()
+ {
protected void updateTrafficMask()
{
@@ -216,9 +231,9 @@
{
//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 @@
{
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 @@
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;
}
}
Modified:
incubator/qpid/trunk/qpid/java/client/src/old_test/java/org/apache/qpid/framing/FieldTableTest.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/old_test/java/org/apache/qpid/framing/FieldTableTest.java?view=diff&rev=495189&r1=495188&r2=495189
==============================================================================
---
incubator/qpid/trunk/qpid/java/client/src/old_test/java/org/apache/qpid/framing/FieldTableTest.java
(original)
+++
incubator/qpid/trunk/qpid/java/client/src/old_test/java/org/apache/qpid/framing/FieldTableTest.java
Thu Jan 11 02:53:22 2007
@@ -39,7 +39,7 @@
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 @@
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 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 @@
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;
Modified:
incubator/qpid/trunk/qpid/java/client/src/old_test/java/org/apache/qpid/headers/MessageFactory.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/old_test/java/org/apache/qpid/headers/MessageFactory.java?view=diff&rev=495189&r1=495188&r2=495189
==============================================================================
---
incubator/qpid/trunk/qpid/java/client/src/old_test/java/org/apache/qpid/headers/MessageFactory.java
(original)
+++
incubator/qpid/trunk/qpid/java/client/src/old_test/java/org/apache/qpid/headers/MessageFactory.java
Thu Jan 11 02:53:22 2007
@@ -129,14 +129,14 @@
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;
}