From 8a8f41c33b904ef38a8e7844f7f6d00ea254bfe0 Mon Sep 17 00:00:00 2001 From: Robert Davies Date: Thu, 2 Nov 2006 15:47:46 +0000 Subject: [PATCH] Added test to make sure ConnectionFactory is serializable - which is a requirement of the JMS spec git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@470395 13f79535-47bb-0310-9956-ffa450edef68 --- .../ActiveMQConnectionFactoryTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/activemq-core/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java b/activemq-core/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java index 034ad9ca95..4bdba49dba 100755 --- a/activemq-core/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java @@ -17,6 +17,10 @@ */ package org.apache.activemq; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; import java.net.URI; import java.net.URISyntaxException; @@ -106,6 +110,21 @@ public class ActiveMQConnectionFactoryTest extends CombinationTestSupport { } catch (JMSException e) { } } + + public void testFactorySerializable() throws Exception{ + String clientID="TestClientID"; + ActiveMQConnectionFactory cf=new ActiveMQConnectionFactory(); + cf.setClientID(clientID); + ByteArrayOutputStream bytesOut=new ByteArrayOutputStream(); + ObjectOutputStream objectsOut=new ObjectOutputStream(bytesOut); + objectsOut.writeObject(cf); + objectsOut.flush(); + byte[] data=bytesOut.toByteArray(); + ByteArrayInputStream bytesIn=new ByteArrayInputStream(data); + ObjectInputStream objectsIn=new ObjectInputStream(bytesIn); + cf=(ActiveMQConnectionFactory)objectsIn.readObject(); + assertEquals(cf.getClientID(),clientID); + } protected void assertCreateConnection(String uri) throws Exception { // Start up a broker with a tcp connector.