[jboss-cvs] JBossAS SVN: r81239 - projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Nov 18 12:15:04 EST 2008


Author: adrian at jboss.org
Date: 2008-11-18 12:15:04 -0500 (Tue, 18 Nov 2008)
New Revision: 81239

Added:
   projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/NamingTestSuite.java
Modified:
   projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/JndiPermissionUnitTest.java
   projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/NamingEventsUnitTest.java
   projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/NamingMCUnitTest.java
   projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/NamingServerSecurityManagerUnitTest.java
   projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/SecurityUtil.java
   projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/TestJNPSockets.java
Log:
Add a testsuite and source code tidyup for tests

Modified: projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/JndiPermissionUnitTest.java
===================================================================
--- projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/JndiPermissionUnitTest.java	2008-11-18 17:14:34 UTC (rev 81238)
+++ projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/JndiPermissionUnitTest.java	2008-11-18 17:15:04 UTC (rev 81239)
@@ -30,6 +30,8 @@
 import javax.naming.CompositeName;
 import javax.naming.Name;
 
+import junit.framework.Test;
+
 import org.jboss.naming.JndiPermission;
 import org.jboss.test.BaseTestCase;
 
@@ -71,6 +73,11 @@
       ALL_ACTIONS = builder.toString();
    }
    
