@Test
  public void shouldCreateFile() throws InterruptedException {
    // when
    fileCreator.createFile(fileName);

    // then
    boolean fileExists = checkThatFileExists(fileName);
    assertThat(fileExists, is(true));
  }
Exemplo n.º 2
0
  protected void prepare() {

    DatanodeReg dr = new DatanodeReg();
    dr.setDatanodeNum(dataNum);
    dr.init();
    dr.runTest();

    FileCreator fc = new FileCreator();
    fc.setParams(threadNum, fileNum);
    fc.init();
    fc.runTest();
    fidarray = fc.getCreatedFileIds();

    BlockAllocator ba = new BlockAllocator();
    ba.setParams(threadNum, blockNum, fidarray);
    ba.init();
    ba.runTest();
    blkarray = ba.getBlockIdarray();
  }
  @Test
  public void testRun() throws Exception {

    newFileCreated.run(cssparam, frameworkparam, scriptparam);

    newlyCreatedZipFile = new File(productZippedFolder);

    assertNotNull(newlyCreatedZipFile);

    System.out.println(cssparam + " " + frameworkparam + " " + scriptparam);
    System.out.println("Zip file: " + newlyCreatedZipFile);
  }
Exemplo n.º 4
0
 public static void main(String[] args) throws InterruptedException, IOException {
   if (DebugOutput.init()) {
     if (Config.load()) {
       if (!Config.firstRun) {
         print("Beginning Lib parsing...");
         if (ParseLib.parseTheLib()) {
           print("Lib parsing complete. Beginning Java parsing...");
           if (FileCreator.createDir(FileCreator.recipeDir)) {
             if (ParseJava.parseTheJava()) {
               print("Java parsing complete.  Beginning Javascript output...");
               JavascriptOutput.outputJavascript();
               print("Congratz, all done!");
               DebugOutput.log.close();
               Thread.sleep(15000);
             } else {
               DebugOutput.log.close();
               Thread.sleep(15000);
             }
           } else {
             DebugOutput.log.close();
             Thread.sleep(15000);
           }
         } else {
           DebugOutput.log.close();
           Thread.sleep(15000);
         }
       } else {
         DebugOutput.out(
             "\n\n"
                 + "#########################################################################\n"
                 + "Program stopping due to this being the first run.\n"
                 + "Please check that the config options are to your liking before rerunning.\n"
                 + "Config location: "
                 + Config.configFile.getAbsolutePath()
                 + "\n"
                 + "#########################################################################",
             0);
         DebugOutput.log.close();
         Thread.sleep(15000);
       }
     } else {
       DebugOutput.log.close();
       Thread.sleep(15000);
     }
   } else {
     DebugOutput.log.close();
     Thread.sleep(15000);
   }
 }
Exemplo n.º 5
0
  /** Download InputStream, use FileCreator to create output file */
  private static boolean download(InputStream in, FileCreator creator, String libname) {
    boolean success = false;
    java.io.BufferedOutputStream bout = creator.create(libname);
    if (bout == null) {
      System.err.println("Not possible to create a file for downloading");
      creator.done(success);
      return success;
    }

    BufferedInputStream bin = new BufferedInputStream(in);
    byte data[] = new byte[BUF_SZ];

    while (true) {
      int count = 0;
      try {
        count = bin.read(data, 0, BUF_SZ);
      } catch (IOException e) {
        System.err.println(e);
        creator.done(success);
        return success;
      }
      if (count == -1) {
        break;
      }

      try {
        bout.write(data, 0, count);
      } catch (IOException e) {
        System.err.println(e);
        creator.done(success);
        return success;
      }
      //          break;
    }

    try {
      bout.close();
    } catch (IOException e) {
      System.err.println(e);
      creator.done(success);
      return success;
    }

    success = true;
    creator.done(success);
    return success;
  }
 public void testStartZipping() throws Exception {
   newFileCreated.startZipping();
 }