Search in sources :

Example 1 with StoreConfig

use of com.fsck.k9.mail.store.StoreConfig in project k-9 by k9mail.

the class WebDavStoreTest method getPersonalNamespaces_shouldProvideListOfAllFoldersSentFromResponses.

@Test
public void getPersonalNamespaces_shouldProvideListOfAllFoldersSentFromResponses() throws Exception {
    StoreConfig storeConfig = createStoreConfig("webdav://user:password@example.org:80");
    WebDavStore webDavStore = new WebDavStore(storeConfig, mockHttpClientFactory);
    configureHttpResponses(UNAUTHORIZED_401_RESPONSE, OK_200_RESPONSE, createOkPropfindResponse(), createOkSearchResponse());
    List<? extends Folder> folders = webDavStore.getPersonalNamespaces(true);
    List<HttpGeneric> requests = requestCaptor.getAllValues();
    assertEquals(3, folders.size());
}
Also used : StoreConfig(com.fsck.k9.mail.store.StoreConfig) Test(org.junit.Test)

Example 2 with StoreConfig

use of com.fsck.k9.mail.store.StoreConfig in project k-9 by k9mail.

the class SmtpTransportTest method SmtpTransport_withValidTransportUri.

@Test
public void SmtpTransport_withValidTransportUri() throws Exception {
    StoreConfig storeConfig = createStoreConfigWithTransportUri("smtp://user:password:CRAM_MD5@server:123456");
    new SmtpTransport(storeConfig, socketFactory, oAuth2TokenProvider);
}
Also used : StoreConfig(com.fsck.k9.mail.store.StoreConfig) XOAuth2ChallengeParserTest(com.fsck.k9.mail.XOAuth2ChallengeParserTest) Test(org.junit.Test)

Example 3 with StoreConfig

use of com.fsck.k9.mail.store.StoreConfig in project k-9 by k9mail.

the class RemoteStore method getInstance.

/**
     * Get an instance of a remote mail store.
     */
public static synchronized Store getInstance(Context context, StoreConfig storeConfig) throws MessagingException {
    String uri = storeConfig.getStoreUri();
    if (uri.startsWith("local")) {
        throw new RuntimeException("Asked to get non-local Store object but given LocalStore URI");
    }
    Store store = sStores.get(uri);
    if (store == null) {
        if (uri.startsWith("imap")) {
            OAuth2TokenProvider oAuth2TokenProvider = null;
            store = new ImapStore(storeConfig, new DefaultTrustedSocketFactory(context), (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE), oAuth2TokenProvider);
        } else if (uri.startsWith("pop3")) {
            store = new Pop3Store(storeConfig, new DefaultTrustedSocketFactory(context));
        } else if (uri.startsWith("webdav")) {
            store = new WebDavStore(storeConfig, new WebDavHttpClient.WebDavHttpClientFactory());
        }
        if (store != null) {
            sStores.put(uri, store);
        }
    }
    if (store == null) {
        throw new MessagingException("Unable to locate an applicable Store for " + uri);
    }
    return store;
}
Also used : Pop3Store(com.fsck.k9.mail.store.pop3.Pop3Store) DefaultTrustedSocketFactory(com.fsck.k9.mail.ssl.DefaultTrustedSocketFactory) MessagingException(com.fsck.k9.mail.MessagingException) OAuth2TokenProvider(com.fsck.k9.mail.oauth.OAuth2TokenProvider) ConnectivityManager(android.net.ConnectivityManager) Pop3Store(com.fsck.k9.mail.store.pop3.Pop3Store) Store(com.fsck.k9.mail.Store) WebDavStore(com.fsck.k9.mail.store.webdav.WebDavStore) ImapStore(com.fsck.k9.mail.store.imap.ImapStore) ImapStore(com.fsck.k9.mail.store.imap.ImapStore) WebDavStore(com.fsck.k9.mail.store.webdav.WebDavStore)

Example 4 with StoreConfig

use of com.fsck.k9.mail.store.StoreConfig in project k-9 by k9mail.

the class ImapPusherTest method getRefreshInterval.

@Test
public void getRefreshInterval() throws Exception {
    StoreConfig storeConfig = mock(StoreConfig.class);
    when(storeConfig.getIdleRefreshMinutes()).thenReturn(23);
    when(imapStore.getStoreConfig()).thenReturn(storeConfig);
    int result = imapPusher.getRefreshInterval();
    assertEquals(23 * 60 * 1000, result);
}
Also used : StoreConfig(com.fsck.k9.mail.store.StoreConfig) Test(org.junit.Test)

Example 5 with StoreConfig

use of com.fsck.k9.mail.store.StoreConfig in project k-9 by k9mail.

the class SmtpTransportTest method createStoreConfigWithTransportUri.

private StoreConfig createStoreConfigWithTransportUri(String value) {
    StoreConfig storeConfig = mock(StoreConfig.class);
    when(storeConfig.getTransportUri()).thenReturn(value);
    return storeConfig;
}
Also used : StoreConfig(com.fsck.k9.mail.store.StoreConfig)

Aggregations

StoreConfig (com.fsck.k9.mail.store.StoreConfig)11 Test (org.junit.Test)8 ConnectivityManager (android.net.ConnectivityManager)2 XOAuth2ChallengeParserTest (com.fsck.k9.mail.XOAuth2ChallengeParserTest)2 OAuth2TokenProvider (com.fsck.k9.mail.oauth.OAuth2TokenProvider)2 MessagingException (com.fsck.k9.mail.MessagingException)1 Store (com.fsck.k9.mail.Store)1 DefaultTrustedSocketFactory (com.fsck.k9.mail.ssl.DefaultTrustedSocketFactory)1 TrustedSocketFactory (com.fsck.k9.mail.ssl.TrustedSocketFactory)1 ImapStore (com.fsck.k9.mail.store.imap.ImapStore)1 Pop3Store (com.fsck.k9.mail.store.pop3.Pop3Store)1 WebDavStore (com.fsck.k9.mail.store.webdav.WebDavStore)1 Before (org.junit.Before)1