Search in sources :

Example 1 with MultipleCryptoFailedException

use of org.jivesoftware.smackx.omemo.exceptions.MultipleCryptoFailedException in project Smack by igniterealtime.

the class OmemoExceptionsTest method multipleCryptoFailedExceptionTest.

@Test
public void multipleCryptoFailedExceptionTest() {
    CryptoFailedException e1 = new CryptoFailedException("Fail");
    CryptoFailedException e2 = new CryptoFailedException("EpicFail");
    ArrayList<CryptoFailedException> l = new ArrayList<>();
    l.add(e1);
    l.add(e2);
    MultipleCryptoFailedException m = MultipleCryptoFailedException.from(l);
    assertEquals(2, m.getCryptoFailedExceptions().size());
    assertTrue(m.getCryptoFailedExceptions().contains(e1));
    assertTrue(m.getCryptoFailedExceptions().contains(e2));
    ArrayList<CryptoFailedException> el = new ArrayList<>();
    try {
        MultipleCryptoFailedException m2 = MultipleCryptoFailedException.from(el);
        fail("MultipleCryptoFailedException must not allow empty list, but returned: " + m2);
    } catch (IllegalArgumentException e) {
    // Expected
    }
}
Also used : MultipleCryptoFailedException(org.jivesoftware.smackx.omemo.exceptions.MultipleCryptoFailedException) CryptoFailedException(org.jivesoftware.smackx.omemo.exceptions.CryptoFailedException) ArrayList(java.util.ArrayList) MultipleCryptoFailedException(org.jivesoftware.smackx.omemo.exceptions.MultipleCryptoFailedException) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 CryptoFailedException (org.jivesoftware.smackx.omemo.exceptions.CryptoFailedException)1 MultipleCryptoFailedException (org.jivesoftware.smackx.omemo.exceptions.MultipleCryptoFailedException)1 Test (org.junit.Test)1