/** Test for getLoginServerFromURL. */
 public void testGetLoginServerFromURL() {
   assertProduction(loginServerManager.getLoginServerFromURL(PRODUCTION_URL));
   assertSandbox(loginServerManager.getLoginServerFromURL(SANDBOX_URL));
   assertOther(loginServerManager.getLoginServerFromURL(OTHER_URL));
   assertNull(
       "Expected null", loginServerManager.getLoginServerFromURL("https://wrong.salesforce.com"));
 }
  /** Test for useSandbox. */
  public void testUseSandbox() {

    // Starting point, production selected by default.
    assertProduction(loginServerManager.getSelectedLoginServer());

    // Calling useSandbox.
    loginServerManager.useSandbox();
    assertSandbox(loginServerManager.getSelectedLoginServer());
  }
  /** Test for getSelectedLoginServer/setSelectedLoginServer when there is a custom login server. */
  public void testGetSetLoginServerWithCustomServer() {

    // Starting point, production selected by default.
    assertProduction(loginServerManager.getSelectedLoginServer());

    // Adding custom server, custom should be selected.
    loginServerManager.addCustomLoginServer(CUSTOM_NAME, CUSTOM_URL);
    assertCustom(loginServerManager.getSelectedLoginServer());
  }
  /** Test for getCustomLoginServer/setCustomLoginServer. */
  public void testGetSetCustomLoginServer() {

    // Starting point, custom is null.
    assertNull(
        "Expected no custom login server", loginServerManager.getLoginServerFromURL(CUSTOM_URL));

    // Adding custom server.
    loginServerManager.addCustomLoginServer(CUSTOM_NAME, CUSTOM_URL);
    assertCustom(loginServerManager.getSelectedLoginServer());

    // Adding a second custom server.
    loginServerManager.addCustomLoginServer(CUSTOM_NAME_2, CUSTOM_URL_2);
    assertCustom2(loginServerManager.getSelectedLoginServer());
  }
 /** Test for getDefaultLoginServer. */
 public void testGetDefaultLoginServers() {
   final List<LoginServer> servers = loginServerManager.getAllSavedSevers();
   assertEquals("Wrong number of servers", 3, servers.size());
   assertProduction(servers.get(0));
   assertSandbox(servers.get(1));
   assertOther(servers.get(2));
 }
  /** Test for adding more than one custom server. */
  public void testAddMultipleCustomServers() {

    // Starting point, only 3 servers.
    List<LoginServer> servers = loginServerManager.getAllSavedSevers();
    assertEquals("Expected no custom login servers", 3, servers.size());

    // Adding first custom server.
    loginServerManager.addCustomLoginServer(CUSTOM_NAME, CUSTOM_URL);
    servers = loginServerManager.getAllSavedSevers();
    assertEquals("Expected one custom login server", 4, servers.size());

    // Adding second custom server.
    loginServerManager.addCustomLoginServer(CUSTOM_NAME_2, CUSTOM_URL_2);
    servers = loginServerManager.getAllSavedSevers();
    assertEquals("Expected one custom login server", 5, servers.size());
  }
 @Override
 public void tearDown() throws Exception {
   if (loginServerManager != null) {
     loginServerManager.reset();
   }
   if (eq != null) {
     eq.tearDown();
     eq = null;
   }
   super.tearDown();
 }
  /**
   * Test for getSelectedLoginServer/setSelectedLoginServer when there is no custom login server.
   */
  public void testGetSetLoginServerWithoutCustomServer() {

    // Starting point, production selected by default.
    assertProduction(loginServerManager.getSelectedLoginServer());

    // Selecting production.
    loginServerManager.setSelectedLoginServer(new LoginServer("Production", PRODUCTION_URL, false));
    assertProduction(loginServerManager.getSelectedLoginServer());

    // Selecting sandbox.
    loginServerManager.setSelectedLoginServer(new LoginServer("Sandbox", SANDBOX_URL, false));
    assertSandbox(loginServerManager.getSelectedLoginServer());

    // Selecting other.
    loginServerManager.setSelectedLoginServer(new LoginServer("Other", OTHER_URL, false));
    assertOther(loginServerManager.getSelectedLoginServer());
  }
  /** Test for reset. */
  public void testReset() {

    // Starting point, only 3 servers.
    List<LoginServer> servers = loginServerManager.getAllSavedSevers();
    assertEquals("Expected no custom login servers", 3, servers.size());

    // Adding custom server.
    loginServerManager.addCustomLoginServer(CUSTOM_NAME, CUSTOM_URL);
    servers = loginServerManager.getAllSavedSevers();
    assertEquals("Expected one custom login server", 4, servers.size());

    // Selecting sandbox.
    loginServerManager.useSandbox();
    assertSandbox(loginServerManager.getSelectedLoginServer());

    /*
     * Calling reset - selection should go back to production
     * and custom server should be removed from shared prefs.
     */
    loginServerManager.reset();
    servers = loginServerManager.getAllSavedSevers();
    assertEquals("Expected no custom login servers", 3, servers.size());
    assertProduction(loginServerManager.getSelectedLoginServer());
  }