Package java.lang.reflect

Examples of java.lang.reflect.Method


  public void testIsSetter() throws SecurityException, NoSuchMethodException
  {
    BindableBean bean = new BindableBean();
    Class<? extends BindableBean> clazz = bean.getClass();

    Method method = clazz.getMethod("setBoolValue", new Class[]
    {
      Boolean.TYPE
    });
    assert ReflectHelper.isSetter(method);
View Full Code Here


  @Test
  public void testWildCardType() throws SecurityException, NoSuchMethodException
  {

    Method method = getWildcardMethod("setUpperValue");

    Assert.assertEquals(ReflectHelper.getTypeDescription(method.getGenericParameterTypes()[0]),
        "parameterized interface java.util.Collection (wildcard generic type with upper bound (interface java.util.List))");
   

    method = getWildcardMethod("setLowerValue");

    Assert.assertEquals(ReflectHelper.getTypeDescription(method.getGenericParameterTypes()[0]),
        "parameterized interface java.util.Collection (wildcard generic type with upper bound (class java.lang.Object) and lower bound (class java.util.ArrayList))");

  }
View Full Code Here

  private Method getWildcardMethod(String methodName)
  {
    Method[] methods = ClassWithWildcardTypes.class.getMethods();
   
    Method method  = null;
   
    for (int i = 0; i < methods.length; i++)
    {
      String name = methods[i].getName();
      if (name.startsWith(methodName))
View Full Code Here

  public void testInvalidType1() throws Exception
  {
    try
    {
      TestAction action = new TestAction();
      Method setterMethod = getSetter(action, "setIntegerInput", Integer.class);
      PropertyValueSetter.setPropertyValue(action, setterMethod, Integer.class,
          "should be an int but is a String");
    }
    catch (ApplicationRuntimeException e)
    {
View Full Code Here

  @Test
  public void testPropertyValueSetter1() throws Exception
  {
    TestAction action = new TestAction();
    Method setterMethod = getSetter(action, "setIntegerInput", Integer.class);
    PropertyValueSetter.setPropertyValue(action, setterMethod, Integer.class, new Integer(1));
    assert action.getIntegerInput().equals(1);
  }
View Full Code Here

  @Test
  public void testPropertyValueSetter2() throws Exception
  {
    TestAction action = new TestAction();
    Method setterMethod = getSetter(action, "setIntegerInput", Integer.class);
    PropertyDescriptor descriptor = BeanUtils.findPropertyForMethod(setterMethod);

    PropertyValueSetter.setPropertyValue(action, descriptor, new Integer(1));
    assert action.getIntegerInput().equals(1);
  }
View Full Code Here

  }

  @Test
  public void testPrimitives1() throws NoSuchMethodException
  {
    Method setterMethod = getSetter(action, "setByteInput", Byte.TYPE);

    PropertyValueSetter.setPropertyValue(action, setterMethod, Byte.TYPE, null);
    assert action.getByteInput() == 0;

    PropertyValueSetter.setPropertyValue(action, setterMethod, Byte.TYPE, (byte) 1);
View Full Code Here

    testNullPrimitive("doubleInput");
  }

  private Method getSetter(TestAction action, String name, Class clazz) throws NoSuchMethodException
  {
    Method setterMethod = action.getClass().getMethod(name, new Class[]
    {
      clazz
    });
    return setterMethod;
  }
View Full Code Here

  @Test
  public void testGetGetter() throws Exception
  {
    ValidationAnnotationReader reader = new ValidationAnnotationReader();
    Method setter = BeanWithGetterValidator.class.getMethod("setProperty", new Class[]
    {
      String.class
    });

    assert null != reader.getGetter(setter);
View Full Code Here

  @Test
  public void testGetNoGetter() throws Exception
  {
    ValidationAnnotationReader reader = new ValidationAnnotationReader();
    Method setter = BeanWithNoGetter.class.getMethod("setStringProperty", new Class[]
    {
      String.class
    });

    try
View Full Code Here

TOP

Related Classes of java.lang.reflect.Method

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.