use of org.mockito.InOrder in project hadoop by apache.
the class TestLs method processPathDirOrderAtime.
// check access time order (-u -t options)
@Test
public void processPathDirOrderAtime() throws IOException {
TestFile testfile01 = new TestFile("testDirectory", "testFile01");
TestFile testfile02 = new TestFile("testDirectory", "testFile02");
TestFile testfile03 = new TestFile("testDirectory", "testFile03");
TestFile testfile04 = new TestFile("testDirectory", "testFile04");
TestFile testfile05 = new TestFile("testDirectory", "testFile05");
TestFile testfile06 = new TestFile("testDirectory", "testFile06");
// set file atime in different order to file names
testfile01.setAtime(NOW.getTime() + 10);
testfile02.setAtime(NOW.getTime() + 30);
testfile03.setAtime(NOW.getTime() + 20);
testfile04.setAtime(NOW.getTime() + 60);
testfile05.setAtime(NOW.getTime() + 50);
testfile06.setAtime(NOW.getTime() + 40);
// set file mtime in different order to atime
testfile01.setMtime(NOW.getTime() + 60);
testfile02.setMtime(NOW.getTime() + 50);
testfile03.setMtime(NOW.getTime() + 20);
testfile04.setMtime(NOW.getTime() + 30);
testfile05.setMtime(NOW.getTime() + 10);
testfile06.setMtime(NOW.getTime() + 40);
TestFile testDir = new TestFile("", "testDirectory");
testDir.setIsDir(true);
testDir.addContents(testfile01, testfile02, testfile03, testfile04, testfile05, testfile06);
LinkedList<PathData> pathData = new LinkedList<PathData>();
pathData.add(testDir.getPathData());
PrintStream out = mock(PrintStream.class);
Ls ls = new Ls();
ls.out = out;
LinkedList<String> options = new LinkedList<String>();
options.add("-t");
options.add("-u");
ls.processOptions(options);
String lineFormat = TestFile.computeLineFormat(pathData);
ls.processArguments(pathData);
InOrder inOrder = inOrder(out);
inOrder.verify(out).println("Found 6 items");
inOrder.verify(out).println(testfile04.formatLineAtime(lineFormat));
inOrder.verify(out).println(testfile05.formatLineAtime(lineFormat));
inOrder.verify(out).println(testfile06.formatLineAtime(lineFormat));
inOrder.verify(out).println(testfile02.formatLineAtime(lineFormat));
inOrder.verify(out).println(testfile03.formatLineAtime(lineFormat));
inOrder.verify(out).println(testfile01.formatLineAtime(lineFormat));
verifyNoMoreInteractions(out);
}
use of org.mockito.InOrder in project hadoop by apache.
the class TestLs method processPathFiles.
// check listing of multiple files
@Test
public void processPathFiles() throws IOException {
TestFile testfile01 = new TestFile("testDir01", "testFile01");
TestFile testfile02 = new TestFile("testDir02", "testFile02");
TestFile testfile03 = new TestFile("testDir03", "testFile03");
TestFile testfile04 = new TestFile("testDir04", "testFile04");
TestFile testfile05 = new TestFile("testDir05", "testFile05");
TestFile testfile06 = new TestFile("testDir06", "testFile06");
LinkedList<PathData> pathData = new LinkedList<PathData>();
pathData.add(testfile01.getPathData());
pathData.add(testfile02.getPathData());
pathData.add(testfile03.getPathData());
pathData.add(testfile04.getPathData());
pathData.add(testfile05.getPathData());
pathData.add(testfile06.getPathData());
PrintStream out = mock(PrintStream.class);
Ls ls = new Ls();
ls.out = out;
LinkedList<String> options = new LinkedList<String>();
ls.processOptions(options);
String lineFormat = TestFile.computeLineFormat(pathData);
ls.processArguments(pathData);
InOrder inOrder = inOrder(out);
inOrder.verify(out).println(testfile01.formatLineMtime(lineFormat));
inOrder.verify(out).println(testfile02.formatLineMtime(lineFormat));
inOrder.verify(out).println(testfile03.formatLineMtime(lineFormat));
inOrder.verify(out).println(testfile04.formatLineMtime(lineFormat));
inOrder.verify(out).println(testfile05.formatLineMtime(lineFormat));
inOrder.verify(out).println(testfile06.formatLineMtime(lineFormat));
verifyNoMoreInteractions(out);
}
use of org.mockito.InOrder in project hadoop by apache.
the class TestLs method processPathDirectoryPathOnly.
// check path only display (-C option)
@Test
public void processPathDirectoryPathOnly() throws IOException {
TestFile testfile01 = new TestFile("testDirectory", "testFile01");
TestFile testfile02 = new TestFile("testDirectory", "testFile02");
TestFile testfile03 = new TestFile("testDirectory", "testFile03");
TestFile testfile04 = new TestFile("testDirectory", "testFile04");
TestFile testfile05 = new TestFile("testDirectory", "testFile05");
TestFile testfile06 = new TestFile("testDirectory", "testFile06");
TestFile testDir = new TestFile("", "testDirectory");
testDir.setIsDir(true);
testDir.addContents(testfile01, testfile02, testfile03, testfile04, testfile05, testfile06);
LinkedList<PathData> pathData = new LinkedList<PathData>();
pathData.add(testDir.getPathData());
PrintStream out = mock(PrintStream.class);
Ls ls = new Ls();
ls.out = out;
LinkedList<String> options = new LinkedList<String>();
options.add("-C");
ls.processOptions(options);
ls.processArguments(pathData);
InOrder inOrder = inOrder(out);
inOrder.verify(out).println(testfile01.getPath().toString());
inOrder.verify(out).println(testfile02.getPath().toString());
inOrder.verify(out).println(testfile03.getPath().toString());
inOrder.verify(out).println(testfile04.getPath().toString());
inOrder.verify(out).println(testfile05.getPath().toString());
inOrder.verify(out).println(testfile06.getPath().toString());
verifyNoMoreInteractions(out);
}
use of org.mockito.InOrder in project hadoop by apache.
the class TestFind method processArgumentsOptionFollowArg.
// check symlinks given as path arguments are processed correctly with the
// follow arg option set
@Test
public void processArgumentsOptionFollowArg() throws IOException {
LinkedList<PathData> items = createDirectories();
Find find = new Find();
find.getOptions().setFollowArgLink(true);
find.setConf(conf);
PrintStream out = mock(PrintStream.class);
find.getOptions().setOut(out);
PrintStream err = mock(PrintStream.class);
find.getOptions().setErr(err);
Expression expr = mock(Expression.class);
when(expr.apply((PathData) any(), anyInt())).thenReturn(Result.PASS);
FileStatusChecker fsCheck = mock(FileStatusChecker.class);
Expression test = new TestExpression(expr, fsCheck);
find.setRootExpression(test);
find.processArguments(items);
InOrder inOrder = inOrder(expr);
inOrder.verify(expr).setOptions(find.getOptions());
inOrder.verify(expr).prepare();
inOrder.verify(expr).apply(item1, 0);
inOrder.verify(expr).apply(item1a, 1);
inOrder.verify(expr).apply(item1aa, 2);
inOrder.verify(expr).apply(item1b, 1);
inOrder.verify(expr).apply(item2, 0);
inOrder.verify(expr).apply(item3, 0);
inOrder.verify(expr).apply(item4, 0);
inOrder.verify(expr).apply(item5, 0);
inOrder.verify(expr).apply(item5a, 1);
inOrder.verify(expr).apply(item5b, 1);
inOrder.verify(expr).apply(item5c, 1);
inOrder.verify(expr).apply(item5ca, 2);
inOrder.verify(expr).apply(item5d, 1);
inOrder.verify(expr).apply(item5e, 1);
inOrder.verify(expr).finish();
verifyNoMoreInteractions(expr);
InOrder inOrderFsCheck = inOrder(fsCheck);
inOrderFsCheck.verify(fsCheck).check(item1.stat);
inOrderFsCheck.verify(fsCheck).check(item1a.stat);
inOrderFsCheck.verify(fsCheck).check(item1aa.stat);
inOrderFsCheck.verify(fsCheck).check(item1b.stat);
inOrderFsCheck.verify(fsCheck).check(item2.stat);
inOrderFsCheck.verify(fsCheck, times(2)).check(item3.stat);
inOrderFsCheck.verify(fsCheck).check(item5.stat);
inOrderFsCheck.verify(fsCheck).check(item5a.stat);
inOrderFsCheck.verify(fsCheck).check(item5b.stat);
inOrderFsCheck.verify(fsCheck).check(item5c.stat);
inOrderFsCheck.verify(fsCheck).check(item5ca.stat);
inOrderFsCheck.verify(fsCheck).check(item5d.stat);
inOrderFsCheck.verify(fsCheck).check(item5e.stat);
verifyNoMoreInteractions(fsCheck);
verifyNoMoreInteractions(out);
verifyNoMoreInteractions(err);
}
use of org.mockito.InOrder in project hadoop by apache.
the class TestFind method processArgumentsOptionFollow.
// check symlinks given as path arguments are processed correctly with the
// follow option
@Test
public void processArgumentsOptionFollow() throws IOException {
LinkedList<PathData> items = createDirectories();
Find find = new Find();
find.getOptions().setFollowLink(true);
find.setConf(conf);
PrintStream out = mock(PrintStream.class);
find.getOptions().setOut(out);
PrintStream err = mock(PrintStream.class);
find.getOptions().setErr(err);
Expression expr = mock(Expression.class);
when(expr.apply((PathData) any(), anyInt())).thenReturn(Result.PASS);
FileStatusChecker fsCheck = mock(FileStatusChecker.class);
Expression test = new TestExpression(expr, fsCheck);
find.setRootExpression(test);
find.processArguments(items);
InOrder inOrder = inOrder(expr);
inOrder.verify(expr).setOptions(find.getOptions());
inOrder.verify(expr).prepare();
inOrder.verify(expr).apply(item1, 0);
inOrder.verify(expr).apply(item1a, 1);
inOrder.verify(expr).apply(item1aa, 2);
inOrder.verify(expr).apply(item1b, 1);
inOrder.verify(expr).apply(item2, 0);
inOrder.verify(expr).apply(item3, 0);
inOrder.verify(expr).apply(item4, 0);
inOrder.verify(expr).apply(item5, 0);
inOrder.verify(expr).apply(item5a, 1);
// triggers infinite loop message
inOrder.verify(expr).apply(item5b, 1);
inOrder.verify(expr).apply(item5c, 1);
inOrder.verify(expr).apply(item5ca, 2);
inOrder.verify(expr).apply(item5d, 1);
// following item5d symlink
inOrder.verify(expr).apply(item5ca, 2);
inOrder.verify(expr).apply(item5e, 1);
inOrder.verify(expr).finish();
verifyNoMoreInteractions(expr);
InOrder inOrderFsCheck = inOrder(fsCheck);
inOrderFsCheck.verify(fsCheck).check(item1.stat);
inOrderFsCheck.verify(fsCheck).check(item1a.stat);
inOrderFsCheck.verify(fsCheck).check(item1aa.stat);
inOrderFsCheck.verify(fsCheck).check(item1b.stat);
inOrderFsCheck.verify(fsCheck).check(item2.stat);
inOrderFsCheck.verify(fsCheck, times(2)).check(item3.stat);
inOrderFsCheck.verify(fsCheck).check(item5.stat);
inOrderFsCheck.verify(fsCheck).check(item1b.stat);
inOrderFsCheck.verify(fsCheck).check(item5.stat);
inOrderFsCheck.verify(fsCheck).check(item5c.stat);
inOrderFsCheck.verify(fsCheck).check(item5ca.stat);
inOrderFsCheck.verify(fsCheck).check(item5c.stat);
inOrderFsCheck.verify(fsCheck, times(2)).check(item5ca.stat);
verifyNoMoreInteractions(fsCheck);
verifyNoMoreInteractions(out);
verify(err).println("Infinite loop ignored: " + item5b.toString() + " -> " + item5.toString());
verifyNoMoreInteractions(err);
}
Aggregations