View Javadoc

1   package fit;
2   
3   import java.lang.reflect.Field;
4   
5   /**
6    * Simplified Fixture for setting fields directly without setter
7    * methods.
8    */
9   public class FieldActionFixture extends ActionFixture
10  {
11  
12    @Override
13    public void doCells(Parse arg0)
14    {
15       super.doCells(arg0);
16    }
17    
18    @Override
19    public void enter() throws Exception
20    {
21      String fieldName = cells.more.text();
22      String value = cells.more.more.text();
23  
24      Field field = actor.getClass().getDeclaredField(fieldName);
25      if (field != null)
26      {
27        field.setAccessible(true);
28        field.set(actor, value);
29      }
30      else
31      {
32        super.enter();
33      }
34    }
35  }