title: How do I write a unit test to cover the case where an IOException is thrown?
body: <p>I have the following class:</p>
  
  <pre><code>    public class FileLoader {   
  
           private Map&lt;Brand, String&gt; termsOfUseText = new HashMap&lt;Brand, String&gt;();
  
           public void load() {
              for (Brand brand : Brand.values()) {
                  readAndStoreTermsOfUseForBrand(brand);
              }
           }
  
           private void readAndStoreTermsOfUseForBrand(Brand brand) {
              String resourceName = "termsOfUse/" + brand.name().toLowerCase() + ".txt";          
              InputStream in = this.getClass().getClassLoader().getResourceAsStream(resourceName);            
              try {
                  String content = IOUtils.toString(in);          
                  termsOfUseText.put(brand, content);
              } catch (IOException e) {
                  throw new IllegalStateException(String.format("Failed to find terms of use source file %s", resourceName),e);
              }
           }
  
          public String getTextForBrand(Brand brand) {
              return termsOfUseText.get(brand);
          }
      }
  </code></pre>
  
  <p>Brand is an enum, and I need all the valid .txt files to be on the classpath. How do I make the IOException occur, given that the Brand enum contains all the valid brands and therfore all the .txt files for them exist?</p>
  
  <p>Suggestions around refactoring the current code are welcome if it makes it more testable!</p>