Search in sources :

Example 16 with InOrder

use of org.mockito.InOrder in project k-9 by k9mail.

the class ImapConnectionTest method open_authXoauthWithSaslIrInvalidatesAndRetriesNewTokenOnMissingStatusJsonResponse.

@Test
public void open_authXoauthWithSaslIrInvalidatesAndRetriesNewTokenOnMissingStatusJsonResponse() throws Exception {
    settings.setAuthType(AuthType.XOAUTH2);
    when(oAuth2TokenProvider.getToken("user", OAuth2TokenProvider.OAUTH2_TIMEOUT)).thenReturn("token").thenReturn("token2");
    MockImapServer server = new MockImapServer();
    preAuthenticationDialog(server, "SASL-IR AUTH=XOAUTH AUTH=XOAUTH2");
    server.expect("2 AUTHENTICATE XOAUTH2 " + XOAUTH_STRING);
    server.output("+ " + XOAuth2ChallengeParserTest.MISSING_STATUS_RESPONSE);
    server.expect("");
    server.output("2 NO SASL authentication failed");
    server.expect("3 AUTHENTICATE XOAUTH2 " + XOAUTH_STRING_RETRY);
    server.output("3 OK Success");
    simplePostAuthenticationDialog(server, "4");
    ImapConnection imapConnection = startServerAndCreateImapConnection(server);
    imapConnection.open();
    server.verifyConnectionStillOpen();
    server.verifyInteractionCompleted();
    InOrder inOrder = inOrder(oAuth2TokenProvider);
    inOrder.verify(oAuth2TokenProvider).getToken("user", OAuth2TokenProvider.OAUTH2_TIMEOUT);
    inOrder.verify(oAuth2TokenProvider).invalidateToken("user");
    inOrder.verify(oAuth2TokenProvider).getToken("user", OAuth2TokenProvider.OAUTH2_TIMEOUT);
}
Also used : InOrder(org.mockito.InOrder) MockImapServer(com.fsck.k9.mail.store.imap.mockserver.MockImapServer) XOAuth2ChallengeParserTest(com.fsck.k9.mail.XOAuth2ChallengeParserTest) Test(org.junit.Test)

Example 17 with InOrder

use of org.mockito.InOrder in project hadoop by apache.

the class TestContentSummary method testWrite.

// check the write method
@Test
public void testWrite() throws IOException {
    long length = 11111;
    long fileCount = 22222;
    long directoryCount = 33333;
    long quota = 44444;
    long spaceConsumed = 55555;
    long spaceQuota = 66666;
    ContentSummary contentSummary = new ContentSummary.Builder().length(length).fileCount(fileCount).directoryCount(directoryCount).quota(quota).spaceConsumed(spaceConsumed).spaceQuota(spaceQuota).build();
    DataOutput out = mock(DataOutput.class);
    InOrder inOrder = inOrder(out);
    contentSummary.write(out);
    inOrder.verify(out).writeLong(length);
    inOrder.verify(out).writeLong(fileCount);
    inOrder.verify(out).writeLong(directoryCount);
    inOrder.verify(out).writeLong(quota);
    inOrder.verify(out).writeLong(spaceConsumed);
    inOrder.verify(out).writeLong(spaceQuota);
}
Also used : DataOutput(java.io.DataOutput) InOrder(org.mockito.InOrder) Test(org.junit.Test)

Example 18 with InOrder

use of org.mockito.InOrder in project hadoop by apache.

the class TestLs method processPathDirOrderLengthLarge.

// check length ordering with large size gaps between files (checks integer
// overflow issues)
@Test
public void processPathDirOrderLengthLarge() 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 length in different order to file names
    long length = 1234567890;
    testfile01.setLength(length + 3l * Integer.MAX_VALUE);
    testfile02.setLength(length + Integer.MAX_VALUE);
    testfile03.setLength(length + 2l * Integer.MAX_VALUE);
    testfile04.setLength(length + 4l * Integer.MAX_VALUE);
    testfile05.setLength(length + 2l * Integer.MAX_VALUE);
    testfile06.setLength(length + 0);
    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("-S");
    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.formatLineMtime(lineFormat));
    inOrder.verify(out).println(testfile01.formatLineMtime(lineFormat));
    inOrder.verify(out).println(testfile03.formatLineMtime(lineFormat));
    inOrder.verify(out).println(testfile05.formatLineMtime(lineFormat));
    inOrder.verify(out).println(testfile02.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 19 with InOrder

use of org.mockito.InOrder in project hadoop by apache.

the class TestLs method processPathDirOrderMtime.

// check mtime ordering (-t option); most recent first in line with unix
// convention
@Test
public void processPathDirOrderMtime() 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 mtime in different order to file names
    testfile01.setMtime(NOW.getTime() + 10);
    testfile02.setMtime(NOW.getTime() + 30);
    testfile03.setMtime(NOW.getTime() + 20);
    testfile04.setMtime(NOW.getTime() + 60);
    testfile05.setMtime(NOW.getTime() + 50);
    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");
    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.formatLineMtime(lineFormat));
    inOrder.verify(out).println(testfile05.formatLineMtime(lineFormat));
    inOrder.verify(out).println(testfile06.formatLineMtime(lineFormat));
    inOrder.verify(out).println(testfile02.formatLineMtime(lineFormat));
    inOrder.verify(out).println(testfile03.formatLineMtime(lineFormat));
    inOrder.verify(out).println(testfile01.formatLineMtime(lineFormat));
    verifyNoMoreInteractions(out);
}
Also used : PrintStream(java.io.PrintStream) InOrder(org.mockito.InOrder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 20 with InOrder

use of org.mockito.InOrder in project hadoop by apache.

the class TestLs method processPathDirectoryAtime.

// check access time display (-u option)
@Test
public void processPathDirectoryAtime() 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("-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(testfile01.formatLineAtime(lineFormat));
    inOrder.verify(out).println(testfile02.formatLineAtime(lineFormat));
    inOrder.verify(out).println(testfile03.formatLineAtime(lineFormat));
    inOrder.verify(out).println(testfile04.formatLineAtime(lineFormat));
    inOrder.verify(out).println(testfile05.formatLineAtime(lineFormat));
    inOrder.verify(out).println(testfile06.formatLineAtime(lineFormat));
    verifyNoMoreInteractions(out);
}
Also used : PrintStream(java.io.PrintStream) InOrder(org.mockito.InOrder) LinkedList(java.util.LinkedList) 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