directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ersi...@apache.org
Subject svn commit: r414967 - in /directory/trunks/shared/ldap/src: main/java/org/apache/directory/shared/ldap/util/DirectoryClassUtils.java test/java/org/apache/directory/shared/ldap/util/DirectoryClassUtilsTest.java
Date Sat, 17 Jun 2006 00:22:36 GMT
Author: ersiner
Date: Fri Jun 16 17:22:35 2006
New Revision: 414967

URL: http://svn.apache.org/viewvc?rev=414967&view=rev
Log:
Added test case for DirectoryClassUtils.

Added:
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/util/DirectoryClassUtilsTest.java
Modified:
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/DirectoryClassUtils.java

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/DirectoryClassUtils.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/DirectoryClassUtils.java?rev=414967&r1=414966&r2=414967&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/DirectoryClassUtils.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/DirectoryClassUtils.java
Fri Jun 16 17:22:35 2006
@@ -27,7 +27,7 @@
 {
     
     /**
-     * A replacement {@link java.lang.Class.getMethod} with extended functionality.
+     * A replacement for {@link java.lang.Class.getMethod} with extended functionality.
      * 
      * <p>
      * This method returns parameter-list assignment-compatible method as well as

Added: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/util/DirectoryClassUtilsTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/util/DirectoryClassUtilsTest.java?rev=414967&view=auto
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/util/DirectoryClassUtilsTest.java
(added)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/util/DirectoryClassUtilsTest.java
Fri Jun 16 17:22:35 2006
@@ -0,0 +1,115 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.directory.shared.ldap.util;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Test case for {@link DirectoryClassUtils}.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev:$
+ */
+public class DirectoryClassUtilsTest extends TestCase
+{
+    private static class TestClass
+    {
+        public static void methodA( String str )
+        {
+            
+        }
+        
+        public static void methodB( Collection c )
+        {
+            
+        }
+    }
+    
+    public void testSameBehaviourOfStandardGetMethod()
+    {
+        Method m1 = null;
+        Method m2 = null;
+        
+        try
+        {
+            m1 = TestClass.class.getMethod( "methodA", new Class[] { String.class } );
+        }
+        catch ( SecurityException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch ( NoSuchMethodException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        
+        try
+        {
+            m2 = DirectoryClassUtils.getAssignmentCompatibleMethod( TestClass.class, "methodA",
new Class[] { String.class } );
+        }
+        catch ( NoSuchMethodException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        
+        assertEquals( m1, m2 );
+        
+    }
+    
+    public void testNewBehaviourOfAssignmentCompatibleGetMethod()
+    {
+        Method m2 = null;
+        
+        try
+        {
+            TestClass.class.getMethod( "methodB", new Class[] { ArrayList.class } );
+            fail( "We should not have come here." );
+        }
+        catch ( SecurityException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch ( NoSuchMethodException e )
+        {
+            assertNotNull( e );
+        }
+        
+        try
+        {
+            m2 = DirectoryClassUtils.getAssignmentCompatibleMethod( TestClass.class, "methodB",
new Class[] { ArrayList.class } );
+        }
+        catch ( NoSuchMethodException e )
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        
+        assertNotNull( m2 );
+        
+    }
+
+}



Mime
View raw message