Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Unified Diff: net/android/junit/src/org/chromium/net/HttpNegotiateAuthenticatorTest.java

Issue 2076783004: Changes to update Junit and Mockito. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes to update Junit and Mockito. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/android/junit/src/org/chromium/net/HttpNegotiateAuthenticatorTest.java
diff --git a/net/android/junit/src/org/chromium/net/HttpNegotiateAuthenticatorTest.java b/net/android/junit/src/org/chromium/net/HttpNegotiateAuthenticatorTest.java
index 09485e348783d206d1aa987c94c04a15e046f03b..69f4cdf3bc1e00636bf356ee12b541c9659d0028 100644
--- a/net/android/junit/src/org/chromium/net/HttpNegotiateAuthenticatorTest.java
+++ b/net/android/junit/src/org/chromium/net/HttpNegotiateAuthenticatorTest.java
@@ -9,11 +9,11 @@ import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
+import static org.mockito.AdditionalMatchers.or;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.isNull;
import static org.mockito.Mockito.doNothing;
@@ -117,15 +117,11 @@ public class HttpNegotiateAuthenticatorTest {
authenticator.getNextAuthToken(0, "test_principal", "", true);
- verify(sMockAccountManager).getAuthTokenByFeatures(
- eq(accountType),
- eq("SPNEGO:HOSTBASED:test_principal"),
- eq(new String[] {"SPNEGO"}),
- any(Activity.class),
- isNull(Bundle.class),
- mBundleCaptor.capture(),
- mBundleCallbackCaptor.capture(),
- any(Handler.class));
+ verify(sMockAccountManager)
+ .getAuthTokenByFeatures(eq(accountType), eq("SPNEGO:HOSTBASED:test_principal"),
+ eq(new String[] {"SPNEGO"}), any(Activity.class), isNull(),
+ mBundleCaptor.capture(), mBundleCallbackCaptor.capture(),
+ any(Handler.class));
assertThat("There is no existing context",
mBundleCaptor.getValue().get(HttpNegotiateConstants.KEY_SPNEGO_CONTEXT),
@@ -194,28 +190,20 @@ public class HttpNegotiateAuthenticatorTest {
// Should fail because there are no accounts
callback.run(makeFuture(new Account[]{}));
- verify(authenticator).nativeSetResult(
- eq(42L),
- eq(NetError.ERR_MISSING_AUTH_CREDENTIALS),
- isNull(String.class));
+ verify(authenticator)
+ .nativeSetResult(eq(42L), eq(NetError.ERR_MISSING_AUTH_CREDENTIALS), isNull());
// Should succeed, for a single account we use it for the AccountManager#getAuthToken call.
Account testAccount = new Account("a", type);
callback.run(makeFuture(new Account[]{testAccount}));
- verify(sMockAccountManager).getAuthToken(
- eq(testAccount),
- anyString(),
- any(Bundle.class),
- eq(true),
- any(HttpNegotiateAuthenticator.GetTokenCallback.class),
- any(Handler.class));
+ verify(sMockAccountManager)
+ .getAuthToken(eq(testAccount), isNull(), isNull(), eq(true),
+ any(HttpNegotiateAuthenticator.GetTokenCallback.class), any(Handler.class));
// Should fail because there is more than one account
callback.run(makeFuture(new Account[]{new Account("a", type), new Account("b", type)}));
- verify(authenticator, times(2)).nativeSetResult(
- eq(42L),
- eq(NetError.ERR_MISSING_AUTH_CREDENTIALS),
- isNull(String.class));
+ verify(authenticator, times(2))
+ .nativeSetResult(eq(42L), eq(NetError.ERR_MISSING_AUTH_CREDENTIALS), isNull());
}
/**
@@ -248,13 +236,9 @@ public class HttpNegotiateAuthenticatorTest {
receiver.onReceive(Robolectric.getShadowApplication().getApplicationContext(), intent);
// Verify that the auth token is properly requested from the account manager.
- verify(sMockAccountManager).getAuthToken(
- eq(new Account("a", type)),
- eq("foo"),
- isNull(Bundle.class),
- eq(true),
- any(HttpNegotiateAuthenticator.GetTokenCallback.class),
- any(Handler.class));
+ verify(sMockAccountManager)
+ .getAuthToken(eq(new Account("a", type)), eq("foo"), isNull(), eq(true),
+ any(HttpNegotiateAuthenticator.GetTokenCallback.class), isNull());
}
/**
@@ -269,8 +253,8 @@ public class HttpNegotiateAuthenticatorTest {
// Call getNextAuthToken to get the callback
authenticator.getNextAuthToken(1234, "test_principal", "", true);
verify(sMockAccountManager)
- .getAuthTokenByFeatures(anyString(), anyString(), any(String[].class),
- any(Activity.class), any(Bundle.class), any(Bundle.class),
+ .getAuthTokenByFeatures(any(String.class), any(String.class), any(String[].class),
+ any(Activity.class), isNull(), any(Bundle.class),
mBundleCallbackCaptor.capture(), any(Handler.class));
Bundle resultBundle = new Bundle();
@@ -285,8 +269,8 @@ public class HttpNegotiateAuthenticatorTest {
// Check that the next call to getNextAuthToken uses the correct context
authenticator.getNextAuthToken(5678, "test_principal", "", true);
verify(sMockAccountManager, times(2))
- .getAuthTokenByFeatures(anyString(), anyString(), any(String[].class),
- any(Activity.class), any(Bundle.class), mBundleCaptor.capture(),
+ .getAuthTokenByFeatures(any(String.class), any(String.class), any(String[].class),
+ any(Activity.class), isNull(), mBundleCaptor.capture(),
mBundleCallbackCaptor.capture(), any(Handler.class));
assertThat("The spnego context is preserved between calls",
@@ -304,13 +288,14 @@ public class HttpNegotiateAuthenticatorTest {
Robolectric.buildActivity(Activity.class).create().start().resume().visible();
HttpNegotiateAuthenticator authenticator = createWithoutNative("Dummy_Account");
- doReturn(true).when(authenticator)
- .lacksPermission(any(Context.class), anyString(), anyBoolean());
+ doReturn(true)
+ .when(authenticator)
+ .lacksPermission(any(Context.class), any(String.class), anyBoolean());
authenticator.getNextAuthToken(1234, "test_principal", "", true);
verify(authenticator)
- .nativeSetResult(anyLong(), eq(NetError.ERR_MISCONFIGURED_AUTH_ENVIRONMENT),
- isNull(String.class));
+ .nativeSetResult(
+ anyLong(), eq(NetError.ERR_MISCONFIGURED_AUTH_ENVIRONMENT), isNull());
}
@Test
@@ -392,22 +377,17 @@ public class HttpNegotiateAuthenticatorTest {
// Call getNextAuthToken to get the callback
authenticator.getNextAuthToken(1234, "test_principal", "", true);
- verify(sMockAccountManager).getAuthTokenByFeatures(
- anyString(),
- anyString(),
- any(String[].class),
- any(Activity.class),
- any(Bundle.class),
- any(Bundle.class),
- mBundleCallbackCaptor.capture(),
- any(Handler.class));
+ verify(sMockAccountManager)
+ .getAuthTokenByFeatures(any(String.class), any(String.class), any(String[].class),
+ any(Activity.class), isNull(), any(Bundle.class),
+ mBundleCallbackCaptor.capture(), any(Handler.class));
Bundle resultBundle = new Bundle();
if (spnegoError != null) {
resultBundle.putInt(HttpNegotiateConstants.KEY_SPNEGO_RESULT, spnegoError);
}
mBundleCallbackCaptor.getValue().run(makeFuture(resultBundle));
- verify(authenticator).nativeSetResult(anyLong(), eq(expectedError), anyString());
+ verify(authenticator).nativeSetResult(anyLong(), eq(expectedError), isNull());
}
/**
@@ -453,10 +433,12 @@ public class HttpNegotiateAuthenticatorTest {
private HttpNegotiateAuthenticator createWithoutNative(String accountType) {
HttpNegotiateAuthenticator authenticator =
spy(HttpNegotiateAuthenticator.create(accountType));
- doNothing().when(authenticator).nativeSetResult(anyLong(), anyInt(), anyString());
+ doNothing()
+ .when(authenticator)
+ .nativeSetResult(anyLong(), anyInt(), or(any(String.class), isNull()));
doReturn(false)
.when(authenticator)
- .lacksPermission(any(Context.class), anyString(), anyBoolean());
+ .lacksPermission(any(Context.class), any(String.class), anyBoolean());
return authenticator;
}
}
« no previous file with comments | « net/android/BUILD.gn ('k') | third_party/hamcrest/BUILD.gn » ('j') | third_party/junit/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698