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


Java InvalidPropertyException类代码示例

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


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

示例1: testIntrospectPropertyForItemsConnectedTo

import org.springframework.beans.InvalidPropertyException; //导入依赖的package包/类
@Test
public void testIntrospectPropertyForItemsConnectedTo()
        throws InvalidPropertyException, InvocationTargetException, IllegalAccessException {
    String logicalId = "/myitem/myid";
    MyItemType myItemType = new MyItemType();
    String logicalId1 = logicalId + "1";
    String logicalId2 = logicalId + "2";
    MyItem myItem1 = new MyItem(logicalId1, myItemType);
    MyItem myItem2 = new MyItem(logicalId2, myItemType);
    myItem1.addConnectedRelationships(myItem2, "");
    MyItem[] myItemArray = {myItem1, myItem2};
    List<Fibre> items = Arrays.asList(myItemArray);

    String propertyName = RelationshipUtil.getRelationshipNameBetweenItems(myItem1, myItem2, "");
    List<Object> properties = FibreIntrospectionUtils.introspectPropertyForFibres(propertyName, items, null);

    assertNotNull("Returned properties was null", properties);
    assertEquals("Returned properties incorrect size", 2, properties.size());
    for (int count = 0; count < properties.size(); count++) {
        assertNotNull("Returned property was null at " + count, properties.get(count));
    }
    assertEquals("First property incorrect", myItem2, properties.get(0));
    assertEquals("Second property incorrect", myItem1, properties.get(1));
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:25,代码来源:BaseModelTest.java

示例2: testAutoGrowBeyondDefaultLimit

import org.springframework.beans.InvalidPropertyException; //导入依赖的package包/类
@Test
public void testAutoGrowBeyondDefaultLimit() throws Exception {
	TestBean testBean = new TestBean();
	DataBinder binder = new DataBinder(testBean, "testBean");

	MutablePropertyValues mpvs = new MutablePropertyValues();
	mpvs.add("friends[256]", "");
	try {
		binder.bind(mpvs);
		fail("Should have thrown InvalidPropertyException");
	}
	catch (InvalidPropertyException ex) {
		// expected
		assertTrue(ex.getRootCause() instanceof IndexOutOfBoundsException);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:DataBinderTests.java

示例3: testAutoGrowBeyondCustomLimit

import org.springframework.beans.InvalidPropertyException; //导入依赖的package包/类
@Test
public void testAutoGrowBeyondCustomLimit() throws Exception {
	TestBean testBean = new TestBean();
	DataBinder binder = new DataBinder(testBean, "testBean");
	binder.setAutoGrowCollectionLimit(10);

	MutablePropertyValues mpvs = new MutablePropertyValues();
	mpvs.add("friends[16]", "");
	try {
		binder.bind(mpvs);
		fail("Should have thrown InvalidPropertyException");
	}
	catch (InvalidPropertyException ex) {
		// expected
		assertTrue(ex.getRootCause() instanceof IndexOutOfBoundsException);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:DataBinderTests.java

示例4: resolvePropertyName

import org.springframework.beans.InvalidPropertyException; //导入依赖的package包/类
private String resolvePropertyName(BeanWrapper target, String prefix, String name) {
	Iterable<String> names = getNameAndAliases(name);
	for (String nameOrAlias : names) {
		for (String candidate : new RelaxedNames(nameOrAlias)) {
			try {
				if (target.getPropertyType(joinString(prefix, candidate)) != null) {
					return candidate;
				}
			}
			catch (InvalidPropertyException ex) {
				// swallow and continue
			}
		}
	}
	return null;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:RelaxedDataBinder.java

示例5: getPropertyValue

import org.springframework.beans.InvalidPropertyException; //导入依赖的package包/类
/**
 * Returns the value for the given property growing nested paths depending on the parameter.
 *
 * @param propertyName name of the property to get value for
 * @param autoGrowNestedPaths whether nested paths should be grown (initialized if null)
 * @return value for property
 */
protected Object getPropertyValue(String propertyName, boolean autoGrowNestedPaths) {
    setAutoGrowNestedPaths(autoGrowNestedPaths);

    Object value = null;
    try {
        value = super.getPropertyValue(propertyName);
    } catch (NullValueInNestedPathException e) {
        // swallow null values in path and return null as the value
    } catch (InvalidPropertyException e1) {
        if (!(e1.getRootCause() instanceof NullValueInNestedPathException)) {
            throw e1;
        }
    }

    return value;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:24,代码来源:UifBeanWrapper.java

示例6: testAutoGrowBeyondCustomLimit

import org.springframework.beans.InvalidPropertyException; //导入依赖的package包/类
public void testAutoGrowBeyondCustomLimit() throws Exception {
	TestBean testBean = new TestBean();
	DataBinder binder = new DataBinder(testBean, "testBean");
	binder.setAutoGrowCollectionLimit(10);

	MutablePropertyValues mpvs = new MutablePropertyValues();
	mpvs.add("friends[16]", "");
	try {
		binder.bind(mpvs);
		fail("Should have thrown InvalidPropertyException");
	}
	catch (InvalidPropertyException ex) {
		// expected
		assertTrue(ex.getRootCause() instanceof IndexOutOfBoundsException);
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:17,代码来源:DataBinderTests.java

示例7: testBeanWrapperAccess

import org.springframework.beans.InvalidPropertyException; //导入依赖的package包/类
/**
 * This test ensures that the Spring Bean accessor classes work properly
 * since our REST implementation uses bean access to update the values.
 */
@Test
public void testBeanWrapperAccess() throws Exception {
    createRequisition();
    Requisition r = m_repository.getRequisition(m_defaultForeignSourceName);
    BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(r);
    assertEquals("AC", wrapper.getPropertyValue("node[0].category[0].name"));
    assertEquals("UK", wrapper.getPropertyValue("node[0].category[1].name"));
    assertEquals("low", wrapper.getPropertyValue("node[0].category[2].name"));
    
    try {
        wrapper.getPropertyValue("node[1].category[0].name");
        fail("Did not catch expected InvalidPropertyException exception");
    } catch (InvalidPropertyException e) {
        // Expected failure
    }
    
    assertEquals(0, ((RequisitionCategory[])wrapper.getPropertyValue("node[1].category")).length);
    
    wrapper.setPropertyValue("node[1].categories[0]", new RequisitionCategory("Hello world"));
    wrapper.setPropertyValue("node[1].categories[1]", new RequisitionCategory("Hello again"));
    
    assertEquals(2, ((RequisitionCategory[])wrapper.getPropertyValue("node[1].category")).length);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:28,代码来源:MockForeignSourceRepositoryTest.java

示例8: testCreateBoundComboBoxStringStringString

import org.springframework.beans.InvalidPropertyException; //导入依赖的package包/类
public void testCreateBoundComboBoxStringStringString() {
    TestableBinding b = (TestableBinding)sbf.createBoundComboBox("name", "listProperty", "displayProperty");
    assertBindingProperties(b, JComboBox.class, null, "name");
    assertEquals(4, b.getContext().size());
    assertEquals(sbf.getFormModel().getValueModel("listProperty"), b.getContext().get(
            ComboBoxBinder.SELECTABLE_ITEMS_KEY));
    assertEquals("displayProperty",
            ((BeanPropertyValueListRenderer)b.getContext().get(ComboBoxBinder.RENDERER_KEY)).getPropertyName());
    assertEquals("displayProperty",
            ((BeanPropertyEditorClosure)b.getContext().get(ComboBoxBinder.EDITOR_KEY)).getRenderedProperty());
    assertEquals("displayProperty", getComparatorProperty(b));

    try {
        b = (TestableBinding)sbf.createBoundComboBox("name", "someUnknownProperty", "displayProperty");
        fail("cant use an unknown property to provide the selectable items");
    }
    catch (InvalidPropertyException e) {
        // expected
    }
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:21,代码来源:SwingBindingFactoryTests.java

示例9: getPropertyType

import org.springframework.beans.InvalidPropertyException; //导入依赖的package包/类
@Override
public Class<?> getPropertyType(String propertyName) throws BeansException {
    try {
        PropertyDescriptor pd = getPropertyDescriptorInternal(propertyName);
        if (pd != null) {
            return pd.getPropertyType();
        }

        // Maybe an indexed/mapped property...
        Object value = super.getPropertyValue(propertyName);
        if (value != null) {
            return value.getClass();
        }

        // Check to see if there is a custom editor,
        // which might give an indication on the desired target type.
        Class<?> editorType = guessPropertyTypeFromEditors(propertyName);
        if (editorType != null) {
            return editorType;
        }
    } catch (InvalidPropertyException ex) {
        // Consider as not determinable.
    }

    return null;
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:27,代码来源:UifViewBeanWrapper.java

示例10: testIntrospectPropertyReserved

import org.springframework.beans.InvalidPropertyException; //导入依赖的package包/类
@Test(expected = IllegalAccessException.class)
public void testIntrospectPropertyReserved()
        throws InvalidPropertyException, InvocationTargetException, IllegalAccessException {
    String logicalId = "/myfibre/myid";
    MyFibreType myFibreType = new MyFibreType();
    MyFibre myFibre = new MyFibre(logicalId, myFibreType);

    FibreIntrospectionUtils.introspectPropertyStrict("memberOf", myFibre, null);
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:10,代码来源:BaseModelTest.java

示例11: testIntrospectPropertyForFibresReserved

import org.springframework.beans.InvalidPropertyException; //导入依赖的package包/类
@Test(expected = IllegalAccessException.class)
public void testIntrospectPropertyForFibresReserved()
        throws InvalidPropertyException, InvocationTargetException, IllegalAccessException {
    String logicalId = "/myfibre/myid";
    MyFibreType myFibreType = new MyFibreType();
    MyFibre myFibre = new MyFibre(logicalId, myFibreType);
    MyFibre[] myFibreArray = {myFibre};
    List<Fibre> fibres = Arrays.asList(myFibreArray);

    FibreIntrospectionUtils.introspectPropertyForFibres("memberOf", fibres, null);
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:12,代码来源:BaseModelTest.java

示例12: introspectProperty

import org.springframework.beans.InvalidPropertyException; //导入依赖的package包/类
/**
 * Return a named property value for the fibre. This method is not strict about the validity of
 * the named property, and will return a null value if the property is unknown.
 *
 * @param <T> Type of the returned property.
 * @param propertyName Name of property to return.
 * @param fibre fibre to introspect
 * @param context query context
 * @return Value of property. Note that the value will be reported as null if it is unknown.
 */
@JsonIgnore
public static <T> T introspectProperty(final String propertyName, final Fibre fibre,
        final OperationContext context) {
    try {
        return introspectPropertyStrict(propertyName, fibre, context);
    } catch (InvocationTargetException | InvalidPropertyException | IllegalAccessException e) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Could not find property " + propertyName);
        }
        return null;
    }
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:23,代码来源:FibreIntrospectionUtils.java

示例13: getValue

import org.springframework.beans.InvalidPropertyException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <X> X getValue(String attrName) throws AttributeValidationException {
    X attributeValue = null;

    Exception e = null;
    try {
        attributeValue = (X) beanWrapper.getPropertyValue(attrName);
    } catch (IllegalArgumentException iae) {
        e = iae;
    } catch (InvalidPropertyException ipe) {
        //just return null
    }

    if (e != null) {
        throw new AttributeValidationException(
                "Unable to lookup attribute value by name (" + attrName + ") using introspection", e);
    }

    //			JLR : KS has code to handle dynamic attributes -- not sure whether this is really needed anymore if we're actually relying on types
    //            // Extract dynamic attributes
    //            if(DYNAMIC_ATTRIBUTE.equals(propName)) {
    //                dataMap.putAll((Map<String, String>)value);
    //            } else {
    //				dataMap.put(propName, value);
    //            }

    return attributeValue;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:30,代码来源:DictionaryObjectAttributeValueReader.java

示例14: serializeEnum

import org.springframework.beans.InvalidPropertyException; //导入依赖的package包/类
public static <T extends Enum<T>> String serializeEnum(ObjectMapper objMapper, Class<T> enumClass) throws BeansException, InvalidPropertyException,
    JsonProcessingException, PropertyAccessException {
    T[] enumItems = enumClass.getEnumConstants();
    Map<String, Map<String, Object>> enumMap = new LinkedHashMap<>(enumItems.length);
    Map<String, Object> enumItemMap;
    Map<String, String> enumItemValueMap;
    String enumItemKey;
    BeanWrapper enumItemWrapper;
    PropertyDescriptor[] enumItemPropDescs;
    Method enumItemPropGetter;
    String enumItemPropName;

    for (T enumItem : enumItems) {
        enumMap.put((enumItemKey = enumItem.name()), (enumItemMap = new LinkedHashMap<>(2)));

        enumItemMap.put(KEY_PROP_NAME, enumItemKey);

        enumItemMap.put(VALUE_PROP_NAME,
            (enumItemValueMap =
                new LinkedHashMap<>((enumItemPropDescs = (enumItemWrapper = new BeanWrapperImpl(enumItem)).getPropertyDescriptors()).length)));

        for (PropertyDescriptor enumItemPropDesc : enumItemPropDescs) {
            if (((enumItemPropGetter = enumItemPropDesc.getReadMethod()) == null) || !enumItemPropGetter.isAnnotationPresent(JsonProperty.class)) {
                continue;
            }

            enumItemValueMap.put((enumItemPropName = enumItemPropDesc.getName()), enumItemWrapper.getPropertyValue(enumItemPropName).toString());
        }
    }

    return objMapper.writeValueAsString(enumMap);
}
 
开发者ID:esacinc,项目名称:crigtt,代码行数:33,代码来源:CrigttJsonUtils.java

示例15: testAutoGrowBeyondDefaultLimit

import org.springframework.beans.InvalidPropertyException; //导入依赖的package包/类
public void testAutoGrowBeyondDefaultLimit() throws Exception {
	TestBean testBean = new TestBean();
	DataBinder binder = new DataBinder(testBean, "testBean");

	MutablePropertyValues mpvs = new MutablePropertyValues();
	mpvs.add("friends[256]", "");
	try {
		binder.bind(mpvs);
		fail("Should have thrown InvalidPropertyException");
	}
	catch (InvalidPropertyException ex) {
		// expected
		assertTrue(ex.getRootCause() instanceof IndexOutOfBoundsException);
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:16,代码来源:DataBinderTests.java


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