/** * Load a {@link ClassPathResource} qualified by the simple name of clazz, * and relative to the package for clazz. * <p>Example: given a clazz 'com.foo.BarTests' and a resourceSuffix of 'context.xml', * this method will return a ClassPathResource representing com/foo/BarTests-context.xml * <p>Intended for use loading context configuration XML files within JUnit tests. */ public static ClassPathResource qualifiedResource(Class<?> clazz, String resourceSuffix) { return new ClassPathResource(String.format("%s-%s", clazz.getSimpleName(), resourceSuffix), clazz); }
private final Set<String> singletonsCurrentlyInCreation = Collections.newSetFromMap(new ConcurrentHashMap<>(16));
本文介绍了一个实用的方法,用于根据类的简单名称和相对包路径加载资源。通过使用此方法,可以轻松地在JUnit单元测试中加载上下文配置XML文件。
1126

被折叠的 条评论
为什么被折叠?



