public void test_removeOpenVpnStateListener_does_not_accept_null() throws RemoteException { try { wrapper.removeOpenVpnStateListener(null); fail("NullPointerException expected"); } catch (NullPointerException e) { assertEquals("listener is null in removeOpenVpnStateListener", e.getMessage()); } }
public void test_removeOpenVpnStateListener_delegates_to_stub() throws RemoteException { IOpenVpnStateListener param = mock(IOpenVpnStateListener.class); wrapper.onServiceConnected(COMPONENT_NAME, openVpnServiceStub); wrapper.removeOpenVpnStateListener(param); Mockito.verify(openVpnServiceStub).removeOpenVpnStateListener(param); }
public void test_removeOpenVpnStateListener_RemoteException_disables_binding() throws RemoteException { IOpenVpnStateListener param = mock(IOpenVpnStateListener.class); Mockito.doThrow(new RemoteException()) .when(openVpnServiceStub) .removeOpenVpnStateListener(param); wrapper.onServiceConnected(COMPONENT_NAME, openVpnServiceStub); wrapper.removeOpenVpnStateListener(param); assertFalse(wrapper.isBound()); }
public void test_onServiceConnected_registers_only_listeners_which_where_not_removed() throws RemoteException { IOpenVpnStateListener param1 = mock(IOpenVpnStateListener.class); IOpenVpnStateListener param2 = mock(IOpenVpnStateListener.class); IOpenVpnStateListener param3 = mock(IOpenVpnStateListener.class); wrapper.addOpenVpnStateListener(param1); wrapper.addOpenVpnStateListener(param2); wrapper.addOpenVpnStateListener(param3); wrapper.removeOpenVpnStateListener(param2); wrapper.onServiceConnected(COMPONENT_NAME, openVpnServiceStub); Mockito.verify(openVpnServiceStub).addOpenVpnStateListener(param1); Mockito.verify(openVpnServiceStub, never()).addOpenVpnStateListener(param2); Mockito.verify(openVpnServiceStub).addOpenVpnStateListener(param3); }