title: How do I mock an autowired @Value field in Spring with Mockito?
body: <p>I'm using Spring 3.1.4.RELEASE and Mockito 1.9.5.  In my Spring class I have:</p>
  
  <pre><code>@Value("#{myProps['default.url']}")
  private String defaultUrl;
  
  @Value("#{myProps['default.password']}")
  private String defaultrPassword;
  
  // ...
  </code></pre>
  
  <p>From my JUnit test, which I currently have set up like so:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration({ "classpath:test-context.xml" })
  public class MyTest 
  { 
  </code></pre>
  
  <p>I would like to mock a value for my "defaultUrl" field.  Note that I don't want to mock values for the other fields — I'd like to keep those as they are, only the "defaultUrl" field.  Also note that I have no explicit "setter" methods (e.g. <code>setDefaultUrl</code>) in my class and I don't want to create any just for the purposes of testing.</p>
  
  <p>Given this, how can I mock a value for that one field?</p>