commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
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 GMT
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 @@
     <action dev="simonetripodi" type="add" issue="SANDBOX-401" due-to="Benedikt Ritter">
       Performance improvement: store hash code of AccessibleObjectDescriptor as member variable
     </action>
+    <action dev="simonetripodi" type="add" issue="SANDBOX-398" due-to="Benedikt Ritter">
+      Implement unit tests for BeanUtils.onClassName()
+    </action>
     <action dev="simonetripodi" type="add" issue="SANDBOX-396" due-to="Benedikt Ritter">
       Implement clone() on DefaultBeanAccessor
     </action>

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



Mime
View raw message