我有 spring 3.1 应用程序。我有 spring-instrument java 代理,我有可配置的类:
@Configurable
public class WeavingClass {
@Resource
@Getter
private ApplicationContext ac;
public WeavingClass()
{
}
}
并进行单元测试:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes={WebBackendContextConfig.class})
@Slf4j
public class TestWeavingInjection extends TestCase {
@Test
public void isInjectedTest()
{
WeavingClass wc = new WeavingClass();
assertNotNull(wc.getAc());
}
}
并且有:
@Configuration
@PropertySource(value={"classpath:META-INF/conf/liteicms-backend.properties"})
@ComponentScan(value={"ru.icb.liteicms.backend.service", "ru.icb.liteicms.domain", "ru.icb.liteicms.backend.domain.contentpage.wrappers"})
@EnableSpringConfigured
@EnableLoadTimeWeaving
@EnableAspectJAutoProxy
public class WebBackendContextConfig {
}
我使用 -javaagent:org.springframework.instrument-3.1.1.RELEASE.jar 运行我的测试我的测试工作没有错误。
但如果我添加这个:
private HashMap<Class<?>, Class<?>> builderMap = new HashMap<Class<?>, Class<?>>()
{
private static final long serialVersionUID = 1L;
{
put(String.class, WeavingClass.class);
}
};
我的测试坏了。