Code example for Field

Methods: setAccessiblegetgetAnnotation

0
public class AgentDetailsTest extends TestCase {
    public void testProfile() throws Exception { 
        Class<AgentDetails> cls = AgentDetails.class;
         
        Field profile = cls.getDeclaredField("profile");
        profile.setAccessible(true);
        assertTrue(profile.getAnnotation(XmlAttribute.class).required());
         
        AgentDetails ad = new AgentDetails();
        assertEquals("default", ad.getProfile());
        ad.setProfile("production");
        assertEquals("production", ad.getProfile());
        assertEquals("production", profile.get(ad));
    } 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE