diff options
author | evitayan <evitayan@google.com> | 2019-10-10 20:48:22 -0700 |
---|---|---|
committer | evitayan <evitayan@google.com> | 2019-10-23 16:07:45 -0700 |
commit | e45db1b36ad14a794ba321d28cc2faf7101b56cf (patch) | |
tree | 8c18c489f2b022e77f732eb597c95307076ee7ad /tests | |
parent | 7b0ea194cef75cad479da4a1752a04d517dc0bd8 (diff) | |
download | ike-e45db1b36ad14a794ba321d28cc2faf7101b56cf.tar.gz |
Rename ChildCallback and IkeCallback
This commit:
- Renames IChildSessionCallback and IIkeSessionCallback
- Renames #onError and #onInfo
Bug: 142139930
Test: atest FrameworksIkeTests(all tests passed)
Change-Id: If6e5dbe2273820e73ddcf73331341359d1f5b41c
Diffstat (limited to 'tests')
3 files changed, 45 insertions, 40 deletions
diff --git a/tests/iketests/src/java/com/android/ike/ikev2/ChildSessionStateMachineTest.java b/tests/iketests/src/java/com/android/ike/ikev2/ChildSessionStateMachineTest.java index 9aca851e..1b6276a6 100644 --- a/tests/iketests/src/java/com/android/ike/ikev2/ChildSessionStateMachineTest.java +++ b/tests/iketests/src/java/com/android/ike/ikev2/ChildSessionStateMachineTest.java @@ -194,7 +194,7 @@ public final class ChildSessionStateMachineTest { private ChildSaProposal mMockNegotiatedProposal; private Executor mSpyUserCbExecutor; - private IChildSessionCallback mMockChildSessionCallback; + private ChildSessionCallback mMockChildSessionCallback; private IChildSessionSmCallback mMockChildSessionSmCallback; private ArgumentCaptor<ChildSaRecordConfig> mChildSaRecordConfigCaptor = @@ -246,7 +246,7 @@ public final class ChildSessionStateMachineTest { command.run(); }); - mMockChildSessionCallback = mock(IChildSessionCallback.class); + mMockChildSessionCallback = mock(ChildSessionCallback.class); mChildSessionOptions = buildChildSessionOptions(); // Setup thread and looper @@ -587,7 +587,7 @@ public final class ChildSessionStateMachineTest { verify(mMockChildSessionSmCallback).onProcedureFinished(mChildSessionStateMachine); verify(mMockChildSessionSmCallback).onChildSessionClosed(mMockChildSessionCallback); - verify(mMockChildSessionCallback).onError(any(exceptionClass)); + verify(mMockChildSessionCallback).onClosedExceptionally(any(exceptionClass)); } @Test @@ -764,7 +764,7 @@ public final class ChildSessionStateMachineTest { mLooper.dispatchAll(); assertNull(mChildSessionStateMachine.getCurrentState()); - verify(mMockChildSessionCallback).onError(any(InvalidSyntaxException.class)); + verify(mMockChildSessionCallback).onClosedExceptionally(any(InvalidSyntaxException.class)); verifyNotifyUserDeleteChildSa(mSpyCurrentChildSaRecord); } diff --git a/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionStateMachineTest.java b/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionStateMachineTest.java index 9821d742..6d93255d 100644 --- a/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionStateMachineTest.java +++ b/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionStateMachineTest.java @@ -257,8 +257,8 @@ public final class IkeSessionStateMachineTest { private ChildSessionOptions mChildSessionOptions; private Executor mSpyUserCbExecutor; - private IIkeSessionCallback mMockIkeSessionCallback; - private IChildSessionCallback mMockChildSessionCallback; + private IkeSessionCallback mMockIkeSessionCallback; + private ChildSessionCallback mMockChildSessionCallback; private EncryptionTransform mIkeEncryptionTransform; private IntegrityTransform mIkeIntegrityTransform; @@ -635,8 +635,8 @@ public final class IkeSessionStateMachineTest { command.run(); }); - mMockIkeSessionCallback = mock(IIkeSessionCallback.class); - mMockChildSessionCallback = mock(IChildSessionCallback.class); + mMockIkeSessionCallback = mock(IkeSessionCallback.class); + mMockChildSessionCallback = mock(ChildSessionCallback.class); mLooper = new TestLooper(); @@ -1286,7 +1286,7 @@ public final class IkeSessionStateMachineTest { eq(mContext), eq(mChildSessionOptions), eq(mSpyUserCbExecutor), - any(IChildSessionCallback.class), + any(ChildSessionCallback.class), any(IChildSessionSmCallback.class))) .thenReturn(child); } @@ -1301,7 +1301,7 @@ public final class IkeSessionStateMachineTest { * @param sm The ChildSessionStateMachine instance to be used. */ private void registerChildStateMachine( - IChildSessionCallback callback, ChildSessionStateMachine sm) { + ChildSessionCallback callback, ChildSessionStateMachine sm) { setupChildStateMachineFactory(sm); mIkeSessionStateMachine.registerChildSessionCallback( mChildSessionOptions, callback, false /*isFirstChild*/); @@ -1311,7 +1311,7 @@ public final class IkeSessionStateMachineTest { public void testCreateAdditionalChild() throws Exception { setupIdleStateMachine(); - IChildSessionCallback childCallback = mock(IChildSessionCallback.class); + ChildSessionCallback childCallback = mock(ChildSessionCallback.class); ChildSessionStateMachine childStateMachine = mock(ChildSessionStateMachine.class); registerChildStateMachine(childCallback, childStateMachine); @@ -1420,7 +1420,7 @@ public final class IkeSessionStateMachineTest { IkeSessionStateMachine.CMD_EXECUTE_LOCAL_REQ, new ChildLocalRequest( IkeSessionStateMachine.CMD_LOCAL_REQUEST_DELETE_CHILD, - mock(IChildSessionCallback.class), + mock(ChildSessionCallback.class), null /*childOptions*/)); mLooper.dispatchAll(); @@ -1470,11 +1470,11 @@ public final class IkeSessionStateMachineTest { private IChildSessionSmCallback createChildAndGetChildSessionSmCallback( ChildSessionStateMachine child, int remoteSpi) throws Exception { return createChildAndGetChildSessionSmCallback( - child, remoteSpi, mock(IChildSessionCallback.class)); + child, remoteSpi, mock(ChildSessionCallback.class)); } private IChildSessionSmCallback createChildAndGetChildSessionSmCallback( - ChildSessionStateMachine child, int remoteSpi, IChildSessionCallback childCallback) + ChildSessionStateMachine child, int remoteSpi, ChildSessionCallback childCallback) throws Exception { registerChildStateMachine(childCallback, child); @@ -1843,8 +1843,8 @@ public final class IkeSessionStateMachineTest { ChildSessionStateMachine childOne = mock(ChildSessionStateMachine.class); ChildSessionStateMachine childTwo = mock(ChildSessionStateMachine.class); - registerChildStateMachine(mock(IChildSessionCallback.class), childOne); - registerChildStateMachine(mock(IChildSessionCallback.class), childTwo); + registerChildStateMachine(mock(ChildSessionCallback.class), childOne); + registerChildStateMachine(mock(ChildSessionCallback.class), childTwo); mIkeSessionStateMachine.mCurrentIkeSaRecord = null; @@ -2071,7 +2071,8 @@ public final class IkeSessionStateMachineTest { // Verify IKE Session was closed properly assertNull(mIkeSessionStateMachine.getCurrentState()); - verify(mMockIkeSessionCallback).onError(any(AuthenticationFailedException.class)); + verify(mMockIkeSessionCallback) + .onClosedExceptionally(any(AuthenticationFailedException.class)); } @Test @@ -2094,7 +2095,7 @@ public final class IkeSessionStateMachineTest { // Verify IKE Session is closed properly assertNull(mIkeSessionStateMachine.getCurrentState()); - verify(mMockIkeSessionCallback).onError(any(InvalidSyntaxException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(InvalidSyntaxException.class)); } @Test @@ -2216,7 +2217,8 @@ public final class IkeSessionStateMachineTest { mLooper.dispatchAll(); // Verify state machine quit properly - verify(mMockIkeSessionCallback).onError(any(AuthenticationFailedException.class)); + verify(mMockIkeSessionCallback) + .onClosedExceptionally(any(AuthenticationFailedException.class)); assertNull(mIkeSessionStateMachine.getCurrentState()); } @@ -2260,7 +2262,8 @@ public final class IkeSessionStateMachineTest { mLooper.dispatchAll(); // Fires user error callbacks - verify(mMockIkeSessionCallback).onError(argThat(err -> err.getCause() == error)); + verify(mMockIkeSessionCallback) + .onClosedExceptionally(argThat(err -> err.getCause() == error)); // Verify state machine quit properly verify(mSpyCurrentIkeSaRecord).close(); @@ -2281,7 +2284,8 @@ public final class IkeSessionStateMachineTest { mLooper.dispatchAll(); // Fires user error callbacks - verify(mMockIkeSessionCallback).onError(any(AuthenticationFailedException.class)); + verify(mMockIkeSessionCallback) + .onClosedExceptionally(any(AuthenticationFailedException.class)); // Verify state machine quit properly verify(mSpyCurrentIkeSaRecord).close(); @@ -2446,7 +2450,7 @@ public final class IkeSessionStateMachineTest { // Verify IKE Session is closed properly assertNull(mIkeSessionStateMachine.getCurrentState()); - verify(mMockIkeSessionCallback).onError(any(InvalidSyntaxException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(InvalidSyntaxException.class)); // Collected response fragments are cleared assertNull(mSpyCurrentIkeSaRecord.getCollectedFragments(true /*isResp*/)); @@ -2561,7 +2565,7 @@ public final class IkeSessionStateMachineTest { // Verify IKE Session is closed properly assertNull(mIkeSessionStateMachine.getCurrentState()); - verify(mMockIkeSessionCallback).onError(any(InvalidSyntaxException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(InvalidSyntaxException.class)); } @Test @@ -2615,7 +2619,7 @@ public final class IkeSessionStateMachineTest { // Verify IKE Session is closed properly assertNull(mIkeSessionStateMachine.getCurrentState()); - verify(mMockIkeSessionCallback).onError(any(InvalidSyntaxException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(InvalidSyntaxException.class)); } @Test @@ -2646,7 +2650,7 @@ public final class IkeSessionStateMachineTest { // Verify IKE Session is closed properly assertNull(mIkeSessionStateMachine.getCurrentState()); - verify(mMockIkeSessionCallback).onError(any(IkeInternalException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(IkeInternalException.class)); } @Test @@ -3457,7 +3461,7 @@ public final class IkeSessionStateMachineTest { verifyEncryptAndEncodeNeverCalled(mSpyCurrentIkeSaRecord); // Verify state machine quit properly - verify(mMockIkeSessionCallback).onError(any(InvalidSyntaxException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(InvalidSyntaxException.class)); assertNull(mIkeSessionStateMachine.getCurrentState()); } @@ -3481,7 +3485,7 @@ public final class IkeSessionStateMachineTest { mLooper.dispatchAll(); // Verify state machine quit properly - verify(mMockIkeSessionCallback).onError(any(InvalidSyntaxException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(InvalidSyntaxException.class)); assertNull(mIkeSessionStateMachine.getCurrentState()); } @@ -3678,7 +3682,7 @@ public final class IkeSessionStateMachineTest { public void testOpenChildSession() throws Exception { setupIdleStateMachine(); - IChildSessionCallback cb = mock(IChildSessionCallback.class); + ChildSessionCallback cb = mock(ChildSessionCallback.class); mIkeSessionStateMachine.openChildSession(mChildSessionOptions, cb); // Test that inserting the same cb returns an error, even before the state @@ -3714,7 +3718,7 @@ public final class IkeSessionStateMachineTest { // Expect failure - callbacks not registered try { - mIkeSessionStateMachine.closeChildSession(mock(IChildSessionCallback.class)); + mIkeSessionStateMachine.closeChildSession(mock(ChildSessionCallback.class)); } catch (IllegalArgumentException expected) { } } @@ -3735,7 +3739,7 @@ public final class IkeSessionStateMachineTest { public void testCloseImmediatelyAfterOpenChildSession() throws Exception { setupIdleStateMachine(); - IChildSessionCallback cb = mock(IChildSessionCallback.class); + ChildSessionCallback cb = mock(ChildSessionCallback.class); mIkeSessionStateMachine.openChildSession(mChildSessionOptions, cb); // Verify that closing the session immediately still picks up the child callback @@ -3781,7 +3785,7 @@ public final class IkeSessionStateMachineTest { assertNull(ikeSession.getCurrentState()); verify(mSpyUserCbExecutor).execute(any(Runnable.class)); - verify(mMockIkeSessionCallback).onError(any(IkeInternalException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(IkeInternalException.class)); verify(spyIkeLog).wtf(anyString(), anyString(), any(RuntimeException.class)); } @@ -3797,7 +3801,7 @@ public final class IkeSessionStateMachineTest { assertNull(mIkeSessionStateMachine.getCurrentState()); verify(mSpyUserCbExecutor).execute(any(Runnable.class)); - verify(mMockIkeSessionCallback).onError(any(IkeInternalException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(IkeInternalException.class)); verify(spyIkeLog).wtf(anyString(), anyString(), any(RuntimeException.class)); } @@ -3825,7 +3829,8 @@ public final class IkeSessionStateMachineTest { // Fires user error callbacks verify(mMockIkeSessionCallback) - .onError(argThat(err -> err instanceof NoValidProposalChosenException)); + .onClosedExceptionally( + argThat(err -> err instanceof NoValidProposalChosenException)); // Verify state machine quit properly assertNull(mIkeSessionStateMachine.getCurrentState()); } @@ -3907,7 +3912,7 @@ public final class IkeSessionStateMachineTest { mLooper.dispatchAll(); assertNull(mIkeSessionStateMachine.getCurrentState()); - verify(mMockIkeSessionCallback).onError(any(IkeInternalException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(IkeInternalException.class)); } @Test @@ -3968,7 +3973,7 @@ public final class IkeSessionStateMachineTest { // Verify IKE Session is closed properly assertNull(mIkeSessionStateMachine.getCurrentState()); - verify(mMockIkeSessionCallback).onError(any(InvalidSyntaxException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(InvalidSyntaxException.class)); } @Test @@ -3997,7 +4002,7 @@ public final class IkeSessionStateMachineTest { // Verify IKE Session has quit assertNull(mIkeSessionStateMachine.getCurrentState()); - verify(mMockIkeSessionCallback).onError(any(InvalidSyntaxException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(InvalidSyntaxException.class)); } @Test diff --git a/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionTest.java b/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionTest.java index 60e99b02..e33a67cc 100644 --- a/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionTest.java +++ b/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionTest.java @@ -54,8 +54,8 @@ public final class IkeSessionTest { private IkeSessionOptions mIkeSessionOptions; private ChildSessionOptions mMockChildSessionOptions; private Executor mUserCbExecutor; - private IIkeSessionCallback mMockIkeSessionCb; - private IChildSessionCallback mMockChildSessionCb; + private IkeSessionCallback mMockIkeSessionCb; + private ChildSessionCallback mMockChildSessionCb; @Before public void setUp() throws Exception { @@ -68,8 +68,8 @@ public final class IkeSessionTest { mIkeSessionOptions = buildIkeSessionOptions(); mMockChildSessionOptions = mock(ChildSessionOptions.class); mUserCbExecutor = (r) -> r.run(); // Inline executor for testing purposes. - mMockIkeSessionCb = mock(IIkeSessionCallback.class); - mMockChildSessionCb = mock(IChildSessionCallback.class); + mMockIkeSessionCb = mock(IkeSessionCallback.class); + mMockChildSessionCb = mock(ChildSessionCallback.class); } private IkeSessionOptions buildIkeSessionOptions() throws Exception { |