add matchers to the test peer for the various delivery outcomes

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

Branch: refs/heads/master
Commit: 92b50f87b79ec70df4de40e407bc41f8356e7e3a
Parents: d7ea4b1
Author: Robert Gemmell <[email protected]>
Authored: Wed Nov 19 16:03:26 2014 +0000
Committer: Robert Gemmell <[email protected]>
Committed: Wed Nov 19 16:03:26 2014 +0000

----------------------------------------------------------------------
 .../test/testpeer/matchers/AcceptedMatcher.java | 126 ++++++++++++
 .../test/testpeer/matchers/DeclaredMatcher.java | 150 ++++++++++++++
 .../test/testpeer/matchers/ModifiedMatcher.java | 196 +++++++++++++++++++
 .../test/testpeer/matchers/RejectedMatcher.java | 150 ++++++++++++++
 .../test/testpeer/matchers/ReleasedMatcher.java | 126 ++++++++++++
 .../testpeer/matchers/generate-matchers.xsl     |   6 +-
 6 files changed, 751 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/92b50f87/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/AcceptedMatcher.java
----------------------------------------------------------------------
diff --git 
a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/AcceptedMatcher.java
 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/AcceptedMatcher.java
new file mode 100644
index 0000000..b6fae07
--- /dev/null
+++ 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/AcceptedMatcher.java
@@ -0,0 +1,126 @@
+/*
+ * 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.matchers;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+
+import java.util.List;
+
+import org.apache.qpid.proton.amqp.DescribedType;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.jms.test.testpeer.AbstractFieldAndDescriptorMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
+
+/**
+ * Generated by generate-matchers.xsl, which resides in this package.
+ */
+public class AcceptedMatcher extends TypeSafeMatcher<Object>
+{
+    private AcceptedMatcherCore coreMatcher = new AcceptedMatcherCore();
+    private String mismatchTextAddition;
+    private Object described;
+    private Object descriptor;
+
+    public AcceptedMatcher()
+    {
+    }
+
+    @Override
+    protected boolean matchesSafely(Object received)
+    {
+        try
+        {
+            assertThat(received, instanceOf(DescribedType.class));
+            descriptor = ((DescribedType)received).getDescriptor();
+            if(!coreMatcher.descriptorMatches(descriptor))
+            {
+                mismatchTextAddition = "Descriptor mismatch";
+                return false;
+            }
+
+            described = ((DescribedType)received).getDescribed();
+            assertThat(described, instanceOf(List.class));
+            @SuppressWarnings("unchecked")
+            List<Object> fields = (List<Object>) described;
+
+            coreMatcher.verifyFields(fields);
+        }
+        catch (AssertionError ae)
+        {
+            mismatchTextAddition = "AssertionFailure: " + ae.getMessage();
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    protected void describeMismatchSafely(Object item, Description 
mismatchDescription)
+    {
+        mismatchDescription.appendText("\nActual form: ").appendValue(item);
+
+        mismatchDescription.appendText("\nExpected descriptor: ")
+                .appendValue(coreMatcher.getSymbolicDescriptor())
+                .appendText(" / ")
+                .appendValue(coreMatcher.getNumericDescriptor());
+
+        if(mismatchTextAddition != null)
+        {
+            mismatchDescription.appendText("\nAdditional info: 
").appendValue(mismatchTextAddition);
+        }
+    }
+
+    public void describeTo(Description description)
+    {
+        description
+            .appendText("Accepted which matches: ")
+            .appendValue(coreMatcher.getMatchers());
+    }
+
+
+
+
+    //Inner core matching class
+    public static class AcceptedMatcherCore extends 
AbstractFieldAndDescriptorMatcher
+    {
+        /** Note that the ordinals of the Field enums match the order 
specified in the AMQP spec */
+        public enum Field
+        {
+        }
+
+        public AcceptedMatcherCore()
+        {
+            super(UnsignedLong.valueOf(0x0000000000000024L),
+                  Symbol.valueOf("amqp:accepted:list"));
+        }
+
+
+        @Override
+        protected Enum<?> getField(int fieldIndex)
+        {
+            return Field.values()[fieldIndex];
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/92b50f87/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/DeclaredMatcher.java
----------------------------------------------------------------------
diff --git 
a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/DeclaredMatcher.java
 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/DeclaredMatcher.java
new file mode 100644
index 0000000..d78ff63
--- /dev/null
+++ 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/DeclaredMatcher.java
@@ -0,0 +1,150 @@
+/*
+ * 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.matchers;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+
+import java.util.List;
+
+import org.apache.qpid.proton.amqp.DescribedType;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.jms.test.testpeer.AbstractFieldAndDescriptorMatcher;
+import org.hamcrest.Matcher;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
+
+/**
+ * Generated by generate-matchers.xsl, which resides in this package.
+ */
+public class DeclaredMatcher extends TypeSafeMatcher<Object>
+{
+    private DeclaredMatcherCore coreMatcher = new DeclaredMatcherCore();
+    private String mismatchTextAddition;
+    private Object described;
+    private Object descriptor;
+
+    public DeclaredMatcher()
+    {
+    }
+
+    @Override
+    protected boolean matchesSafely(Object received)
+    {
+        try
+        {
+            assertThat(received, instanceOf(DescribedType.class));
+            descriptor = ((DescribedType)received).getDescriptor();
+            if(!coreMatcher.descriptorMatches(descriptor))
+            {
+                mismatchTextAddition = "Descriptor mismatch";
+                return false;
+            }
+
+            described = ((DescribedType)received).getDescribed();
+            assertThat(described, instanceOf(List.class));
+            @SuppressWarnings("unchecked")
+            List<Object> fields = (List<Object>) described;
+
+            coreMatcher.verifyFields(fields);
+        }
+        catch (AssertionError ae)
+        {
+            mismatchTextAddition = "AssertionFailure: " + ae.getMessage();
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    protected void describeMismatchSafely(Object item, Description 
mismatchDescription)
+    {
+        mismatchDescription.appendText("\nActual form: ").appendValue(item);
+
+        mismatchDescription.appendText("\nExpected descriptor: ")
+                .appendValue(coreMatcher.getSymbolicDescriptor())
+                .appendText(" / ")
+                .appendValue(coreMatcher.getNumericDescriptor());
+
+        if(mismatchTextAddition != null)
+        {
+            mismatchDescription.appendText("\nAdditional info: 
").appendValue(mismatchTextAddition);
+        }
+    }
+
+    public void describeTo(Description description)
+    {
+        description
+            .appendText("Declared which matches: ")
+            .appendValue(coreMatcher.getMatchers());
+    }
+
+
+    public DeclaredMatcher withTxnId(Matcher<?> m)
+    {
+        coreMatcher.withTxnId(m);
+        return this;
+    }
+
+    public Object getReceivedTxnId()
+    {
+        return coreMatcher.getReceivedTxnId();
+    }
+
+
+
+    //Inner core matching class
+    public static class DeclaredMatcherCore extends 
AbstractFieldAndDescriptorMatcher
+    {
+        /** Note that the ordinals of the Field enums match the order 
specified in the AMQP spec */
+        public enum Field
+        {
+            TXN_ID,
+        }
+
+        public DeclaredMatcherCore()
+        {
+            super(UnsignedLong.valueOf(0x0000000000000033L),
+                  Symbol.valueOf("amqp:declared:list"));
+        }
+
+
+        public DeclaredMatcherCore withTxnId(Matcher<?> m)
+        {
+            getMatchers().put(Field.TXN_ID, m);
+            return this;
+        }
+
+        public Object getReceivedTxnId()
+        {
+            return getReceivedFields().get(Field.TXN_ID);
+        }
+
+        @Override
+        protected Enum<?> getField(int fieldIndex)
+        {
+            return Field.values()[fieldIndex];
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/92b50f87/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/ModifiedMatcher.java
----------------------------------------------------------------------
diff --git 
a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/ModifiedMatcher.java
 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/ModifiedMatcher.java
new file mode 100644
index 0000000..d70a9a4
--- /dev/null
+++ 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/ModifiedMatcher.java
@@ -0,0 +1,196 @@
+/*
+ * 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.matchers;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+
+import java.util.List;
+
+import org.apache.qpid.proton.amqp.DescribedType;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.jms.test.testpeer.AbstractFieldAndDescriptorMatcher;
+import org.hamcrest.Matcher;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
+
+/**
+ * Generated by generate-matchers.xsl, which resides in this package.
+ */
+public class ModifiedMatcher extends TypeSafeMatcher<Object>
+{
+    private ModifiedMatcherCore coreMatcher = new ModifiedMatcherCore();
+    private String mismatchTextAddition;
+    private Object described;
+    private Object descriptor;
+
+    public ModifiedMatcher()
+    {
+    }
+
+    @Override
+    protected boolean matchesSafely(Object received)
+    {
+        try
+        {
+            assertThat(received, instanceOf(DescribedType.class));
+            descriptor = ((DescribedType)received).getDescriptor();
+            if(!coreMatcher.descriptorMatches(descriptor))
+            {
+                mismatchTextAddition = "Descriptor mismatch";
+                return false;
+            }
+
+            described = ((DescribedType)received).getDescribed();
+            assertThat(described, instanceOf(List.class));
+            @SuppressWarnings("unchecked")
+            List<Object> fields = (List<Object>) described;
+
+            coreMatcher.verifyFields(fields);
+        }
+        catch (AssertionError ae)
+        {
+            mismatchTextAddition = "AssertionFailure: " + ae.getMessage();
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    protected void describeMismatchSafely(Object item, Description 
mismatchDescription)
+    {
+        mismatchDescription.appendText("\nActual form: ").appendValue(item);
+
+        mismatchDescription.appendText("\nExpected descriptor: ")
+                .appendValue(coreMatcher.getSymbolicDescriptor())
+                .appendText(" / ")
+                .appendValue(coreMatcher.getNumericDescriptor());
+
+        if(mismatchTextAddition != null)
+        {
+            mismatchDescription.appendText("\nAdditional info: 
").appendValue(mismatchTextAddition);
+        }
+    }
+
+    public void describeTo(Description description)
+    {
+        description
+            .appendText("Modified which matches: ")
+            .appendValue(coreMatcher.getMatchers());
+    }
+
+
+    public ModifiedMatcher withDeliveryFailed(Matcher<?> m)
+    {
+        coreMatcher.withDeliveryFailed(m);
+        return this;
+    }
+
+    public ModifiedMatcher withUndeliverableHere(Matcher<?> m)
+    {
+        coreMatcher.withUndeliverableHere(m);
+        return this;
+    }
+
+    public ModifiedMatcher withMessageAnnotations(Matcher<?> m)
+    {
+        coreMatcher.withMessageAnnotations(m);
+        return this;
+    }
+
+    public Object getReceivedDeliveryFailed()
+    {
+        return coreMatcher.getReceivedDeliveryFailed();
+    }
+
+    public Object getReceivedUndeliverableHere()
+    {
+        return coreMatcher.getReceivedUndeliverableHere();
+    }
+
+    public Object getReceivedMessageAnnotations()
+    {
+        return coreMatcher.getReceivedMessageAnnotations();
+    }
+
+
+
+    //Inner core matching class
+    public static class ModifiedMatcherCore extends 
AbstractFieldAndDescriptorMatcher
+    {
+        /** Note that the ordinals of the Field enums match the order 
specified in the AMQP spec */
+        public enum Field
+        {
+            DELIVERY_FAILED,
+            UNDELIVERABLE_HERE,
+            MESSAGE_ANNOTATIONS,
+        }
+
+        public ModifiedMatcherCore()
+        {
+            super(UnsignedLong.valueOf(0x0000000000000027L),
+                  Symbol.valueOf("amqp:modified:list"));
+        }
+
+
+        public ModifiedMatcherCore withDeliveryFailed(Matcher<?> m)
+        {
+            getMatchers().put(Field.DELIVERY_FAILED, m);
+            return this;
+        }
+
+        public ModifiedMatcherCore withUndeliverableHere(Matcher<?> m)
+        {
+            getMatchers().put(Field.UNDELIVERABLE_HERE, m);
+            return this;
+        }
+
+        public ModifiedMatcherCore withMessageAnnotations(Matcher<?> m)
+        {
+            getMatchers().put(Field.MESSAGE_ANNOTATIONS, m);
+            return this;
+        }
+
+        public Object getReceivedDeliveryFailed()
+        {
+            return getReceivedFields().get(Field.DELIVERY_FAILED);
+        }
+
+        public Object getReceivedUndeliverableHere()
+        {
+            return getReceivedFields().get(Field.UNDELIVERABLE_HERE);
+        }
+
+        public Object getReceivedMessageAnnotations()
+        {
+            return getReceivedFields().get(Field.MESSAGE_ANNOTATIONS);
+        }
+
+        @Override
+        protected Enum<?> getField(int fieldIndex)
+        {
+            return Field.values()[fieldIndex];
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/92b50f87/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/RejectedMatcher.java
----------------------------------------------------------------------
diff --git 
a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/RejectedMatcher.java
 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/RejectedMatcher.java
new file mode 100644
index 0000000..6c78b94
--- /dev/null
+++ 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/RejectedMatcher.java
@@ -0,0 +1,150 @@
+/*
+ * 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.matchers;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+
+import java.util.List;
+
+import org.apache.qpid.proton.amqp.DescribedType;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.jms.test.testpeer.AbstractFieldAndDescriptorMatcher;
+import org.hamcrest.Matcher;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
+
+/**
+ * Generated by generate-matchers.xsl, which resides in this package.
+ */
+public class RejectedMatcher extends TypeSafeMatcher<Object>
+{
+    private RejectedMatcherCore coreMatcher = new RejectedMatcherCore();
+    private String mismatchTextAddition;
+    private Object described;
+    private Object descriptor;
+
+    public RejectedMatcher()
+    {
+    }
+
+    @Override
+    protected boolean matchesSafely(Object received)
+    {
+        try
+        {
+            assertThat(received, instanceOf(DescribedType.class));
+            descriptor = ((DescribedType)received).getDescriptor();
+            if(!coreMatcher.descriptorMatches(descriptor))
+            {
+                mismatchTextAddition = "Descriptor mismatch";
+                return false;
+            }
+
+            described = ((DescribedType)received).getDescribed();
+            assertThat(described, instanceOf(List.class));
+            @SuppressWarnings("unchecked")
+            List<Object> fields = (List<Object>) described;
+
+            coreMatcher.verifyFields(fields);
+        }
+        catch (AssertionError ae)
+        {
+            mismatchTextAddition = "AssertionFailure: " + ae.getMessage();
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    protected void describeMismatchSafely(Object item, Description 
mismatchDescription)
+    {
+        mismatchDescription.appendText("\nActual form: ").appendValue(item);
+
+        mismatchDescription.appendText("\nExpected descriptor: ")
+                .appendValue(coreMatcher.getSymbolicDescriptor())
+                .appendText(" / ")
+                .appendValue(coreMatcher.getNumericDescriptor());
+
+        if(mismatchTextAddition != null)
+        {
+            mismatchDescription.appendText("\nAdditional info: 
").appendValue(mismatchTextAddition);
+        }
+    }
+
+    public void describeTo(Description description)
+    {
+        description
+            .appendText("Rejected which matches: ")
+            .appendValue(coreMatcher.getMatchers());
+    }
+
+
+    public RejectedMatcher withError(Matcher<?> m)
+    {
+        coreMatcher.withError(m);
+        return this;
+    }
+
+    public Object getReceivedError()
+    {
+        return coreMatcher.getReceivedError();
+    }
+
+
+
+    //Inner core matching class
+    public static class RejectedMatcherCore extends 
AbstractFieldAndDescriptorMatcher
+    {
+        /** Note that the ordinals of the Field enums match the order 
specified in the AMQP spec */
+        public enum Field
+        {
+            ERROR,
+        }
+
+        public RejectedMatcherCore()
+        {
+            super(UnsignedLong.valueOf(0x0000000000000025L),
+                  Symbol.valueOf("amqp:rejected:list"));
+        }
+
+
+        public RejectedMatcherCore withError(Matcher<?> m)
+        {
+            getMatchers().put(Field.ERROR, m);
+            return this;
+        }
+
+        public Object getReceivedError()
+        {
+            return getReceivedFields().get(Field.ERROR);
+        }
+
+        @Override
+        protected Enum<?> getField(int fieldIndex)
+        {
+            return Field.values()[fieldIndex];
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/92b50f87/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/ReleasedMatcher.java
----------------------------------------------------------------------
diff --git 
a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/ReleasedMatcher.java
 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/ReleasedMatcher.java
new file mode 100644
index 0000000..f45b249
--- /dev/null
+++ 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/ReleasedMatcher.java
@@ -0,0 +1,126 @@
+/*
+ * 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.matchers;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+
+import java.util.List;
+
+import org.apache.qpid.proton.amqp.DescribedType;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.jms.test.testpeer.AbstractFieldAndDescriptorMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
+
+/**
+ * Generated by generate-matchers.xsl, which resides in this package.
+ */
+public class ReleasedMatcher extends TypeSafeMatcher<Object>
+{
+    private ReleasedMatcherCore coreMatcher = new ReleasedMatcherCore();
+    private String mismatchTextAddition;
+    private Object described;
+    private Object descriptor;
+
+    public ReleasedMatcher()
+    {
+    }
+
+    @Override
+    protected boolean matchesSafely(Object received)
+    {
+        try
+        {
+            assertThat(received, instanceOf(DescribedType.class));
+            descriptor = ((DescribedType)received).getDescriptor();
+            if(!coreMatcher.descriptorMatches(descriptor))
+            {
+                mismatchTextAddition = "Descriptor mismatch";
+                return false;
+            }
+
+            described = ((DescribedType)received).getDescribed();
+            assertThat(described, instanceOf(List.class));
+            @SuppressWarnings("unchecked")
+            List<Object> fields = (List<Object>) described;
+
+            coreMatcher.verifyFields(fields);
+        }
+        catch (AssertionError ae)
+        {
+            mismatchTextAddition = "AssertionFailure: " + ae.getMessage();
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    protected void describeMismatchSafely(Object item, Description 
mismatchDescription)
+    {
+        mismatchDescription.appendText("\nActual form: ").appendValue(item);
+
+        mismatchDescription.appendText("\nExpected descriptor: ")
+                .appendValue(coreMatcher.getSymbolicDescriptor())
+                .appendText(" / ")
+                .appendValue(coreMatcher.getNumericDescriptor());
+
+        if(mismatchTextAddition != null)
+        {
+            mismatchDescription.appendText("\nAdditional info: 
").appendValue(mismatchTextAddition);
+        }
+    }
+
+    public void describeTo(Description description)
+    {
+        description
+            .appendText("Released which matches: ")
+            .appendValue(coreMatcher.getMatchers());
+    }
+
+
+
+
+    //Inner core matching class
+    public static class ReleasedMatcherCore extends 
AbstractFieldAndDescriptorMatcher
+    {
+        /** Note that the ordinals of the Field enums match the order 
specified in the AMQP spec */
+        public enum Field
+        {
+        }
+
+        public ReleasedMatcherCore()
+        {
+            super(UnsignedLong.valueOf(0x0000000000000026L),
+                  Symbol.valueOf("amqp:released:list"));
+        }
+
+
+        @Override
+        protected Enum<?> getField(int fieldIndex)
+        {
+            return Field.values()[fieldIndex];
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/92b50f87/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/generate-matchers.xsl
----------------------------------------------------------------------
diff --git 
a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/generate-matchers.xsl
 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/generate-matchers.xsl
index 4a8c422..52bbea1 100644
--- 
a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/generate-matchers.xsl
+++ 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/generate-matchers.xsl
@@ -46,7 +46,7 @@
           </xsl:call-template>
         </xsl:if>
 
-        <xsl:if test="@provides = 'source' or @provides = 'target' or 
@name='transactional-state'">
+        <xsl:if test="@provides = 'source' or @provides = 'target' or 
@name='transactional-state'  or @provides='delivery-state, outcome'">
           <xsl:variable name="typename"><xsl:call-template 
name="dashToCamel"><xsl:with-param name="input" 
select="@name"/></xsl:call-template></xsl:variable>
           <xsl:call-template name="fieldClass">
               <xsl:with-param name="license" select="$license"/>
@@ -143,8 +143,8 @@ import java.util.List;
 import org.apache.qpid.proton.amqp.DescribedType;
 import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.apache.qpid.jms.test.testpeer.AbstractFieldAndDescriptorMatcher;
-import org.hamcrest.Matcher;
+import 
org.apache.qpid.jms.test.testpeer.AbstractFieldAndDescriptorMatcher;<xsl:if 
test="@name != 'accepted' and @name != 'released'">
+import org.hamcrest.Matcher;</xsl:if>
 import org.hamcrest.Description;
 import org.hamcrest.TypeSafeMatcher;
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to