Package br.com.mystudies.niotwo

Source Code of br.com.mystudies.niotwo.ScannerPathTest

package br.com.mystudies.niotwo;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class ScannerPathTest {

  private ScannerPath scannerPath;


  @Before
  public void setUp() throws Exception {
    scannerPath = new ScannerPath();
  }

  @After
  public void tearDown() throws Exception {
    scannerPath = null;
  }

  @Test
  public void shouldReturnNewFile() throws IOException, InterruptedException {

    if(Files.exists(Paths.get("src/test/resources/scanner/dir1"))){

      Files.delete(Paths.get("src/test/resources/scanner/dir1"));
      Files.delete(Paths.get("src/test/resources/scanner/dir2"));
      Files.delete(Paths.get("src/test/resources/scanner/dir3"));
    }


    Path path =
        Paths.get("src/test/resources/scanner/");


    scannerPath.scan(path);

    Files.createDirectory(Paths.get("src/test/resources/scanner/dir1"));
    Files.createDirectory(Paths.get("src/test/resources/scanner/dir2"));
    Files.createDirectory(Paths.get("src/test/resources/scanner/dir3"));


    List<Path> paths = scannerPath.getNewFiles();

    assertNotNull(paths);
    assertEquals(3, paths.size());


    scannerPath.stopScan();

  }

}
TOP

Related Classes of br.com.mystudies.niotwo.ScannerPathTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.