[jboss-cvs] JBoss Messaging SVN: r4533 - trunk/tests/src/org/jboss/messaging/tests/unit/jms.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jun 20 07:40:32 EDT 2008
Author: jmesnil
Date: 2008-06-20 07:40:31 -0400 (Fri, 20 Jun 2008)
New Revision: 4533
Added:
trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossDestinationTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossQueueTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossTemporaryQueueTest.java
Log:
added unit tests for JBossDestination & subclasses
Added: trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossDestinationTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossDestinationTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossDestinationTest.java 2008-06-20 11:40:31 UTC (rev 4533)
@@ -0,0 +1,114 @@
+/*
+ * 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;
+
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import javax.jms.Queue;
+import javax.jms.TemporaryQueue;
+import javax.jms.TemporaryTopic;
+import javax.jms.Topic;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.jms.JBossDestination;
+import org.jboss.messaging.jms.JBossQueue;
+import org.jboss.messaging.jms.JBossTemporaryQueue;
+import org.jboss.messaging.jms.JBossTemporaryTopic;
+import org.jboss.messaging.jms.JBossTopic;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class JBossDestinationTest extends TestCase
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testFromAddressWithQueueAddressPrefix() throws Exception
+ {
+ String destinationName = randomString();
+ String address = JBossQueue.JMS_QUEUE_ADDRESS_PREFIX + destinationName;
+ JBossDestination destination = JBossDestination.fromAddress(address);
+ assertTrue(destination instanceof Queue);
+ assertEquals(destinationName, ((Queue)destination).getQueueName());
+ }
+
+ public void testFromAddressWithTopicAddressPrefix() throws Exception
+ {
+ String destinationName = randomString();
+ String address = JBossTopic.JMS_TOPIC_ADDRESS_PREFIX + destinationName;
+ JBossDestination destination = JBossDestination.fromAddress(address);
+ assertTrue(destination instanceof Topic);
+ assertEquals(destinationName, ((Topic)destination).getTopicName());
+ }
+
+ public void testFromAddressWithTemporaryQueueAddressPrefix() throws Exception
+ {
+ String destinationName = randomString();
+ String address = JBossTemporaryQueue.JMS_TEMP_QUEUE_ADDRESS_PREFIX + destinationName;
+ JBossDestination destination = JBossDestination.fromAddress(address);
+ assertTrue(destination instanceof TemporaryQueue);
+ assertEquals(destinationName, ((TemporaryQueue)destination).getQueueName());
+ }
+
+ public void testFromAddressWithTemporaryTopicAddressPrefix() throws Exception
+ {
+ String destinationName = randomString();
+ String address = JBossTemporaryTopic.JMS_TEMP_TOPIC_ADDRESS_PREFIX + destinationName;
+ JBossDestination destination = JBossDestination.fromAddress(address);
+ assertTrue(destination instanceof TemporaryTopic);
+ assertEquals(destinationName, ((TemporaryTopic)destination).getTopicName());
+ }
+
+ public void testFromAddressWithInvalidPrefix() throws Exception
+ {
+ String invalidPrefix = "junk";
+ String destinationName = randomString();
+ String address = invalidPrefix + destinationName;
+ try
+ {
+ JBossDestination.fromAddress(address);
+ fail("IllegalArgumentException");
+ } catch (IllegalArgumentException e)
+ {
+ }
+ }
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossQueueTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossQueueTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossQueueTest.java 2008-06-20 11:40:31 UTC (rev 4533)
@@ -0,0 +1,69 @@
+/*
+ * 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;
+
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+import junit.framework.TestCase;
+
+import org.jboss.messaging.jms.JBossQueue;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class JBossQueueTest extends TestCase
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testIsTemporary() throws Exception
+ {
+ JBossQueue queue = new JBossQueue(randomString());
+ assertFalse(queue.isTemporary());
+ }
+
+ public void testGetQueueName() throws Exception
+ {
+ String queueName = randomString();
+ JBossQueue queue = new JBossQueue(queueName);
+ assertEquals(queueName, queue.getQueueName());
+ }
+
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossTemporaryQueueTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossTemporaryQueueTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/JBossTemporaryQueueTest.java 2008-06-20 11:40:31 UTC (rev 4533)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-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;
+
+import static org.easymock.EasyMock.isA;
+import static org.easymock.classextension.EasyMock.createStrictMock;
+import static org.easymock.classextension.EasyMock.replay;
+import static org.easymock.classextension.EasyMock.verify;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+import junit.framework.TestCase;
+
+import org.jboss.messaging.jms.JBossTemporaryQueue;
+import org.jboss.messaging.jms.client.JBossSession;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class JBossTemporaryQueueTest extends TestCase
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testIsTemporary() throws Exception
+ {
+ String queueName = randomString();
+ JBossSession session = createStrictMock(JBossSession.class);
+ replay(session);
+
+ JBossTemporaryQueue tempQueue = new JBossTemporaryQueue(session,
+ queueName);
+ assertEquals(true, tempQueue.isTemporary());
+
+ verify(session);
+ }
+
+ public void testDelete() throws Exception
+ {
+ String queueName = randomString();
+ JBossSession session = createStrictMock(JBossSession.class);
+ session.deleteTemporaryQueue(isA(JBossTemporaryQueue.class));
+ replay(session);
+
+ JBossTemporaryQueue tempQueue = new JBossTemporaryQueue(session,
+ queueName);
+ tempQueue.delete();
+
+ verify(session);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
More information about the jboss-cvs-commits
mailing list