title: What do I use instead of Whitebox in Mockito 2.2 to set fields?
body: <p>When using Mockito 1.9.x I have been using <code>Whitebox</code>to set values of fields to "inject" mocks. Se example below:</p>
  
  <pre><code>@Before
  public void setUp() {
  
      eventHandler = new ProcessEventHandler();
      securityService = new SecurityServiceMock();
      registrationService = mock(RegistrationService.class);
  
      Whitebox.setInternalState(eventHandler, "registrationService", registrationService);
      Whitebox.setInternalState(eventHandler, "securityService", securityService);
  }
  </code></pre>
  
  <p>I really like this approach, but now that I tried to upgrade to <code>Mockito</code>  <code>2.2.7</code> I noticed (or rather, my IDE noticed and told me quite a few times) that Whitebox was no longer to be found in Mockito.</p>
  
  <p><del>I have found one alternative, that can work as a replacement, and that is <code>org.powermock.reflect.Whitebox</code>, the problem with that is that I get another dependency (Powermock), just to use Whitebox.</del> </p>
  
  <p><code>Powermock</code> also have a class named <code>Whitebox</code>, but unfortunately  it looks as if it can not be used with <code>Mockito 2.2.x</code></p>
  
  <p>Is there any good alternatives in Mockito that I can use to manually "inject" fields, now that <code>Whitebox</code> is no longer available?   </p>
  
  <hr>
  
  <h2>Solution</h2>
  
  <p>I wrote in a comment in response to the post made of @JeffBowman. In short I chose to copy the code of WhiteBox, and use that, since it is used in most of the test cases and the class does not have dependencies to other classes. It was the fastest path to solve this issue.</p>
  
  <p><strong>Note</strong> The solution that @bcody suggest is a better alternative, if you are using spring, it ads no extra code for you to maintain. I got that information to late :( </p>