Example usage for org.apache.commons.lang.reflect FieldUtils readStaticField

List of usage examples for org.apache.commons.lang.reflect FieldUtils readStaticField

Introduction

In this page you can find the example usage for org.apache.commons.lang.reflect FieldUtils readStaticField.

Prototype

public static Object readStaticField(Class cls, String fieldName) throws IllegalAccessException 

Source Link

Document

Read the named public static field.

Usage

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 ava  2  s .  c  om*/

    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.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  ww  w  . j av  a 2s .  com*/
    Object value = FieldUtils.readStaticField(props, true);
    if (value == null) {
        PropsUI mock = mock(PropsUI.class);
        FieldUtils.writeStaticField(props, mock, true);
        changedPropsUi = true;
    } else {
        changedPropsUi = false;
    }
}