### Question:
ExtensionLoader { public static <T extends Role> T getExtensionByRole(Class<T> clazz, RpcRole role) { try { List<T> extensions = getExtensionList(clazz); for (T t : extensions) { if (t != null && t.getRole() == null) { throw new RpcException("Class " + t.getClass().getName() + " rpcRole is null, please check getRole function."); } if (t != null && (t.getRole().equals(role) || t.getRole().equals(RpcRole.MULTIROLE))) { return t; } } return null; } catch (Throwable e) { logger.error("Get extensions of {} failed.", clazz.getName(), e); throw new RpcException(e); } } private  ExtensionLoader(); static T getExtension(Class<T> clazz); static T getExtensionWithName(Class<T> clazz, String name); static List<T> getExtensionListByRole(Class<T> clazz, RpcRole role); static T getExtensionByRole(Class<T> clazz, RpcRole role); static List<T> getExtensionList(Class<T> clazz); static T getNewExtension(Class<T> clazz); static List<T> newExtensionList(Class<T> clazz);  }### Answer:
@Test public void testGetExtensionByRole() { Extension extension = ExtensionLoader.getExtensionByRole(Extension.class, RpcRole.INVOKER); Assert.assertTrue(extension instanceof SecondExtension); }