[jboss-cvs] JBossAS SVN: r66074 - in projects/microcontainer/trunk/container/src: tests/org/jboss/test and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 12 03:19:31 EDT 2007


Author: alesj
Date: 2007-10-12 03:19:31 -0400 (Fri, 12 Oct 2007)
New Revision: 66074

Added:
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/spi/ContainerSPITestSuite.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/spi/signature/SignatureTestCase.java
Removed:
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/spi/signature/SignatureTest.java
Modified:
   projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/Signature.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/ContainerTest.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/MetaDataAllTestSuite.java
Log:
Refactored genman's SignatureTC.
Removed duplicated test util methods on ContainerTest - already part of jboss test.

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/Signature.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/Signature.java	2007-10-12 06:00:02 UTC (rev 66073)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/signature/Signature.java	2007-10-12 07:19:31 UTC (rev 66074)
@@ -22,7 +22,6 @@
 package org.jboss.metadata.spi.signature;
 
 import java.lang.reflect.Array;
-import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
@@ -60,6 +59,7 @@
    private static final Map<String, Class<?>> primitiveTypes = new HashMap<String, Class<?>>();
    private static final Map<String, String> primitiveArrayTypes = new HashMap<String, String>();
    private static final Map<String, Class<?>> primitiveArrayTypesClassMap = new HashMap<String, Class<?>>();
+
    static
    {
       primitiveTypes.put(Byte.TYPE.getName(), Byte.TYPE);
@@ -294,16 +294,6 @@
    }
    
    /**
-    * Constructs a new Signature.
-    * 
-    * @param method class method
-    */
-   public Signature(Method method)
-   {
-	   this(method.getName(), method.getParameterTypes());
-   }
-
-   /**
     * Returns the name.
     * 
     * @return the name.

Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/ContainerTest.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/ContainerTest.java	2007-10-12 06:00:02 UTC (rev 66073)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/ContainerTest.java	2007-10-12 07:19:31 UTC (rev 66074)
@@ -21,10 +21,6 @@
 */
 package org.jboss.test;
 
