[jboss-remoting-commits] JBoss Remoting SVN: r5876 - remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Wed Jun 23 10:12:56 EDT 2010


Author: ron.sigal at jboss.com
Date: 2010-06-23 10:12:55 -0400 (Wed, 23 Jun 2010)
New Revision: 5876

Added:
   remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingTestBase.java
Modified:
   remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteConfigurationTestCase.java
   remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointConfigurationTestCase.java
   remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ServiceRegistrationTestCase.java
Log:
JBREM-1228: Added RemotingTestBase as parent class.

Modified: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteConfigurationTestCase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteConfigurationTestCase.java	2010-06-22 22:30:04 UTC (rev 5875)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteConfigurationTestCase.java	2010-06-23 14:12:55 UTC (rev 5876)
@@ -63,7 +63,6 @@
 import org.jboss.xnio.Options;
 import org.jboss.xnio.TcpServer;
 import org.jboss.xnio.Xnio;
-import org.jboss.xnio.IoFuture.Status;
 import org.jboss.xnio.channels.BoundChannel;
 import org.jboss.xnio.channels.ConnectedStreamChannel;
 import org.jboss.xnio.log.Logger;
@@ -81,39 +80,12 @@
  * Copyright Jun 7, 2010
  */
 @Test(suiteName = "ClientServerRemoteConfiguration")
-public class ClientServerRemoteConfigurationTestCase {
+public class ClientServerRemoteConfigurationTestCase extends RemotingTestBase {
 
    private static final Logger log = Logger.getLogger(ClientServerRemoteConfigurationTestCase.class);
 
    private static int counter;
 
-   static void enter() {
-      final StackTraceElement e = new Throwable().getStackTrace()[1];
-      log.info("Entering: %s#%s", e.getClassName(), e.getMethodName());
-   }
-
-   static void exit() {
-      final StackTraceElement e = new Throwable().getStackTrace()[1];
-      log.info("Exiting: %s#%s", e.getClassName(), e.getMethodName());
-      log.info("-------------------------------------------------------------");
-   }
-   
-   static <T> T getFutureResult(IoFuture<T> future, String errorMessage) throws IOException {
-      Status status = null;
-      switch (status = future.await(5000, TimeUnit.MILLISECONDS)) {
-         case DONE: {
-            return future.get();
-         }
-         case FAILED: {
-            log.error(errorMessage);
-            throw future.getException();
-         }
-         default: {
-            throw new RuntimeException("unexpected future state: " + status);
-         }
-      }
-   }
-
    @BeforeMethod
    public void setUp() {
       ServiceLoader.load(RemotingServiceDescriptor.class);
@@ -178,7 +150,7 @@
          }
          assertEquals(20, sp0.requestListener.counter, "Should be equal");
          assertEquals(20, sp1.requestListener.counter, "Should be equal");
-         log.info("testAllDistinct() PASSES");
+         log.info(getName() + " PASSES");
       } finally {
          clients.close();
          connections.close();
@@ -248,7 +220,7 @@
          }
          assertEquals(20, sp0.requestListener.counter, "Should be equal");
          assertEquals(20, sp1.requestListener.counter, "Should be equal");
-         log.info("testSharedExecutor() PASSES");
+         log.info(getName() + " PASSES");
       } finally {
          clients.close();
          connections.close();
@@ -317,7 +289,7 @@
          }
          assertEquals(20, sp0.requestListener.counter, "Should be equal");
          assertEquals(20, sp1.requestListener.counter, "Should be equal");
-         log.info("testSharedExecutorEndpoint() PASSES");
+         log.info(getName() + " PASSES");
       } finally {
          clients.close();
          connections.close();
@@ -386,7 +358,7 @@
          }
          assertEquals(20, sp0.requestListener.counter, "Should be equal");
          assertEquals(20, sp1.requestListener.counter, "Should be equal");
-         log.info("testSharedExecutorEndpointXnio() PASSES");
+         log.info(getName() + " PASSES");
       } finally {
          clients.close();
          connections.close();
@@ -474,7 +446,7 @@
          assertEquals(10, sp01.requestListener.counter, "Should be equal");
          assertEquals(10, sp10.requestListener.counter, "Should be equal");
          assertEquals(10, sp11.requestListener.counter, "Should be equal");
-         log.info("testSharedExecutorEndpointXnioTcpServer() PASSES");
+         log.info(getName() + " PASSES");
       } finally {
          clients.close();
          connections.close();
@@ -558,7 +530,7 @@
             assertEquals(id0, client111.invoke("dummy"), "Should be equal");
          }
          assertEquals(40, sp00.requestListener.counter, "Should be equal");
