public void test_onServiceConnected_registers_several_listeners() 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.onServiceConnected(COMPONENT_NAME, openVpnServiceStub);

    Mockito.verify(openVpnServiceStub).addOpenVpnStateListener(param1);
    Mockito.verify(openVpnServiceStub).addOpenVpnStateListener(param2);
    Mockito.verify(openVpnServiceStub).addOpenVpnStateListener(param3);
  }
  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);
  }
  public void test_addOpenVpnStateListener_delegates_to_stub() throws RemoteException {
    IOpenVpnStateListener param = mock(IOpenVpnStateListener.class);
    wrapper.onServiceConnected(COMPONENT_NAME, openVpnServiceStub);

    wrapper.addOpenVpnStateListener(param);

    Mockito.verify(openVpnServiceStub).addOpenVpnStateListener(param);
  }
 public void test_addOpenVpnStateListener_does_not_accept_null() throws RemoteException {
   try {
     wrapper.addOpenVpnStateListener(null);
     fail("NullPointerException expected");
   } catch (NullPointerException e) {
     assertEquals("listener is null in addOpenVpnStateListener", e.getMessage());
   }
 }
  public void test_resumeListeners_after_onServiceDisconnected() 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.onServiceConnected(COMPONENT_NAME, openVpnServiceStub);
    wrapper.resumeListeners();
    resetOpenVpnServiceStub();

    wrapper.onServiceDisconnected(COMPONENT_NAME);
    wrapper.onServiceConnected(COMPONENT_NAME, openVpnServiceStub);

    Mockito.verify(openVpnServiceStub).addOpenVpnStateListener(param1);
    Mockito.verify(openVpnServiceStub).addOpenVpnStateListener(param2);
    Mockito.verify(openVpnServiceStub).addOpenVpnStateListener(param3);
  }
  public void test_onServiceConnected_registers_identical_listeners_only_once()
      throws RemoteException {
    IOpenVpnStateListener param = mock(IOpenVpnStateListener.class);
    wrapper.addOpenVpnStateListener(param);
    wrapper.addOpenVpnStateListener(param);

    wrapper.onServiceConnected(COMPONENT_NAME, openVpnServiceStub);

    Mockito.verify(openVpnServiceStub).addOpenVpnStateListener(param);
  }
  public void test_addOpenVpnStateListener_RemoteException_disables_binding()
      throws RemoteException {
    IOpenVpnStateListener param = mock(IOpenVpnStateListener.class);
    Mockito.doThrow(new RemoteException()).when(openVpnServiceStub).addOpenVpnStateListener(param);
    wrapper.onServiceConnected(COMPONENT_NAME, openVpnServiceStub);

    wrapper.addOpenVpnStateListener(param);

    assertFalse(wrapper.isBound());
  }