-import java.util.Arrays;
-
-import junit.framework.AssertionFailedError;
-
 /**
  * A ContainerTest.
  * 
@@ -44,39 +40,6 @@
    }
    
    /**
-    * Assert an array is empty or null
-    * 
-    * TODO Move this to the AbstractTestCase
-    * @param array the array
-    */
-   protected static void assertEmpty(Object[] array)
-   {
-      if (array != null)
-         assertEquals(Arrays.asList(array).toString(), 0, array.length);
-   }
-
-   /**
-    * Assert two arrays are equal
-    *
-    * TODO fix the abstract test case
-    * @param expected the expected array
-    * @param actual the actual array
-    */
-   protected void assertEquals(Object[] expected, Object[] actual)
-   {
-      if (Arrays.equals(expected, actual) == false)
-      {
-         String expectedString = null;
-         if (expected != null)
-            expectedString = Arrays.asList(expected).toString();
-         String actualString = null;
-         if (actual != null)
-            actualString = Arrays.asList(actual).toString();
-         throw new AssertionFailedError("expected: " + expectedString + " actual: " + actualString);
-      }
-   }
-
-   /**
     * Default setup with security manager enabled
     * 
     * @param clazz the class

Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/MetaDataAllTestSuite.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/MetaDataAllTestSuite.java	2007-10-12 06:00:02 UTC (rev 66073)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/MetaDataAllTestSuite.java	2007-10-12 07:19:31 UTC (rev 66074)
@@ -26,6 +26,7 @@
 import org.jboss.test.metadata.repository.test.RepositoryTestSuite;
 import org.jboss.test.metadata.retrieval.test.RetrievalTestSuite;
 import org.jboss.test.metadata.scope.test.ScopeTestSuite;
+import org.jboss.test.metadata.spi.ContainerSPITestSuite;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -53,7 +54,8 @@
       suite.addTest(MetaDataLoaderTestSuite.suite());
       suite.addTest(MetaDataContextTestSuite.suite());
       suite.addTest(RepositoryTestSuite.suite());
-      
+      suite.addTest(ContainerSPITestSuite.suite());
+
       return suite;
    }
 }

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/spi/ContainerSPITestSuite.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/spi/ContainerSPITestSuite.java	                        (rev 0)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/spi/ContainerSPITestSuite.java	2007-10-12 07:19:31 UTC (rev 66074)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.metadata.spi;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.jboss.test.metadata.spi.signature.SignatureTestCase;
+
+/**
+ * Container spi tests.
+ * 
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ContainerSPITestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Container SPI Tests");
+
+      suite.addTest(SignatureTestCase.suite());
+
+      return suite;
+   }
+}
\ No newline at end of file

Deleted: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/spi/signature/SignatureTest.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/spi/signature/SignatureTest.java	2007-10-12 06:00:02 UTC (rev 66073)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/spi/signature/SignatureTest.java	2007-10-12 07:19:31 UTC (rev 66074)
@@ -1,30 +0,0 @@
-package org.jboss.test.metadata.spi.signature;
-
-import java.lang.reflect.Method;
-import java.util.Arrays;
-
-import org.jboss.metadata.spi.signature.Signature;
-
-import junit.framework.TestCase;
-
-public class SignatureTest extends TestCase
-{
-
-   public void testArray() throws Exception
-   {
-      Method method = getClass().getMethod("method", String.class, byte[].class, Byte[].class, String[][].class);
-      Signature s = new Signature(method);
-      Class<?>[] parametersTypes = s.getParametersTypes(getClass());
-      assertEquals(4, parametersTypes.length);
-
-      String p[] = { String.class.getName(), byte[].class.getName(), Byte[].class.getName(), String[][].class.getName()};
-      Signature s2 = new Signature("method", p);
-      Class<?>[] parametersTypes2 = s2.getParametersTypes(getClass());
-      assert Arrays.equals(parametersTypes, parametersTypes2);
-   }
-
-   public void method(String s, byte b[], Byte b2[], String[][] sa)
-   {
-   }
-
-}

Copied: projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/spi/signature/SignatureTestCase.java (from rev 66073, projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/spi/signature/SignatureTest.java)
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/spi/signature/SignatureTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/metadata/spi/signature/SignatureTestCase.java	2007-10-12 07:19:31 UTC (rev 66074)
@@ -0,0 +1,46 @@
+package org.jboss.test.metadata.spi.signature;
+
+import java.lang.reflect.Method;
+
+import junit.framework.Test;
+import org.jboss.metadata.spi.signature.Signature;
+import org.jboss.test.ContainerTest;
+
+/**
+ * @author genman
+ */
+public class SignatureTestCase extends ContainerTest
+{
+   public SignatureTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(SignatureTestCase.class);
+   }
+
+   public void testArray() throws Exception
+   {
+      Method method = getClass().getMethod("method", String.class, byte[].class, Byte[].class, String[][].class);
+      Signature s = getSignature(method);
+      Class<?>[] parametersTypes = s.getParametersTypes(getClass());
+      assertEquals(4, parametersTypes.length);
+
+      String p[] = { String.class.getName(), byte[].class.getName(), Byte[].class.getName(), String[][].class.getName()};
+      Signature s2 = new Signature("method", p);
+      Class<?>[] parametersTypes2 = s2.getParametersTypes(getClass());
+      assertEquals(parametersTypes, parametersTypes2);
+   }
+
+   // here for a reason - this test uses it
+   public void method(String s, byte b[], Byte b2[], String[][] sa)
+   {
+   }
+
+   protected Signature getSignature(Method method)
+   {
+      return new Signature(method.getName(), method.getParameterTypes());
+   }
+}




More information about the jboss-cvs-commits mailing list