예제 #1
0
 public void testConnect() {
   try {
     store.addConnectionListener(this);
     store.connect();
     assertNotNull(event);
     assertEquals(event.getType(), ConnectionEvent.OPENED);
   } catch (MessagingException e) {
     fail(e.getMessage());
   }
 }
예제 #2
0
  public Store getStore(boolean useOldStores) throws MailException {
    Store store = null;

    try {
      String storeKey = _incomingHostName.concat(_outgoingHostName).concat(_login);

      if (useOldStores) {
        store = _allStores.get(storeKey);

        if ((store != null) && !store.isConnected()) {
          store.close();

          store = null;
        }
      }

      if (store == null) {
        Session session = getSession();

        if (_incomingSecure) {
          store = session.getStore("imaps");
        } else {
          store = session.getStore("imap");
        }

        store.addConnectionListener(new ConnectionListener(storeKey));
        store.connect(_incomingHostName, _incomingPort, _login, _password);

        if (useOldStores) {
          _allStores.put(storeKey, store);
        }
      }

      return store;
    } catch (MessagingException me) {
      throw new MailException(MailException.ACCOUNT_INCOMING_CONNECTION_FAILED, me);
    }
  }