Skip to content

Commit

Permalink
Add basic test for setAuthentication
Browse files Browse the repository at this point in the history
Signed-off-by: jmehrens <[email protected]>
  • Loading branch information
jmehrens committed Nov 2, 2023
1 parent cf7beb6 commit cb1bcef
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3725,6 +3725,33 @@ private int nextCapacity(int capacity) {
}
}

@Test
public void testAuthentication() {
MailHandler instance = new MailHandler(createInitProperties(""));
InternalErrorManager em = new InternalErrorManager();
instance.setErrorManager(em);

instance.setAuthentication((String) null);
assertNull(instance.getAuthenticator());

instance.setAuthentication(EmptyAuthenticator.class.getName());
assertEquals(EmptyAuthenticator.class,
instance.getAuthenticator().getClass());

instance.setAuthentication("");
assertTrue(instance.getAuthenticator().getClass().getName()
.contains("DefaultAuthenticator"));

instance.setAuthentication("foo");
assertTrue(instance.getAuthenticator().getClass().getName()
.contains("DefaultAuthenticator"));

for (Exception t : em.exceptions) {
dump(t);
}
assertTrue(em.exceptions.isEmpty());
}

@Test
public void testAuthenticator_Authenticator_Arg() {
Authenticator auth = new EmptyAuthenticator();
Expand Down

0 comments on commit cb1bcef

Please sign in to comment.