-         log.info("testSharedExecutorEndpointXnioTcpServerRequestListener() PASSES");
+         log.info(getName() + " PASSES");
       } finally {
          clients.close();
          connections.close();

Modified: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointConfigurationTestCase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointConfigurationTestCase.java	2010-06-22 22:30:04 UTC (rev 5875)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointConfigurationTestCase.java	2010-06-23 14:12:55 UTC (rev 5876)
@@ -73,21 +73,10 @@
  * Copyright Jun 21, 2010
  */
 @Test(suiteName = "EndpointConfiguration")
-public class EndpointConfigurationTestCase {
+public class EndpointConfigurationTestCase extends RemotingTestBase {
 
    private static final Logger log = Logger.getLogger(EndpointConfigurationTestCase.class);
 
-   static void enter() {
-      final StackTraceElement e = new Throwable().getStackTrace()[1];
-      log.info("Entering: %s#%s", e.getClassName(), e.getMethodName());
-   }
-
-   static void exit() {
-      final StackTraceElement e = new Throwable().getStackTrace()[1];
-      log.info("Exiting: %s#%s", e.getClassName(), e.getMethodName());
-      log.info("-------------------------------------------------------------");
-   }
-
    @BeforeMethod
    public void setUp() {
       System.clearProperty("remoting.property.file");
@@ -148,7 +137,7 @@
          assertSame(mockClassTable, context.getProtocolServiceProvider(ProtocolServiceType.CLASS_TABLE, "mockClassTable"));
          assertSame(mockObjectResolver, context.getProtocolServiceProvider(ProtocolServiceType.OBJECT_RESOLVER, "mockObjectResolver"));
          assertSame(mockObjectTable, context.getProtocolServiceProvider(ProtocolServiceType.OBJECT_TABLE, "mockObjectTable"));
-         log.info("testProgrammaticConfiguration() PASSES");
+         log.info(getName() + " PASSES");
          
       } finally {
          if (regClassExternalizerFactoryProvider != null) {
@@ -195,7 +184,7 @@
          assertTrue(context.getProtocolServiceProvider(ProtocolServiceType.CLASS_TABLE, "mockClassTable_sd") instanceof MockClassTable);
          assertTrue(context.getProtocolServiceProvider(ProtocolServiceType.OBJECT_RESOLVER, "mockObjectResolver_sd") instanceof MockObjectResolver);
          assertTrue(context.getProtocolServiceProvider(ProtocolServiceType.OBJECT_TABLE, "mockObjectTable_sd") instanceof MockObjectTable);
-         log.info("testConfigurationByServiceDescriptorFile() PASSES");
+         log.info(getName() + " PASSES");
       } finally {
          exit();
       }

Added: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingTestBase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingTestBase.java	                        (rev 0)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingTestBase.java	2010-06-23 14:12:55 UTC (rev 5876)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.remoting3.test;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.xnio.IoFuture;
+import org.jboss.xnio.IoFuture.Status;
+import org.jboss.xnio.log.Logger;
+
+/**
+ * 
+ * @author <a href="ron.sigal at jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jun 23, 2010
+ */
+public class RemotingTestBase {
+   private static final Logger log = Logger.getLogger(RemotingTestBase.class);
+   
+   protected String getName() {
+      final StackTraceElement e = new Throwable().getStackTrace()[1];
+      return e.getMethodName();      
+   }
+   
+   protected static void enter() {
+      final StackTraceElement e = new Throwable().getStackTrace()[1];
+      log.info("Entering: %s#%s", e.getClassName(), e.getMethodName());
+   }
+
+   protected static void exit() {
+      final StackTraceElement e = new Throwable().getStackTrace()[1];
+      log.info("Exiting: %s#%s", e.getClassName(), e.getMethodName());
+      log.info("-------------------------------------------------------------");
+   }
+   
+   protected static <T> T getFutureResult(IoFuture<T> future, String errorMessage) throws IOException {
+      return getFutureResult(future, 5000, errorMessage);
+   }
+   
+   protected static <T> T getFutureResult(IoFuture<T> future, int timeout, String errorMessage) throws IOException {
+      Status status = null;
+      switch (status = future.await(timeout, TimeUnit.MILLISECONDS)) {
+         case DONE: {
+            return future.get();
+         }
+         case FAILED: {
+            log.error(errorMessage);
+            throw future.getException();
+         }
+         default: {
+            throw new RuntimeException("unexpected future state: " + status);
+         }
+      }
+   }
+}

Modified: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ServiceRegistrationTestCase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ServiceRegistrationTestCase.java	2010-06-22 22:30:04 UTC (rev 5875)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ServiceRegistrationTestCase.java	2010-06-23 14:12:55 UTC (rev 5876)
@@ -58,22 +58,11 @@
  * @param <O>
  */
 @Test(suiteName = "ServiceRegistration")
-public class ServiceRegistrationTestCase<O> {
+public class ServiceRegistrationTestCase<O> extends RemotingTestBase {
 
    private static final Logger log = Logger.getLogger(ServiceRegistrationTestCase.class);
    private static Object lock = new Object();
 
-   static void enter() {
-      final StackTraceElement e = new Throwable().getStackTrace()[1];
-      log.info("Entering: %s#%s", e.getClassName(), e.getMethodName());
-   }
-
-   static void exit() {
-      final StackTraceElement e = new Throwable().getStackTrace()[1];
-      log.info("Exiting: %s#%s", e.getClassName(), e.getMethodName());
-      log.info("-------------------------------------------------------------");
-   }
-
    @BeforeMethod
    public void setUp() {
    }
@@ -115,6 +104,8 @@
          assertEquals(SubReplyType.class, registrationListener.info.getReplyClass());
          assertSame(optionMap, registrationListener.info.getOptionMap());
          
+         log.info(getName() + " PASSES");
+         
       } finally {
          if (registration != null) {
             registration.close();
@@ -172,6 +163,5 @@
             lock.notify();
          }
       }
-      
    }
 }



More information about the jboss-remoting-commits mailing list