qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject [2/2] qpid-jms git commit: QPIDJMS-208 Assign the set deserialization policy to new connections.
Date Tue, 20 Sep 2016 15:29:15 GMT
QPIDJMS-208 Assign the set deserialization policy to new connections.

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

Branch: refs/heads/master
Commit: 1c3ff1cbba17bb1f2fe09735abd16d96c1c40339
Parents: 6dd3d2b
Author: Timothy Bish <tabish121@gmail.com>
Authored: Tue Sep 20 11:23:40 2016 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Tue Sep 20 11:23:40 2016 -0400

----------------------------------------------------------------------
 .../apache/qpid/jms/JmsConnectionFactory.java   |  1 +
 .../qpid/jms/JmsConnectionFactoryTest.java      | 24 ++++++++++++++++++++
 .../qpid/jms/SerializationTestSupport.java      | 15 ++++++++++++
 3 files changed, 40 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/1c3ff1cb/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 4105842..c40b9f1 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
@@ -219,6 +219,7 @@ public class JmsConnectionFactory extends JNDIStorable implements ConnectionFact
             connection.setPrefetchPolicy(prefetchPolicy.copy());
             connection.setPresettlePolicy(presettlePolicy.copy());
             connection.setRedeliveryPolicy(redeliveryPolicy.copy());
+            connection.setDeserializationPolicy(deserializationPolicy.copy());
 
             PropertyUtil.setProperties(connection, properties);
             connection.setExceptionListener(exceptionListener);

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/1c3ff1cb/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 48c668b..ea8c867 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
@@ -732,4 +732,28 @@ public class JmsConnectionFactoryTest extends QpidJmsTestCase {
             fail("should throw IllegalArgumentException");
         } catch (IllegalArgumentException ex) {}
     }
+
+    @Test
+    public void testDeserializationPolicyRestsToDefault() {
+        JmsConnectionFactory factory = new JmsConnectionFactory("amqp://127.0.0.1:5672");
+
+        assertNotNull(factory.getDeserializationPolicy());
+        factory.setDeserializationPolicy(null);
+        assertNotNull(factory.getDeserializationPolicy());
+        assertTrue(factory.getDeserializationPolicy() instanceof JmsDefaultDeserializationPolicy);
+    }
+
+    @Test
+    public void testCustomDeserializationPolicyIsAppliedToConnections() throws JMSException
{
+        JmsConnectionFactory factory = new JmsConnectionFactory("mock://127.0.0.1:5672");
+
+        assertNotNull(factory.getDeserializationPolicy());
+        factory.setDeserializationPolicy(new SerializationTestSupport.TestJmsDeserializationPolicy());
+        assertNotNull(factory.getDeserializationPolicy());
+        assertTrue(factory.getDeserializationPolicy() instanceof SerializationTestSupport.TestJmsDeserializationPolicy);
+
+        JmsConnection connection = (JmsConnection) factory.createConnection();
+
+        assertTrue(connection.getDeserializationPolicy() instanceof SerializationTestSupport.TestJmsDeserializationPolicy);
+    }
 }

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/1c3ff1cb/qpid-jms-client/src/test/java/org/apache/qpid/jms/SerializationTestSupport.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/SerializationTestSupport.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/SerializationTestSupport.java
index 0078aaa..bcb2eca 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/SerializationTestSupport.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/SerializationTestSupport.java
@@ -22,6 +22,8 @@ import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
+import org.apache.qpid.jms.policy.JmsDeserializationPolicy;
+
 public class SerializationTestSupport {
 
     public static Object roundTripSerialize(final Object o) throws IOException, ClassNotFoundException
{
@@ -47,4 +49,17 @@ public class SerializationTestSupport {
         ois.close();
         return deserializedObject;
     }
+
+    public static class TestJmsDeserializationPolicy implements JmsDeserializationPolicy
{
+
+        @Override
+        public JmsDeserializationPolicy copy() {
+            return new TestJmsDeserializationPolicy();
+        }
+
+        @Override
+        public boolean isTrustedType(JmsDestination destination, Class<?> clazz) {
+            return true;
+        }
+    }
 }


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


Mime
View raw message