org.hamcrest.io.FileMatchers Java Examples

The following examples show how to use org.hamcrest.io.FileMatchers. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EagleEyeLogUtilTest.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 6 votes vote down vote up
@Test
public void testChangeLogBase() throws Exception {
    String userHome = System.getProperty("user.home");
    String newLogBase = userHome + File.separator + "tmpLogDir" + System.currentTimeMillis();
    System.setProperty(LogBase.LOG_DIR, newLogBase);

    EagleEyeLogUtil.log("resourceName", "BlockException", "app1", "origin", 1);

    final File file = new File(RecordLog.getLogBaseDir() + EagleEyeLogUtil.FILE_NAME);
    await().timeout(2, TimeUnit.SECONDS)
        .until(new Callable<File>() {
            @Override
            public File call() throws Exception {
                return file;
            }
        }, FileMatchers.anExistingFile());
}
 
Example #2
Source File: EagleEyeLogUtilTest.java    From Sentinel with Apache License 2.0 6 votes vote down vote up
public void testChangeLogBase() throws Exception {
    String userHome = System.getProperty("user.home");
    String newLogBase = userHome + File.separator + "tmpLogDir" + System.currentTimeMillis();
    System.setProperty(LogBase.LOG_DIR, newLogBase);

    EagleEyeLogUtil.log("resourceName", "BlockException", "app1", "origin", 1);


    final File file = new File(LogBase.getLogBaseDir() + EagleEyeLogUtil.FILE_NAME);
    await().timeout(2, TimeUnit.SECONDS)
            .until(new Callable<File>() {
                @Override
                public File call() throws Exception {
                    return file;
                }
            }, FileMatchers.anExistingFile());
    Assert.assertTrue(file.getAbsolutePath().startsWith(newLogBase));
    deleteLogDir(new File(LogBase.getLogBaseDir()));
}
 
Example #3
Source File: FileSystemBaselineRepositoryTests.java    From vividus with Apache License 2.0 5 votes vote down vote up
@Test
void shouldSaveBaselineIntoFolder(@TempDir File folder) throws IOException
{
    fileSystemBaselineRepository.setBaselinesFolder(folder);
    Screenshot screenshot = mock(Screenshot.class);
    BufferedImage baseline = loadBaseline();
    when(screenshot.getImage()).thenReturn(baseline);
    fileSystemBaselineRepository.saveBaseline(screenshot, BASELINE);
    File baselineFile = new File(folder, BASELINE + DEFAULT_EXTENSION);
    assertThat(baselineFile, FileMatchers.anExistingFile());
    assertThat(logger.getLoggingEvents(), is(List.of(info("Baseline saved to: {}",
            baselineFile.getAbsolutePath()))));
    assertThat(ImageIO.read(baselineFile), ImageTool.equalImage(baseline));
}
 
Example #4
Source File: EagleEyeLogUtilTest.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriteLog() throws Exception {
    EagleEyeLogUtil.log("resourceName", "BlockException", "app1", "origin", 1);

    final File file = new File(RecordLog.getLogBaseDir() + EagleEyeLogUtil.FILE_NAME);
    await().timeout(2, TimeUnit.SECONDS)
        .until(new Callable<File>() {
            @Override
            public File call() throws Exception {
                return file;
            }
        }, FileMatchers.anExistingFile());
}
 
Example #5
Source File: EagleEyeLogUtilTest.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriteLog() throws Exception {
    EagleEyeLogUtil.log("resourceName", "BlockException", "app1", "origin", 1);

    final File file = new File(LogBase.getLogBaseDir() + EagleEyeLogUtil.FILE_NAME);
    await().timeout(2, TimeUnit.SECONDS)
        .until(new Callable<File>() {
            @Override
            public File call() throws Exception {
                return file;
            }
        }, FileMatchers.anExistingFile());
}
 
Example #6
Source File: WorkMgrTest.java    From batfish with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddToSerializedListNoListNoAddition() throws IOException {
  TemporaryFolder tmp = new TemporaryFolder();
  tmp.create();
  File serializedList = tmp.newFile();
  Path serializedListPath = serializedList.toPath();
  serializedList.delete();

  addToSerializedList(
      serializedListPath, ImmutableList.of(), new TypeReference<List<NodeInterfacePair>>() {});

  // Confirm no file was created (since there was no list to begin with and nothing was added)
  assertThat(serializedList, not(FileMatchers.anExistingFile()));
}