Class dataSourceClass = ReflectHelper.classForName( DATA_SOURCE, ConnectionProviderBuilder.class ); DataSource actualDataSource = (DataSource) dataSourceClass.newInstance(); ReflectHelper.findSetterMethod( dataSourceClass, "URL", String.class ).invoke( actualDataSource, String.format( URL, dbName ) ); ReflectHelper.findSetterMethod( dataSourceClass, "user", String.class ).invoke( actualDataSource, USER ); ReflectHelper.findSetterMethod( dataSourceClass, "password", String.class ) .invoke( actualDataSource, PASS );
public PropertyAccessBasicImpl( PropertyAccessStrategyBasicImpl strategy, Class containerJavaType, final String propertyName) { this.strategy = strategy; final Method getterMethod = ReflectHelper.findGetterMethod( containerJavaType, propertyName ); this.getter = new GetterMethodImpl( containerJavaType, propertyName, getterMethod ); final Method setterMethod = ReflectHelper.findSetterMethod( containerJavaType, propertyName, getterMethod.getReturnType() ); this.setter = new SetterMethodImpl( containerJavaType, propertyName, setterMethod ); }
@Test public void test_setMethod_nestedInterfaces() { assertNotNull( ReflectHelper.findSetterMethod( C.class, "id", Integer.class ) ); }
@TestForIssue(jiraKey = "HHH-12090") @Test public void test_setMethod_nestedInterfaces_on_superclasses() { assertNotNull( ReflectHelper.findSetterMethod( E.class, "id", String.class ) ); } }
@Test @TestForIssue( jiraKey = "HHH-11202") public void testProtectedMethodSetter() throws Exception { final AnEntity entity = new AnEntity( new PK( 1L ) ); final Getter getter = new GetterMethodImpl( AnEntity.class, "pk", ReflectHelper.findGetterMethod( AnEntity.class, "pk" ) ); final Setter setter = new SetterMethodImpl( AnEntity.class, "pk", ReflectHelper.findSetterMethod( AnEntity.class, "pk", PK.class ) ); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject( setter ); final ObjectInputStream ois = new ObjectInputStream( new ByteArrayInputStream( baos.toByteArray() ) ); final Setter setterClone = (Setter) ois.readObject(); final PK pkNew = new PK( 2L ); setterClone.set( entity, pkNew, null ); assertSame( pkNew, getter.get( entity ) ); } }
public PropertyAccessBasicImpl( PropertyAccessStrategyBasicImpl strategy, Class containerJavaType, final String propertyName) { this.strategy = strategy; final Method getterMethod = ReflectHelper.findGetterMethod( containerJavaType, propertyName ); this.getter = new GetterMethodImpl( containerJavaType, propertyName, getterMethod ); final Method setterMethod = ReflectHelper.findSetterMethod( containerJavaType, propertyName, getterMethod.getReturnType() ); this.setter = new SetterMethodImpl( containerJavaType, propertyName, setterMethod ); }