title: Null Pointer Exception at Junit test with fileSystem and spring boot
body: <p>This is my File system code:</p>
  
  <pre><code>  public String fileBackup(byte[] fileContent, String name) {
          String status = "Created file...";
          String file = (env.getProperty("file.path"))+ name;
          File srcfile = new File(file);
          try {
               String archive = (env.getProperty("file.archivePath")) + name;
               File destFile = new File(archive);
               //System.out.println(destFile);
               if (destFile.exists()) {
                    return "alreadyExists";
               } else {
                   destFile.createNewFile();
                    BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(destFile));
                    stream.write(fileContent);
                    stream.close();
                    srcfile.delete();
               }
          } catch (IOException ex) {
               status = "Failed to create file...";
               Logger.getLogger(FileSystemHandler.class.getName()).log(Level.SEVERE, null, ex);
          }
          return status;
    }
  </code></pre>
  
  <p>Imported Junit 4.12 and springframework mock. but while running junit test getting NullPointer Exception at   <code>String archive = (env.getProperty("file.archivePath")) + name;</code> Accessing path from application.properties. Test code is below.</p>
  
  <pre><code>import static org.junit.Assert.*;
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.List;
  import org.junit.Test;
  import org.springframework.mock.web.*;
  import prj.iopo.filesystem.FileSystemHandler;
  
  public class TestFileSystemHandler {
      FileSystemHandler fsh = new FileSystemHandler();
  @Test
      public void testBackup() {
          FileInputStream inputFile;
          try {
              inputFile = new FileInputStream("D:\\LAB\\job\\8972067.zip");
              MockMultipartFile file = new MockMultipartFile("file", "8972067.zip", "application/zip", inputFile);
              byte[] fileContent = file.getBytes();
              String name = file.getOriginalFilename();
              String backupOutput = fsh.fileBackup(fileContent, name);
              assertEquals("Backup Created", backupOutput);
  
          } catch (FileNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
      }
  }
  </code></pre>
  
  <p>Stack Trace of Exception:</p>
  
  <blockquote>
    <p>java.lang.NullPointerException    at
    prj.iopo.filesystem.FileSystemHandler.listVersionRestore(FileSystemHandler.java:231)
      at
    prj.iopo.testcase.TestFileSystemHandler.testListVersionRestore(TestFileSystemHandler.java:20)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
    sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)   at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)   at
    java.lang.reflect.Method.invoke(Unknown Source)   at
    org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at
    org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at
    org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at
    org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)    at
    org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      at
    org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)  at
    org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)   at
    org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)     at
    org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)   at
    org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)  at
    org.junit.runners.ParentRunner.run(ParentRunner.java:363)     at
    org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
      at
    org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
      at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
      at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
      at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)</p>
  </blockquote>