/*
* 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.
*/
package org.apache.commons.beanutils;
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.commons.beanutils.priv.PrivateBeanFactory;
import org.apache.commons.beanutils.priv.PrivateDirect;
import org.apache.commons.beanutils.priv.PublicSubBean;
/**
* <p>Test Case for the PropertyUtils class. The majority of these tests use
* instances of the TestBean class, so be sure to update the tests if you
* change the characteristics of that class.</p>
*
* <p>So far, this test case has tests for the following methods of the
* <code>PropertyUtils</code> class:</p>
* <ul>
* <li>getIndexedProperty(Object,String)</li>
* <li>getIndexedProperty(Object,String,int)</li>
* <li>getMappedProperty(Object,String)</li>
* <li>getMappedProperty(Object,String,String</li>
* <li>getNestedProperty(Object,String)</li>
* <li>getPropertyDescriptor(Object,String)</li>
* <li>getPropertyDescriptors(Object)</li>
* <li>getPropertyType(Object,String)</li>
* <li>getSimpleProperty(Object,String)</li>
* <li>setIndexedProperty(Object,String,Object)</li>
* <li>setIndexedProperty(Object,String,String,Object)</li>
* <li>setMappedProperty(Object,String,Object)</li>
* <li>setMappedProperty(Object,String,String,Object)</li>
* <li>setNestedProperty(Object,String,Object)</li>
* <li>setSimpleProperty(Object,String,Object)</li>
* </ul>
*
* @version $Id: PropertyUtilsTestCase.java 1547898 2013-12-04 20:33:06Z oheger $
*/
public class PropertyUtilsTestCase extends TestCase {
// ---------------------------------------------------- Instance Variables
/**
* The fully qualified class name of our private directly
* implemented interface.
*/
private static final String PRIVATE_DIRECT_CLASS =
"org.apache.commons.beanutils.priv.PrivateDirect";
/**
* The fully qualified class name of our private indirectly
* implemented interface.
*/
private static final String PRIVATE_INDIRECT_CLASS =
"org.apache.commons.beanutils.priv.PrivateIndirect";
/**
* The fully qualified class name of our test bean class.
*/
private static final String TEST_BEAN_CLASS =
"org.apache.commons.beanutils.TestBean";
/**
* The basic test bean for each test.
*/
protected TestBean bean = null;
/**
* The "package private subclass" test bean for each test.
*/
protected TestBeanPackageSubclass beanPackageSubclass = null;
/**
* The test bean for private access tests.
*/
protected PrivateDirect beanPrivate = null;
/**
* The test bean for private access tests of subclasses.
*/
protected PrivateDirect beanPrivateSubclass = null;
/**
* The "public subclass" test bean for each test.
*/
protected TestBeanPublicSubclass beanPublicSubclass = null;
/**
* The set of properties that should be described.
*/
protected String describes[] =
{ "booleanProperty",
"booleanSecond",
"doubleProperty",
"floatProperty",
"intArray",
// "intIndexed",
"intProperty",
"listIndexed",
"longProperty",
// "mappedObjects",
// "mappedProperty",
// "mappedIntProperty",
"nested",
"nullProperty",
// "readOnlyProperty",
"shortProperty",
"stringArray",
// "stringIndexed",
"stringProperty"
};
/**
* The set of property names we expect to have returned when calling
* <code>getPropertyDescriptors()</code>. You should update this list
* when new properties are added to TestBean.
*/
protected final static String[] properties = {
"booleanProperty",
"booleanSecond",
"doubleProperty",
"dupProperty",
"floatProperty",
"intArray",
"intIndexed",
"intProperty",
"listIndexed",
"longProperty",
"nested",
"nullProperty",
"readOnlyProperty",
"shortProperty",
"stringArray",
"stringIndexed",
"stringProperty",
"writeOnlyProperty",
};
// ---------------------------------------------------------- Constructors
/**
* Construct a new instance of this test case.
*
* @param name Name of the test case
*/
public PropertyUtilsTestCase(String name) {
super(name);
}
// -------------------------------------------------- Overall Test Methods
/**
* Set up instance variables required by this test case.
*/
@Override
public void setUp() {
bean = new TestBean();
beanPackageSubclass = new TestBeanPackageSubclass();
beanPrivate = PrivateBeanFactory.create();
beanPrivateSubclass = PrivateBeanFactory.createSubclass();
beanPublicSubclass = new TestBeanPublicSubclass();
DynaProperty[] properties = new DynaProperty[] {
new DynaProperty("stringProperty", String.class),
new DynaProperty("nestedBean", TestBean.class),
new DynaProperty("nullDynaBean", DynaBean.class)
};
BasicDynaClass dynaClass = new BasicDynaClass("nestedDynaBean", BasicDynaBean.class, properties);
BasicDynaBean nestedDynaBean = new BasicDynaBean(dynaClass);
nestedDynaBean.set("nestedBean", bean);
bean.setNestedDynaBean(nestedDynaBean);
PropertyUtils.clearDescriptors();
}
/**
* Return the tests included in this test suite.
*/
public static Test suite() {
return (new TestSuite(PropertyUtilsTestCase.class));
}
/**
* Tear down instance variables required by this test case.
*/
@Override
public void tearDown() {
bean = null;
beanPackageSubclass = null;
beanPrivate = null;
beanPrivateSubclass = null;
beanPublicSubclass = null;
PropertyUtils.resetBeanIntrospectors();
}
// ------------------------------------------------ Individual Test Methods
/**
* Test copyProperties() when the origin is a a <code>Map</code>.
*/
public void testCopyPropertiesMap() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("booleanProperty", Boolean.FALSE);
map.put("doubleProperty", new Double(333.0));
map.put("dupProperty", new String[] { "New 0", "New 1", "New 2" });
map.put("floatProperty", new Float((float) 222.0));
map.put("intArray", new int[
没有合适的资源?快使用搜索试试~ 我知道了~
common-beanutils和common-logging
共1036个文件
html:730个
java:252个
xml:14个
需积分: 10 53 下载量 124 浏览量
2015-09-26
21:41:24
上传
评论
收藏 5.02MB RAR 举报
温馨提示
common-beanutils下载地址:http://commons.apache.org/proper/commons-beanutils/ common-logging现在地址:http://commons.apache.org/proper/commons-logging/
资源推荐
资源详情
资源评论
收起资源包目录
common-beanutils和common-logging (1036个子文件)
download_beanutils.cgi 160B
stylesheet.css 11KB
stylesheet.css 1KB
stylesheet.css 1KB
titlebar.gif 10KB
background.gif 2KB
titlebar_end.gif 849B
tab.gif 291B
inherit.gif 57B
inherit.gif 57B
index-all.html 576KB
index-all.html 576KB
PropertyUtilsBean.html 217KB
PropertyUtilsBean.html 217KB
index-all.html 134KB
MethodUtils.html 129KB
MethodUtils.html 129KB
PropertyUtilsBean.html 119KB
PropertyUtilsBean.html 119KB
PropertyUtils.html 115KB
PropertyUtils.html 115KB
BeanUtilsBean.html 108KB
BeanUtilsBean.html 108KB
LocaleBeanUtilsBean.html 106KB
LocaleBeanUtilsBean.html 106KB
LocaleBeanUtilsBean.html 101KB
LocaleBeanUtilsBean.Descriptor.html 101KB
LocaleBeanUtilsBean.html 101KB
LocaleBeanUtilsBean.Descriptor.html 101KB
LocaleBeanUtils.html 100KB
LocaleBeanUtils.html 100KB
ConvertUtilsBean.html 88KB
ConvertUtilsBean.html 88KB
LazyDynaBean.html 87KB
LazyDynaBean.html 87KB
PropertyUtils.html 86KB
PropertyUtils.html 86KB
MethodUtils.html 84KB
MethodUtils.html 84KB
BeanMap.Entry.html 79KB
BeanMap.html 79KB
BeanMap.Entry.html 79KB
BeanMap.html 79KB
LazyDynaBean.html 75KB
LazyDynaBean.html 75KB
BeanUtilsBean.html 75KB
BeanUtilsBean.html 75KB
LocaleBeanUtils.Descriptor.html 74KB
LocaleBeanUtils.html 74KB
LocaleBeanUtils.Descriptor.html 74KB
LocaleBeanUtils.html 74KB
package-summary.html 69KB
package-summary.html 69KB
BeanMap.html 69KB
BeanMap.html 69KB
BeanUtils.html 67KB
BeanUtils.html 67KB
LogFactory.html 65KB
FastHashMap.html 62KB
FastHashMap.html 62KB
LazyDynaList.html 62KB
LazyDynaList.html 62KB
SimpleLog.html 59KB
LazyDynaMap.html 58KB
LazyDynaMap.html 58KB
DateTimeConverter.html 58KB
DateTimeConverter.html 58KB
Converter.html 58KB
Converter.html 58KB
LogFactoryImpl.html 56KB
RowSetDynaClass.html 55KB
RowSetDynaClass.html 55KB
LocaleConvertUtils.html 54KB
LocaleConvertUtils.html 54KB
LocaleConvertUtilsBean.html 53KB
LocaleConvertUtilsBean.html 53KB
NumberConverter.html 52KB
NumberConverter.html 52KB
LocaleConvertUtilsBean.html 52KB
LocaleConvertUtilsBean.html 52KB
LazyDynaList.html 51KB
ConvertUtilsBean.html 51KB
ConvertUtilsBean.html 51KB
LazyDynaList.html 51KB
serialized-form.html 50KB
MappedPropertyDescriptor.html 48KB
MappedPropertyDescriptor.html 48KB
serialized-form.html 48KB
BeanUtils.html 47KB
BeanUtils.html 47KB
ArrayConverter.html 47KB
ArrayConverter.html 47KB
LazyDynaClass.html 47KB
LazyDynaClass.html 47KB
FastHashMap.html 47KB
FastHashMap.html 46KB
ResultSetDynaClass.html 45KB
ResultSetDynaClass.html 45KB
ConvertUtils.html 45KB
ConvertUtils.html 45KB
共 1036 条
- 1
- 2
- 3
- 4
- 5
- 6
- 11
资源评论
mofei123456789
- 粉丝: 14
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功