Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 34323 invoked from network); 17 Jun 2006 00:22:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 17 Jun 2006 00:22:58 -0000 Received: (qmail 44779 invoked by uid 500); 17 Jun 2006 00:22:57 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 44741 invoked by uid 500); 17 Jun 2006 00:22:57 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 44730 invoked by uid 99); 17 Jun 2006 00:22:57 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Jun 2006 17:22:57 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Jun 2006 17:22:56 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id A22511A983A; Fri, 16 Jun 2006 17:22:36 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@directory.apache.org From: ersiner@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060617002236.A22511A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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. * *

* 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 Apache Directory Project + * @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 ); + + } + +}