title: How can I create fake data and the data object for unit testing?
body: <p>I have a class that implements a cache and I want to write a JUnit test for it.<br>
  The class implements and interface with methods like:  </p>
  
  <pre><code>public void insert(Object key, Object value);  
  public Object getFromCache(Object key);
  </code></pre>
  
  <p>and the basic implementation is a singleton.<br>
  I am writing a JUnit test but I don't know how to properly create a dummy cache with data in order to use for testing.<br>
  Right now I am doing:  </p>
  
  <pre><code>@Test
  public void myTest() {  
      MyCache cache = MyCache.getInstance();  
      populateWithData(cache);  
      //test cache  
      asserEquals etc  
  }  
  </code></pre>
  
  <p>How can I avoid using the <code>getInstance()</code> and not populate on each test?</p>