title: JUnit - Unit Testing Dearchivers
body: <p>I'd like to test the 2 methods below but I have no idea where to start. Possible scenarios I can think of:
  1) Test that decompressing the input produces output that is bigger than the input.(not valid for .tar?)
  2) Test edge cases such as zero length and very long input.
  3) Test very large size input.</p>
  
  <p>Could you hint for test cases or provide 1 code example?</p>
  
  <pre><code>    /**
       * uncompresses .tar file
       * @param in
       * @param out
       * @throws IOException
       */
      public static void decompressTar(String in, File out) throws IOException {
          try (TarArchiveInputStream tin = new TarArchiveInputStream(new FileInputStream(in))){
              TarArchiveEntry entry;
              while ((entry = tin.getNextTarEntry()) != null) {
                  if (entry.isDirectory()) {
                      continue;
                  }
                  File curfile = new File(out, entry.getName());
                  File parent = curfile.getParentFile();
                  if (!parent.exists()) {
                      parent.mkdirs();
                  }
                  IOUtils.copy(tin, new FileOutputStream(curfile));
              }
          }
      }
  
      /**
       * uncompresses .7z file
       * @param in
       * @param destination
       * @throws IOException
       */
      public static void decompressSevenz(String in, File destination) throws IOException {
          //@SuppressWarnings("resource")
          SevenZFile sevenZFile = new SevenZFile(new File(in));
          SevenZArchiveEntry entry;
          while ((entry = sevenZFile.getNextEntry()) != null){
              if (entry.isDirectory()){
                  continue;
              }
              File curfile = new File(destination, entry.getName());
              File parent = curfile.getParentFile();
              if (!parent.exists()) {
                  parent.mkdirs();
              }
              FileOutputStream out = new FileOutputStream(curfile);
              byte[] content = new byte[(int) entry.getSize()];
              sevenZFile.read(content, 0, content.length);
              out.write(content);
              out.close();
          }
          sevenZFile.close();
      }
  </code></pre>
  
  <p>Here is current emptyness:</p>
  
  <pre><code>package jfe;
  
  import static org.junit.Assert.*;
  
  import org.junit.Test;
  
  /**
   * @author test
   */
  public class JThreadTarTest {
  
      private String dir_input ="unit_test/jfe/files/input"; //input file directory
      private String dir_exp_out = "unit_test/jfe/files/expectedOutput/"; //actual output directory
      private String dir_act_out = "unit_test/jfe/files/actualOutput/"; //actual output directory
  
      @Test
      public void testdecompressTar() {
          fail("Not yet implemented");
      }
  
      @Test
      public void testdecompressSevenz() {
          fail("Not yet implemented");
      }
      //check if file size is too big
      //check null pointers
      //check etc.
      //assertNotNull
  }
  </code></pre>