}
private static <T> T getSpringBeanByType(final ApplicationContext ctx, final Class<T> type) {
Map<String, T> beans = ctx.getBeansOfType(type);
if (beans == null || beans.size() == 0) {
throw new JTesterException("Unable to get Spring bean by type. No Spring bean found for type "
+ type.getSimpleName());
}
if (beans.size() > 1) {
throw new JTesterException(
"Unable to get Spring bean by type. More than one possible Spring bean for type "
+ type.getSimpleName() + ". Possible beans; " + beans);
}
return beans.values().iterator().next();
}