package com.business.service;
import org.junit.Test;
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
import com.business.service.BrokerManagerService;
public class DeployManagerActionTestCase extends AbstractDependencyInjectionSpringContextTests
{
private BrokerManagerService brokerManagerService;
public BrokerManagerService getBrokerManagerService()
{
return brokerManagerService;
}
public void setBrokerManagerService(BrokerManagerService brokerManagerService)
{
this.brokerManagerService = brokerManagerService;
}
@Override
protected String[] getConfigLocations()
{
return new String[]{"file:F:\\wmba\\src\\applicationContext.xml","file:F:\\wmba\\src\\applicationContext-wmba.xml"};
}
public void testDeployManagerMethod(){
System.out.println("--->"+brokerManagerService);
}
}
1.上面文件路径可以为其他写法,不过我对路径不熟,所以把路径写死了!!!
2.brokerManagerService属性在Spring文件中有配置,可以注入进来.....
3.AbstractDependencyInjectionSpringContextTests继承了这个类,那么就不能给测试方法加@Test注解了,只能给方法名称前加上test......
----------所使用的架包为:spring-test.jar、junit-4.1.jar