List of usage examples for org.apache.commons.lang.reflect FieldUtils writeStaticField
public static void writeStaticField(Class cls, String fieldName, Object value) throws IllegalAccessException
From source file:org.pentaho.di.ui.trans.steps.fileinput.text.TextFileInputDialogTest.java
@BeforeClass public static void hackPropsUi() throws Exception { Field props = getPropsField(); if (props == null) { throw new IllegalStateException("Cannot find 'props' field in " + Props.class.getName()); }// www . j a va 2 s.co m Object value = FieldUtils.readStaticField(props, true); if (value == null) { PropsUI mock = mock(PropsUI.class); FieldUtils.writeStaticField(props, mock, true); changedPropsUi = true; } else { changedPropsUi = false; } }
From source file:org.pentaho.di.ui.trans.steps.fileinput.text.TextFileInputDialogTest.java
@AfterClass public static void restoreNullInPropsUi() throws Exception { if (changedPropsUi) { Field props = getPropsField(); FieldUtils.writeStaticField(props, null, true); }/*from w ww . ja v a2 s . c o m*/ }
From source file:org.pentaho.di.ui.trans.steps.salesforceinput.SalesforceInputDialogTest.java
@BeforeClass public static void hackPropsUi() throws Exception { Field props = getPropsField(); if (props == null) { throw new IllegalStateException("Cannot find 'props' field in " + Props.class.getName()); }/*from w w w . j a v a2 s . c o m*/ Object value = FieldUtils.readStaticField(props, true); if (value == null) { PropsUI mock = mock(PropsUI.class); FieldUtils.writeStaticField(props, mock, true); changedPropsUi = true; } else { changedPropsUi = false; } }
From source file:org.pepstock.jem.jbpm.tasks.workitems.CustomMethodWorkItem.java
/** * Assigns the value of parameters /*ww w .ja v a2 s. c om*/ * @param object instance of object * @param parameters parameters to set * @throws IllegalAccessException if any error occurs */ private void applyByAnnotation(Object object, Map<String, Object> parameters) throws IllegalAccessException { // scans all declared fields for (Field field : object.getClass().getDeclaredFields()) { // if has got data description annotation if (field.isAnnotationPresent(AssignParameters.class)) { if (Modifier.isStatic(field.getModifiers())) { FieldUtils.writeStaticField(field, parameters, true); } else { FieldUtils.writeField(field, object, parameters, true); } } } }
From source file:org.pepstock.jem.jbpm.tasks.workitems.MainClassWorkItem.java
/** * Assigns the value of parameters /* w w w . j a va2s .c o m*/ * @param object instance of object * @param parameters parameters to set * @throws IllegalAccessException if any error occurs */ private void applyByAnnotation(Class<?> clazz, Map<String, Object> parameters) throws IllegalAccessException { // scans all declared fields for (Field field : clazz.getDeclaredFields()) { // if has got data description annotation if (field.isAnnotationPresent(AssignParameters.class) && (Modifier.isStatic(field.getModifiers()))) { FieldUtils.writeStaticField(field, parameters, true); } } }