title: How to change values of "private static final String filePath" for unittesting
body: <p>I have my class as</p>
  
  <pre><code>    public class MappingLoader
      {
       private static final String filepath = "/tmp/mapping.properties" // unix path of production system
       private static Map&lt;String,String&gt; mapping = new HashMap&lt;String,String&gt;()
  
       static
       {
          loadMappingFile()
       }
  
  
  @VisibleForTesting     
  static void loadMappingFile()
      {
        //reading properties files here
  
       final Properties prop = new Properties();
          try (final InputStream input = Files.newInputStream(Paths.get(filepath)))
          {
              prop.load(input);
          }
          catch (final Exception e)
          {
              ...
              ...
              throw new RuntimeException(e);
          }
  
                 //now load "mapping" from properties file
                ....
                    ....
          }
      }
  </code></pre>
  
  <p>For testing, I need to change the value of string variable "filepath" such that it should take development system path(say c:\project\target\mapping.properties)</p>
  
  <p>I have tried powermocks in junits, but it always throws exception and terminates. </p>
  
  <p>annotations at class level:</p>
  
  <pre><code>@RunWith(PowerMockRunner.class)
  @SuppressStaticInitializationFor("some.package.ClassWithStaticInit")
  </code></pre>
  
  <p>and in test case:</p>
  
  <pre><code>Whitebox.setInternalState(Mappingloader.class, "filepath", testfilepath);
  Mappingloader.loadMappingFile();
  </code></pre>
  
  <p>I also tried to change this via reflection as given in(<a href="https://stackoverflow.com/questions/3301635/change-private-static-final-field-using-java-reflection">Change private static final field using Java reflection</a>) but it always throws the FileNotFoundException for "filepath" and does not takes the changed path "testFilePath"</p>
  
  <p>Is there any way i can change this variable such that it does not throw FileNotFoundException without any modification in source code?</p>
  
  <p>If I remove "throw new RuntimeException(e);" in source code, powermocks works for me. but i want to achieve this without modifying source code, either via powermock, reflection api.</p>