Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 913CE95AF for ; Thu, 15 Mar 2012 12:07:24 +0000 (UTC) Received: (qmail 51446 invoked by uid 500); 15 Mar 2012 12:07:24 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 51264 invoked by uid 500); 15 Mar 2012 12:07:24 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 51251 invoked by uid 99); 15 Mar 2012 12:07:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Mar 2012 12:07:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Mar 2012 12:07:22 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id BAC3E2388978 for ; Thu, 15 Mar 2012 12:07:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1300947 - in /commons/sandbox/beanutils2/trunk/src: changes/changes.xml test/java/org/apache/commons/beanutils2/OnClassNameTestCase.java Date: Thu, 15 Mar 2012 12:07:02 -0000 To: commits@commons.apache.org From: simonetripodi@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120315120702.BAC3E2388978@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: simonetripodi Date: Thu Mar 15 12:07:02 2012 New Revision: 1300947 URL: http://svn.apache.org/viewvc?rev=1300947&view=rev Log: [SANDBOX-398] Implement unit tests for BeanUtils.onClassName() - patch provided by Benedikt Ritter Added: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/OnClassNameTestCase.java (with props) Modified: commons/sandbox/beanutils2/trunk/src/changes/changes.xml Modified: commons/sandbox/beanutils2/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/changes/changes.xml?rev=1300947&r1=1300946&r2=1300947&view=diff ============================================================================== --- commons/sandbox/beanutils2/trunk/src/changes/changes.xml (original) +++ commons/sandbox/beanutils2/trunk/src/changes/changes.xml Thu Mar 15 12:07:02 2012 @@ -26,6 +26,9 @@ Performance improvement: store hash code of AccessibleObjectDescriptor as member variable + + Implement unit tests for BeanUtils.onClassName() + Implement clone() on DefaultBeanAccessor Added: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/OnClassNameTestCase.java URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/OnClassNameTestCase.java?rev=1300947&view=auto ============================================================================== --- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/OnClassNameTestCase.java (added) +++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/OnClassNameTestCase.java Thu Mar 15 12:07:02 2012 @@ -0,0 +1,96 @@ +package org.apache.commons.beanutils2; + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +import static org.apache.commons.beanutils2.BeanUtils.onClassName; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class OnClassNameTestCase +{ + + @Test( expected = NullPointerException.class ) + public void onClassNameNull() + { + onClassName( null ); + } + + @Test( expected = ClassNotFoundException.class ) + public void onClassNameUnknown() + throws Exception + { + onClassName( "unknown" ).loadWithBeanUtilsClassLoader(); + } + + @Test( expected = NullPointerException.class ) + public void onClassNameTestBeanWithClassLoaderNull() + throws Exception + { + assertNotNull( onClassName( TestBean.class.getName() ).loadWithClassLoader( null ) ); + } + + @Test + public void onClassNameTestBeanWithThreadContextClassLoader() + throws Exception + { + assertNotNull( onClassName( TestBean.class.getName() ).loadWithThreadContextClassLoader() ); + } + + @Test + public void onClassNameTestBeanWithBeanUtilsClassLoader() + throws Exception + { + assertNotNull( onClassName( TestBean.class.getName() ).loadWithBeanUtilsClassLoader() ); + } + + @Test + public void onClassNameTestBeanWithJUnitClassLoader() + throws Exception + { + assertNotNull( onClassName( TestBean.class.getName() ).loadWithClassLoader( getClass().getClassLoader() ) ); + } + + @Test + public void correctInstanceThreadContextClassLoader() + throws Exception + { + Object instance = + onClassName( TestBean.class.getName() ).loadWithThreadContextClassLoader().newInstance().get(); + assertTrue( instance instanceof TestBean ); + } + + @Test + public void correctInstanceBeanUtilsClassLoader() + throws Exception + { + Object instance = onClassName( TestBean.class.getName() ).loadWithBeanUtilsClassLoader().newInstance().get(); + assertTrue( instance instanceof TestBean ); + } + + @Test + public void correctInstanceJUnitClassLoader() + throws Exception + { + Object instance = + onClassName( TestBean.class.getName() ).loadWithClassLoader( getClass().getClassLoader() ).newInstance().get(); + assertTrue( instance instanceof TestBean ); + } + +} Propchange: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/OnClassNameTestCase.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/OnClassNameTestCase.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/OnClassNameTestCase.java ------------------------------------------------------------------------------ svn:mime-type = text/plain