From jboss-remoting-commits at lists.jboss.org Wed Aug 4 21:27:09 2010 Content-Type: multipart/mixed; boundary="===============8342361905193588784==" MIME-Version: 1.0 From: jboss-remoting-commits at lists.jboss.org To: jboss-remoting-commits at lists.jboss.org Subject: [jboss-remoting-commits] JBoss Remoting SVN: r6007 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timertask. Date: Wed, 04 Aug 2010 21:27:09 -0400 Message-ID: <201008050127.o751R9nO009165@svn01.web.mwc.hst.phx2.redhat.com> --===============8342361905193588784== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: ron.sigal(a)jboss.com Date: 2010-08-04 21:27:09 -0400 (Wed, 04 Aug 2010) New Revision: 6007 Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisoc= ket/timertask/TimerTaskTestCase.java Log: JBREM-1241: Added svn:eol-style subversion property. Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transpor= t/bisocket/timertask/TimerTaskTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/biso= cket/timertask/TimerTaskTestCase.java 2010-08-05 01:26:37 UTC (rev 6006) +++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/biso= cket/timertask/TimerTaskTestCase.java 2010-08-05 01:27:09 UTC (rev 6007) @@ -1,341 +1,341 @@ -/* -* 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.test.remoting.transport.bisocket.timertask; - -import java.lang.reflect.Field; -import java.net.InetAddress; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.Timer; -import java.util.TimerTask; - -import javax.management.MBeanServer; - -import junit.framework.TestCase; - -import org.apache.log4j.ConsoleAppender; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.PatternLayout; -import org.jboss.logging.XLevel; -import org.jboss.remoting.Client; -import org.jboss.remoting.InvocationRequest; -import org.jboss.remoting.InvokerLocator; -import org.jboss.remoting.ServerInvocationHandler; -import org.jboss.remoting.ServerInvoker; -import org.jboss.remoting.callback.Callback; -import org.jboss.remoting.callback.HandleCallbackException; -import org.jboss.remoting.callback.InvokerCallbackHandler; -import org.jboss.remoting.callback.ServerInvokerCallbackHandler; -import org.jboss.remoting.transport.Connector; -import org.jboss.remoting.transport.PortUtil; -import org.jboss.remoting.transport.bisocket.Bisocket; -import org.jboss.remoting.transport.bisocket.BisocketClientInvoker; -import org.jboss.remoting.transport.bisocket.BisocketServerInvoker; - - -/** - * Unit test for JBREM-1005. - * = - * @author Ron Sigal - * @version $Revision: 1.1 $ - *
- * Copyright Jun 26, 2008 - *
- */ -public class TimerTaskTestCase extends TestCase -{ - private static Logger log =3D Logger.getLogger(TimerTaskTestCase.class); - = - private static boolean firstTime =3D true; - private static boolean purgeMethodAvailable; - = - protected String host; - protected int port; - protected String locatorURI; - protected InvokerLocator serverLocator; - protected Connector connector; - protected TestInvocationHandler invocationHandler; - - = - public void setUp() throws Exception - { - if (firstTime) - { - firstTime =3D false; - Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO); - Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); - String pattern =3D "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; - PatternLayout layout =3D new PatternLayout(pattern); - ConsoleAppender consoleAppender =3D new ConsoleAppender(layout); - Logger.getRootLogger().addAppender(consoleAppender); - = - try - { - Timer.class.getDeclaredMethod("purge", new Class[]{}); - purgeMethodAvailable =3D true; - } - catch (Exception e) - { - log.info("Timer.purge() is not available: must be running with= jdk 1.4"); - } - } - } - - = - public void tearDown() - { - } - = - = - public void testZeroPingFrequency() throws Throwable - { - log.info("entering " + getName()); - = - if (!purgeMethodAvailable) - { - log.info(getName() + " PASSES (trivially)"); - return; - } - = - // Start server. - setupServer("0"); - = - // Create client. - InvokerLocator clientLocator =3D new InvokerLocator(locatorURI); - HashMap clientConfig =3D new HashMap(); - clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); - addExtraClientConfig(clientConfig); - Client client =3D new Client(clientLocator, clientConfig); - client.connect(); - = - // Test connections. - assertEquals("abc", client.invoke("abc")); - log.info("connection is good"); - = - // Set up callback handler. - TestCallbackHandler callbackHandler =3D new TestCallbackHandler(); - HashMap metadata =3D new HashMap(); - metadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); - client.addListener(callbackHandler, metadata); - assertEquals(1, callbackHandler.counter); - = - // Verify ControlMonitorTimerTask is not created. - Set callbackConnectors =3D client.getCallbackConnectors(callbackHand= ler); - assertEquals(1, callbackConnectors.size()); - Connector callbackConnector =3D (Connector) callbackConnectors.itera= tor().next(); - Field field =3D BisocketServerInvoker.class.getDeclaredField("contro= lMonitorTimerTask"); - field.setAccessible(true); = - BisocketServerInvoker serverInvoker =3D (BisocketServerInvoker) call= backConnector.getServerInvoker(); - TimerTask timerTask =3D (TimerTask) field.get(serverInvoker); - assertNull(timerTask); - log.info("ControlMonitorTimerTask was not created"); - = - // Verify PingTimerTask is not created. - field =3D ServerInvoker.class.getDeclaredField("callbackHandlers"); - field.setAccessible(true); - serverInvoker =3D (BisocketServerInvoker) connector.getServerInvoker= (); - Map callbackHandlers =3D (Map) field.get(serverInvoker); - assertEquals(1, callbackHandlers.size()); - Object o =3D callbackHandlers.values().iterator().next(); - Client callbackClient =3D ((ServerInvokerCallbackHandler) o).getCall= backClient(); - BisocketClientInvoker clientInvoker =3D (BisocketClientInvoker) call= backClient.getInvoker(); - field =3D BisocketClientInvoker.class.getDeclaredField("pingTimerTas= k"); - field.setAccessible(true); - timerTask =3D (TimerTask) field.get(clientInvoker); - assertNull(timerTask); - log.info("PingTimerTask was not created"); - = - client.disconnect(); - shutdownServer(); - log.info(getName() + " PASSES"); - } - = - = - public void testNonZeroPingFrequency() throws Throwable - { - log.info("entering " + getName()); - = - if (!purgeMethodAvailable) - { - log.info(getName() + " PASSES (trivially)"); - return; - } - = - // Start server. - setupServer("20"); - = - // Create client. - InvokerLocator clientLocator =3D new InvokerLocator(locatorURI); - HashMap clientConfig =3D new HashMap(); - clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); - addExtraClientConfig(clientConfig); - Client client =3D new Client(clientLocator, clientConfig); - client.connect(); - = - // Test connections. - assertEquals("abc", client.invoke("abc")); - log.info("connection is good"); - = - // Set up callback handler. - TestCallbackHandler callbackHandler =3D new TestCallbackHandler(); - HashMap metadata =3D new HashMap(); - metadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); - client.addListener(callbackHandler, metadata); - assertEquals(1, callbackHandler.counter); - = - // Verify ControlMonitorTimerTask is created. - Set callbackConnectors =3D client.getCallbackConnectors(callbackHand= ler); - assertEquals(1, callbackConnectors.size()); - Connector callbackConnector =3D (Connector) callbackConnectors.itera= tor().next(); - Field field =3D BisocketServerInvoker.class.getDeclaredField("contro= lMonitorTimerTask"); - field.setAccessible(true); = - BisocketServerInvoker serverInvoker =3D (BisocketServerInvoker) call= backConnector.getServerInvoker(); - TimerTask timerTask =3D (TimerTask) field.get(serverInvoker); - assertNotNull(timerTask); - log.info("ControlMonitorTimerTask was created"); - = - // Verify PingTimerTask is created. - field =3D ServerInvoker.class.getDeclaredField("callbackHandlers"); - field.setAccessible(true); - BisocketServerInvoker callbackServerInvoker =3D (BisocketServerInvok= er) connector.getServerInvoker(); - Map callbackHandlers =3D (Map) field.get(callbackServerInvoker); - assertEquals(1, callbackHandlers.size()); - Object o =3D callbackHandlers.values().iterator().next(); - Client callbackClient =3D ((ServerInvokerCallbackHandler) o).getCall= backClient(); - BisocketClientInvoker clientInvoker =3D (BisocketClientInvoker) call= backClient.getInvoker(); - field =3D BisocketClientInvoker.class.getDeclaredField("pingTimerTas= k"); - field.setAccessible(true); - timerTask =3D (TimerTask) field.get(clientInvoker); - assertNotNull(timerTask); - log.info("PingTimerTask was created"); - = - // Get count of ControlMonitorTimerTasks. - field =3D BisocketServerInvoker.class.getDeclaredField("timer"); - field.setAccessible(true); - Timer timer =3D (Timer) field.get(null); - field =3D Timer.class.getDeclaredField("queue"); - field.setAccessible(true); - Object taskQueue =3D field.get(timer); - Field serverTimerfield =3D taskQueue.getClass().getDeclaredField("si= ze"); - serverTimerfield.setAccessible(true); - int serverSize =3D ((Integer) serverTimerfield.get(taskQueue)).intVa= lue(); - log.info("ControlMonitorTimerTasks: " + serverSize); - = - // Get count of PingTimerTasks. - field =3D BisocketClientInvoker.class.getDeclaredField("timer"); - field.setAccessible(true); - timer =3D (Timer) field.get(null); - field =3D Timer.class.getDeclaredField("queue"); - field.setAccessible(true); - taskQueue =3D field.get(timer); - Field clientTimerfield =3D taskQueue.getClass().getDeclaredField("si= ze"); - clientTimerfield.setAccessible(true); - int clientSize =3D ((Integer) clientTimerfield.get(taskQueue)).intVa= lue(); - log.info("PingTimerTasks: " + clientSize); - - // Shut down callback connection and verify TimerTasks are removed f= rom = - // Timer queue. - client.removeListener(callbackHandler); - serverSize =3D ((Integer) serverTimerfield.get(taskQueue)).intValue(= ); - log.info("ControlMonitorTimerTasks: " + serverSize); - assertEquals(0, serverSize); - clientSize =3D ((Integer) clientTimerfield.get(taskQueue)).intValue(= ); - log.info("PingTimerTasks: " + clientSize); - assertEquals(0, clientSize); - = - client.disconnect(); - shutdownServer(); - log.info(getName() + " PASSES"); - } - = - = - protected String getTransport() - { - return "bisocket"; - } - = - = - protected void addExtraClientConfig(Map config) {} - protected void addExtraServerConfig(Map config) {} - = - - protected void setupServer(String pingFrequency) throws Exception - { - host =3D InetAddress.getLocalHost().getHostAddress(); - port =3D PortUtil.findFreePort(host); - locatorURI =3D getTransport() + "://" + host + ":" + port; = - locatorURI +=3D "/?" + Bisocket.PING_FREQUENCY + "=3D" + pingFrequen= cy; - serverLocator =3D new InvokerLocator(locatorURI); - log.info("Starting remoting server with locator uri of: " + locatorU= RI); - HashMap config =3D new HashMap(); - config.put(InvokerLocator.FORCE_REMOTE, "true"); - addExtraServerConfig(config); - connector =3D new Connector(serverLocator, config); - connector.create(); - invocationHandler =3D new TestInvocationHandler(); - connector.addInvocationHandler("test", invocationHandler); - connector.start(); - } - = - = - protected void shutdownServer() throws Exception - { - if (connector !=3D null) - connector.stop(); - } - = - = - static class TestInvocationHandler implements ServerInvocationHandler - { - public void addListener(InvokerCallbackHandler callbackHandler) - { - try - { - callbackHandler.handleCallback(new Callback("callback")); - } - catch (HandleCallbackException e) - { - log.error("Unable to send callback", e); - } - } - public Object invoke(final InvocationRequest invocation) throws Thro= wable - { - return invocation.getParameter(); - } - public void removeListener(InvokerCallbackHandler callbackHandler) {} - public void setMBeanServer(MBeanServer server) {} - public void setInvoker(ServerInvoker invoker) {} - } - = - = - static class TestCallbackHandler implements InvokerCallbackHandler - { - public int counter; - public void handleCallback(Callback callback) throws HandleCallbackE= xception - { - counter++; - log.info("received callback"); - } = - } +/* +* 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.test.remoting.transport.bisocket.timertask; + +import java.lang.reflect.Field; +import java.net.InetAddress; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; + +import javax.management.MBeanServer; + +import junit.framework.TestCase; + +import org.apache.log4j.ConsoleAppender; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.PatternLayout; +import org.jboss.logging.XLevel; +import org.jboss.remoting.Client; +import org.jboss.remoting.InvocationRequest; +import org.jboss.remoting.InvokerLocator; +import org.jboss.remoting.ServerInvocationHandler; +import org.jboss.remoting.ServerInvoker; +import org.jboss.remoting.callback.Callback; +import org.jboss.remoting.callback.HandleCallbackException; +import org.jboss.remoting.callback.InvokerCallbackHandler; +import org.jboss.remoting.callback.ServerInvokerCallbackHandler; +import org.jboss.remoting.transport.Connector; +import org.jboss.remoting.transport.PortUtil; +import org.jboss.remoting.transport.bisocket.Bisocket; +import org.jboss.remoting.transport.bisocket.BisocketClientInvoker; +import org.jboss.remoting.transport.bisocket.BisocketServerInvoker; + + +/** + * Unit test for JBREM-1005. + * = + * @author Ron Sigal + * @version $Revision: 1.1 $ + *+ * Copyright Jun 26, 2008 + *
+ */ +public class TimerTaskTestCase extends TestCase +{ + private static Logger log =3D Logger.getLogger(TimerTaskTestCase.class); + = + private static boolean firstTime =3D true; + private static boolean purgeMethodAvailable; + = + protected String host; + protected int port; + protected String locatorURI; + protected InvokerLocator serverLocator; + protected Connector connector; + protected TestInvocationHandler invocationHandler; + + = + public void setUp() throws Exception + { + if (firstTime) + { + firstTime =3D false; + Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO); + Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); + String pattern =3D "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; + PatternLayout layout =3D new PatternLayout(pattern); + ConsoleAppender consoleAppender =3D new ConsoleAppender(layout); + Logger.getRootLogger().addAppender(consoleAppender); + = + try + { + Timer.class.getDeclaredMethod("purge", new Class[]{}); + purgeMethodAvailable =3D true; + } + catch (Exception e) + { + log.info("Timer.purge() is not available: must be running with= jdk 1.4"); + } + } + } + + = + public void tearDown() + { + } + = + = + public void testZeroPingFrequency() throws Throwable + { + log.info("entering " + getName()); + = + if (!purgeMethodAvailable) + { + log.info(getName() + " PASSES (trivially)"); + return; + } + = + // Start server. + setupServer("0"); + = + // Create client. + InvokerLocator clientLocator =3D new InvokerLocator(locatorURI); + HashMap clientConfig =3D new HashMap(); + clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); + addExtraClientConfig(clientConfig); + Client client =3D new Client(clientLocator, clientConfig); + client.connect(); + = + // Test connections. + assertEquals("abc", client.invoke("abc")); + log.info("connection is good"); + = + // Set up callback handler. + TestCallbackHandler callbackHandler =3D new TestCallbackHandler(); + HashMap metadata =3D new HashMap(); + metadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); + client.addListener(callbackHandler, metadata); + assertEquals(1, callbackHandler.counter); + = + // Verify ControlMonitorTimerTask is not created. + Set callbackConnectors =3D client.getCallbackConnectors(callbackHand= ler); + assertEquals(1, callbackConnectors.size()); + Connector callbackConnector =3D (Connector) callbackConnectors.itera= tor().next(); + Field field =3D BisocketServerInvoker.class.getDeclaredField("contro= lMonitorTimerTask"); + field.setAccessible(true); = + BisocketServerInvoker serverInvoker =3D (BisocketServerInvoker) call= backConnector.getServerInvoker(); + TimerTask timerTask =3D (TimerTask) field.get(serverInvoker); + assertNull(timerTask); + log.info("ControlMonitorTimerTask was not created"); + = + // Verify PingTimerTask is not created. + field =3D ServerInvoker.class.getDeclaredField("callbackHandlers"); + field.setAccessible(true); + serverInvoker =3D (BisocketServerInvoker) connector.getServerInvoker= (); + Map callbackHandlers =3D (Map) field.get(serverInvoker); + assertEquals(1, callbackHandlers.size()); + Object o =3D callbackHandlers.values().iterator().next(); + Client callbackClient =3D ((ServerInvokerCallbackHandler) o).getCall= backClient(); + BisocketClientInvoker clientInvoker =3D (BisocketClientInvoker) call= backClient.getInvoker(); + field =3D BisocketClientInvoker.class.getDeclaredField("pingTimerTas= k"); + field.setAccessible(true); + timerTask =3D (TimerTask) field.get(clientInvoker); + assertNull(timerTask); + log.info("PingTimerTask was not created"); + = + client.disconnect(); + shutdownServer(); + log.info(getName() + " PASSES"); + } + = + = + public void testNonZeroPingFrequency() throws Throwable + { + log.info("entering " + getName()); + = + if (!purgeMethodAvailable) + { + log.info(getName() + " PASSES (trivially)"); + return; + } + = + // Start server. + setupServer("20"); + = + // Create client. + InvokerLocator clientLocator =3D new InvokerLocator(locatorURI); + HashMap clientConfig =3D new HashMap(); + clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); + addExtraClientConfig(clientConfig); + Client client =3D new Client(clientLocator, clientConfig); + client.connect(); + = + // Test connections. + assertEquals("abc", client.invoke("abc")); + log.info("connection is good"); + = + // Set up callback handler. + TestCallbackHandler callbackHandler =3D new TestCallbackHandler(); + HashMap metadata =3D new HashMap(); + metadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); + client.addListener(callbackHandler, metadata); + assertEquals(1, callbackHandler.counter); + = + // Verify ControlMonitorTimerTask is created. + Set callbackConnectors =3D client.getCallbackConnectors(callbackHand= ler); + assertEquals(1, callbackConnectors.size()); + Connector callbackConnector =3D (Connector) callbackConnectors.itera= tor().next(); + Field field =3D BisocketServerInvoker.class.getDeclaredField("contro= lMonitorTimerTask"); + field.setAccessible(true); = + BisocketServerInvoker serverInvoker =3D (BisocketServerInvoker) call= backConnector.getServerInvoker(); + TimerTask timerTask =3D (TimerTask) field.get(serverInvoker); + assertNotNull(timerTask); + log.info("ControlMonitorTimerTask was created"); + = + // Verify PingTimerTask is created. + field =3D ServerInvoker.class.getDeclaredField("callbackHandlers"); + field.setAccessible(true); + BisocketServerInvoker callbackServerInvoker =3D (BisocketServerInvok= er) connector.getServerInvoker(); + Map callbackHandlers =3D (Map) field.get(callbackServerInvoker); + assertEquals(1, callbackHandlers.size()); + Object o =3D callbackHandlers.values().iterator().next(); + Client callbackClient =3D ((ServerInvokerCallbackHandler) o).getCall= backClient(); + BisocketClientInvoker clientInvoker =3D (BisocketClientInvoker) call= backClient.getInvoker(); + field =3D BisocketClientInvoker.class.getDeclaredField("pingTimerTas= k"); + field.setAccessible(true); + timerTask =3D (TimerTask) field.get(clientInvoker); + assertNotNull(timerTask); + log.info("PingTimerTask was created"); + = + // Get count of ControlMonitorTimerTasks. + field =3D BisocketServerInvoker.class.getDeclaredField("timer"); + field.setAccessible(true); + Timer timer =3D (Timer) field.get(null); + field =3D Timer.class.getDeclaredField("queue"); + field.setAccessible(true); + Object taskQueue =3D field.get(timer); + Field serverTimerfield =3D taskQueue.getClass().getDeclaredField("si= ze"); + serverTimerfield.setAccessible(true); + int serverSize =3D ((Integer) serverTimerfield.get(taskQueue)).intVa= lue(); + log.info("ControlMonitorTimerTasks: " + serverSize); + = + // Get count of PingTimerTasks. + field =3D BisocketClientInvoker.class.getDeclaredField("timer"); + field.setAccessible(true); + timer =3D (Timer) field.get(null); + field =3D Timer.class.getDeclaredField("queue"); + field.setAccessible(true); + taskQueue =3D field.get(timer); + Field clientTimerfield =3D taskQueue.getClass().getDeclaredField("si= ze"); + clientTimerfield.setAccessible(true); + int clientSize =3D ((Integer) clientTimerfield.get(taskQueue)).intVa= lue(); + log.info("PingTimerTasks: " + clientSize); + + // Shut down callback connection and verify TimerTasks are removed f= rom = + // Timer queue. + client.removeListener(callbackHandler); + serverSize =3D ((Integer) serverTimerfield.get(taskQueue)).intValue(= ); + log.info("ControlMonitorTimerTasks: " + serverSize); + assertEquals(0, serverSize); + clientSize =3D ((Integer) clientTimerfield.get(taskQueue)).intValue(= ); + log.info("PingTimerTasks: " + clientSize); + assertEquals(0, clientSize); + = + client.disconnect(); + shutdownServer(); + log.info(getName() + " PASSES"); + } + = + = + protected String getTransport() + { + return "bisocket"; + } + = + = + protected void addExtraClientConfig(Map config) {} + protected void addExtraServerConfig(Map config) {} + = + + protected void setupServer(String pingFrequency) throws Exception + { + host =3D InetAddress.getLocalHost().getHostAddress(); + port =3D PortUtil.findFreePort(host); + locatorURI =3D getTransport() + "://" + host + ":" + port; = + locatorURI +=3D "/?" + Bisocket.PING_FREQUENCY + "=3D" + pingFrequen= cy; + serverLocator =3D new InvokerLocator(locatorURI); + log.info("Starting remoting server with locator uri of: " + locatorU= RI); + HashMap config =3D new HashMap(); + config.put(InvokerLocator.FORCE_REMOTE, "true"); + addExtraServerConfig(config); + connector =3D new Connector(serverLocator, config); + connector.create(); + invocationHandler =3D new TestInvocationHandler(); + connector.addInvocationHandler("test", invocationHandler); + connector.start(); + } + = + = + protected void shutdownServer() throws Exception + { + if (connector !=3D null) + connector.stop(); + } + = + = + static class TestInvocationHandler implements ServerInvocationHandler + { + public void addListener(InvokerCallbackHandler callbackHandler) + { + try + { + callbackHandler.handleCallback(new Callback("callback")); + } + catch (HandleCallbackException e) + { + log.error("Unable to send callback", e); + } + } + public Object invoke(final InvocationRequest invocation) throws Thro= wable + { + return invocation.getParameter(); + } + public void removeListener(InvokerCallbackHandler callbackHandler) {} + public void setMBeanServer(MBeanServer server) {} + public void setInvoker(ServerInvoker invoker) {} + } + = + = + static class TestCallbackHandler implements InvokerCallbackHandler + { + public int counter; + public void handleCallback(Callback callback) throws HandleCallbackE= xception + { + counter++; + log.info("received callback"); + } = + } } \ No newline at end of file Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoti= ng/transport/bisocket/timertask/TimerTaskTestCase.java ___________________________________________________________________ Name: svn:eol-style + native --===============8342361905193588784==--