zoukankan      html  css  js  c++  java
  • Struts2+Spring+Mybatis+Junit 测试

    Java代码  收藏代码
    1. package com.action.kioskmonitor;  
    2. /** 
    3.  * Junit群体测试Struts2 、spring、Mybatis 
    4.  */  
    5. import static org.junit.Assert.assertNotNull;  
    6.   
    7. import java.util.List;  
    8. import java.util.UUID;  
    9.   
    10. import org.apache.log4j.Logger;  
    11. import org.junit.Before;  
    12. import org.junit.Test;  
    13. import org.springframework.context.ApplicationContext;  
    14. import org.springframework.context.support.ClassPathXmlApplicationContext;  
    15. import org.springframework.dao.DataAccessException;  
    16.   
    17. import com.entity.custQuery.SearchRequire;  
    18. import com.entity.kioskmonitor.Monitor;  
    19. import com.service.kioskmonitor.MonitorService;  
    20. import com.util.Page;  
    21.   
    22. public class TestAccountService  {  
    23.   
    24.  Logger logger = Logger.getLogger("TestAccountService");  
    25.   
    26.  MonitorService service=null;  
    27.  @Before  
    28.  public void init() {  
    29.      //这里获取spring总配置文件  
    30.       ApplicationContext aCtx = new ClassPathXmlApplicationContext  (  
    31.         "classpath:applicationContext.xml");  
    32.       //获取在spring注入的service名字  
    33.       MonitorService service = (MonitorService) aCtx  
    34.         .getBean("monitorService");  
    35.       assertNotNull(service);  
    36.       this.service = service;  
    37.      }  
    38.        
    39.      @Test  
    40.      public void testInsertAccount() {  
    41.          //添加  
    42.          SearchRequire gcj = new SearchRequire();  
    43.             Page pg =new Page();  
    44.             Monitor mk=new Monitor();  
    45.             gcj.setMonitor(mk);  
    46.             pg.setSrc(gcj);  
    47.             String uuid2 =  UUID.randomUUID().toString().trim().replaceAll("-", "");  
    48.             pg.getSrc().getMonitor().setType_id(uuid2);  
    49.             String uuid1 =  UUID.randomUUID().toString().trim().replaceAll("-", "");  
    50.             pg.getSrc().getMonitor().setKiosk_id(uuid1);  
    51.             System.out.println(uuid1);  
    52.             System.out.println(uuid2);  
    53.         //////////////////////////////////////////////////////////////////////////  
    54.         //////  
    55.         //////kiosk表操作  
    56.         //////  
    57.         ///////////////////////////////////////////////////////////////////////////      
    58.         //获取总记录数  
    59. //      service.getCountByMonitor(pg);  
    60. //      // 分页查询  
    61. //       List<Monitor> dd= service.getMonitorByFenYe(pg);  
    62.         //添加kiosk  
    63.           int fdf=service.addMonitor(pg.getSrc().getMonitor());  
    64.         //修改kiosk  
    65.         int uMonitor= service.updateMonitor(pg.getSrc().getMonitor());  
    66.         //删除Kiosk  
    67.          // int aa= service.delMonitor(pg.getSrc().getMonitor());  
    68.         //////////////////////////////////////////////////////////////////////////  
    69.         //////  
    70.         //////kiosk_type表操作  
    71.         //////  
    72.         ///////////////////////////////////////////////////////////////////////////     
    73.         //添加kiosk_type  
    74.           int fdas=service.addMonitorT(pg.getSrc().getMonitor());  
    75.         //删除kiosk_type  
    76.         //  int delky=service.delMonitorT(pg.getSrc().getMonitor());  
    77.         //修改kiosk_type  
    78.           int  uty= service.updateMonitorT(pg.getSrc().getMonitor());  
    79.         //////////////////////////////////////////////////////////////////////////  
    80.         //////  
    81.         //////kiosk_type_detail表操作  
    82.         //////  
    83.         ///////////////////////////////////////////////////////////////////////////     
    84.         //删除kiosk_type_detail  
    85.           //int ktyd=service.delMonitorTD(pg.getSrc().getMonitor());  
    86.         //添加kiosk_type_detail  
    87.           int ktyda=service.addMonitorTD(pg.getSrc().getMonitor());  
    88.         //修改kiosk_type_detail  
    89.           int ktyu=service.updateMonitorTD(pg.getSrc().getMonitor());  
    90.      }  
    91. }  
  • 相关阅读:
    Mysql 常用函数(15)- upper 函数
    Mysql 常用函数(14)- lower 函数
    Mysql 常用函数(13)- right 函数
    Mysql 常用函数(12)- left 函数
    Mysql 常用函数(11)- trim 函数
    Mysql 常用函数(10)- strcmp 函数
    Mysql 常用函数(9)- reverse 函数
    Mysql 常用函数(8)- concat 函数
    Mysql 常用函数(7)- length 函数
    影评1|发个以前写的影评《情书》
  • 原文地址:https://www.cnblogs.com/huhuan123/p/5994138.html
Copyright © 2011-2022 走看看