+   public static Test suite()
+   {
+      return suite(JndiPermissionUnitTest.class);
+   }
+   
    public JndiPermissionUnitTest(String name)
    {
       super(name);

Modified: projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/NamingEventsUnitTest.java
===================================================================
--- projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/NamingEventsUnitTest.java	2008-11-18 17:14:34 UTC (rev 81238)
+++ projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/NamingEventsUnitTest.java	2008-11-18 17:15:04 UTC (rev 81239)
@@ -29,30 +29,39 @@
 import javax.naming.InitialContext;
 import javax.naming.event.EventContext;
 import javax.naming.event.NamingEvent;
-import javax.naming.event.NamingListener;
 
+import junit.framework.Test;
+
+import org.jboss.test.BaseTestCase;
 import org.jnp.interfaces.MarshalledValuePair;
 import org.jnp.server.ExecutorEventMgr;
 import org.jnp.server.NamingBeanImpl;
-import org.jnp.test.TestJNPSockets.ClientSocketFactory;
-import org.jnp.test.TestJNPSockets.ServerSocketFactory;
 import org.jnp.test.support.QueueEventListener;
 
-import junit.framework.TestCase;
-
 /**
  * @author Scott.Stark at jboss.org
  * @version $Revision:$
  */
-public class NamingEventsUnitTest extends TestCase
+public class NamingEventsUnitTest extends BaseTestCase
 {
    /** The actual namingMain service impl bean */
    private static NamingBeanImpl namingBean;
    private QueueEventListener listener = new QueueEventListener();
+   
+   public static Test suite()
+   {
+      return suite(NamingEventsUnitTest.class);
+   }
+   
+   public NamingEventsUnitTest(String name)
+   {
+      super(name);
+   }
 
    @Override
    protected void setUp() throws Exception
    {
+      super.setUp();
       namingBean = new NamingBeanImpl();
       namingBean.setInstallGlobalService(true);
       namingBean.setEventMgr(new ExecutorEventMgr());

Modified: projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/NamingMCUnitTest.java
===================================================================
--- projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/NamingMCUnitTest.java	2008-11-18 17:14:34 UTC (rev 81238)
+++ projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/NamingMCUnitTest.java	2008-11-18 17:15:04 UTC (rev 81239)
@@ -71,7 +71,7 @@
    /**
     * Obtain the InitialContext from the InitialContextFactory bean ctx property.
     * Each test expects an InitialContextFactory bean
-    * @see org.jboss.naming.InitialContextFactory
+    * @see org.jboss.naming.NamingContextFactory
     * 
     * @param ctx
     */

Modified: projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/NamingServerSecurityManagerUnitTest.java
===================================================================
--- projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/NamingServerSecurityManagerUnitTest.java	2008-11-18 17:14:34 UTC (rev 81238)
+++ projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/NamingServerSecurityManagerUnitTest.java	2008-11-18 17:15:04 UTC (rev 81239)
@@ -31,9 +31,10 @@
 
 import javax.naming.InitialContext;
 
-import junit.framework.TestCase;
+import junit.framework.Test;
 
 import org.jboss.naming.JndiPermission;
+import org.jboss.test.BaseTestCase;
 import org.jnp.server.ExecutorEventMgr;
 import org.jnp.server.NamingBeanImpl;
 import org.jnp.test.support.QueueSecurityManager;
@@ -45,15 +46,26 @@
  * @author Scott.Stark at jboss.org
  * @version $Revision$
  */
-public class NamingServerSecurityManagerUnitTest extends TestCase
+public class NamingServerSecurityManagerUnitTest extends BaseTestCase
 {
    /** The actual namingMain service impl bean */
    private NamingBeanImpl namingBean;
    private InitialContext ic;
+   
+   public static Test suite()
+   {
+      return suite(NamingServerSecurityManagerUnitTest.class);
+   }
+   
+   public NamingServerSecurityManagerUnitTest(String name)
+   {
+      super(name);
+   }
 
    @Override
    protected void setUp() throws Exception
    {
+      super.setUp();
       System.out.println("+++ setUp, creating NamingBean");
       namingBean = new NamingBeanImpl();
       namingBean.setInstallGlobalService(true);
@@ -67,9 +79,10 @@
       env.setProperty("java.naming.factory.url.pkgs", "org.jnp.interfaces");
       ic = new InitialContext(env);
    }
-   protected void tearDown()
+   protected void tearDown() throws Exception
    {
       System.setSecurityManager(null);
+      super.tearDown();
    }
 
    /**

Added: projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/NamingTestSuite.java
===================================================================
--- projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/NamingTestSuite.java	                        (rev 0)
+++ projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/NamingTestSuite.java	2008-11-18 17:15:04 UTC (rev 81239)
@@ -0,0 +1,53 @@
+/*
+* 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.jnp.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * NamingTestSuite.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class NamingTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Controller Tests");
+
+      suite.addTest(JndiPermissionUnitTest.suite());
+      suite.addTest(NamingEventsUnitTest.suite());
+      suite.addTest(NamingMCUnitTest.suite());
+      suite.addTest(NamingServerSecurityManagerUnitTest.suite());
+      suite.addTest(TestJNPSockets.suite());
+      
+      return suite;
+   }
+}

Modified: projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/SecurityUtil.java
===================================================================
--- projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/SecurityUtil.java	2008-11-18 17:14:34 UTC (rev 81238)
+++ projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/SecurityUtil.java	2008-11-18 17:15:04 UTC (rev 81239)
@@ -23,9 +23,10 @@
 
 import java.security.AccessControlException;
 
-import javax.naming.Context;
 import javax.naming.InitialContext;
 
+import org.jboss.test.AbstractTestCase;
+
 import junit.framework.AssertionFailedError;
 
 /**
@@ -42,7 +43,7 @@
       throws Exception
    {
       ic.createSubcontext("path1");
-      Object p1 = ic.lookup("path1");
+      ic.lookup("path1");
       ic.list("path1");
       ic.listBindings("path1");
       ic.bind("path1/x", "x.bind");
@@ -63,11 +64,11 @@
          if(expectFailure)
             fail("Was able to create path2 subcontext");
       }
-      catch(AccessControlException e)
+      catch(Exception e)
       {
-         System.out.println(e);
+         AbstractTestCase.checkThrowable(AccessControlException.class, e);
       }
-      Context path1x = ic.createSubcontext("path1x");
+      ic.createSubcontext("path1x");
       try
       {
          if(expectFailure)
@@ -76,9 +77,9 @@
             fail("Was able to rebind path1x subcontext");
          }
       }
-      catch(AccessControlException e)
+      catch(Exception e)
       {
-         System.out.println(e);
+         AbstractTestCase.checkThrowable(AccessControlException.class, e);
       }
       
       try
@@ -98,9 +99,9 @@
          if(expectFailure)
             fail("Was able to list path1x subcontext");
       }
-      catch(AccessControlException e)
+      catch(Exception e)
       {
-         System.out.println(e);
+         AbstractTestCase.checkThrowable(AccessControlException.class, e);
       }
 
       try
@@ -109,9 +110,9 @@
          if(expectFailure)
             fail("Was able to listBindings path1x subcontext");
       }
-      catch(AccessControlException e)
+      catch(Exception e)
       {
-         System.out.println(e);
+         AbstractTestCase.checkThrowable(AccessControlException.class, e);
       }
 
       try
@@ -120,9 +121,9 @@
          if(expectFailure)
             fail("Was able to bind path1x/x");
       }
-      catch(AccessControlException e)
+      catch(Exception e)
       {
-         System.out.println(e);
+         AbstractTestCase.checkThrowable(AccessControlException.class, e);
       }
 
       try
@@ -131,9 +132,9 @@
          if(expectFailure)
             fail("Was able to rebind path1x/x");
       }
-      catch(AccessControlException e)
+      catch(Exception e)
       {
-         System.out.println(e);
+         AbstractTestCase.checkThrowable(AccessControlException.class, e);
       }
 
       ic.unbind("path1x");

Modified: projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/TestJNPSockets.java
===================================================================
--- projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/TestJNPSockets.java	2008-11-18 17:14:34 UTC (rev 81238)
+++ projects/naming/branches/Branch_5_0/jnpserver/src/test/java/org/jnp/test/TestJNPSockets.java	2008-11-18 17:15:04 UTC (rev 81239)
@@ -23,18 +23,19 @@
 
 import java.io.IOException;
 import java.io.Serializable;
+import java.net.ServerSocket;
 import java.net.Socket;
-import java.net.ServerSocket;
 import java.rmi.server.RMIClientSocketFactory;
 import java.rmi.server.RMIServerSocketFactory;
 import java.util.Properties;
+
 import javax.naming.InitialContext;
 
-import junit.framework.TestSuite;
-import junit.framework.TestCase;
+import junit.framework.Test;
 
+import org.jboss.logging.Logger;
+import org.jboss.test.BaseTestCase;
 import org.jnp.server.Main;
-import org.jnp.server.NamingBean;
 import org.jnp.server.NamingBeanImpl;
 
 /** A test of RMI custom sockets with the jnp JNDI provider.
@@ -42,14 +43,21 @@
  @author Scott.Stark at jboss.org
  @version $Revision:70105 $
  */
-public class TestJNPSockets extends TestCase
+public class TestJNPSockets extends BaseTestCase
 {
+   private static final Logger log = Logger.getLogger(TestJNPSockets.class);
+   
    /** The actual namingMain service impl bean */
    private static NamingBeanImpl namingBean;
    /** */
    private static Main namingMain = new Main("org.jnp.server");
 
    static int serverPort;
+   
+   public static Test suite()
+   {
+      return suite(TestJNPSockets.class);
+   }
 
    public TestJNPSockets(String name)
    {
@@ -58,6 +66,7 @@
 
    protected void setUp() throws Exception
    {
+      super.setUp();
       if (namingBean != null)
          return;
 
@@ -79,7 +88,7 @@
       env.setProperty("java.naming.provider.url", "localhost:" + serverPort);
       env.setProperty("java.naming.factory.url.pkgs", "org.jnp.interfaces");
       InitialContext ctx = new InitialContext(env);
-      System.out.println("Connected to jnp service");
+      log.info("Connected to jnp service");
       ctx.list("");
       ctx.close();
       if (ClientSocketFactory.created == false)
@@ -91,8 +100,7 @@
 
    public static void main(String[] args) throws Exception
    {
-      System.setErr(System.out);
-      TestSuite suite = new TestSuite(TestJNPSockets.class);
+      Test suite = suite();
       junit.textui.TestRunner.run(suite);
    }
 
@@ -105,7 +113,7 @@
       public Socket createSocket(String host, int port) throws IOException
       {
          Socket clientSocket = new Socket(host, port);
-         System.out.println("createSocket -> " + clientSocket);
+         log.info("createSocket -> " + clientSocket);
          created = true;
          return clientSocket;
       }
@@ -120,7 +128,7 @@
       public ServerSocket createServerSocket(int port) throws IOException
       {
          ServerSocket serverSocket = new ServerSocket(port);
-         System.out.println("createServerSocket -> " + serverSocket);
+         log.info("createServerSocket -> " + serverSocket);
          created = true;
          return serverSocket;
       }




More information about the jboss-cvs-commits mailing list