### Question:
SecurityContext implements AutoCloseable { public static SecurityContext set(SecurityContext ctx) { if (currentContext.get() != null) throw new IllegalStateException("Security context already set."); currentContext.set(ctx); return ctx; } protected  SecurityContext(AccessController accessController, IdentityResolver identityResolver, Credentials credentials); static SecurityContext get(); static SecurityContext set(SecurityContext ctx); static boolean isSet(); static SecurityContext clear(); @Override void close(); Credentials getCredentials(); void checkPermission(NamedFunction function); void checkPermission(NamedFunction function, UUID organizationID); UUID getCurrentUserID(); Set<UUID> getAvailableOrganizationID();  }### Answer:
@Test(expected = IllegalStateException.class) public void testSetContextTwice() { try (SecurityContext ignored = SecurityContext.set(context)) { SecurityContext.set(context); } }