当前位置: 首页>>代码示例>>Java>>正文


Java BeanComparisonException类代码示例

本文整理汇总了Java中org.kuali.rice.krad.util.BeanPropertyComparator.BeanComparisonException的典型用法代码示例。如果您正苦于以下问题:Java BeanComparisonException类的具体用法?Java BeanComparisonException怎么用?Java BeanComparisonException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BeanComparisonException类属于org.kuali.rice.krad.util.BeanPropertyComparator包,在下文中一共展示了BeanComparisonException类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCompare_unknownPropertyNames

import org.kuali.rice.krad.util.BeanPropertyComparator.BeanComparisonException; //导入依赖的package包/类
@Test
/**
 * tests comparison with an unknown property name
 *
 * <p>test that a <code>NullPointerException</code> is thrown when the list of property names contains a property name
 * that does not exist in the first argument to  @{link  org.kuali.rice.krad.util.BeanPropertyComparator#compare(java.lang.Object, java.lang.Object)}</p>
 */
public void testCompare_unknownPropertyNames() {
    List unknownProperties = Arrays.asList(new String[] { "one", "two", "three" });

    BeanPropertyComparator bpc = new BeanPropertyComparator(unknownProperties);
    A a = new A("something", new Integer(0), Boolean.valueOf(false));
    B b = new B("something else", new Integer(1), Boolean.valueOf(true));

    boolean failedAsExpected = false;
    try {
        bpc.compare(a, b);
    }
    catch (BeanComparisonException e) {
        if (e.getCause() instanceof NullPointerException) {
            failedAsExpected = true;
        }
    }
    Assert.assertTrue(failedAsExpected);
}
 
开发者ID:kuali,项目名称:rice,代码行数:26,代码来源:BeanPropertyComparatorTest.java

示例2: testCompare_unknownPropertyNames

import org.kuali.rice.krad.util.BeanPropertyComparator.BeanComparisonException; //导入依赖的package包/类
@Test
/**
 * tests comparison with an unknown property name
 *
 * <p>test that a <code>NullPointerException</code> is thrown when the list of property names contains a property name
 * that does not exist in the first argument to  @{link  org.kuali.rice.krad.util.BeanPropertyComparator#compare(java.lang.Object, java.lang.Object)}</p>
 */
public void testCompare_unknownPropertyNames() {
    List unknownProperties = Arrays.asList(new String[] { "one", "two", "three" });

    BeanPropertyComparator bpc = new BeanPropertyComparator(unknownProperties);
    A a = new A("something", new Integer(0), Boolean.valueOf(false));
    B b = new B("something else", new Integer(1), Boolean.valueOf(true));

    // boolean failedAsExpected = false;
    try {
        // bpc.compare(a, b);
        int lessThan = bpc.compare(a, b);
        Assert.assertTrue(lessThan < 0);
    }
    catch (BeanComparisonException e) {
        if (e.getCause() instanceof NullPointerException) {
          // failedAsExpected = true;
          throw new Error(e);
        }
    }
    // Assert.assertTrue(failedAsExpected);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:29,代码来源:BeanPropertyComparatorTest.java

示例3: testCompare_privateProperty

import org.kuali.rice.krad.util.BeanPropertyComparator.BeanComparisonException; //导入依赖的package包/类
@Test
/**
 * tests comparison when a property has a getter with private scope
 *
 * <p>test that a NullPointerException exception is thrown when the first argument to
 * @{link  org.kuali.rice.krad.util.BeanPropertyComparator#compare(java.lang.Object, java.lang.Object)}
 * has a private scoped getter</p>
 */
public void testCompare_privateProperty() {
    List privateProperty = Arrays.asList(new String[] { "s" });

    BeanPropertyComparator bpc = new BeanPropertyComparator(privateProperty);
    C c = new C("something else", 1, true);
    A a = new A("something", new Integer(0), Boolean.valueOf(false));


    // boolean failedAsExpected = false;
    try {
        // bpc.compare(c, a);
        int lessThan = bpc.compare(c, a);
        Assert.assertTrue(lessThan < 0);
    }
    catch (BeanComparisonException e) {
        if (e.getCause() instanceof NullPointerException) {
            throw new Error(e);
        }
    }
    // Assert.assertTrue(failedAsExpected);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:30,代码来源:BeanPropertyComparatorTest.java

示例4: testCompare_privateProperty

import org.kuali.rice.krad.util.BeanPropertyComparator.BeanComparisonException; //导入依赖的package包/类
@Test
/**
 * tests comparison when a property has a getter with private scope
 *
 * <p>test that a NullPointerException exception is thrown when the first argument to
 * @{link  org.kuali.rice.krad.util.BeanPropertyComparator#compare(java.lang.Object, java.lang.Object)}
 * has a private scoped getter</p>
 */
public void testCompare_privateProperty() {
    List privateProperty = Arrays.asList(new String[] { "s" });

    BeanPropertyComparator bpc = new BeanPropertyComparator(privateProperty);
    C c = new C("something else", 1, true);
    A a = new A("something", new Integer(0), Boolean.valueOf(false));


    boolean failedAsExpected = false;
    try {
        bpc.compare(c, a);
    }
    catch (BeanComparisonException e) {
        if (e.getCause() instanceof NullPointerException) {
            failedAsExpected = true;
        }
    }
    Assert.assertTrue(failedAsExpected);
}
 
开发者ID:kuali,项目名称:rice,代码行数:28,代码来源:BeanPropertyComparatorTest.java


注:本文中的org.kuali.rice.krad.util.BeanPropertyComparator.BeanComparisonException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。