[jboss-cvs] JBoss Messaging SVN: r4426 - in trunk: src/main/org/jboss/messaging/core/remoting and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 11 07:04:37 EDT 2008
Author: ataylor
Date: 2008-06-11 07:04:37 -0400 (Wed, 11 Jun 2008)
New Revision: 4426
Added:
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/ConnectorRegistryImplTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/PacketDispatcherTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingConfigurationValidatorTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingConnectionFactoryImplTest.java
Removed:
trunk/src/main/org/jboss/messaging/core/client/impl/ServerPingerImpl.java
trunk/src/main/org/jboss/messaging/core/remoting/KeepAliveHandler.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/ClientKeepAliveHandler.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/ClientKeepAliveHandlerTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/ConnectorRegistryTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/PacketDispatcherTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/RemotingConfigurationValidatorTest.java
Modified:
trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingConnectionTest.java
Log:
updated tests and removed un referenced classes
Deleted: trunk/src/main/org/jboss/messaging/core/client/impl/ServerPingerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ServerPingerImpl.java 2008-06-10 22:49:14 UTC (rev 4425)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ServerPingerImpl.java 2008-06-11 11:04:37 UTC (rev 4426)
@@ -1,74 +0,0 @@
-/*
- * 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.core.client.impl;
-
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.remoting.KeepAliveHandler;
-import org.jboss.messaging.core.remoting.Packet;
-import org.jboss.messaging.core.remoting.PacketHandler;
-import org.jboss.messaging.core.remoting.PacketReturner;
-import org.jboss.messaging.core.remoting.impl.wireformat.Ping;
-import org.jboss.messaging.core.remoting.impl.wireformat.Pong;
-
-/**
- * @author <a href="ataylor at redhat.com">Andy Taylor</a>
- */
-public class ServerPingerImpl implements PacketHandler
-{
- private static Logger log = Logger.getLogger(ServerPingerImpl.class);
- private static boolean traceEnabled = log.isTraceEnabled();
- private long id;
- KeepAliveHandler keepAliveHandler;
-
- public ServerPingerImpl(KeepAliveHandler keepAliveHandler, Long id)
- {
- this.keepAliveHandler = keepAliveHandler;
- this.id = id;
- }
-
- public long getID()
- {
- return id;
- }
-
- public void handle(Packet packet, PacketReturner sender)
- {
- Ping ping = (Ping) packet;
- if(traceEnabled)
- {
- log.trace("received ping:" + ping);
- }
- Pong pong = keepAliveHandler.ping(ping);
-
- if(pong != null)
- {
- try
- {
- sender.send(pong);
- }
- catch (Exception e)
- {
- log.warn("error sending pong to server", e);
- }
- }
- }
-}
Deleted: trunk/src/main/org/jboss/messaging/core/remoting/KeepAliveHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/KeepAliveHandler.java 2008-06-10 22:49:14 UTC (rev 4425)
+++ trunk/src/main/org/jboss/messaging/core/remoting/KeepAliveHandler.java 2008-06-11 11:04:37 UTC (rev 4426)
@@ -1,14 +0,0 @@
-package org.jboss.messaging.core.remoting;
-
-import org.jboss.messaging.core.remoting.impl.wireformat.Ping;
-import org.jboss.messaging.core.remoting.impl.wireformat.Pong;
-
-/**
- * pluggable component that defines how a client responds to a server ping command
- *
- * @author <a href="ataylor at redhat.com">Andy Taylor</a>
- */
-public interface KeepAliveHandler
-{
- Pong ping(Ping pong);
-}
Deleted: trunk/src/main/org/jboss/messaging/core/remoting/impl/ClientKeepAliveHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/ClientKeepAliveHandler.java 2008-06-10 22:49:14 UTC (rev 4425)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/ClientKeepAliveHandler.java 2008-06-11 11:04:37 UTC (rev 4426)
@@ -1,43 +0,0 @@
-/*
- * 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.core.remoting.impl;
-
-import org.jboss.messaging.core.remoting.KeepAliveHandler;
-import org.jboss.messaging.core.remoting.NIOConnector;
-import org.jboss.messaging.core.remoting.impl.wireformat.Ping;
-import org.jboss.messaging.core.remoting.impl.wireformat.Pong;
-
-/**
- * pluggable component that defines how a client responds to a server ping command. This simple implementation returns a
- * valid pong
- * @author <a href="ataylor at redhat.com">Andy Taylor</a>
- */
-public class ClientKeepAliveHandler implements KeepAliveHandler
-{
-
- public Pong ping(Ping ping)
- {
- Pong pong = new Pong(ping.getSessionID(), false);
- pong.setTargetID(ping.getResponseTargetID());
- return pong;
- }
-}
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java 2008-06-10 22:49:14 UTC (rev 4425)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java 2008-06-11 11:04:37 UTC (rev 4426)
@@ -6,12 +6,6 @@
*/
package org.jboss.messaging.core.remoting.impl.mina;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ExecutorService;
-
-import org.apache.mina.common.AttributeKey;
import org.apache.mina.common.IoHandlerAdapter;
import org.apache.mina.common.IoSession;
import org.jboss.messaging.core.exception.MessagingException;
@@ -22,15 +16,18 @@
import org.jboss.messaging.core.remoting.PacketReturner;
import org.jboss.messaging.util.OrderedExecutorFactory;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
+
/**
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
* @version <tt>$Revision$</tt>
- *
*/
public class MinaHandler extends IoHandlerAdapter implements
- PacketHandlerRegistrationListener
+ PacketHandlerRegistrationListener
{
// Constants -----------------------------------------------------
@@ -54,6 +51,7 @@
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
+
public MinaHandler(final PacketDispatcher dispatcher,
final ExecutorService executorService,
final CleanUpNotifier failureNotifier,
@@ -95,7 +93,7 @@
@Override
public void exceptionCaught(final IoSession session, final Throwable cause)
- throws Exception
+ throws Exception
{
log.error("caught exception " + cause + " for session " + session, cause);
@@ -103,7 +101,7 @@
{
long serverSessionID = session.getId();
MessagingException me = new MessagingException(
- MessagingException.INTERNAL_ERROR, "unexpected exception");
+ MessagingException.INTERNAL_ERROR, "unexpected exception");
me.initCause(cause);
failureNotifier.fireCleanup(serverSessionID, me);
}
@@ -115,7 +113,7 @@
@Override
public void messageReceived(final IoSession session, final Object message)
- throws Exception
+ throws Exception
{
final Packet packet = (Packet) message;
@@ -165,7 +163,7 @@
// Private -------------------------------------------------------
private void messageReceivedInternal(final IoSession session, Packet packet)
- throws Exception
+ throws Exception
{
PacketReturner returner;
Deleted: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/ClientKeepAliveHandlerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/ClientKeepAliveHandlerTest.java 2008-06-10 22:49:14 UTC (rev 4425)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/ClientKeepAliveHandlerTest.java 2008-06-11 11:04:37 UTC (rev 4426)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.tests.unit.core.remoting;
-
-import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
-import junit.framework.TestCase;
-
-import org.jboss.messaging.core.remoting.impl.ClientKeepAliveHandler;
-import org.jboss.messaging.core.remoting.impl.wireformat.Ping;
-import org.jboss.messaging.core.remoting.impl.wireformat.Pong;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public class ClientKeepAliveHandlerTest extends TestCase
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void testPing() throws Exception
- {
- ClientKeepAliveHandler handler = new ClientKeepAliveHandler();
-
- Ping ping = new Ping(randomLong());
- Pong pong = handler.ping(ping);
-
- assertEquals(ping.getSessionID(), pong.getSessionID());
- assertEquals(ping.getResponseTargetID(), pong.getTargetID());
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/ConnectorRegistryTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/ConnectorRegistryTest.java 2008-06-10 22:49:14 UTC (rev 4425)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/ConnectorRegistryTest.java 2008-06-11 11:04:37 UTC (rev 4426)
@@ -1,209 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.tests.unit.core.remoting;
-
-import static org.jboss.messaging.core.remoting.TransportType.INVM;
-import static org.jboss.messaging.tests.integration.core.remoting.mina.TestSupport.PORT;
-import junit.framework.TestCase;
-
-import org.jboss.messaging.core.client.Location;
-import org.jboss.messaging.core.client.impl.ConnectionParamsImpl;
-import org.jboss.messaging.core.client.impl.LocationImpl;
-import org.jboss.messaging.core.config.Configuration;
-import org.jboss.messaging.core.remoting.ConnectorRegistry;
-import org.jboss.messaging.core.remoting.NIOConnector;
-import org.jboss.messaging.core.remoting.PacketDispatcher;
-import org.jboss.messaging.core.remoting.TransportType;
-import org.jboss.messaging.core.remoting.impl.ConnectorRegistryImpl;
-import org.jboss.messaging.core.remoting.impl.PacketDispatcherImpl;
-import org.jboss.messaging.tests.unit.core.remoting.impl.ConfigurationHelper;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public class ConnectorRegistryTest extends TestCase
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- private ConnectorRegistry registry;
- private PacketDispatcher dispatcher;
-
- @Override
- protected void setUp() throws Exception
- {
- registry = new ConnectorRegistryImpl();
- dispatcher = new PacketDispatcherImpl(null);
- assertEquals(0, registry.getRegisteredConfigurationSize());
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- assertEquals(0, registry.getRegisteredConfigurationSize());
- registry = null;
- }
-
- public void testConfigurationRegistration() throws Exception
- {
- Configuration config = ConfigurationHelper.newTCPConfiguration("localhost", PORT);
-
- assertTrue(registry.register(config.getLocation(), dispatcher));
- assertFalse(registry.register(config.getLocation(), dispatcher));
-
- assertTrue(registry.unregister(config.getLocation()));
- assertFalse(registry.unregister(config.getLocation()));
-
- assertTrue(registry.register(config.getLocation(), dispatcher));
- assertTrue(registry.unregister(config.getLocation()));
- }
-
- public void testRegistrationForTwoConfigurations() throws Exception
- {
- Configuration config_1 = ConfigurationHelper.newTCPConfiguration("localhost", PORT);
- Configuration config_2 = ConfigurationHelper.newTCPConfiguration("localhost", PORT + 1);
- PacketDispatcher dispatcher_1 = new PacketDispatcherImpl(null);
- PacketDispatcher dispatcher_2 = new PacketDispatcherImpl(null);
-
- assertTrue(registry.register(config_1.getLocation(), dispatcher_1));
- assertTrue(registry.register(config_2.getLocation(), dispatcher_2));
-
- assertTrue(registry.unregister(config_1.getLocation()));
- assertTrue(registry.unregister(config_2.getLocation()));
- }
-
- // TODO run this test when invm transport is reenabled
- public void _testINVMConnectorFromTCPConfiguration() throws Exception
- {
- Configuration config = ConfigurationHelper.newTCPConfiguration("localhost", PORT);
-
- // config is registered -> client and server are in the same vm
- assertTrue(registry.register(config.getLocation(), dispatcher));
-
- NIOConnector connector = registry.getConnector(config.getLocation(), new ConnectionParamsImpl());
-
- assertTrue(connector.getServerURI().startsWith(INVM.toString()));
-
- assertTrue(registry.unregister(config.getLocation()));
-
- assertNotNull(registry.removeConnector(config.getLocation()));
- }
-
-
- public void testTCPConnectorFromTCPConfiguration() throws Exception
- {
- Configuration config = ConfigurationHelper.newTCPConfiguration("localhost", PORT);
- // config is not registered -> client and server are not in the same vm
-
- NIOConnector connector = registry.getConnector(config.getLocation(), config.getConnectionParams());
-
- assertNotNull(connector);
- assertEquals(config.getURI(), connector.getServerURI());
-
- assertNotNull(registry.removeConnector(config.getLocation()));
- }
-
- public void testConnectorCount() throws Exception
- {
- Configuration config = ConfigurationHelper.newTCPConfiguration("localhost", PORT);
- assertEquals(0, registry.getConnectorCount(config.getLocation()));
-
- NIOConnector connector1 = registry.getConnector(config.getLocation(), new ConnectionParamsImpl());
- assertEquals(1, registry.getConnectorCount(config.getLocation()));
-
- NIOConnector connector2 = registry.getConnector(config.getLocation(), new ConnectionParamsImpl());
- assertEquals(2, registry.getConnectorCount(config.getLocation()));
-
- assertSame(connector1, connector2);
-
- assertNull(registry.removeConnector(config.getLocation()));
- assertEquals(1, registry.getConnectorCount(config.getLocation()));
-
- NIOConnector connector3 = registry.getConnector(config.getLocation(), new ConnectionParamsImpl());
- assertEquals(2, registry.getConnectorCount(config.getLocation()));
-
- assertSame(connector1, connector3);
-
- assertNull(registry.removeConnector(config.getLocation()));
- assertNotNull(registry.removeConnector(config.getLocation()));
- assertEquals(0, registry.getConnectorCount(config.getLocation()));
- }
-
- public void testConnectorCount_2() throws Exception
- {
- Configuration config1 = ConfigurationHelper.newTCPConfiguration("localhost", PORT);
- Configuration config2 = ConfigurationHelper.newTCPConfiguration("127.0.0.1", PORT);
-
- assertNotSame(config1, config2);
-
- assertEquals(0, registry.getConnectorCount(config1.getLocation()));
- assertEquals(0, registry.getConnectorCount(config2.getLocation()));
-
- NIOConnector connector1 = registry.getConnector(config1.getLocation(), new ConnectionParamsImpl());
- assertEquals(1, registry.getConnectorCount(config1.getLocation()));
-
- NIOConnector connector2 = registry.getConnector(config2.getLocation(), new ConnectionParamsImpl());
- assertEquals(1, registry.getConnectorCount(config2.getLocation()));
-
- assertNotSame(connector1, connector2);
-
- assertNotNull(registry.removeConnector(config1.getLocation()));
- assertNotNull(registry.removeConnector(config2.getLocation()));
- }
-
- /**
- * Check that 2 configuration which are similar (but not the same object) will
- * return the same NIOConnector
- */
- public void testConfigurationEquality() throws Exception
- {
- Configuration config1 = ConfigurationHelper.newTCPConfiguration("localhost", PORT);
- Configuration config2 = ConfigurationHelper.newTCPConfiguration("localhost", PORT);
-
- assertNotSame(config1, config2);
-
- NIOConnector connector1 = registry.getConnector(config1.getLocation(), new ConnectionParamsImpl());
- assertEquals(1, registry.getConnectorCount(config1.getLocation()));
-
- NIOConnector connector2 = registry.getConnector(config2.getLocation(), new ConnectionParamsImpl());
- assertEquals(2, registry.getConnectorCount(config2.getLocation()));
-
- assertSame(connector1, connector2);
-
- assertNull(registry.removeConnector(config1.getLocation()));
- assertNotNull(registry.removeConnector(config2.getLocation()));
- }
-
- public void testRemoveUnknownLocation() throws Exception
- {
- Location location = new LocationImpl(TransportType.TCP, "whatever", PORT);
- try {
- registry.removeConnector(location);
- fail("removing a connector for an unknown location throws an IllegalStateException");
- } catch (IllegalStateException e)
- {
- }
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/PacketDispatcherTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/PacketDispatcherTest.java 2008-06-10 22:49:14 UTC (rev 4425)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/PacketDispatcherTest.java 2008-06-11 11:04:37 UTC (rev 4426)
@@ -1,153 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.tests.unit.core.remoting;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
-import junit.framework.TestCase;
-
-import org.jboss.messaging.core.remoting.PacketHandler;
-import org.jboss.messaging.core.remoting.PacketHandlerRegistrationListener;
-import org.jboss.messaging.core.remoting.PacketReturner;
-import org.jboss.messaging.core.remoting.impl.PacketDispatcherImpl;
-import org.jboss.messaging.core.remoting.impl.wireformat.Ping;
-import org.jboss.messaging.tests.util.RandomUtil;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public class PacketDispatcherTest extends TestCase
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- PacketDispatcherImpl dispatcher;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- // TestCase overrides --------------------------------------------
-
- @Override
- protected void setUp() throws Exception
- {
- dispatcher = new PacketDispatcherImpl(null);
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- dispatcher = null;
- }
-
- public void testUnregisterAnUnregisteredHandlerReturnsNull() throws Exception
- {
- PacketHandler handler = createMock(PacketHandler.class);
- long id = randomLong();
-
- replay(handler);
-
- try
- {
- dispatcher.unregister(id);
- fail("Should throw Exception");
- }
- catch (IllegalArgumentException e)
- {
- //Ok
- }
- assertNull(dispatcher.getHandler(id));
-
- verify(handler);
- }
-
- public void testRegisterAndUnregisterValidHandler() throws Exception
- {
- PacketHandler handler = createMock(PacketHandler.class);
- long id = randomLong();
- expect(handler.getID()).andReturn(id).anyTimes();
-
- replay(handler);
-
- dispatcher.register(handler);
-
- PacketHandler registeredHandler = dispatcher.getHandler(id);
- assertSame(handler, registeredHandler);
-
- dispatcher.unregister(id);
- assertNull(dispatcher.getHandler(id));
-
- verify(handler);
- }
-
- public void testDispatchPacketWithRegisteredHandler() throws Exception
- {
- PacketHandler handler = createMock(PacketHandler.class);
- PacketReturner sender = createMock(PacketReturner.class);
-
- Ping packet = new Ping(randomLong());
-
- long id = randomLong();
- expect(handler.getID()).andStubReturn(id);
- handler.handle(packet, sender);
- expectLastCall().once();
-
- replay(handler, sender);
-
- dispatcher.register(handler);
-
- PacketHandler registeredHandler = dispatcher.getHandler(id);
- assertSame(handler, registeredHandler);
-
- packet.setTargetID(handler.getID());
- dispatcher.dispatch(packet, sender);
-
- dispatcher.unregister(id);
- assertNull(dispatcher.getHandler(id));
-
- verify(handler, sender);
- }
-
- public void testRegistrationListener() throws Exception
- {
- PacketHandlerRegistrationListener listener = createMock(PacketHandlerRegistrationListener.class);
- PacketHandler handler = createMock(PacketHandler.class);
-
- long id = randomLong();
- expect(handler.getID()).andStubReturn(id);
- listener.handlerRegistered(id);
- expectLastCall().once();
- listener.handlerUnregistered(id);
- expectLastCall().once();
-
- replay(handler, listener);
-
- dispatcher.setListener(listener);
- dispatcher.register(handler);
- dispatcher.unregister(id);
-
- verify(handler, listener);
- }
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/RemotingConfigurationValidatorTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/RemotingConfigurationValidatorTest.java 2008-06-10 22:49:14 UTC (rev 4425)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/RemotingConfigurationValidatorTest.java 2008-06-11 11:04:37 UTC (rev 4426)
@@ -1,161 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.tests.unit.core.remoting;
-
-import static org.jboss.messaging.core.remoting.TransportType.INVM;
-import static org.jboss.messaging.core.remoting.impl.RemotingConfigurationValidator.validate;
-import junit.framework.TestCase;
-
-import org.jboss.messaging.core.config.Configuration;
-import org.jboss.messaging.core.config.impl.ConfigurationImpl;
-import org.jboss.messaging.tests.unit.core.remoting.impl.ConfigurationHelper;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public class RemotingConfigurationValidatorTest extends TestCase
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void testINVMConfiguration()
- {
- ConfigurationImpl config = new ConfigurationImpl();
- config.setTransport(INVM);
-
- validate(config);
- }
-
- public void testNegativePort()
- {
- Configuration config = ConfigurationHelper.newTCPConfiguration("localhost", -1);
-
- try
- {
- validate(config);
- fail("can not set a negative port");
- } catch (Exception e)
- {
- }
- }
-
- public void test_TcpReceiveBufferSize_to_0()
- {
- ConfigurationImpl config = ConfigurationHelper.newTCPConfiguration("localhost", 9000);
- config.setTcpReceiveBufferSize(0);
- try
- {
- validate(config);
- fail("can not set tcp receive buffer size to 0");
- } catch (Exception e)
- {
- }
- }
-
- public void test_TcpReceiveBufferSize_to_minusOne()
- {
- ConfigurationImpl config = ConfigurationHelper.newTCPConfiguration("localhost", 9000);
- config.setTcpReceiveBufferSize(-1);
- validate(config);
- }
-
- public void test_TcpReceiveBufferSize_to_NegativeNumber()
- {
- ConfigurationImpl config = ConfigurationHelper.newTCPConfiguration("localhost", 9000);
- config.setTcpReceiveBufferSize(-2);
- try
- {
- validate(config);
- fail("can not set tcp receive buffer size to a negative number other than -1");
- } catch (Exception e)
- {
- }
- }
-
- public void test_TcpSendBufferSize_to_0()
- {
- ConfigurationImpl config = ConfigurationHelper.newTCPConfiguration("localhost", 9000);
- config.setTcpSendBufferSize(0);
- try
- {
- validate(config);
- fail("can not set tcp send buffer size to 0");
- } catch (Exception e)
- {
- }
- }
-
- public void test_TcpSendBufferSize_to_minusOne()
- {
- ConfigurationImpl config = ConfigurationHelper.newTCPConfiguration("localhost", 9000);
- config.setTcpSendBufferSize(-1);
- validate(config);
- }
-
- public void test_TcpSendBufferSize_to_NegativeNumber()
- {
- ConfigurationImpl config = ConfigurationHelper.newTCPConfiguration("localhost", 9000);
- config.setTcpSendBufferSize(-2);
- try
- {
- validate(config);
- fail("can not set tcp send buffer size to a negative number other than -1");
- } catch (Exception e)
- {
- }
- }
-
- public void test_DisableINVM_With_INVMTransport()
- {
- ConfigurationImpl config = new ConfigurationImpl();
- config.setTransport(INVM);
- config.setInvmDisabled(true);
-
- try
- {
- validate(config);
- fail("can not disable INVM when INVM transport is set");
- } catch (Exception e)
- {
-
- }
- }
-
- public void test_EnableSSL_With_INVMTransport()
- {
- ConfigurationImpl config = new ConfigurationImpl();
- config.setTransport(INVM);
- config.setSSLEnabled(true);
-
- try
- {
- validate(config);
- fail("can not enable SSL when INVM transport is set");
- } catch (Exception e)
- {
-
- }
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Copied: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/ConnectorRegistryImplTest.java (from rev 4423, trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/ConnectorRegistryTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/ConnectorRegistryImplTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/ConnectorRegistryImplTest.java 2008-06-11 11:04:37 UTC (rev 4426)
@@ -0,0 +1,234 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.tests.unit.core.remoting.impl;
+
+import junit.framework.TestCase;
+import org.jboss.messaging.core.client.Location;
+import org.jboss.messaging.core.client.impl.ConnectionParamsImpl;
+import org.jboss.messaging.core.client.impl.LocationImpl;
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.remoting.ConnectorRegistry;
+import org.jboss.messaging.core.remoting.NIOConnector;
+import org.jboss.messaging.core.remoting.PacketDispatcher;
+import org.jboss.messaging.core.remoting.TransportType;
+import static org.jboss.messaging.core.remoting.TransportType.INVM;
+import org.jboss.messaging.core.remoting.impl.ConnectorRegistryImpl;
+import org.jboss.messaging.core.remoting.impl.PacketDispatcherImpl;
+import static org.jboss.messaging.tests.integration.core.remoting.mina.TestSupport.PORT;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * @version <tt>$Revision$</tt>
+ */
+public class ConnectorRegistryImplTest extends TestCase
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ private ConnectorRegistry registry;
+ private PacketDispatcher dispatcher;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ registry = new ConnectorRegistryImpl();
+ dispatcher = new PacketDispatcherImpl(null);
+ assertEquals(0, registry.getRegisteredConfigurationSize());
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ assertEquals(0, registry.getRegisteredConfigurationSize());
+ registry = null;
+ }
+
+ public void testConfigurationRegistration() throws Exception
+ {
+ Configuration config = ConfigurationHelper.newTCPConfiguration("localhost", PORT);
+
+ assertTrue(registry.register(config.getLocation(), dispatcher));
+ assertFalse(registry.register(config.getLocation(), dispatcher));
+
+ assertTrue(registry.unregister(config.getLocation()));
+ assertFalse(registry.unregister(config.getLocation()));
+
+ assertTrue(registry.register(config.getLocation(), dispatcher));
+ assertTrue(registry.unregister(config.getLocation()));
+ }
+
+ public void testRegistrationForTwoConfigurations() throws Exception
+ {
+ Configuration config_1 = ConfigurationHelper.newTCPConfiguration("localhost", PORT);
+ Configuration config_2 = ConfigurationHelper.newTCPConfiguration("localhost", PORT + 1);
+ PacketDispatcher dispatcher_1 = new PacketDispatcherImpl(null);
+ PacketDispatcher dispatcher_2 = new PacketDispatcherImpl(null);
+
+ assertTrue(registry.register(config_1.getLocation(), dispatcher_1));
+ assertTrue(registry.register(config_2.getLocation(), dispatcher_2));
+
+ assertTrue(registry.unregister(config_1.getLocation()));
+ assertTrue(registry.unregister(config_2.getLocation()));
+ }
+
+ // TODO run this test when invm transport is reenabled
+ public void _testINVMConnectorFromTCPConfiguration() throws Exception
+ {
+ Configuration config = ConfigurationHelper.newTCPConfiguration("localhost", PORT);
+
+ // config is registered -> client and server are in the same vm
+ assertTrue(registry.register(config.getLocation(), dispatcher));
+
+ NIOConnector connector = registry.getConnector(config.getLocation(), new ConnectionParamsImpl());
+
+ assertTrue(connector.getServerURI().startsWith(INVM.toString()));
+
+ assertTrue(registry.unregister(config.getLocation()));
+
+ assertNotNull(registry.removeConnector(config.getLocation()));
+ }
+
+
+ public void testTCPConnectorFromTCPConfiguration() throws Exception
+ {
+ Configuration config = ConfigurationHelper.newTCPConfiguration("localhost", PORT);
+ // config is not registered -> client and server are not in the same vm
+
+ NIOConnector connector = registry.getConnector(config.getLocation(), config.getConnectionParams());
+
+ assertNotNull(connector);
+ assertEquals(config.getURI(), connector.getServerURI());
+
+ assertNotNull(registry.removeConnector(config.getLocation()));
+ }
+
+ public void testConnectorCount() throws Exception
+ {
+ Configuration config = ConfigurationHelper.newTCPConfiguration("localhost", PORT);
+ assertEquals(0, registry.getConnectorCount(config.getLocation()));
+
+ NIOConnector connector1 = registry.getConnector(config.getLocation(), new ConnectionParamsImpl());
+ assertEquals(1, registry.getConnectorCount(config.getLocation()));
+
+ NIOConnector connector2 = registry.getConnector(config.getLocation(), new ConnectionParamsImpl());
+ assertEquals(2, registry.getConnectorCount(config.getLocation()));
+
+ assertSame(connector1, connector2);
+
+ assertNull(registry.removeConnector(config.getLocation()));
+ assertEquals(1, registry.getConnectorCount(config.getLocation()));
+
+ NIOConnector connector3 = registry.getConnector(config.getLocation(), new ConnectionParamsImpl());
+ assertEquals(2, registry.getConnectorCount(config.getLocation()));
+
+ assertSame(connector1, connector3);
+
+ assertNull(registry.removeConnector(config.getLocation()));
+ assertNotNull(registry.removeConnector(config.getLocation()));
+ assertEquals(0, registry.getConnectorCount(config.getLocation()));
+ }
+
+ public void testConnectorCount_2() throws Exception
+ {
+ Configuration config1 = ConfigurationHelper.newTCPConfiguration("localhost", PORT);
+ Configuration config2 = ConfigurationHelper.newTCPConfiguration("127.0.0.1", PORT);
+
+ assertNotSame(config1, config2);
+
+ assertEquals(0, registry.getConnectorCount(config1.getLocation()));
+ assertEquals(0, registry.getConnectorCount(config2.getLocation()));
+
+ NIOConnector connector1 = registry.getConnector(config1.getLocation(), new ConnectionParamsImpl());
+ assertEquals(1, registry.getConnectorCount(config1.getLocation()));
+
+ NIOConnector connector2 = registry.getConnector(config2.getLocation(), new ConnectionParamsImpl());
+ assertEquals(1, registry.getConnectorCount(config2.getLocation()));
+
+ assertNotSame(connector1, connector2);
+
+ assertNotNull(registry.removeConnector(config1.getLocation()));
+ assertNotNull(registry.removeConnector(config2.getLocation()));
+ }
+
+ public void testConnectorCountAfterClear() throws Exception
+ {
+ Configuration config1 = ConfigurationHelper.newTCPConfiguration("localhost", PORT);
+ Configuration config2 = ConfigurationHelper.newTCPConfiguration("127.0.0.1", PORT);
+
+ assertNotSame(config1, config2);
+
+ assertEquals(0, registry.getConnectorCount(config1.getLocation()));
+ assertEquals(0, registry.getConnectorCount(config2.getLocation()));
+
+ NIOConnector connector1 = registry.getConnector(config1.getLocation(), new ConnectionParamsImpl());
+ assertEquals(1, registry.getConnectorCount(config1.getLocation()));
+
+ NIOConnector connector2 = registry.getConnector(config2.getLocation(), new ConnectionParamsImpl());
+ assertEquals(1, registry.getConnectorCount(config2.getLocation()));
+
+ assertNotSame(connector1, connector2);
+
+ assertNotNull(registry.removeConnector(config1.getLocation()));
+ assertNotNull(registry.removeConnector(config2.getLocation()));
+
+ registry.clear();
+
+ assertEquals(0, registry.getConnectorCount(config1.getLocation()));
+ assertEquals(0, registry.getConnectorCount(config2.getLocation()));
+ }
+
+ /**
+ * Check that 2 configuration which are similar (but not the same object) will
+ * return the same NIOConnector
+ */
+ public void testConfigurationEquality() throws Exception
+ {
+ Configuration config1 = ConfigurationHelper.newTCPConfiguration("localhost", PORT);
+ Configuration config2 = ConfigurationHelper.newTCPConfiguration("localhost", PORT);
+
+ assertNotSame(config1, config2);
+
+ NIOConnector connector1 = registry.getConnector(config1.getLocation(), new ConnectionParamsImpl());
+ assertEquals(1, registry.getConnectorCount(config1.getLocation()));
+
+ NIOConnector connector2 = registry.getConnector(config2.getLocation(), new ConnectionParamsImpl());
+ assertEquals(2, registry.getConnectorCount(config2.getLocation()));
+
+ assertSame(connector1, connector2);
+
+ assertNull(registry.removeConnector(config1.getLocation()));
+ assertNotNull(registry.removeConnector(config2.getLocation()));
+ }
+
+ public void testRemoveUnknownLocation() throws Exception
+ {
+ Location location = new LocationImpl(TransportType.TCP, "whatever", PORT);
+ try
+ {
+ registry.removeConnector(location);
+ fail("removing a connector for an unknown location throws an IllegalStateException");
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Copied: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/PacketDispatcherTest.java (from rev 4423, trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/PacketDispatcherTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/PacketDispatcherTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/PacketDispatcherTest.java 2008-06-11 11:04:37 UTC (rev 4426)
@@ -0,0 +1,220 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.tests.unit.core.remoting.impl;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.*;
+import org.jboss.messaging.core.remoting.*;
+import org.jboss.messaging.core.remoting.impl.PacketDispatcherImpl;
+import org.jboss.messaging.core.remoting.impl.wireformat.Ping;
+import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
+
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * @version <tt>$Revision$</tt>
+ */
+public class PacketDispatcherTest extends TestCase
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ PacketDispatcherImpl dispatcher;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // TestCase overrides --------------------------------------------
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ dispatcher = new PacketDispatcherImpl(null);
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ dispatcher = null;
+ }
+
+ public void testGenerateId()
+ {
+ for (int i = 1; i < 1000; i++)
+ {
+ assertEquals(dispatcher.generateID(), i);
+ }
+ }
+
+ public void testFiltersCalled() throws Exception
+ {
+ PacketHandler handler = createMock(PacketHandler.class);
+ PacketReturner sender = createMock(PacketReturner.class);
+ Packet packet = createMock(Packet.class);
+ Interceptor interceptor = EasyMock.createStrictMock(Interceptor.class);
+ ArrayList<Interceptor> filters = new ArrayList<Interceptor>();
+ filters.add(interceptor);
+ long id = randomLong();
+ expect(handler.getID()).andStubReturn(id);
+ handler.handle(packet, sender);
+ expectLastCall().once();
+ expect(packet.getTargetID()).andReturn(id);
+ interceptor.intercept(packet);
+ replay(handler, sender, packet, interceptor);
+
+ dispatcher = new PacketDispatcherImpl(filters);
+ dispatcher.register(handler);
+ dispatcher.dispatch(packet, sender);
+
+ verify(interceptor);
+ }
+
+ public void testUnregisterAnUnregisteredHandlerReturnsNull() throws Exception
+ {
+ PacketHandler handler = createMock(PacketHandler.class);
+ long id = randomLong();
+
+ replay(handler);
+
+ try
+ {
+ dispatcher.unregister(id);
+ fail("Should throw Exception");
+ }
+ catch (IllegalArgumentException e)
+ {
+ //Ok
+ }
+ assertNull(dispatcher.getHandler(id));
+
+ verify(handler);
+ }
+
+ public void testRegisterAndUnregisterValidHandler() throws Exception
+ {
+ PacketHandler handler = createMock(PacketHandler.class);
+ long id = randomLong();
+ expect(handler.getID()).andReturn(id).anyTimes();
+
+ replay(handler);
+
+ dispatcher.register(handler);
+
+ PacketHandler registeredHandler = dispatcher.getHandler(id);
+ assertSame(handler, registeredHandler);
+
+ dispatcher.unregister(id);
+ assertNull(dispatcher.getHandler(id));
+
+ verify(handler);
+ }
+
+ public void testDispatchPacketWithRegisteredHandler() throws Exception
+ {
+ PacketHandler handler = createMock(PacketHandler.class);
+ PacketReturner sender = createMock(PacketReturner.class);
+
+ Ping packet = new Ping(randomLong());
+
+ long id = randomLong();
+ expect(handler.getID()).andStubReturn(id);
+ handler.handle(packet, sender);
+ expectLastCall().once();
+
+ replay(handler, sender);
+
+ dispatcher.register(handler);
+
+ PacketHandler registeredHandler = dispatcher.getHandler(id);
+ assertSame(handler, registeredHandler);
+
+ packet.setTargetID(handler.getID());
+ dispatcher.dispatch(packet, sender);
+
+ dispatcher.unregister(id);
+ assertNull(dispatcher.getHandler(id));
+
+ verify(handler, sender);
+ }
+
+ public void testDispatchPacketWithNoIDSetIsNotDispatched() throws Exception
+ {
+ PacketHandler handler = createMock(PacketHandler.class);
+ PacketReturner sender = createMock(PacketReturner.class);
+ Packet packet = createMock(Packet.class);
+
+ long id = randomLong();
+ expect(handler.getID()).andStubReturn(id);
+ expect(packet.getTargetID()).andReturn(-1l);
+ expectLastCall().once();
+
+ replay(handler, sender, packet);
+
+ dispatcher.register(handler);
+
+ PacketHandler registeredHandler = dispatcher.getHandler(id);
+ assertSame(handler, registeredHandler);
+
+ dispatcher.dispatch(packet, sender);
+
+ dispatcher.unregister(id);
+ assertNull(dispatcher.getHandler(id));
+
+ verify(handler, sender);
+ }
+
+ public void testDispatchPacketWithUnRegisteredHandlerNoException() throws Exception
+ {
+ PacketReturner sender = createMock(PacketReturner.class);
+
+ Ping packet = new Ping(randomLong());
+
+ long id = randomLong();
+
+ replay(sender);
+
+ packet.setTargetID(id);
+ dispatcher.dispatch(packet, sender);
+
+ verify(sender);
+ }
+
+
+ public void testRegistrationListener() throws Exception
+ {
+ PacketHandlerRegistrationListener listener = createMock(PacketHandlerRegistrationListener.class);
+ PacketHandler handler = createMock(PacketHandler.class);
+
+ long id = randomLong();
+ expect(handler.getID()).andStubReturn(id);
+ listener.handlerRegistered(id);
+ expectLastCall().once();
+ listener.handlerUnregistered(id);
+ expectLastCall().once();
+
+ replay(handler, listener);
+
+ dispatcher.setListener(listener);
+ dispatcher.register(handler);
+ dispatcher.unregister(id);
+
+ verify(handler, listener);
+ }
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Copied: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingConfigurationValidatorTest.java (from rev 4423, trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/RemotingConfigurationValidatorTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingConfigurationValidatorTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingConfigurationValidatorTest.java 2008-06-11 11:04:37 UTC (rev 4426)
@@ -0,0 +1,164 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.tests.unit.core.remoting.impl;
+
+import junit.framework.TestCase;
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import static org.jboss.messaging.core.remoting.TransportType.INVM;
+import static org.jboss.messaging.core.remoting.impl.RemotingConfigurationValidator.validate;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * @version <tt>$Revision$</tt>
+ */
+public class RemotingConfigurationValidatorTest extends TestCase
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testINVMConfiguration()
+ {
+ ConfigurationImpl config = new ConfigurationImpl();
+ config.setTransport(INVM);
+
+ validate(config);
+ }
+
+ public void testNegativePort()
+ {
+ Configuration config = ConfigurationHelper.newTCPConfiguration("localhost", -1);
+
+ try
+ {
+ validate(config);
+ fail("can not set a negative port");
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+ public void test_TcpReceiveBufferSize_to_0()
+ {
+ ConfigurationImpl config = ConfigurationHelper.newTCPConfiguration("localhost", 9000);
+ config.setTcpReceiveBufferSize(0);
+ try
+ {
+ validate(config);
+ fail("can not set tcp receive buffer size to 0");
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+ public void test_TcpReceiveBufferSize_to_minusOne()
+ {
+ ConfigurationImpl config = ConfigurationHelper.newTCPConfiguration("localhost", 9000);
+ config.setTcpReceiveBufferSize(-1);
+ validate(config);
+ }
+
+ public void test_TcpReceiveBufferSize_to_NegativeNumber()
+ {
+ ConfigurationImpl config = ConfigurationHelper.newTCPConfiguration("localhost", 9000);
+ config.setTcpReceiveBufferSize(-2);
+ try
+ {
+ validate(config);
+ fail("can not set tcp receive buffer size to a negative number other than -1");
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+ public void test_TcpSendBufferSize_to_0()
+ {
+ ConfigurationImpl config = ConfigurationHelper.newTCPConfiguration("localhost", 9000);
+ config.setTcpSendBufferSize(0);
+ try
+ {
+ validate(config);
+ fail("can not set tcp send buffer size to 0");
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+ public void test_TcpSendBufferSize_to_minusOne()
+ {
+ ConfigurationImpl config = ConfigurationHelper.newTCPConfiguration("localhost", 9000);
+ config.setTcpSendBufferSize(-1);
+ validate(config);
+ }
+
+ public void test_TcpSendBufferSize_to_NegativeNumber()
+ {
+ ConfigurationImpl config = ConfigurationHelper.newTCPConfiguration("localhost", 9000);
+ config.setTcpSendBufferSize(-2);
+ try
+ {
+ validate(config);
+ fail("can not set tcp send buffer size to a negative number other than -1");
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+ public void test_DisableINVM_With_INVMTransport()
+ {
+ ConfigurationImpl config = new ConfigurationImpl();
+ config.setTransport(INVM);
+ config.setInvmDisabled(true);
+
+ try
+ {
+ validate(config);
+ fail("can not disable INVM when INVM transport is set");
+ }
+ catch (Exception e)
+ {
+
+ }
+ }
+
+ public void test_EnableSSL_With_INVMTransport()
+ {
+ ConfigurationImpl config = new ConfigurationImpl();
+ config.setTransport(INVM);
+ config.setSSLEnabled(true);
+
+ try
+ {
+ validate(config);
+ fail("can not enable SSL when INVM transport is set");
+ }
+ catch (Exception e)
+ {
+
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingConnectionFactoryImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingConnectionFactoryImplTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingConnectionFactoryImplTest.java 2008-06-11 11:04:37 UTC (rev 4426)
@@ -0,0 +1,43 @@
+/*
+ * 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;
+
+import org.jboss.messaging.core.client.impl.ConnectionParamsImpl;
+import org.jboss.messaging.core.client.impl.LocationImpl;
+import org.jboss.messaging.core.remoting.RemotingConnection;
+import org.jboss.messaging.core.remoting.TransportType;
+import org.jboss.messaging.core.remoting.impl.RemotingConnectionFactoryImpl;
+import org.jboss.messaging.tests.util.UnitTestCase;
+
+/**
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class RemotingConnectionFactoryImplTest extends UnitTestCase
+{
+ public void testCreateRemotingConnection() throws Exception
+ {
+ RemotingConnectionFactoryImpl remotingConnectionFactory = new RemotingConnectionFactoryImpl();
+ LocationImpl location = new LocationImpl(TransportType.TCP, "localhost");
+ RemotingConnection remotingConnection = remotingConnectionFactory.createRemotingConnection(location, new ConnectionParamsImpl());
+ assertEquals(location, remotingConnection.getLocation());
+ }
+}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingConnectionTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingConnectionTest.java 2008-06-10 22:49:14 UTC (rev 4425)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingConnectionTest.java 2008-06-11 11:04:37 UTC (rev 4426)
@@ -21,7 +21,6 @@
*/
package org.jboss.messaging.tests.unit.core.remoting.impl;
-import junit.framework.TestCase;
import org.easymock.EasyMock;
import org.jboss.messaging.core.client.ConnectionParams;
import org.jboss.messaging.core.client.Location;
@@ -30,11 +29,12 @@
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.remoting.*;
import org.jboss.messaging.core.remoting.impl.RemotingConnectionImpl;
+import org.jboss.messaging.tests.util.UnitTestCase;
/**
* @author <a href="ataylor at redhat.com">Andy Taylor</a>
*/
-public class RemotingConnectionTest extends TestCase
+public class RemotingConnectionTest extends UnitTestCase
{
protected void tearDown() throws Exception
{
More information about the jboss-cvs-commits
mailing list