title: Mocking a dependency on a property file
body: <p>I'm trying to write a unit test that involves using legacy code. Problem is, from what I can tell, the legacy code uses a key/value pair from a property file to initialize one of its final static private members, and I haven't the slightest as to where that property file might be (the entire application is quite huge).</p>
  
  <p>So, in my test, I want to do something like this (using Mockito):</p>
  
  <pre><code>LegacyClass legacyClass = mock(LegacyClass.class);
  </code></pre>
  
  <p>I end up getting a <code>ExceptionInInitializationError</code> which indicates it can't find a certain property key.</p>
  
  <p>In LegacyClass.java, there's:</p>
  
  <pre><code>private static final int LEGACY_PROPERTY = 
      Integer.parseInt(LegacyPropertyManager.getProp("legacy.property.key"));
  </code></pre>
  
  <p>Is there a way to write a test that uses this legacy class, even if the property key it's looking for doesn't exist? Can it be mocked somehow?</p>