Search in sources :

Example 21 with InOrder

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);
}
Also used : PrintStream(java.io.PrintStream) InOrder(org.mockito.InOrder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 22 with InOrder

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);
}
Also used : PrintStream(java.io.PrintStream) InOrder(org.mockito.InOrder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 23 with InOrder

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);
}
Also used : PrintStream(java.io.PrintStream) InOrder(org.mockito.InOrder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 24 with InOrder

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);
}
Also used : PrintStream(java.io.PrintStream) InOrder(org.mockito.InOrder) BaseExpression(org.apache.hadoop.fs.shell.find.BaseExpression) Expression(org.apache.hadoop.fs.shell.find.Expression) Find(org.apache.hadoop.fs.shell.find.Find) PathData(org.apache.hadoop.fs.shell.PathData) Test(org.junit.Test)

Example 25 with InOrder

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);
}
Also used : PrintStream(java.io.PrintStream) InOrder(org.mockito.InOrder) BaseExpression(org.apache.hadoop.fs.shell.find.BaseExpression) Expression(org.apache.hadoop.fs.shell.find.Expression) Find(org.apache.hadoop.fs.shell.find.Find) PathData(org.apache.hadoop.fs.shell.PathData) Test(org.junit.Test)

Aggregations

InOrder (org.mockito.InOrder)3292 Test (org.junit.Test)2308 Test (org.junit.jupiter.api.Test)377 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)108 HashMap (java.util.HashMap)104 ArrayList (java.util.ArrayList)98 Response (com.jayway.restassured.response.Response)79 Matchers.containsString (org.hamcrest.Matchers.containsString)69 IOException (java.io.IOException)64 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)63 SmallTest (org.mule.tck.size.SmallTest)62 List (java.util.List)57 CompletableFuture (java.util.concurrent.CompletableFuture)52 Cleanup (lombok.Cleanup)46 InvocationOnMock (org.mockito.invocation.InvocationOnMock)46 WireCommands (io.pravega.shared.protocol.netty.WireCommands)45 ProcessorInterceptor (org.mule.runtime.api.interception.ProcessorInterceptor)44 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)44 Metadata (io.grpc.Metadata)43 ComponentLocation (org.mule.runtime.api.component.location.ComponentLocation)41