You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2006/12/28 01:31:14 UTC
svn commit: r490613 [3/4] - in
/incubator/qpid/branches/new_persistence/java: ./
broker/src/main/java/org/apache/qpid/server/exchange/
broker/src/main/java/org/apache/qpid/server/handler/
broker/src/main/java/org/apache/qpid/server/protocol/ broker/src...
Modified: incubator/qpid/branches/new_persistence/java/cluster/src/main/java/org/apache/qpid/server/queue/PrivateQueue.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/cluster/src/main/java/org/apache/qpid/server/queue/PrivateQueue.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/cluster/src/main/java/org/apache/qpid/server/queue/PrivateQueue.java (original)
+++ incubator/qpid/branches/new_persistence/java/cluster/src/main/java/org/apache/qpid/server/queue/PrivateQueue.java Wed Dec 27 16:31:11 2006
@@ -54,7 +54,9 @@
super.autodelete();
//send delete request to peers:
- QueueDeleteBody request = new QueueDeleteBody();
+ // AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
+ // TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
+ QueueDeleteBody request = new QueueDeleteBody((byte)8, (byte)0);
request.queue = getName();
_groupMgr.broadcast(new SimpleBodySendable(request));
}
Modified: incubator/qpid/branches/new_persistence/java/cluster/src/test/java/org/apache/qpid/server/cluster/BrokerTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/cluster/src/test/java/org/apache/qpid/server/cluster/BrokerTest.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/cluster/src/test/java/org/apache/qpid/server/cluster/BrokerTest.java (original)
+++ incubator/qpid/branches/new_persistence/java/cluster/src/test/java/org/apache/qpid/server/cluster/BrokerTest.java Wed Dec 27 16:31:11 2006
@@ -148,6 +148,9 @@
TestMethod(Object id)
{
+ // AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
+ // TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
+ super((byte)8, (byte)0);
this.id = id;
}
Modified: incubator/qpid/branches/new_persistence/java/common/pom.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/pom.xml?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/pom.xml (original)
+++ incubator/qpid/branches/new_persistence/java/common/pom.xml Wed Dec 27 16:31:11 2006
@@ -35,14 +35,12 @@
<properties>
<topDirectoryLocation>..</topDirectoryLocation>
- <cluster.asl>${basedir}/src/main/xsl/cluster.asl</cluster.asl>
- <spec.stylesheet>${basedir}/src/main/xsl/framing.xsl</spec.stylesheet>
- <registry.stylesheet>${basedir}/src/main/xsl/registry.xsl</registry.stylesheet>
- <registry.template>${basedir}/src/main/xsl/registry.template</registry.template>
+ <gentools.home>${topDirectoryLocation}/../gentools</gentools.home>
<generated.path>${project.build.directory}/generated-sources/xsl</generated.path>
<generated.package>org/apache/qpid/framing</generated.package>
<generated.dir>${generated.path}/${generated.package}</generated.dir>
<specs.dir>${topDirectoryLocation}/../specs</specs.dir>
+ <cluster.asl>${basedir}/src/main/xsl/cluster.asl</cluster.asl>
</properties>
<build>
@@ -57,13 +55,9 @@
<configuration>
<tasks>
<ant antfile="protocol-version.xml">
- <property name="cluster.asl" value="${cluster.asl}"/>
- <property name="spec.stylesheet" value="${spec.stylesheet}"/>
- <property name="registry.stylesheet" value="${registry.stylesheet}"/>
- <property name="registry.template" value="${registry.template}"/>
+ <property name="gentools.home" value="${gentools.home}"/>
<property name="generated.dir" value="${generated.dir}"/>
- <property name="proto_version" value="${generated.dir}/ProtocolVersionList.java"/>
- <property name="specs.dir" value="${specs.dir}"/>
+ <property name="xml.spec.list" value="${specs.dir}/amqp.0-8.xml ${specs.dir}/cluster.0-8.xml"/>
</ant>
</tasks>
<sourceRoot>${generated.path}</sourceRoot>
Modified: incubator/qpid/branches/new_persistence/java/common/protocol-version.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/protocol-version.xml?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/protocol-version.xml (original)
+++ incubator/qpid/branches/new_persistence/java/common/protocol-version.xml Wed Dec 27 16:31:11 2006
@@ -20,102 +20,13 @@
-->
<project name="Qpid Common Protocol Versions" default="generate">
- <property name="saxon.jar" value="lib/saxon/saxon8.jar"/>
- <!-- temporarily hard-wired XML spec version for build avoidance -->
- <property name="amqp.xml" value="${specs.dir}/amqp-8.0.xml"/>
-
- <macrodef name="saxon">
- <attribute name="out"/>
- <attribute name="src"/>
- <attribute name="xsl"/>
- <element name="args" implicit="true" optional="true"/>
- <sequential>
- <java jar="${saxon.jar}" fork="true">
- <arg value="-o"/>
- <arg value="@{out}"/>
- <arg value="@{src}"/>
- <arg value="@{xsl}"/>
- <args/>
- </java>
- </sequential>
- </macrodef>
-
- <macrodef name="amqp">
- <attribute name="ver"/>
- <sequential>
- <!-- Check for the existence of the AMQP specification file -->
- <property name="amqpspecfile-@{ver}" value="${specs.dir}/amqp-@{ver}.xml"/>
- <available file="${specs.dir}/amqp-@{ver}.xml"
- property="amqpspecfile.present-@{ver}"/>
- <fail unless="amqpspecfile.present-@{ver}"
- message="ERROR: AMQP specification file ${specs.dir}/amqp-@{ver}.xml not found."/>
-
- <!-- Read in the file as a set of properties; extract the amqp version -->
- <xmlproperty prefix="@{ver}" file="${specs.dir}/amqp-@{ver}.xml"/>
- <echo>Found AMQP specification file "${specs.dir}/amqp-@{ver}.xml"; major=${@{ver}.amqp(major)} minor=${@{ver}.amqp(minor)}</echo>
-
- <!-- Add the version to the ProtocolVersionList.java file -->
- <replaceregexp file="${proto_version}" match=" // !VER!"
- replace=",${line.separator} {${@{ver}.amqp(major)}, ${@{ver}.amqp(minor)}} // !VER!"
- flags="s" byline="true"/>
- <replaceregexp file="${proto_version}" match=" // !VER1!"
- replace="{${@{ver}.amqp(major)}, ${@{ver}.amqp(minor)}} // !VER!"
- flags="s" byline="true"/>
-
- <!-- Create directory; generate from specification file -->
- <saxon out="${generated.dir}/results.out"
- src="${specs.dir}/amqp-@{ver}.xml"
- xsl="${spec.stylesheet}">
- <arg value="major=${@{ver}.amqp(major)}"/>
- <arg value="minor=${@{ver}.amqp(minor)}"/>
- <arg value="registry_name=MainRegistry"/>
- </saxon>
- <!-- -->
- <saxon out="${generated.dir}/cluster.out"
- src="${cluster.asl}"
- xsl="${spec.stylesheet}">
- <arg value="major=${@{ver}.amqp(major)}"/>
- <arg value="minor=${@{ver}.amqp(minor)}"/>
- <arg value="registry_name=ClusterRegistry"/>
- </saxon>
- <saxon out="${generated.dir}/registry.out"
- src="${registry.template}"
- xsl="${registry.stylesheet}">
- <arg value="major=${@{ver}.amqp(major)}"/>
- <arg value="minor=${@{ver}.amqp(minor)}"/>
- </saxon>
- </sequential>
- </macrodef>
-
- <uptodate property="generated" targetfile="${generated.dir}/results.out"
- srcfile="${amqp.xml}"/>
-
- <target name="generate" unless="generated">
+ <target name="generate">
<mkdir dir="${generated.dir}"/>
- <copy file="src/main/versions/ProtocolVersionList.java.tmpl" tofile="${proto_version}"
- overwrite="true"/>
- <!--
- NOTE: Set the AMQP version numbers to be supported in this build here.
- The last version in this list will be the version returned when a protocol
- ProtocolInitiation NAK frame is returned by the broker. Usually this is the
- highest or most recent version.
- -->
- <!-- <amqp ver="0.8"/>
- <amqp ver="0.9"/>
- <amqp ver="0.10"/> -->
- <amqp ver="8.0"/>
-
-<!-- <saxon out="${generated.dir}/results.out" src="${amqp.xml}"
- xsl="${stylesheet}">
- <arg value="asl_base=${asl.base}"/>
- <arg value="registry_name=MainRegistry"/>
- </saxon>
- <saxon out="${generated.dir}/cluster.out" src="${cluster.asl}"
- xsl="${stylesheet}">
- <arg value="registry_name=ClusterRegistry"/>
- </saxon>
- <saxon out="${generated.dir}/registry.out" src="${registry_template}"
- xsl="${registry_stylesheet}"/> -->
+<!-- <exec dir="${gentools.home}/src" executable="pwd" />-->
+ <echo>XML files to be processed: ${xml.spec.list}</echo>
+ <java classname="org.apache.qpid.gentools.Main" fork="true" dir="${gentools.home}/src">
+ <arg line="-j -o ${generated.dir} -t ${gentools.home}/templ.java ${xml.spec.list}"/>
+ </java>
</target>
<target name="precompile" depends="generate"/>
Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/AMQChannelException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/AMQChannelException.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/AMQChannelException.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/AMQChannelException.java Wed Dec 27 16:31:11 2006
@@ -27,23 +27,30 @@
{
private final int _classId;
private final int _methodId;
+ /* AMQP version for which exception ocurred */
+ private final byte major;
+ private final byte minor;
- public AMQChannelException(int errorCode, String msg, int classId, int methodId, Throwable t)
+ public AMQChannelException(int errorCode, String msg, int classId, int methodId, byte major, byte minor, Throwable t)
{
super(errorCode, msg, t);
_classId = classId;
_methodId = methodId;
+ this.major = major;
+ this.minor = minor;
}
- public AMQChannelException(int errorCode, String msg, int classId, int methodId)
+ public AMQChannelException(int errorCode, String msg, int classId, int methodId, byte major, byte minor)
{
super(errorCode, msg);
_classId = classId;
_methodId = methodId;
+ this.major = major;
+ this.minor = minor;
}
public AMQFrame getCloseFrame(int channel)
{
- return ChannelCloseBody.createAMQFrame(channel, getErrorCode(), getMessage(), _classId, _methodId);
+ return ChannelCloseBody.createAMQFrame(channel, major, minor, _classId, _methodId, getErrorCode(), getMessage());
}
}
Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQBody.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQBody.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQBody.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQBody.java Wed Dec 27 16:31:11 2006
@@ -34,5 +34,6 @@
protected abstract void writePayload(ByteBuffer buffer);
- protected abstract void populateFromBuffer(ByteBuffer buffer, long size) throws AMQFrameDecodingException;
+ protected abstract void populateFromBuffer(ByteBuffer buffer, long size)
+ throws AMQFrameDecodingException, AMQProtocolVersionException;
}
Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java Wed Dec 27 16:31:11 2006
@@ -81,7 +81,7 @@
}
protected Object createAndPopulateFrame(ByteBuffer in)
- throws AMQFrameDecodingException
+ throws AMQFrameDecodingException, AMQProtocolVersionException
{
final byte type = in.get();
if (!isSupportedFrameType(type))
Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQFrame.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQFrame.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQFrame.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQFrame.java Wed Dec 27 16:31:11 2006
@@ -62,7 +62,7 @@
* @throws AMQFrameDecodingException
*/
public void populateFromBuffer(ByteBuffer buffer, int channel, long bodySize, BodyFactory bodyFactory)
- throws AMQFrameDecodingException
+ throws AMQFrameDecodingException, AMQProtocolVersionException
{
this.channel = channel;
bodyFrame = bodyFactory.createBody(buffer);
Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBody.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBody.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBody.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBody.java Wed Dec 27 16:31:11 2006
@@ -26,6 +26,20 @@
public abstract class AMQMethodBody extends AMQBody
{
public static final byte TYPE = 1;
+
+ /**
+ * AMQP version
+ */
+ protected byte major;
+ protected byte minor;
+ public byte getMajor() { return major; }
+ public byte getMinor() { return minor; }
+
+ public AMQMethodBody(byte major, byte minor)
+ {
+ this.major = major;
+ this.minor = minor;
+ }
/** unsigned short */
protected abstract int getBodySize();
@@ -80,11 +94,11 @@
*/
public AMQChannelException getChannelException(int code, String message)
{
- return new AMQChannelException(code, message, getClazz(), getMethod());
+ return new AMQChannelException(code, message, getClazz(), getMethod(), major, minor);
}
public AMQChannelException getChannelException(int code, String message, Throwable cause)
{
- return new AMQChannelException(code, message, getClazz(), getMethod(), cause);
+ return new AMQChannelException(code, message, getClazz(), getMethod(), major, minor, cause);
}
}
Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBodyFactory.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBodyFactory.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBodyFactory.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBodyFactory.java Wed Dec 27 16:31:11 2006
@@ -41,6 +41,11 @@
public AMQBody createBody(ByteBuffer in) throws AMQFrameDecodingException
{
- return MethodBodyDecoderRegistry.get(in.getUnsignedShort(), in.getUnsignedShort());
+ // AMQP version change: MethodBodyDecoderRegistry is obsolete, since all the XML
+ // segments generated together are now handled by MainRegistry. The Cluster class,
+ // if generated together with amqp.xml is a part of MainRegistry.
+ // TODO: Connect with version acquired from ProtocolInitiation class.
+ return MainRegistry.get((short)in.getUnsignedShort(), (short)in.getUnsignedShort(),
+ (byte)8, (byte)0);
}
}
Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java Wed Dec 27 16:31:11 2006
@@ -245,7 +245,7 @@
}
public void populatePropertiesFromBuffer(ByteBuffer buffer, int propertyFlags, int size)
- throws AMQFrameDecodingException
+ throws AMQFrameDecodingException, AMQProtocolVersionException
{
_propertyFlags = propertyFlags;
Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java Wed Dec 27 16:31:11 2006
@@ -58,7 +58,8 @@
return TYPE;
}
- protected void populateFromBuffer(ByteBuffer buffer, long size) throws AMQFrameDecodingException
+ protected void populateFromBuffer(ByteBuffer buffer, long size)
+ throws AMQFrameDecodingException, AMQProtocolVersionException
{
classId = buffer.getUnsignedShort();
weight = buffer.getUnsignedShort();
@@ -75,7 +76,8 @@
* @return
* @throws AMQFrameDecodingException
*/
- public static ContentHeaderBody createFromBuffer(ByteBuffer buffer, long size) throws AMQFrameDecodingException
+ public static ContentHeaderBody createFromBuffer(ByteBuffer buffer, long size)
+ throws AMQFrameDecodingException, AMQProtocolVersionException
{
ContentHeaderBody body = new ContentHeaderBody();
body.populateFromBuffer(buffer, size);
Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderProperties.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderProperties.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderProperties.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderProperties.java Wed Dec 27 16:31:11 2006
@@ -41,7 +41,7 @@
* @throws AMQFrameDecodingException when the buffer does not contain valid data
*/
void populatePropertiesFromBuffer(ByteBuffer buffer, int propertyFlags, int size)
- throws AMQFrameDecodingException;
+ throws AMQFrameDecodingException, AMQProtocolVersionException;
/**
* @return the size of the encoded property list in bytes.
Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java Wed Dec 27 16:31:11 2006
@@ -37,16 +37,19 @@
public ContentHeaderProperties createContentHeaderProperties(int classId, int propertyFlags,
ByteBuffer buffer, int size)
- throws AMQFrameDecodingException
+ throws AMQFrameDecodingException, AMQProtocolVersionException
{
ContentHeaderProperties properties;
- switch (classId)
+ // AMQP version change: "Hardwired" version to major=8, minor=0
+ // TODO: Change so that the actual version is obtained from
+ // the ProtocolInitiation object for this session.
+ if (classId == BasicConsumeBody.getClazz((byte)8, (byte)0))
{
- case BasicConsumeBody.CLASS_ID:
- properties = new BasicContentHeaderProperties();
- break;
- default:
- throw new AMQFrameDecodingException("Unsupport content header class id: " + classId);
+ properties = new BasicContentHeaderProperties();
+ }
+ else
+ {
+ throw new AMQFrameDecodingException("Unsupport content header class id: " + classId);
}
properties.populatePropertiesFromBuffer(buffer, propertyFlags, size);
return properties;
Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java Wed Dec 27 16:31:11 2006
@@ -88,12 +88,12 @@
{
if (table == null)
{
- // size is encoded as 4 octets
+ // length is encoded as 4 octets
return 4;
}
else
{
- // size of the table plus 4 octets for the size
+ // length of the table plus 4 octets for the length
return (int) table.getEncodedSize() + 4;
}
}
@@ -104,6 +104,7 @@
return 0;
}
+
public static void writeShortStringBytes(ByteBuffer buffer, String s)
{
if (s != null)
@@ -448,7 +449,7 @@
byte[] from = new byte[size];
// Is this not the same.
- //bb.get(from, 0, size);
+ //bb.get(from, 0, length);
for (int i = 0; i < size; i++)
{
from[i] = bb.get(i);
Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java Wed Dec 27 16:31:11 2006
@@ -1,98 +1,612 @@
/*
- * 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
+ * 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
*
- * 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.
+ * 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.framing;
+import org.apache.log4j.Logger;
import org.apache.mina.common.ByteBuffer;
+import org.apache.qpid.AMQPInvalidClassException;
-import java.util.Map;
-import java.util.Enumeration;
+import java.util.*;
-public interface FieldTable extends Map
+//extends FieldTable
+public class FieldTable
{
- void writeToBuffer(ByteBuffer buffer);
-
- void setFromBuffer(ByteBuffer buffer, long length) throws AMQFrameDecodingException;
-
- byte[] getDataAsBytes();
-
- public long getEncodedSize();
-
- Object put(Object key, Object value);
-
- Object remove(Object key);
-
-
- public Enumeration getPropertyNames();
-
- public boolean propertyExists(String propertyName);
-
- //Getters
-
- public Boolean getBoolean(String string);
-
- public Byte getByte(String string);
-
- public Short getShort(String string);
-
- public Integer getInteger(String string);
-
- public Long getLong(String string);
-
- public Float getFloat(String string);
-
- public Double getDouble(String string);
-
- public String getString(String string);
-
- public Character getCharacter(String string);
-
- public byte[] getBytes(String string);
-
- public Object getObject(String string);
-
- // Setters
- public Object setBoolean(String string, boolean b);
-
- public Object setByte(String string, byte b);
-
- public Object setShort(String string, short i);
-
- public Object setInteger(String string, int i);
-
- public Object setLong(String string, long l);
-
- public Object setFloat(String string, float v);
-
- public Object setDouble(String string, double v);
-
- public Object setString(String string, String string1);
-
- public Object setChar(String string, char c);
-
- public Object setBytes(String string, byte[] bytes);
-
- public Object setBytes(String string, byte[] bytes, int start, int length);
+ private static final Logger _logger = Logger.getLogger(FieldTable.class);
- public Object setObject(String string, Object object);
+ private LinkedHashMap<String, AMQTypedValue> _properties;
- public boolean isNullStringValue(String name);
+ public FieldTable()
+ {
+ super();
+ _properties = new LinkedHashMap<String, AMQTypedValue>();
+
+ }
+
+
+
+ /**
+ * Construct a new field table.
+ *
+ * @param buffer the buffer from which to read data. The length byte must be read already
+ * @param length the length of the field table. Must be > 0.
+ * @throws AMQFrameDecodingException if there is an error decoding the table
+ */
+ public FieldTable(ByteBuffer buffer, long length) throws AMQFrameDecodingException
+ {
+ this();
+ setFromBuffer(buffer, length);
+ }
+
+
+
+ public Boolean getBoolean(String string)
+ {
+ AMQTypedValue value = _properties.get(string);
+ if (value != null && (value.getType() == AMQType.BOOLEAN))
+ {
+ return (Boolean) value.getValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public Byte getByte(String string)
+ {
+ AMQTypedValue value = _properties.get(string);
+ if (value != null && (value.getType() == AMQType.BYTE))
+ {
+ return (Byte) value.getValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public Short getShort(String string)
+ {
+ AMQTypedValue value = _properties.get(string);
+ if (value != null && (value.getType() == AMQType.SHORT))
+ {
+ return (Short) value.getValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public Integer getInteger(String string)
+ {
+ AMQTypedValue value = _properties.get(string);
+ if (value != null && (value.getType() == AMQType.INT))
+ {
+ return (Integer) value.getValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public Long getLong(String string)
+ {
+ AMQTypedValue value = _properties.get(string);
+ if (value != null && (value.getType() == AMQType.LONG))
+ {
+ return (Long) value.getValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public Float getFloat(String string)
+ {
+ AMQTypedValue value = _properties.get(string);
+ if (value != null && (value.getType() == AMQType.FLOAT))
+ {
+ return (Float) value.getValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public Double getDouble(String string)
+ {
+ AMQTypedValue value = _properties.get(string);
+ if (value != null && (value.getType() == AMQType.DOUBLE))
+ {
+ return (Double) value.getValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public String getString(String string)
+ {
+ AMQTypedValue value = _properties.get(string);
+ if ((value != null) && ((value.getType() == AMQType.WIDE_STRING) ||
+ (value.getType() == AMQType.ASCII_STRING)))
+ {
+ return (String) value.getValue();
+ }
+
+ else if ((value != null) && (value.getValue() != null) && !(value.getValue() instanceof byte[]))
+ {
+ return String.valueOf(value.getValue());
+ }
+ else
+ {
+ return null;
+ }
+
+ }
+
+ public Character getCharacter(String string)
+ {
+ AMQTypedValue value = _properties.get(string);
+ if (value != null && (value.getType() == AMQType.ASCII_CHARACTER))
+ {
+ return (Character) value.getValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public byte[] getBytes(String string)
+ {
+ AMQTypedValue value = _properties.get(string);
+ if (value != null && (value.getType() == AMQType.BINARY))
+ {
+ return (byte[]) value.getValue();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public Object getObject(String string)
+ {
+ AMQTypedValue value = _properties.get(string);
+ if(value != null)
+ {
+ return value.getValue();
+ }
+ else
+ {
+ return value;
+ }
+
+ }
+
+ // ************ Setters
+
+ public Object setBoolean(String string, boolean b)
+ {
+ checkPropertyName(string);
+ return _properties.put(string, AMQType.BOOLEAN.asTypedValue(b));
+ }
+
+ public Object setByte(String string, byte b)
+ {
+ checkPropertyName(string);
+ return _properties.put(string, AMQType.BYTE.asTypedValue(b));
+ }
+
+ public Object setShort(String string, short i)
+ {
+ checkPropertyName(string);
+ return _properties.put(string, AMQType.SHORT.asTypedValue(i));
+ }
+
+ public Object setInteger(String string, int i)
+ {
+ checkPropertyName(string);
+ return _properties.put(string, AMQType.INT.asTypedValue(i));
+ }
+
+ public Object setLong(String string, long l)
+ {
+ checkPropertyName(string);
+ return _properties.put(string, AMQType.LONG.asTypedValue(l));
+ }
+
+ public Object setFloat(String string, float v)
+ {
+ checkPropertyName(string);
+ return _properties.put(string, AMQType.FLOAT.asTypedValue(v));
+ }
+
+ public Object setDouble(String string, double v)
+ {
+ checkPropertyName(string);
+ return _properties.put(string, AMQType.DOUBLE.asTypedValue(v));
+ }
+
+ public Object setString(String string, String value)
+ {
+ checkPropertyName(string);
+ if (value == null)
+ {
+ return _properties.put(string, AMQType.NULL_STRING.asTypedValue(null));
+ }
+ else
+ {
+ //FIXME: determine string encoding and set either WIDE or ASCII string
+// if ()
+ {
+ return _properties.put(string, AMQType.WIDE_STRING.asTypedValue(value));
+ }
+// else
+// {
+// return _properties.put(string, AMQType.ASCII_STRING.asTypedValue(value));
+// }
+ }
+ }
+
+ public Object setChar(String string, char c)
+ {
+ checkPropertyName(string);
+ return _properties.put(string, AMQType.ASCII_CHARACTER.asTypedValue(c));
+ }
+
+ public Object setBytes(String string, byte[] bytes)
+ {
+ checkPropertyName(string);
+ return _properties.put(string, AMQType.BINARY.asTypedValue(bytes));
+ }
+
+ public Object setBytes(String string, byte[] bytes, int start, int length)
+ {
+ checkPropertyName(string);
+ byte[] newBytes = new byte[length];
+ System.arraycopy(bytes,start,newBytes,0,length);
+ return setBytes(string, bytes);
+ }
+
+
+ public Object setObject(String string, Object object)
+ {
+ if (object instanceof Boolean)
+ {
+ return setBoolean(string, (Boolean) object);
+ }
+ else if (object instanceof Byte)
+ {
+ return setByte(string, (Byte) object);
+ }
+ else if (object instanceof Short)
+ {
+ return setShort(string, (Short) object);
+ }
+ else if (object instanceof Integer)
+ {
+ return setInteger(string, (Integer) object);
+ }
+ else if (object instanceof Long)
+ {
+ return setLong(string, (Long) object);
+ }
+ else if (object instanceof Float)
+ {
+ return setFloat(string, (Float) object);
+ }
+ else if (object instanceof Double)
+ {
+ return setDouble(string, (Double) object);
+ }
+ else if (object instanceof String)
+ {
+ return setString(string, (String) object);
+ }
+ else if (object instanceof Character)
+ {
+ return setChar(string, (Character) object);
+ }
+ else if (object instanceof byte[])
+ {
+ return setBytes(string, (byte[]) object);
+ }
+
+ throw new AMQPInvalidClassException("Only Primatives objects allowed Object is:" + object.getClass());
+ }
+
+
+ public boolean isNullStringValue(String name)
+ {
+ AMQTypedValue value = _properties.get(name);
+ return (value != null) && (value.getType() == AMQType.NULL_STRING);
+ }
+
+ // ***** Methods
+
+ public Enumeration getPropertyNames()
+ {
+ return Collections.enumeration(_properties.keySet());
+ }
+
+ public boolean propertyExists(String propertyName)
+ {
+ return itemExists(propertyName);
+ }
+
+ public boolean itemExists(String string)
+ {
+ return _properties.containsKey(string);
+ }
+
+ public String toString()
+ {
+ return _properties.toString();
+ }
+
+
+
+ private void checkPropertyName(String propertyName)
+ {
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException("Property name must not be null");
+ }
+ else if ("".equals(propertyName))
+ {
+ throw new IllegalArgumentException("Property name must not be the empty string");
+ }
+
+ checkIdentiferFormat(propertyName);
+ }
+
+
+ protected static void checkIdentiferFormat(String propertyName)
+ {
+// AMQP Spec: 4.2.5.5 Field Tables
+// Guidelines for implementers:
+// * Field names MUST start with a letter, '$' or '#' and may continue with
+// letters, '$' or '#', digits, or underlines, to a maximum length of 128
+// characters.
+// * The server SHOULD validate field names and upon receiving an invalid
+// field name, it SHOULD signal a connection exception with reply code
+// 503 (syntax error). Conformance test: amq_wlp_table_01.
+// * A peer MUST handle duplicate fields by using only the first instance.
+
+
+ // AMQP length limit
+ if (propertyName.length() > 128)
+ {
+ throw new IllegalArgumentException("AMQP limits property names to 128 characters");
+ }
+
+ // AMQ start character
+ if (!(Character.isLetter(propertyName.charAt(0))
+ || propertyName.charAt(0) == '$'
+ || propertyName.charAt(0) == '#'
+ || propertyName.charAt(0) == '_')) // Not official AMQP added for JMS.
+ {
+ throw new IllegalArgumentException("Identifier '" + propertyName + "' does not start with a valid AMQP start character");
+ }
+ }
+
+
+ // ************************* Byte Buffer Processing
+
+ public void writeToBuffer(ByteBuffer buffer)
+ {
+ final boolean trace = _logger.isTraceEnabled();
+
+ if (trace)
+ {
+ _logger.trace("FieldTable::writeToBuffer: Writing encoded length of " + getEncodedSize() + "...");
+ }
+
+ EncodingUtils.writeUnsignedInteger(buffer, getEncodedSize());
+
+ putDataInBuffer(buffer);
+ }
+
+ public byte[] getDataAsBytes()
+ {
+ final int encodedSize = (int) getEncodedSize();
+ final ByteBuffer buffer = ByteBuffer.allocate(encodedSize); // FIXME XXX: Is cast a problem?
+
+ putDataInBuffer(buffer);
+
+ final byte[] result = new byte[encodedSize];
+ buffer.flip();
+ buffer.get(result);
+ buffer.release();
+ return result;
+ }
+
+ public long getEncodedSize()
+ {
+ int encodedSize = 0;
+ for(Map.Entry<String,AMQTypedValue> e : _properties.entrySet())
+ {
+ encodedSize += EncodingUtils.encodedShortStringLength(e.getKey());
+ encodedSize++; // the byte for the encoding Type
+ encodedSize += e.getValue().getEncodingSize();
+
+ }
+ return encodedSize;
+ }
+
+ public void addAll(FieldTable fieldTable)
+ {
+ _properties.putAll(fieldTable._properties);
+ }
+
+
+ public static interface FieldTableElementProcessor
+ {
+ public boolean processElement(String propertyName, AMQTypedValue value);
+ public Object getResult();
+ }
+
+ public Object processOverElements(FieldTableElementProcessor processor)
+ {
+ for(Map.Entry<String,AMQTypedValue> e : _properties.entrySet())
+ {
+ boolean result = processor.processElement(e.getKey(), e.getValue());
+ if(!result)
+ {
+ break;
+ }
+ }
+ return processor.getResult();
+ }
+
+
+ public int size()
+ {
+ return _properties.size();
+ }
+
+ public boolean isEmpty()
+ {
+ return _properties.isEmpty();
+ }
+
+ public boolean containsKey(String key)
+ {
+ return _properties.containsKey(key);
+ }
+
+ public Set<String> keys()
+ {
+ return _properties.keySet();
+ }
+
+
+ public Object get(Object key)
+ {
+
+ return getObject((String)key);
+ }
+
+
+ public Object put(Object key, Object value)
+ {
+ return setObject(key.toString(), value);
+ }
+
+
+ public Object remove(String key)
+ {
+ AMQTypedValue value = _properties.remove(key);
+ return value == null ? null : value.getValue();
+ }
+
+
+
+ public void clear()
+ {
+ _properties.clear();
+ }
+
+ public Set keySet()
+ {
+ return _properties.keySet();
+ }
+
+ private void putDataInBuffer(ByteBuffer buffer)
+ {
+
+ final Iterator<Map.Entry<String,AMQTypedValue>> it = _properties.entrySet().iterator();
+
+ //If there are values then write out the encoded Size... could check _encodedSize != 0
+ // write out the total length, which we have kept up to date as data is added
+
+
+ while (it.hasNext())
+ {
+ final Map.Entry<String,AMQTypedValue> me = it.next();
+ try
+ {
+ if (_logger.isTraceEnabled())
+ {
+ _logger.trace("Writing Property:" + me.getKey() +
+ " Type:" + me.getValue().getType() +
+ " Value:" + me.getValue().getValue());
+ _logger.trace("Buffer Position:" + buffer.position() +
+ " Remaining:" + buffer.remaining());
+ }
+
+
+
+ //Write the actual parameter name
+ EncodingUtils.writeShortStringBytes(buffer, me.getKey());
+ me.getValue().writeToBuffer(buffer);
+ }
+ catch (Exception e)
+ {
+ if (_logger.isTraceEnabled())
+ {
+ _logger.trace("Exception thrown:" + e);
+ _logger.trace("Writing Property:" + me.getKey() +
+ " Type:" + me.getValue().getType() +
+ " Value:" + me.getValue().getValue());
+ _logger.trace("Buffer Position:" + buffer.position() +
+ " Remaining:" + buffer.remaining());
+ }
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+
+ public void setFromBuffer(ByteBuffer buffer, long length) throws AMQFrameDecodingException
+ {
+ final boolean trace = _logger.isTraceEnabled();
+
+ int sizeRead = 0;
+ while (sizeRead < length)
+ {
+ int sizeRemaining = buffer.remaining();
+ final String key = EncodingUtils.readShortString(buffer);
+ AMQTypedValue value = AMQTypedValue.readFromBuffer(buffer);
+ sizeRead += (sizeRemaining - buffer.remaining());
+
+ if (trace)
+ {
+ _logger.trace("FieldTable::PropFieldTable(buffer," + length + "): Read type '" + value.getType() + "', key '" + key + "', value '" + value.getValue() + "' (now read " + sizeRead + " of " + length + " encoded bytes)...");
+ }
+
+ _properties.put(key,value);
+ }
+
+ if (trace)
+ {
+ _logger.trace("FieldTable::FieldTable(buffer," + length + "): Done.");
+ }
+ }
}
Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/FieldTableFactory.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/FieldTableFactory.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/FieldTableFactory.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/FieldTableFactory.java Wed Dec 27 16:31:11 2006
@@ -26,16 +26,13 @@
{
public static FieldTable newFieldTable()
{
- return new PropertyFieldTable();
+ return new FieldTable();
}
public static FieldTable newFieldTable(ByteBuffer byteBuffer, long length) throws AMQFrameDecodingException
{
- return new PropertyFieldTable(byteBuffer, length);
+ return new FieldTable(byteBuffer, length);
}
- public static FieldTable newFieldTable(String text)
- {
- return new PropertyFieldTable(text);
- }
+
}
Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/JMSPropertyFieldTable.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/JMSPropertyFieldTable.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/JMSPropertyFieldTable.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/JMSPropertyFieldTable.java Wed Dec 27 16:31:11 2006
@@ -32,29 +32,11 @@
{
private FieldTable _fieldtable;
- public JMSPropertyFieldTable()
- {
- _fieldtable = new PropertyFieldTable();
- }
-
public JMSPropertyFieldTable(FieldTable table)
{
_fieldtable = table;
}
- public JMSPropertyFieldTable(ByteBuffer buffer, long length) throws JMSException
- {
- try
- {
- _fieldtable = new PropertyFieldTable(buffer, length);
- }
- catch (AMQFrameDecodingException e)
- {
- JMSException error = new JMSException(e.getMessage());
- error.setLinkedException(e);
- throw error;
- }
- }
private void checkPropertyName(String propertyName)
{
Modified: incubator/qpid/branches/new_persistence/java/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java Wed Dec 27 16:31:11 2006
@@ -31,7 +31,7 @@
{
BasicContentHeaderProperties _testProperties;
- PropertyFieldTable _testTable;
+ FieldTable _testTable;
String _testString = "This is a test string";
int _testint = 666;
@@ -45,11 +45,9 @@
public void setUp()
{
- HashMap _testMap = new HashMap(10);
- _testMap.put("TestString", _testString);
- _testMap.put("Testint", _testint);
- _testTable = new PropertyFieldTable();
- _testTable.putAll(_testMap);
+ _testTable = new FieldTable();
+ _testTable.setString("TestString", _testString);
+ _testTable.setInteger("Testint", _testint);
_testProperties = new BasicContentHeaderProperties();
_testProperties.setHeaders(_testTable);
}
@@ -57,7 +55,7 @@
public void testGetPropertyListSize()
{
//needs a better test but at least we're exercising the code !
- // FT size is encoded in an int
+ // FT length is encoded in an int
int expectedSize = EncodingUtils.encodedIntegerLength();
expectedSize += EncodingUtils.encodedShortStringLength("TestInt");
Modified: incubator/qpid/branches/new_persistence/java/common/src/test/java/org/apache/qpid/framing/JMSPropertyFieldTableTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/test/java/org/apache/qpid/framing/JMSPropertyFieldTableTest.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/test/java/org/apache/qpid/framing/JMSPropertyFieldTableTest.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/test/java/org/apache/qpid/framing/JMSPropertyFieldTableTest.java Wed Dec 27 16:31:11 2006
@@ -51,7 +51,7 @@
*/
public void testReplacement() throws JMSException
{
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable();
+ JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
//Set a boolean value
table1.setBoolean("value", true);
@@ -73,7 +73,7 @@
public void testRemoval() throws JMSException
{
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable();
+ JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
//Set a boolean value
table1.setBoolean("value", true);
@@ -99,7 +99,7 @@
*/
public void testBoolean() throws JMSException
{
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable();
+ JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
table1.setBoolean("value", true);
Assert.assertTrue(table1.propertyExists("value"));
@@ -184,7 +184,7 @@
//but after a remove it doesn't
Assert.assertFalse(table1.propertyExists("value"));
- // Table should now have zero size for encoding
+ // Table should now have zero length for encoding
checkEmpty(table1);
//Looking up an invalid value will return false
@@ -197,7 +197,7 @@
*/
public void testByte() throws JMSException
{
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable();
+ JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
table1.setByte("value", Byte.MAX_VALUE);
Assert.assertTrue(table1.propertyExists("value"));
@@ -243,7 +243,7 @@
//but after a remove it doesn't
Assert.assertFalse(table1.propertyExists("value"));
- // Table should now have zero size for encoding
+ // Table should now have zero length for encoding
checkEmpty(table1);
//Looking up an invalid value returns null
@@ -266,7 +266,7 @@
*/
public void testShort() throws JMSException
{
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable();
+ JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
table1.setShort("value", Short.MAX_VALUE);
Assert.assertTrue(table1.propertyExists("value"));
@@ -323,7 +323,7 @@
//but after a remove it doesn't
Assert.assertFalse(table1.propertyExists("value"));
- // Table should now have zero size for encoding
+ // Table should now have zero length for encoding
checkEmpty(table1);
//Looking up an invalid value returns null
@@ -345,7 +345,7 @@
*/
public void testDouble() throws JMSException
{
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable();
+ JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
table1.setDouble("value", Double.MAX_VALUE);
Assert.assertTrue(table1.propertyExists("value"));
@@ -414,7 +414,7 @@
//but after a remove it doesn't
Assert.assertFalse(table1.propertyExists("value"));
- // Table should now have zero size for encoding
+ // Table should now have zero length for encoding
checkEmpty(table1);
//Looking up an invalid value returns null
@@ -437,7 +437,7 @@
*/
public void testFloat() throws JMSException
{
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable();
+ JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
table1.setFloat("value", Float.MAX_VALUE);
Assert.assertTrue(table1.propertyExists("value"));
@@ -500,7 +500,7 @@
//but after a remove it doesn't
Assert.assertFalse(table1.propertyExists("value"));
- // Table should now have zero size for encoding
+ // Table should now have zero length for encoding
checkEmpty(table1);
//Looking up an invalid value returns null
@@ -522,7 +522,7 @@
*/
public void testInt() throws JMSException
{
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable();
+ JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
table1.setInteger("value", Integer.MAX_VALUE);
Assert.assertTrue(table1.propertyExists("value"));
@@ -586,7 +586,7 @@
//but after a remove it doesn't
Assert.assertFalse(table1.propertyExists("value"));
- // Table should now have zero size for encoding
+ // Table should now have zero length for encoding
checkEmpty(table1);
//Looking up an invalid value returns null
@@ -608,7 +608,7 @@
*/
public void testLong() throws JMSException
{
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable();
+ JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
table1.setLong("value", Long.MAX_VALUE);
Assert.assertTrue(table1.propertyExists("value"));
@@ -679,7 +679,7 @@
//but after a remove it doesn't
Assert.assertFalse(table1.propertyExists("value"));
- // Table should now have zero size for encoding
+ // Table should now have zero length for encoding
checkEmpty(table1);
//Looking up an invalid value
@@ -700,7 +700,7 @@
* Calls all methods that can be used to check the table is empty
* - getEncodedSize
* - isEmpty
- * - size
+ * - length
*
* @param table to check is empty
*/
@@ -716,7 +716,7 @@
*/
public void testString() throws JMSException
{
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable();
+ JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
table1.setString("value", "Hello");
Assert.assertTrue(table1.propertyExists("value"));
@@ -799,7 +799,7 @@
public void testValues() throws JMSException
{
- JMSPropertyFieldTable table = new JMSPropertyFieldTable();
+ JMSPropertyFieldTable table = new JMSPropertyFieldTable(new FieldTable());
table.setBoolean("bool", true);
table.setDouble("double", Double.MAX_VALUE);
table.setFloat("float", Float.MAX_VALUE);
@@ -842,7 +842,7 @@
*/
public void testCheckPropertyNameasNull() throws JMSException
{
- JMSPropertyFieldTable table = new JMSPropertyFieldTable();
+ JMSPropertyFieldTable table = new JMSPropertyFieldTable(new FieldTable());
try
{
@@ -862,7 +862,7 @@
*/
public void testCheckPropertyNameasEmptyString() throws JMSException
{
- JMSPropertyFieldTable table = new JMSPropertyFieldTable();
+ JMSPropertyFieldTable table = new JMSPropertyFieldTable(new FieldTable());
try
{
@@ -882,7 +882,7 @@
*/
public void testCheckPropertyNamehasMaxLength() throws JMSException
{
- JMSPropertyFieldTable table = new JMSPropertyFieldTable();
+ JMSPropertyFieldTable table = new JMSPropertyFieldTable(new FieldTable());
StringBuffer longPropertyName = new StringBuffer(129);
@@ -910,7 +910,7 @@
*/
public void testCheckPropertyNameStartCharacterIsLetter() throws JMSException
{
- JMSPropertyFieldTable table = new JMSPropertyFieldTable();
+ JMSPropertyFieldTable table = new JMSPropertyFieldTable(new FieldTable());
//Try a name that starts with a number
try
@@ -931,7 +931,7 @@
*/
public void testCheckPropertyNameContainsInvalidCharacter() throws JMSException
{
- JMSPropertyFieldTable table = new JMSPropertyFieldTable();
+ JMSPropertyFieldTable table = new JMSPropertyFieldTable(new FieldTable());
//Try a name that starts with a number
try
@@ -953,7 +953,7 @@
*/
public void testCheckPropertyNameIsInvalid() throws JMSException
{
- JMSPropertyFieldTable table = new JMSPropertyFieldTable();
+ JMSPropertyFieldTable table = new JMSPropertyFieldTable(new FieldTable());
//Try a name that starts with a number
try
@@ -995,7 +995,7 @@
public void testSets()
{
- JMSPropertyFieldTable table = new JMSPropertyFieldTable();
+ JMSPropertyFieldTable table = new JMSPropertyFieldTable(new FieldTable());
table.put("n1", "1");
table.put("n2", "2");
Modified: incubator/qpid/branches/new_persistence/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java Wed Dec 27 16:31:11 2006
@@ -37,39 +37,23 @@
private static final Logger _logger = Logger.getLogger(PropertyFieldTableTest.class);
- /**
- * Test that modifying a byte[] after setting property doesn't change property
- */
- public void testByteModification()
- {
- PropertyFieldTable table = new PropertyFieldTable();
- byte[] bytes = {99, 98, 97, 96, 95};
- table.setBytes("bytes", bytes);
- bytes[0] = 1;
- bytes[1] = 2;
- bytes[2] = 3;
- bytes[3] = 4;
- bytes[4] = 5;
-
- assertBytesNotEqual(bytes, table.getBytes("bytes"));
- }
/**
* Test that setting a similar named value replaces any previous value set on that name
*/
public void testReplacement()
{
- PropertyFieldTable table1 = new PropertyFieldTable();
+ FieldTable table1 = new FieldTable();
//Set a boolean value
table1.setBoolean("value", true);
- //Check size of table is correct (<Value length> + <type> + <Boolean length>)
+ //Check length of table is correct (<Value length> + <type> + <Boolean length>)
int size = EncodingUtils.encodedShortStringLength("value") + 1 + EncodingUtils.encodedBooleanLength();
Assert.assertEquals(size, table1.getEncodedSize());
// reset value to an integer
table1.setInteger("value", Integer.MAX_VALUE);
- // Check the size has changed accordingly (<Value length> + <type> + <Integer length>)
+ // Check the length has changed accordingly (<Value length> + <type> + <Integer length>)
size = EncodingUtils.encodedShortStringLength("value") + 1 + EncodingUtils.encodedIntegerLength();
Assert.assertEquals(size, table1.getEncodedSize());
@@ -86,7 +70,7 @@
*/
public void testBoolean()
{
- PropertyFieldTable table1 = new PropertyFieldTable();
+ FieldTable table1 = new FieldTable();
table1.setBoolean("value", true);
Assert.assertTrue(table1.propertyExists("value"));
@@ -107,19 +91,9 @@
//except value as a string
Assert.assertEquals("true", table1.getString("value"));
- //Try setting a null value and read it back
- table1.put(PropertyFieldTable.Prefix.AMQP_BOOLEAN_PROPERTY_PREFIX, "value", null);
-
- // Should be able to get the null back
- Assert.assertEquals(null, table1.getBoolean("value"));
- //but still contains the value
- Assert.assertTrue(table1.containsKey("value"));
-
table1.remove("value");
- //but after a remove it doesn't
- Assert.assertFalse(table1.containsKey("value"));
- // Table should now have zero size for encoding
+ // Table should now have zero length for encoding
checkEmpty(table1);
//Looking up an invalid value returns null
@@ -132,7 +106,7 @@
*/
public void testByte()
{
- PropertyFieldTable table1 = new PropertyFieldTable();
+ FieldTable table1 = new FieldTable();
table1.setByte("value", Byte.MAX_VALUE);
Assert.assertTrue(table1.propertyExists("value"));
@@ -151,20 +125,8 @@
//... and a the string value of it.
Assert.assertEquals("" + Byte.MAX_VALUE, table1.getString("value"));
- //Try setting a null value and read it back
- table1.put(PropertyFieldTable.Prefix.AMQP_BYTE_PROPERTY_PREFIX, "value", null);
-
- // Should be able to get the null back
- Assert.assertEquals(null, table1.getByte("value"));
-
- //but still contains the value
- Assert.assertTrue(table1.containsKey("value"));
-
table1.remove("value");
- //but after a remove it doesn't
- Assert.assertFalse(table1.containsKey("value"));
-
- // Table should now have zero size for encoding
+ // Table should now have zero length for encoding
checkEmpty(table1);
//Looking up an invalid value returns null
@@ -177,7 +139,7 @@
*/
public void testShort()
{
- PropertyFieldTable table1 = new PropertyFieldTable();
+ FieldTable table1 = new FieldTable();
table1.setShort("value", Short.MAX_VALUE);
Assert.assertTrue(table1.propertyExists("value"));
@@ -196,20 +158,8 @@
//... and a the string value of it.
Assert.assertEquals("" + Short.MAX_VALUE, table1.getString("value"));
- //Try setting a null value and read it back
- table1.put(PropertyFieldTable.Prefix.AMQP_SHORT_PROPERTY_PREFIX, "value", null);
-
- // Should be able to get the null back
- Assert.assertEquals(null, table1.getShort("value"));
-
- //but still contains the value
- Assert.assertTrue(table1.containsKey("value"));
-
table1.remove("value");
- //but after a remove it doesn't
- Assert.assertFalse(table1.containsKey("value"));
-
- // Table should now have zero size for encoding
+ // Table should now have zero length for encoding
checkEmpty(table1);
//Looking up an invalid value returns null
@@ -223,7 +173,7 @@
*/
public void testChar()
{
- PropertyFieldTable table1 = new PropertyFieldTable();
+ FieldTable table1 = new FieldTable();
table1.setChar("value", 'c');
Assert.assertTrue(table1.propertyExists("value"));
@@ -242,26 +192,9 @@
//... and a the string value of it.
Assert.assertEquals("c", table1.getString("value"));
- //Try setting a null value and read it back
- table1.put(PropertyFieldTable.Prefix.AMQP_ASCII_CHARACTER_PROPERTY_PREFIX, "value", null);
-
- try
- {
- table1.getString("value");
- fail("Should throw NullPointerException");
- }
- catch (NullPointerException npe)
- {
- //Normal Path
- }
- //but still contains the value
- Assert.assertTrue(table1.containsKey("value"));
-
table1.remove("value");
- //but after a remove it doesn't
- Assert.assertFalse(table1.containsKey("value"));
- // Table should now have zero size for encoding
+ // Table should now have zero length for encoding
checkEmpty(table1);
//Looking up an invalid value returns null
@@ -275,7 +208,7 @@
*/
public void testDouble()
{
- PropertyFieldTable table1 = new PropertyFieldTable();
+ FieldTable table1 = new FieldTable();
table1.setDouble("value", Double.MAX_VALUE);
Assert.assertTrue(table1.propertyExists("value"));
@@ -293,20 +226,11 @@
//... and a the string value of it.
Assert.assertEquals("" + Double.MAX_VALUE, table1.getString("value"));
-
- //Try setting a null value and read it back
- table1.put(PropertyFieldTable.Prefix.AMQP_DOUBLE_PROPERTY_PREFIX, "value", null);
-
- Assert.assertEquals(null, table1.getDouble("value"));
-
- //but still contains the value
- Assert.assertTrue(table1.containsKey("value"));
-
table1.remove("value");
//but after a remove it doesn't
Assert.assertFalse(table1.containsKey("value"));
- // Table should now have zero size for encoding
+ // Table should now have zero length for encoding
checkEmpty(table1);
//Looking up an invalid value returns null
@@ -320,7 +244,7 @@
*/
public void testFloat()
{
- PropertyFieldTable table1 = new PropertyFieldTable();
+ FieldTable table1 = new FieldTable();
table1.setFloat("value", Float.MAX_VALUE);
Assert.assertTrue(table1.propertyExists("value"));
@@ -339,19 +263,12 @@
//... and a the string value of it.
Assert.assertEquals("" + Float.MAX_VALUE, table1.getString("value"));
- //Try setting a null value and read it back
- table1.put(PropertyFieldTable.Prefix.AMQP_FLOAT_PROPERTY_PREFIX, "value", null);
-
- Assert.assertEquals(null, table1.getFloat("value"));
-
- //but still contains the value
- Assert.assertTrue(table1.containsKey("value"));
table1.remove("value");
//but after a remove it doesn't
Assert.assertFalse(table1.containsKey("value"));
- // Table should now have zero size for encoding
+ // Table should now have zero length for encoding
checkEmpty(table1);
//Looking up an invalid value returns null
@@ -365,7 +282,7 @@
*/
public void testInt()
{
- PropertyFieldTable table1 = new PropertyFieldTable();
+ FieldTable table1 = new FieldTable();
table1.setInteger("value", Integer.MAX_VALUE);
Assert.assertTrue(table1.propertyExists("value"));
@@ -384,19 +301,12 @@
//... and a the string value of it.
Assert.assertEquals("" + Integer.MAX_VALUE, table1.getString("value"));
- //Try setting a null value and read it back
- table1.put(PropertyFieldTable.Prefix.AMQP_INT_PROPERTY_PREFIX, "value", null);
-
- Assert.assertEquals(null, table1.getInteger("value"));
-
- //but still contains the value
- Assert.assertTrue(table1.containsKey("value"));
table1.remove("value");
//but after a remove it doesn't
Assert.assertFalse(table1.containsKey("value"));
- // Table should now have zero size for encoding
+ // Table should now have zero length for encoding
checkEmpty(table1);
//Looking up an invalid value returns null
@@ -410,7 +320,7 @@
*/
public void testLong()
{
- PropertyFieldTable table1 = new PropertyFieldTable();
+ FieldTable table1 = new FieldTable();
table1.setLong("value", Long.MAX_VALUE);
Assert.assertTrue(table1.propertyExists("value"));
@@ -429,19 +339,12 @@
//... and a the string value of it.
Assert.assertEquals("" + Long.MAX_VALUE, table1.getString("value"));
- //Try setting a null value and read it back
- table1.put(PropertyFieldTable.Prefix.AMQP_LONG_PROPERTY_PREFIX, "value", null);
-
- Assert.assertEquals(null, table1.getLong("value"));
-
- //but still contains the value
- Assert.assertTrue(table1.containsKey("value"));
table1.remove("value");
//but after a remove it doesn't
Assert.assertFalse(table1.containsKey("value"));
- // Table should now have zero size for encoding
+ // Table should now have zero length for encoding
checkEmpty(table1);
//Looking up an invalid value returns null
@@ -457,7 +360,7 @@
{
byte[] bytes = {99, 98, 97, 96, 95};
- PropertyFieldTable table1 = new PropertyFieldTable();
+ FieldTable table1 = new FieldTable();
table1.setBytes("value", bytes);
Assert.assertTrue(table1.propertyExists("value"));
@@ -476,19 +379,11 @@
//... and a the string value of it is null
Assert.assertEquals(null, table1.getString("value"));
- //Try setting a null value and read it back
- table1.put(PropertyFieldTable.Prefix.AMQP_BINARY_PROPERTY_PREFIX, "value", null);
-
- Assert.assertEquals(null, table1.getBytes("value"));
-
- //but still contains the value
- Assert.assertTrue(table1.containsKey("value"));
-
table1.remove("value");
//but after a remove it doesn't
Assert.assertFalse(table1.containsKey("value"));
- // Table should now have zero size for encoding
+ // Table should now have zero length for encoding
checkEmpty(table1);
//Looking up an invalid value returns null
@@ -499,19 +394,17 @@
* Calls all methods that can be used to check the table is empty
* - getEncodedSize
* - isEmpty
- * - size
+ * - length
*
* @param table to check is empty
*/
- private void checkEmpty(PropertyFieldTable table)
+ private void checkEmpty(FieldTable table)
{
Assert.assertEquals(0, table.getEncodedSize());
Assert.assertTrue(table.isEmpty());
Assert.assertEquals(0, table.size());
Assert.assertEquals(0, table.keySet().size());
- Assert.assertEquals(0, table.values().size());
- Assert.assertEquals(0, table.entrySet().size());
}
@@ -521,7 +414,7 @@
*/
public void testString()
{
- PropertyFieldTable table1 = new PropertyFieldTable();
+ FieldTable table1 = new FieldTable();
table1.setString("value", "Hello");
Assert.assertTrue(table1.propertyExists("value"));
@@ -562,79 +455,11 @@
}
- /**
- * Test that the generated XML can be used to create a field table with the same values.
- */
- public void testValidXML()
- {
- PropertyFieldTable table1 = new PropertyFieldTable();
- table1.setBoolean("bool", true);
- table1.setByte("byte", Byte.MAX_VALUE);
- byte[] bytes = {99, 98, 97, 96, 95};
- table1.setBytes("bytes", bytes);
- table1.setChar("char", 'c');
- table1.setDouble("double", Double.MAX_VALUE);
- table1.setFloat("float", Float.MAX_VALUE);
- table1.setInteger("int", Integer.MAX_VALUE);
- table1.setLong("long", Long.MAX_VALUE);
- table1.setShort("short", Short.MAX_VALUE);
- table1.setString("string", "Hello");
- table1.setString("null-string", null);
-
- table1.setObject("object-bool", true);
- table1.setObject("object-byte", Byte.MAX_VALUE);
- table1.setObject("object-bytes", bytes);
- table1.setObject("object-char", 'c');
- table1.setObject("object-double", Double.MAX_VALUE);
- table1.setObject("object-float", Float.MAX_VALUE);
- table1.setObject("object-int", Integer.MAX_VALUE);
- table1.setObject("object-long", Long.MAX_VALUE);
- table1.setObject("object-short", Short.MAX_VALUE);
- table1.setObject("object-string", "Hello");
-
- Assert.assertEquals(21, table1.size());
-
- String table1XML = table1.toString();
-
- PropertyFieldTable table2 = new PropertyFieldTable(table1XML);
-
- Assert.assertEquals(table1XML, table2.toString());
-
- //Check that when bytes is written out as a string with no new line between items that it is read in ok.
-
- }
-
- /**
- * Test that invalid input throws the correct Exception
- */
- public void testInvalidXML()
- {
- try
- {
- _logger.warn("Testing Invalid XML expecting IllegalArgumentException");
- new PropertyFieldTable("Rubbish");
- fail("IllegalArgumentException expected");
- }
- catch (IllegalArgumentException iae)
- {
- //normal path
- }
- try
- {
- _logger.warn("Testing Invalid XML expecting IllegalArgumentException");
- new PropertyFieldTable("");
- fail("IllegalArgumentException expected");
- }
- catch (IllegalArgumentException iae)
- {
- //normal path
- }
- }
-
+
public void testKeyEnumeration()
{
- PropertyFieldTable table = new PropertyFieldTable();
+ FieldTable table = new FieldTable();
table.setLong("one", 1L);
table.setLong("two", 2L);
table.setLong("three", 3L);
@@ -652,7 +477,7 @@
public void testValues()
{
- PropertyFieldTable table = new PropertyFieldTable();
+ FieldTable table = new FieldTable();
table.setBoolean("bool", true);
table.setByte("byte", Byte.MAX_VALUE);
byte[] bytes = {99, 98, 97, 96, 95};
@@ -707,7 +532,7 @@
{
byte[] bytes = {99, 98, 97, 96, 95};
- PropertyFieldTable table = new PropertyFieldTable();
+ FieldTable table = new FieldTable();
table.setBoolean("bool", true);
table.setByte("byte", Byte.MAX_VALUE);
@@ -732,7 +557,7 @@
try
{
- PropertyFieldTable table2 = new PropertyFieldTable(buffer, length);
+ FieldTable table2 = new FieldTable(buffer, length);
Assert.assertEquals((Boolean) true, table2.getBoolean("bool"));
Assert.assertEquals((Byte) Byte.MAX_VALUE, table2.getByte("byte"));
@@ -756,7 +581,7 @@
public void testEncodingSize()
{
- PropertyFieldTable result = new PropertyFieldTable();
+ FieldTable result = new FieldTable();
int size = 0;
result.setBoolean("boolean", true);
@@ -847,31 +672,31 @@
// public void testEncodingSize1()
// {
// PropertyFieldTable table = new PropertyFieldTable();
-// int size = 0;
+// int length = 0;
// result.put("one", 1L);
-// size = EncodingUtils.encodedShortStringLength("one");
-// size += 1 + EncodingUtils.encodedLongLength();
-// assertEquals(size, result.getEncodedSize());
+// length = EncodingUtils.encodedShortStringLength("one");
+// length += 1 + EncodingUtils.encodedLongLength();
+// assertEquals(length, result.getEncodedSize());
//
// result.put("two", 2L);
-// size += EncodingUtils.encodedShortStringLength("two");
-// size += 1 + EncodingUtils.encodedLongLength();
-// assertEquals(size, result.getEncodedSize());
+// length += EncodingUtils.encodedShortStringLength("two");
+// length += 1 + EncodingUtils.encodedLongLength();
+// assertEquals(length, result.getEncodedSize());
//
// result.put("three", 3L);
-// size += EncodingUtils.encodedShortStringLength("three");
-// size += 1 + EncodingUtils.encodedLongLength();
-// assertEquals(size, result.getEncodedSize());
+// length += EncodingUtils.encodedShortStringLength("three");
+// length += 1 + EncodingUtils.encodedLongLength();
+// assertEquals(length, result.getEncodedSize());
//
// result.put("four", 4L);
-// size += EncodingUtils.encodedShortStringLength("four");
-// size += 1 + EncodingUtils.encodedLongLength();
-// assertEquals(size, result.getEncodedSize());
+// length += EncodingUtils.encodedShortStringLength("four");
+// length += 1 + EncodingUtils.encodedLongLength();
+// assertEquals(length, result.getEncodedSize());
//
// result.put("five", 5L);
-// size += EncodingUtils.encodedShortStringLength("five");
-// size += 1 + EncodingUtils.encodedLongLength();
-// assertEquals(size, result.getEncodedSize());
+// length += EncodingUtils.encodedShortStringLength("five");
+// length += 1 + EncodingUtils.encodedLongLength();
+// assertEquals(length, result.getEncodedSize());
//
// //fixme should perhaps be expanded to incorporate all types.
//
@@ -907,7 +732,7 @@
*/
public void testSetObject()
{
- PropertyFieldTable table = new PropertyFieldTable();
+ FieldTable table = new FieldTable();
//Try setting a non primative object
@@ -920,7 +745,7 @@
{
//normal path
}
- // so size should be zero
+ // so length should be zero
Assert.assertEquals(0, table.getEncodedSize());
}
@@ -929,7 +754,7 @@
*/
public void testCheckPropertyNameasNull()
{
- PropertyFieldTable table = new PropertyFieldTable();
+ FieldTable table = new FieldTable();
try
{
@@ -940,7 +765,7 @@
{
//normal path
}
- // so size should be zero
+ // so length should be zero
Assert.assertEquals(0, table.getEncodedSize());
}
@@ -950,7 +775,7 @@
*/
public void testCheckPropertyNameasEmptyString()
{
- PropertyFieldTable table = new PropertyFieldTable();
+ FieldTable table = new FieldTable();
try
{
@@ -961,7 +786,7 @@
{
//normal path
}
- // so size should be zero
+ // so length should be zero
Assert.assertEquals(0, table.getEncodedSize());
}
@@ -971,7 +796,7 @@
*/
public void testCheckPropertyNamehasMaxLength()
{
- PropertyFieldTable table = new PropertyFieldTable();
+ FieldTable table = new FieldTable();
StringBuffer longPropertyName = new StringBuffer(129);
@@ -989,7 +814,7 @@
{
//normal path
}
- // so size should be zero
+ // so length should be zero
Assert.assertEquals(0, table.getEncodedSize());
}
@@ -999,7 +824,7 @@
*/
public void testCheckPropertyNameStartCharacterIsLetter()
{
- PropertyFieldTable table = new PropertyFieldTable();
+ FieldTable table = new FieldTable();
//Try a name that starts with a number
try
@@ -1011,7 +836,7 @@
{
//normal path
}
- // so size should be zero
+ // so length should be zero
Assert.assertEquals(0, table.getEncodedSize());
}
@@ -1021,7 +846,7 @@
*/
public void testCheckPropertyNameStartCharacterIsHashorDollar()
{
- PropertyFieldTable table = new PropertyFieldTable();
+ FieldTable table = new FieldTable();
//Try a name that starts with a number
try
@@ -1041,12 +866,10 @@
*/
public void testContents()
{
- PropertyFieldTable table = new PropertyFieldTable();
+ FieldTable table = new FieldTable();
table.put("StringProperty", "String");
- Assert.assertTrue(table.containsValue("String"));
-
Assert.assertEquals("String", table.get("StringProperty"));
//Test Clear
@@ -1062,7 +885,7 @@
public void testSets()
{
- PropertyFieldTable table = new PropertyFieldTable();
+ FieldTable table = new FieldTable();
table.put("n1", "1");
table.put("n2", "2");
@@ -1075,63 +898,9 @@
Assert.assertFalse(iterator.hasNext());
- iterator = table.values().iterator();
- Assert.assertEquals("1", iterator.next());
- Assert.assertEquals("2", iterator.next());
- Assert.assertEquals("3", iterator.next());
- Assert.assertFalse(iterator.hasNext());
-
-
- iterator = table.entrySet().iterator();
- Map.Entry entry = (Map.Entry) iterator.next();
- Assert.assertEquals("n1", entry.getKey());
- Assert.assertEquals("1", entry.getValue());
- entry = (Map.Entry) iterator.next();
- Assert.assertEquals("n2", entry.getKey());
- Assert.assertEquals("2", entry.getValue());
- entry = (Map.Entry) iterator.next();
- Assert.assertEquals("n3", entry.getKey());
- Assert.assertEquals("3", entry.getValue());
- Assert.assertFalse(iterator.hasNext());
-
}
-
- /**
- * Test that all the values are preserved after a putAll
- */
- public void testPutAll()
- {
- Map map = new HashMap();
-
- map.put("char", 'c');
- map.put("double", Double.MAX_VALUE);
- map.put("float", Float.MAX_VALUE);
- map.put("int", Integer.MAX_VALUE);
- map.put("long", Long.MAX_VALUE);
- map.put("short", Short.MAX_VALUE);
-
- PropertyFieldTable table = new PropertyFieldTable();
-
- table.putAll(map);
-
- Assert.assertEquals(6, table.size());
-
- Assert.assertTrue(table.containsKey("char"));
- Assert.assertEquals('c', (char) table.getCharacter("char"));
- Assert.assertTrue(table.containsKey("double"));
- Assert.assertEquals(Double.MAX_VALUE, table.getDouble("double"));
- Assert.assertTrue(table.containsKey("float"));
- Assert.assertEquals(Float.MAX_VALUE, table.getFloat("float"));
- Assert.assertTrue(table.containsKey("int"));
- Assert.assertEquals(Integer.MAX_VALUE, (int) table.getInteger("int"));
- Assert.assertTrue(table.containsKey("long"));
- Assert.assertEquals(Long.MAX_VALUE, (long) table.getLong("long"));
- Assert.assertTrue(table.containsKey("short"));
- Assert.assertEquals(Short.MAX_VALUE, (short) table.getShort("short"));
- Assert.assertEquals(Short.MAX_VALUE, (short) table.getShort("short"));
- }
private void assertBytesEqual(byte[] expected, byte[] actual)
Propchange: incubator/qpid/branches/new_persistence/java/distribution/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Dec 27 16:31:11 2006
@@ -0,0 +1 @@
+target
Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java Wed Dec 27 16:31:11 2006
@@ -520,7 +520,7 @@
Composite composite = new Composite(parent, SWT.BORDER);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- ViewUtility.createTabularDataHolder(composite,(TabularDataSupport)attribute.getValue());
+ ViewUtility.createTabularDataHolder(_toolkit, composite,(TabularDataSupport)attribute.getValue());
}
else
{
Modified: incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java?view=diff&rev=490613&r1=490612&r2=490613
==============================================================================
--- incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java (original)
+++ incubator/qpid/branches/new_persistence/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java Wed Dec 27 16:31:11 2006
@@ -492,11 +492,11 @@
{
if (result instanceof TabularDataSupport)
{
- ViewUtility.createTabularDataHolder(parent, (TabularDataSupport)result);
+ ViewUtility.createTabularDataHolder(_toolkit, parent, (TabularDataSupport)result);
}
else if (result instanceof CompositeDataSupport)
{
- ViewUtility.populateCompositeDataHolder(parent, (CompositeDataSupport)result);
+ ViewUtility.populateCompositeDataHolder(_toolkit, parent, (CompositeDataSupport)result);
}
}
@@ -521,6 +521,9 @@
*/
private void clearParameterValues(Composite control)
{
+ if (control == null)
+ return;
+
Control[] controls = control.getChildren();
if (controls == null || controls.length == 0)
return;