title: Internal graphics not initialized yet in JUunit test case
body: <p>I'm making a light weight painting application with JavaFx. 
  I've been having some issues with my <code>LayerController</code> class and it's methods <code>addLayer</code> etc. So I thought that writing some JUunit test cases would be a good idea to check the correctness of my methods. To make the story short, I'm painting on a <code>Canvas</code> using its <code>GraphicsContext</code> in a selfmade class which I call <code>PaintGraphics</code>. This class does all the painting. The <code>LayerController</code> needs a <code>PaintGraphics</code> to do its work on the layers. But it seems something goes wrong when I initiate a <code>GraphicsContext</code> in a test case. I get the error "Internal graphics not initialized yet.". Which I guess has something to do with the <code>GraphicsContext</code> but I'm not sure. Any ideas about why the error occurs, and how to solve it would be much appreciated! </p>
  
  <p>The source code for the test looks like this: </p>
  
  <pre><code>package view;
  
  import static org.junit.Assert.*;
  
  import java.util.ArrayList;
  
  import org.junit.Test;
  
  import controller.LayerController;
  import javafx.scene.canvas.Canvas;
  import javafx.scene.layout.AnchorPane;
  import model.Layer;
  import model.PaintGraphics;
  
  public class LayoutControllerTest {
  
      Layer layer = new Layer(0, new Canvas(100,100));
      ArrayList&lt;Layer&gt; layers = new ArrayList&lt;Layer&gt;();
      PaintGraphics pGraphics = new PaintGraphics(layer.getCanvas().getGraphicsContext2D());
      LayerController layerController; 
  
      @Test
      public void addLayerTest() {
          layers.add(layer);
          layerController.addLayer(layer, (AnchorPane)layer.getCanvas().getParent());
      }
  }
  </code></pre>