[jboss-cvs] JBoss Messaging SVN: r4596 - in trunk: src/main/org/jboss/messaging/jms/client and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jun 26 10:00:19 EDT 2008


Author: jmesnil
Date: 2008-06-26 10:00:19 -0400 (Thu, 26 Jun 2008)
New Revision: 4596

Added:
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/referenceable/
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/referenceable/ConnectionFactoryObjectFactoryTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/referenceable/DestinationObjectFactoryTest.java
Modified:
   trunk/src/main/org/jboss/messaging/jms/JBossDestination.java
   trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossDestinationTest.java
Log:
added unit tests

Modified: trunk/src/main/org/jboss/messaging/jms/JBossDestination.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/JBossDestination.java	2008-06-26 13:13:37 UTC (rev 4595)
+++ trunk/src/main/org/jboss/messaging/jms/JBossDestination.java	2008-06-26 14:00:19 UTC (rev 4596)
@@ -28,6 +28,7 @@
 import javax.naming.NamingException;
 import javax.naming.Reference;
 
+import org.jboss.messaging.jms.referenceable.DestinationObjectFactory;
 import org.jboss.messaging.jms.referenceable.SerializableObjectRefAddr;
 import org.jboss.messaging.util.SimpleString;
 
@@ -109,9 +110,9 @@
    
    public Reference getReference() throws NamingException
    {
-      return new Reference("org.jboss.jms.destination.JBossDestination",
+      return new Reference(this.getClass().getCanonicalName(),
                            new SerializableObjectRefAddr("JBM-DEST", this),
-                           "org.jboss.jms.referenceable.DestinationObjectFactory",
+                           DestinationObjectFactory.class.getCanonicalName(),
                            null);
    }
 

Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java	2008-06-26 13:13:37 UTC (rev 4595)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java	2008-06-26 14:00:19 UTC (rev 4596)
@@ -48,6 +48,7 @@
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.remoting.impl.RemotingConnectionFactoryImpl;
+import org.jboss.messaging.jms.referenceable.ConnectionFactoryObjectFactory;
 import org.jboss.messaging.jms.referenceable.SerializableObjectRefAddr;
 
 /**
@@ -227,9 +228,9 @@
    
    public Reference getReference() throws NamingException
    {
-      return new Reference("org.jboss.messaging.jms.client.JBossConnectionFactory",
+      return new Reference(this.getClass().getCanonicalName(),
                new SerializableObjectRefAddr("JBM-CF", this),
-               "org.jboss.jms.referenceable.ConnectionFactoryObjectFactory",
+               ConnectionFactoryObjectFactory.class.getCanonicalName(),
                null);
    }
    

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossDestinationTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossDestinationTest.java	2008-06-26 13:13:37 UTC (rev 4595)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossDestinationTest.java	2008-06-26 14:00:19 UTC (rev 4596)
@@ -24,10 +24,12 @@
 
 import static org.jboss.messaging.tests.util.RandomUtil.randomString;
 
+import javax.jms.Destination;
 import javax.jms.Queue;
 import javax.jms.TemporaryQueue;
 import javax.jms.TemporaryTopic;
 import javax.jms.Topic;
+import javax.naming.Reference;
 
 import junit.framework.TestCase;
 
@@ -36,6 +38,7 @@
 import org.jboss.messaging.jms.JBossTemporaryQueue;
 import org.jboss.messaging.jms.JBossTemporaryTopic;
 import org.jboss.messaging.jms.JBossTopic;
+import org.jboss.messaging.jms.referenceable.DestinationObjectFactory;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -55,6 +58,20 @@
 
    // Public --------------------------------------------------------
 
+   public void testEquals() throws Exception
+   {
+      String destinationName = randomString();
+      String address = JBossQueue.JMS_QUEUE_ADDRESS_PREFIX + destinationName;
+      JBossDestination destination = JBossDestination.fromAddress(address);
+      JBossDestination sameDestination = JBossDestination.fromAddress(address);
+      JBossDestination differentDestination = JBossDestination.fromAddress(address + randomString());
+      
+      assertFalse(destination.equals(null));
+      assertTrue(destination.equals(destination));
+      assertTrue(destination.equals(sameDestination));
+      assertFalse(destination.equals(differentDestination));
+   }
+   
    public void testFromAddressWithQueueAddressPrefix() throws Exception
    {
       String destinationName = randomString();
@@ -104,6 +121,7 @@
       {
       }
    }
+
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------

Added: trunk/tests/src/org/jboss/messaging/tests/unit/jms/referenceable/ConnectionFactoryObjectFactoryTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/referenceable/ConnectionFactoryObjectFactoryTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/referenceable/ConnectionFactoryObjectFactoryTest.java	2008-06-26 14:00:19 UTC (rev 4596)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+
+package org.jboss.messaging.tests.unit.jms.referenceable;
+
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import javax.naming.Reference;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.jms.client.JBossConnectionFactory;
+import org.jboss.messaging.jms.referenceable.ConnectionFactoryObjectFactory;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class ConnectionFactoryObjectFactoryTest extends TestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testReference() throws Exception
+   {
+      JBossConnectionFactory cf = new JBossConnectionFactory(randomString(), 1, null, null, 1, 1, 1, 1, true, true, true);
+      Reference reference = cf.getReference();
+
+      ConnectionFactoryObjectFactory factory = new ConnectionFactoryObjectFactory();
+      
+      Object object = factory.getObjectInstance(reference, null, null, null);
+      assertNotNull(object);
+      assertTrue(object instanceof JBossConnectionFactory);
+   }
+   
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Added: trunk/tests/src/org/jboss/messaging/tests/unit/jms/referenceable/DestinationObjectFactoryTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/referenceable/DestinationObjectFactoryTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/referenceable/DestinationObjectFactoryTest.java	2008-06-26 14:00:19 UTC (rev 4596)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+
+package org.jboss.messaging.tests.unit.jms.referenceable;
+
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import javax.naming.Reference;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.jms.JBossDestination;
+import org.jboss.messaging.jms.JBossQueue;
+import org.jboss.messaging.jms.referenceable.DestinationObjectFactory;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class DestinationObjectFactoryTest extends TestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testReference() throws Exception
+   {
+      JBossDestination queue = new JBossQueue(randomString());
+      Reference reference = queue.getReference();
+
+      DestinationObjectFactory factory = new DestinationObjectFactory();
+      Object object = factory.getObjectInstance(reference, null, null, null);
+      assertNotNull(object);
+      assertTrue(object instanceof JBossDestination);
+      assertEquals(queue, object);
+   }
+   
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}




More information about the jboss-cvs-commits mailing list