Repository: qpid-jms
Updated Branches:
  refs/heads/master 12decc453 -> a82fd3ab2


add test when factory is serialized with a global exception listener set, add 
note to javadoc to signal behaviour


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

Branch: refs/heads/master
Commit: a82fd3ab2f5604ebb603e3799112538c016c2c94
Parents: 48e0708
Author: Robert Gemmell <[email protected]>
Authored: Tue Jan 27 13:29:21 2015 +0000
Committer: Robert Gemmell <[email protected]>
Committed: Tue Jan 27 14:42:04 2015 +0000

----------------------------------------------------------------------
 .../apache/qpid/jms/JmsConnectionFactory.java   |  4 ++-
 .../qpid/jms/JmsConnectionFactoryTest.java      | 33 ++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/a82fd3ab/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnectionFactory.java
----------------------------------------------------------------------
diff --git 
a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnectionFactory.java 
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnectionFactory.java
index f2b2337..eddc116 100644
--- 
a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnectionFactory.java
+++ 
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnectionFactory.java
@@ -567,6 +567,8 @@ public class JmsConnectionFactory extends JNDIStorable 
implements ConnectionFact
      * Gets the currently configured JMS ExceptionListener that will be set on 
all
      * new Connection objects created from this factory.
      *
+     * NOTE: the listener object is not saved when serializing the factory.
+     *
      * @return the currently configured JMS ExceptionListener.
      */
     public ExceptionListener getExceptionListener() {
@@ -578,7 +580,7 @@ public class JmsConnectionFactory extends JNDIStorable 
implements ConnectionFact
      * created from this factory.
      *
      * @param exceptionListener
-     *        the JMS ExceptionListenenr to apply to new Connection's or null 
to clear.
+     *        the JMS ExceptionListener to apply to new Connection's or null 
to clear.
      */
     public void setExceptionListener(ExceptionListener exceptionListener) {
         this.exceptionListener = exceptionListener;

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/a82fd3ab/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionFactoryTest.java
----------------------------------------------------------------------
diff --git 
a/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionFactoryTest.java
 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionFactoryTest.java
index a99eaae..226a195 100644
--- 
a/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionFactoryTest.java
+++ 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionFactoryTest.java
@@ -20,6 +20,7 @@ import static 
org.apache.qpid.jms.SerializationTestSupport.roundTripSerialize;
 import static org.apache.qpid.jms.SerializationTestSupport.serialize;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -28,7 +29,9 @@ import static org.junit.Assert.fail;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.jms.ExceptionListener;
 import javax.jms.IllegalStateException;
+import javax.jms.JMSException;
 
 import org.apache.qpid.jms.test.QpidJmsTestCase;
 import org.junit.Test;
@@ -181,4 +184,34 @@ public class JmsConnectionFactoryTest extends 
QpidJmsTestCase {
             // Expected, pass
         }
     }
+
+    /**
+     * Verify that the 'global' exception listener set on the connection 
factory
+     * is ignored when the factory gets serialized.
+     */
+    @Test
+    public void testSerializeThenDeserializeIgnoresGlobalExceptionListener() 
throws Exception {
+        String uri = "amqp://localhost:1234";
+
+        JmsConnectionFactory cf = new JmsConnectionFactory(uri);
+        cf.setExceptionListener(new ExceptionListener() {
+            @Override
+            public void onException(JMSException exception) {
+                // Nothing
+            }
+        });
+
+        Map<String, String> props = cf.getProperties();
+
+        Object roundTripped = roundTripSerialize(cf);
+
+        assertNotNull("Null object returned", roundTripped);
+        assertEquals("Unexpected type", JmsConnectionFactory.class, 
roundTripped.getClass());
+        assertEquals("Unexpected uri", uri, 
((JmsConnectionFactory)roundTripped).getRemoteURI());
+
+        Map<String, String> props2 = 
((JmsConnectionFactory)roundTripped).getProperties();
+
+        assertFalse("Properties map should not contain ExceptionListener", 
props.containsKey("exceptionListener"));
+        assertEquals("Properties were not equal", props, props2);
+    }
 }


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

Reply via email to