summaryrefslogtreecommitdiffstats
path: root/server/tests/src/com/vaadin/util/ReflectToolsGetPrimitiveFieldValue.java
blob: 1e1fafe31c44ccc2313ce05316c05a797dd38669 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.vaadin.util;

import static org.junit.Assert.assertFalse;

import org.junit.Test;

public class ReflectToolsGetPrimitiveFieldValue {
    @Test
    public void getFieldValueViaGetter() {
        class MyClass {
            public int field = 1;
        }

        MyClass myInstance = new MyClass();

        java.lang.reflect.Field memberField;
        Object fieldValue = new Boolean(false);
        try {
            memberField = myInstance.getClass().getField("field");
            fieldValue = ReflectTools
                    .getJavaFieldValue(myInstance, memberField);
        } catch (Exception e) {
        }
        assertFalse(fieldValue instanceof Boolean);
    }
}