[jboss-cvs] JBoss Messaging SVN: r4506 - trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/invm.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jun 17 12:15:35 EDT 2008
Author: ataylor
Date: 2008-06-17 12:15:35 -0400 (Tue, 17 Jun 2008)
New Revision: 4506
Added:
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/invm/INVMAcceptorTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/invm/INVMConnectorTest.java
Log:
new tests
Added: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/invm/INVMAcceptorTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/invm/INVMAcceptorTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/invm/INVMAcceptorTest.java 2008-06-17 16:15:35 UTC (rev 4506)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * 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.core.remoting.impl.invm;
+
+import org.easymock.EasyMock;
+import org.jboss.messaging.core.client.Location;
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.remoting.*;
+import org.jboss.messaging.core.remoting.impl.invm.INVMAcceptor;
+import org.jboss.messaging.tests.util.UnitTestCase;
+
+/**
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class INVMAcceptorTest extends UnitTestCase
+{
+ public void testStart() throws Exception
+ {
+ try
+ {
+ RemotingService remotingService = EasyMock.createStrictMock(RemotingService.class);
+ CleanUpNotifier cleanUpNotifier = EasyMock.createStrictMock(CleanUpNotifier.class);
+ final ConnectorRegistry connectorRegistry = EasyMock.createStrictMock(ConnectorRegistry.class);
+ ConnectorRegistryFactory.setRegisteryLocator(new ConnectorRegistryLocator()
+ {
+ public ConnectorRegistry locate()
+ {
+ return connectorRegistry;
+ }
+ });
+ Configuration conf = EasyMock.createStrictMock(Configuration.class);
+ Location location = EasyMock.createStrictMock(Location.class);
+
+ EasyMock.expect(remotingService.getConfiguration()).andReturn(conf).anyTimes();
+ EasyMock.expect(conf.getLocation()).andReturn(location).anyTimes();
+ PacketDispatcher packetDispatcher = EasyMock.createStrictMock(PacketDispatcher.class);
+ EasyMock.expect(remotingService.getDispatcher()).andReturn(packetDispatcher);
+ EasyMock.expect(connectorRegistry.register(location, packetDispatcher)).andReturn(true);
+ EasyMock.replay(remotingService, cleanUpNotifier, packetDispatcher, connectorRegistry, conf, location);
+
+ INVMAcceptor invmAcceptor = new INVMAcceptor();
+ invmAcceptor.startAccepting(remotingService, cleanUpNotifier);
+
+ EasyMock.verify(remotingService, cleanUpNotifier, packetDispatcher, connectorRegistry, conf, location);
+ }
+ finally
+ {
+ ConnectorRegistryFactory.setRegisteryLocator(null);
+ }
+ }
+
+ public void testStop() throws Exception
+ {
+ try
+ {
+ RemotingService remotingService = EasyMock.createStrictMock(RemotingService.class);
+ CleanUpNotifier cleanUpNotifier = EasyMock.createStrictMock(CleanUpNotifier.class);
+ final ConnectorRegistry connectorRegistry = EasyMock.createStrictMock(ConnectorRegistry.class);
+ ConnectorRegistryFactory.setRegisteryLocator(new ConnectorRegistryLocator()
+ {
+ public ConnectorRegistry locate()
+ {
+ return connectorRegistry;
+ }
+ });
+ Configuration conf = EasyMock.createStrictMock(Configuration.class);
+ Location location = EasyMock.createStrictMock(Location.class);
+
+ EasyMock.expect(remotingService.getConfiguration()).andReturn(conf).anyTimes();
+ EasyMock.expect(conf.getLocation()).andReturn(location).anyTimes();
+ PacketDispatcher packetDispatcher = EasyMock.createStrictMock(PacketDispatcher.class);
+ EasyMock.expect(remotingService.getDispatcher()).andReturn(packetDispatcher);
+ EasyMock.expect(connectorRegistry.register(location, packetDispatcher)).andReturn(true);
+ EasyMock.replay(remotingService, cleanUpNotifier, packetDispatcher, connectorRegistry, conf, location);
+
+ INVMAcceptor invmAcceptor = new INVMAcceptor();
+ invmAcceptor.startAccepting(remotingService, cleanUpNotifier);
+
+ EasyMock.verify(remotingService, cleanUpNotifier, packetDispatcher, connectorRegistry, conf, location);
+
+ EasyMock.reset(remotingService, cleanUpNotifier, packetDispatcher, connectorRegistry, conf, location);
+ EasyMock.expect(remotingService.getConfiguration()).andReturn(conf).anyTimes();
+ EasyMock.expect(conf.getLocation()).andReturn(location).anyTimes();
+ EasyMock.expect(connectorRegistry.unregister(location)).andReturn(true);
+ EasyMock.replay(remotingService, cleanUpNotifier, packetDispatcher, connectorRegistry, conf, location);
+ invmAcceptor.stopAccepting();
+
+ EasyMock.verify(remotingService, cleanUpNotifier, packetDispatcher, connectorRegistry, conf, location);
+ }
+ finally
+ {
+ ConnectorRegistryFactory.setRegisteryLocator(null);
+ }
+ }
+}
Added: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/invm/INVMConnectorTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/invm/INVMConnectorTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/invm/INVMConnectorTest.java 2008-06-17 16:15:35 UTC (rev 4506)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * 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.core.remoting.impl.invm;
+
+import org.easymock.EasyMock;
+import org.jboss.messaging.core.client.ConnectionParams;
+import org.jboss.messaging.core.client.Location;
+import org.jboss.messaging.core.remoting.PacketDispatcher;
+import org.jboss.messaging.core.remoting.RemotingSession;
+import org.jboss.messaging.core.remoting.impl.invm.INVMConnector;
+import org.jboss.messaging.tests.util.UnitTestCase;
+
+/**
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class INVMConnectorTest extends UnitTestCase
+{
+ public void testConnect() throws Exception
+ {
+ Location location = EasyMock.createStrictMock(Location.class);
+ ConnectionParams connectionParams = EasyMock.createStrictMock(ConnectionParams.class);
+ PacketDispatcher clientPacketDispatcher = EasyMock.createStrictMock(PacketDispatcher.class);
+ PacketDispatcher serverPacketDispatcher = EasyMock.createStrictMock(PacketDispatcher.class);
+ INVMConnector invmConnector = new INVMConnector(location, connectionParams, 0, clientPacketDispatcher, serverPacketDispatcher);
+ EasyMock.replay(location, connectionParams, clientPacketDispatcher, serverPacketDispatcher);
+ RemotingSession remotingSession = invmConnector.connect();
+ assertNotNull(remotingSession);
+ assertEquals(invmConnector.getConnectionParams(), connectionParams);
+ assertEquals(invmConnector.getDispatcher(), clientPacketDispatcher);
+ assertEquals(invmConnector.getLocation(), location);
+ EasyMock.verify(location, connectionParams, clientPacketDispatcher, serverPacketDispatcher);
+ }
+
+ public void testDisconnect() throws Exception
+ {
+ Location location = EasyMock.createStrictMock(Location.class);
+ ConnectionParams connectionParams = EasyMock.createStrictMock(ConnectionParams.class);
+ PacketDispatcher clientPacketDispatcher = EasyMock.createStrictMock(PacketDispatcher.class);
+ PacketDispatcher serverPacketDispatcher = EasyMock.createStrictMock(PacketDispatcher.class);
+ INVMConnector invmConnector = new INVMConnector(location, connectionParams, 0, clientPacketDispatcher, serverPacketDispatcher);
+ EasyMock.replay(location, connectionParams, clientPacketDispatcher, serverPacketDispatcher);
+ RemotingSession remotingSession = invmConnector.connect();
+ assertNotNull(remotingSession);
+ assertEquals(invmConnector.getConnectionParams(), connectionParams);
+ assertEquals(invmConnector.getDispatcher(), clientPacketDispatcher);
+ assertEquals(invmConnector.getLocation(), location);
+ EasyMock.verify(location, connectionParams, clientPacketDispatcher, serverPacketDispatcher);
+
+ EasyMock.reset(location, connectionParams, clientPacketDispatcher, serverPacketDispatcher);
+ invmConnector.disconnect();
+ EasyMock.replay(location, connectionParams, clientPacketDispatcher, serverPacketDispatcher);
+ EasyMock.verify(location, connectionParams, clientPacketDispatcher, serverPacketDispatcher);
+ }
+}
More information about the jboss-cvs-commits
mailing list