Spring接口测试
来源:互联网 发布:如何在淘宝搜索vpn 编辑:程序博客网 时间:2024/06/07 20:24
// 方法一:SpringJUnit4测试
@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(locations ={ "../spring/spring_core.xml", "../spring/spring_service.xml", "../spring/spring_qsecurity.xml", "../spring/spring_dao.xml" })public class TestO{ @Test public void test() { System.out.println("---->"+OrganizationManagementService.findOrganizationalUnitsByOid("de03e075-cf87-4029-b5e5-82025ec10415").size()); }}
// 方法二:main测试
public class mytest{ public static void main(String[] args) throws IOException { ApplicationContext ac = new ClassPathXmlApplicationContext("../spring/*"); @SuppressWarnings("unused") IDeviceManagerService vs = (IDeviceManagerService) ac.getBean("deviceManagerService"); }}
// 方法三:(ApplicationContext)main测试
public class TestClass{ private static IUserInfoService userInfoService; private static OrganizationService organizationService; static { ApplicationContext ac = new ClassPathXmlApplicationContext("classpath:spring/*"); userInfoService = (IUserInfoService) ac.getBean("userInfoService"); organizationService = (OrganizationService) ac.getBean("organizationService"); } public static void main(String[] args) { List<PersonInfo> list= ServiceUtil.getOrganizationService().queryPersonInfoByCondition("qs00001", "702c2893-ac39-4dff-8c77-33160f485ff1", "", "孙", "", "1", null); System.out.println(list.size()+"@@@@@@@@@@@@@@@@@"); }}
// 方法四:spring+hibernate+junit4 测试
@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(locations={"classpath:/spring-hibernate.xml","classpath:/spring-mvc.xml","classpath:/spring.xml"})@TransactionConfiguration(transactionManager="transactionManager",defaultRollback=false)@Transactionalpublic class Test{ @Autowired private PersonServiceI personServiceDao; @org.junit.Test public void testSave() { try { System.out.println("----------"+personServiceDao); Person person = new Person(); person.setName("王五"); person.setAge(23); person.setUpdateTime(new SimpleDateFormat("YYYY-MM-dd HH:MM:ss").parse(new SimpleDateFormat("YYYY-MM-dd HH:MM:ss").format(new Date()))); personServiceDao.save(person); List<Object[]> objList = personServiceDao.selectAll(); for (int i = 0; i < objList.size(); i++) { System.out.println("--成功--"+objList.get(i)[2].toString()); } } catch (ParseException e) { e.printStackTrace(); } }}
- Spring接口测试
- Spring+Junit4进行接口测试
- Spring+Junit4进行接口测试
- Spring+Dubbo+TestNG接口测试
- 使用spring RestTemplate进行rest接口测试
- 使用spring RestTemplate进行rest接口测试
- 【接口测试】-总结-关于spring框架的数据库连接配置
- 基于Spring开发的DUBBO服务接口测试
- 测试接口
- 接口测试
- 接口测试
- 接口测试
- 接口测试
- 接口测试
- 接口测试
- 接口测试
- 接口测试
- 接口测试
- 跟着示例学Oozie
- GDI泄漏
- jquery默认校验规则
- RedHat/CentOS系统信息查看命令大全
- 使用Apache Avro
- Spring接口测试
- 总结自己失败的经历
- java笔试题---用*打印漏斗形,信雅达笔试题
- WPF ListBox异步加载图片
- 利用visual c++编译时遇到的问题
- 国家气象局提供的天气预报接口
- Spring MVC 对于返回JSON格式数据的中文乱码 解决方法
- JAVA开发环境的配置
- 查询电脑占用端口的程序