You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2014/10/28 14:01:22 UTC

[1/2] git commit: add definitions to testpeer for some of the basic terminus field types and their values

Repository: qpid-jms
Updated Branches:
  refs/heads/master 9ab5ed159 -> de9672305


add definitions to testpeer for some of the basic terminus field types and their values


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/992460d8
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/992460d8
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/992460d8

Branch: refs/heads/master
Commit: 992460d88b8c8960a741c380f587c829d99bef24
Parents: 9ab5ed1
Author: Robert Gemmell <ro...@apache.org>
Authored: Tue Oct 28 12:41:37 2014 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Tue Oct 28 12:41:37 2014 +0000

----------------------------------------------------------------------
 .../test/testpeer/basictypes/StdDistMode.java   |  39 ++++++
 .../testpeer/basictypes/TerminusDurability.java |  40 ++++++
 .../basictypes/TerminusExpiryPolicy.java        |  41 ++++++
 .../test/testpeer/basictypes/generate-types.xsl | 138 +++++++++++++++++++
 4 files changed, 258 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/992460d8/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/basictypes/StdDistMode.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/basictypes/StdDistMode.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/basictypes/StdDistMode.java
new file mode 100644
index 0000000..62cde60
--- /dev/null
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/basictypes/StdDistMode.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.qpid.jms.test.testpeer.basictypes;
+
+
+import org.apache.qpid.proton.amqp.Symbol;
+
+
+/**
+ * Generated by generate-types.xsl, which resides in this package.
+ */
+public class StdDistMode {
+
+    public static final Symbol MOVE = Symbol.valueOf("move");
+    public static final Symbol COPY = Symbol.valueOf("copy");
+
+    private StdDistMode() {
+      //No instances
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/992460d8/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/basictypes/TerminusDurability.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/basictypes/TerminusDurability.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/basictypes/TerminusDurability.java
new file mode 100644
index 0000000..7760ceb
--- /dev/null
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/basictypes/TerminusDurability.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.qpid.jms.test.testpeer.basictypes;
+
+
+import org.apache.qpid.proton.amqp.UnsignedInteger;
+
+
+/**
+ * Generated by generate-types.xsl, which resides in this package.
+ */
+public class TerminusDurability {
+
+    public static final UnsignedInteger NONE = UnsignedInteger.valueOf(0);
+    public static final UnsignedInteger CONFIGURATION = UnsignedInteger.valueOf(1);
+    public static final UnsignedInteger UNSETTLED_STATE = UnsignedInteger.valueOf(2);
+
+    private TerminusDurability() {
+      //No instances
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/992460d8/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/basictypes/TerminusExpiryPolicy.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/basictypes/TerminusExpiryPolicy.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/basictypes/TerminusExpiryPolicy.java
new file mode 100644
index 0000000..b3aa2fc
--- /dev/null
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/basictypes/TerminusExpiryPolicy.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.qpid.jms.test.testpeer.basictypes;
+
+
+import org.apache.qpid.proton.amqp.Symbol;
+
+
+/**
+ * Generated by generate-types.xsl, which resides in this package.
+ */
+public class TerminusExpiryPolicy {
+
+    public static final Symbol LINK_DETACH = Symbol.valueOf("link-detach");
+    public static final Symbol SESSION_END = Symbol.valueOf("session-end");
+    public static final Symbol CONNECTION_CLOSE = Symbol.valueOf("connection-close");
+    public static final Symbol NEVER = Symbol.valueOf("never");
+
+    private TerminusExpiryPolicy() {
+      //No instances
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/992460d8/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/basictypes/generate-types.xsl
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/basictypes/generate-types.xsl b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/basictypes/generate-types.xsl
new file mode 100644
index 0000000..188a655
--- /dev/null
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/basictypes/generate-types.xsl
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+                xmlns:exsl="http://exslt.org/common"
+                extension-element-prefixes="exsl">
+
+<!-- Used to generate the Java classes in this package.
+     Changes to these classes should be effected by modifying this stylesheet then re-running it,
+     using a stylesheet processor that understands the exsl directives such as xsltproc -->
+
+<xsl:template match="/">
+    <xsl:variable name="license">/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+</xsl:variable>
+
+    <xsl:for-each select="descendant-or-self::node()[name()='type']">
+        <xsl:if test="@name = 'terminus-durability' or @name = 'terminus-expiry-policy' or @name = 'std-dist-mode'">
+          <xsl:variable name="classname"><xsl:call-template name="dashToCamel"><xsl:with-param name="input" select="@name"/></xsl:call-template></xsl:variable>
+          <xsl:call-template name="typeClass">
+              <xsl:with-param name="license" select="$license"/>
+              <xsl:with-param name="classname" select="$classname"/>
+              <xsl:with-param name="source" select="@source"/>
+          </xsl:call-template>
+        </xsl:if>
+    </xsl:for-each>
+</xsl:template>
+
+
+<!-- *************************************************************************************************************** -->
+
+<xsl:template name="typeClass">
+    <xsl:param name="license"/>
+    <xsl:param name="classname"/>
+    <xsl:param name="source"/>
+  <exsl:document href="{$classname}.java" method="text">
+  <xsl:value-of select="$license"/>
+package org.apache.qpid.jms.test.testpeer.basictypes;
+
+<xsl:if test="@source = 'symbol' or @source = 'ubyte' or @source = 'ushort' or @source = 'uint' or @source = 'ulong'">
+import org.apache.qpid.proton.amqp.<xsl:call-template name="convertType"><xsl:with-param name="type" select="$source"/></xsl:call-template>;
+</xsl:if>
+
+/**
+ * Generated by generate-types.xsl, which resides in this package.
+ */
+public class <xsl:value-of select="$classname"/> {
+<xsl:for-each select="descendant::node()[name()='choice']">
+    public static final <xsl:call-template name="constructConstantFromLiteral"><xsl:with-param name="type" select="$source"/> <xsl:with-param name="value" select="@value"/> <xsl:with-param name="name" select="@name"/></xsl:call-template>;</xsl:for-each>
+
+    private <xsl:value-of select="$classname"/>() {
+      //No instances
+    }
+}
+
+</exsl:document>
+
+</xsl:template>
+
+<!-- *************************************************************************************************************** -->
+
+<xsl:template name="constructConstantFromLiteral">
+    <xsl:param name="type"/>
+    <xsl:param name="value"/>
+    <xsl:param name="name"/>
+    <xsl:variable name="typeClass"><xsl:call-template name="dashToCamel"><xsl:with-param name="input" select="@type"/></xsl:call-template></xsl:variable>
+    <xsl:variable name="constantName"><xsl:call-template name="toUpperDashToUnderscore"><xsl:with-param name="input" select="@name"/></xsl:call-template></xsl:variable>
+    <xsl:choose>
+        <xsl:when test="$type = 'string'">String <xsl:value-of select="$constantName"/> ="<xsl:value-of select="$value"/>";</xsl:when>
+        <xsl:when test="$type = 'symbol'">Symbol <xsl:value-of select="$constantName"/> = Symbol.valueOf("<xsl:value-of select="$value"/>")</xsl:when>
+        <xsl:when test="$type = 'ubyte'">UnsignedByte<xsl:value-of select="$constantName"/> = UnsignedByte.valueOf((byte) <xsl:value-of select="$value"/>)</xsl:when>
+        <xsl:when test="$type = 'ushort'">UnsignedShort <xsl:value-of select="$constantName"/> = UnsignedShort.valueOf((short) <xsl:value-of select="$value"/>)</xsl:when>
+        <xsl:when test="$type = 'uint'">UnsignedInteger <xsl:value-of select="$constantName"/> = UnsignedInteger.valueOf(<xsl:value-of select="$value"/>)</xsl:when>
+        <xsl:when test="$type = 'ulong'">UnsignedLong <xsl:value-of select="$constantName"/> = UnsignedLong.valueOf(<xsl:value-of select="$value"/>L)</xsl:when>
+        <xsl:when test="$type = 'long'">long <xsl:value-of select="$constantName"/> = <xsl:value-of select="$value"/>L</xsl:when>
+        <xsl:when test="$type = 'short'">short <xsl:value-of select="$constantName"/> = (short)<xsl:value-of select="$value"/></xsl:when>
+        <xsl:when test="$type = 'short'">byte <xsl:value-of select="$constantName"/> = (byte)<xsl:value-of select="$value"/></xsl:when>
+        <xsl:otherwise><xsl:value-of select="$value"/></xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<xsl:template name="convertType">
+    <xsl:param name="type"/>
+    <xsl:choose>
+        <xsl:when test="$type = 'string'">String</xsl:when>
+        <xsl:when test="$type = 'symbol'">Symbol</xsl:when>
+        <xsl:when test="$type = 'ubyte'">UnsignedByte</xsl:when>
+        <xsl:when test="$type = 'ushort'">UnsignedShort</xsl:when>
+        <xsl:when test="$type = 'uint'">UnsignedInteger</xsl:when>
+        <xsl:when test="$type = 'ulong'">UnsignedLong</xsl:when>
+        <xsl:otherwise><xsl:value-of select="$type"/></xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<!-- *************************************************************************************************************** -->
+<xsl:template name="substringAfterLast"><xsl:param name="input"/><xsl:param name="arg"/>
+        <xsl:choose>
+            <xsl:when test="contains($input,$arg)"><xsl:call-template name="substringAfterLast"><xsl:with-param name="input"><xsl:value-of select="substring-after($input,$arg)"/></xsl:with-param><xsl:with-param name="arg"><xsl:value-of select="$arg"/></xsl:with-param></xsl:call-template></xsl:when>
+            <xsl:otherwise><xsl:value-of select="$input"/></xsl:otherwise>
+        </xsl:choose>
+    </xsl:template>
+
+    <xsl:template name="initCap"><xsl:param name="input"/><xsl:value-of select="translate(substring($input,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/><xsl:value-of select="substring($input,2)"/></xsl:template>
+
+    <xsl:template name="initLower"><xsl:param name="input"/><xsl:value-of select="translate(substring($input,1,1),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/><xsl:value-of select="substring($input,2)"/></xsl:template>
+
+    <xsl:template name="toUpper"><xsl:param name="input"/><xsl:value-of select="translate($input,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/></xsl:template>
+
+    <xsl:template name="toUpperDashToUnderscore"><xsl:param name="input"/><xsl:value-of select="translate($input,'abcdefghijklmnopqrstuvwxyz-','ABCDEFGHIJKLMNOPQRSTUVWXYZ_')"/></xsl:template>
+
+    <xsl:template name="dashToCamel">
+        <xsl:param name="input"/>
+        <xsl:choose>
+            <xsl:when test="contains($input,'-')"><xsl:call-template name="initCap"><xsl:with-param name="input" select="substring-before($input,'-')"/></xsl:call-template><xsl:call-template name="dashToCamel"><xsl:with-param name="input" select="substring-after($input,'-')"/></xsl:call-template></xsl:when>
+            <xsl:otherwise><xsl:call-template name="initCap"><xsl:with-param name="input" select="$input"/></xsl:call-template></xsl:otherwise>
+        </xsl:choose>
+    </xsl:template>
+
+    <xsl:template name="dashToLowerCamel">
+        <xsl:param name="input"/>
+        <xsl:call-template name="initLower"><xsl:with-param name="input"><xsl:call-template name="dashToCamel"><xsl:with-param name="input" select="$input"/></xsl:call-template></xsl:with-param></xsl:call-template>
+    </xsl:template>
+</xsl:stylesheet>


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


[2/2] git commit: update the testpeer to use the new constants rather than literals

Posted by ro...@apache.org.
update the testpeer to use the new constants rather than literals


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

Branch: refs/heads/master
Commit: de9672305380bef719f44b49d0a6b644f8750685
Parents: 992460d
Author: Robert Gemmell <ro...@apache.org>
Authored: Tue Oct 28 12:42:54 2014 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Tue Oct 28 12:42:54 2014 +0000

----------------------------------------------------------------------
 .../org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java   | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/de967230/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
index 094668b..7fd48d7 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
@@ -32,6 +32,8 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.qpid.jms.JmsConnectionFactory;
 import org.apache.qpid.jms.provider.amqp.message.AmqpMessageSupport;
+import org.apache.qpid.jms.test.testpeer.basictypes.TerminusDurability;
+import org.apache.qpid.jms.test.testpeer.basictypes.TerminusExpiryPolicy;
 import org.apache.qpid.jms.test.testpeer.describedtypes.Accepted;
 import org.apache.qpid.jms.test.testpeer.describedtypes.AttachFrame;
 import org.apache.qpid.jms.test.testpeer.describedtypes.BeginFrame;
@@ -398,8 +400,8 @@ public class TestAmqpPeer implements AutoCloseable
         TargetMatcher targetMatcher = new TargetMatcher();
         targetMatcher.withAddress(nullValue());
         targetMatcher.withDynamic(equalTo(true));
-        targetMatcher.withDurable(equalTo(UnsignedInteger.valueOf(0)));//TODO: non-literal values for TerminusDurability etc.
-        targetMatcher.withExpiryPolicy(equalTo(Symbol.valueOf("link-detach")));//TODO: non-literal values for ExpiryPolicy etc.
+        targetMatcher.withDurable(equalTo(TerminusDurability.NONE));
+        targetMatcher.withExpiryPolicy(equalTo(TerminusExpiryPolicy.LINK_DETACH));
 
         final AttachMatcher attachMatcher = new AttachMatcher()
                 .withName(notNullValue())
@@ -531,8 +533,8 @@ public class TestAmqpPeer implements AutoCloseable
         sourceMatcher.withAddress(equalTo(topicPrefix + topicName));
         sourceMatcher.withDynamic(equalTo(false));
         //TODO: will possibly be changed to a 1/config durability
-        sourceMatcher.withDurable(equalTo(UnsignedInteger.valueOf(2)));//TODO: non-literal values for TerminusDurability etc.
-        sourceMatcher.withExpiryPolicy(equalTo(Symbol.valueOf("never")));//TODO: non-literal values for ExpiryPolicy etc.
+        sourceMatcher.withDurable(equalTo(TerminusDurability.UNSETTLED_STATE));
+        sourceMatcher.withExpiryPolicy(equalTo(TerminusExpiryPolicy.NEVER));
 
         final AttachMatcher attachMatcher = new AttachMatcher()
                 .withName(equalTo(subscriptionName))


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