Struts2+spring+mybatis+junit Test

Source: Internet
Author: User

Struts2+spring+mybatis+junit Test Blog Category:
    • Htmlunit
Junit Spring Test Mybatis

Java code
  1. Package com.action.kioskmonitor;
  2. /**
  3. * JUnit Group Test Struts2, Spring, Mybatis
  4. */
  5. Import static org.junit.Assert.assertNotNull;
  6. Import java.util.List;
  7. Import Java.util.UUID;
  8. Import Org.apache.log4j.Logger;
  9. Import Org.junit.Before;
  10. Import Org.junit.Test;
  11. Import Org.springframework.context.ApplicationContext;
  12. Import Org.springframework.context.support.ClassPathXmlApplicationContext;
  13. Import org.springframework.dao.DataAccessException;
  14. Import Com.entity.custQuery.SearchRequire;
  15. Import Com.entity.kioskmonitor.Monitor;
  16. Import Com.service.kioskmonitor.MonitorService;
  17. Import Com.util.Page;
  18. Public class Testaccountservice {
  19. Logger Logger = Logger.getlogger ("Testaccountservice");
  20. Monitorservice service=null;
  21. @Before
  22. public void init () {
  23. //Get Spring General configuration file here
  24. ApplicationContext aCtx = new Classpathxmlapplicationcontext (
  25. "Classpath:applicationContext.xml");
  26. //Get the service name injected in spring
  27. Monitorservice service = (monitorservice) aCtx
  28. . Getbean ("Monitorservice");
  29. Assertnotnull (service);
  30. this.service = Service;
  31. }
  32. @Test
  33. public void Testinsertaccount () {
  34. //Add
  35. Searchrequire GCJ = new Searchrequire ();
  36. Page pg =new page ();
  37. Monitor mk=new Monitor ();
  38. Gcj.setmonitor (MK);
  39. PG.SETSRC (GCJ);
  40. String Uuid2 = Uuid.randomuuid (). toString (). Trim (). ReplaceAll ("-", "" ");
  41. PG.GETSRC (). Getmonitor (). settype_id (UUID2);
  42. String uuid1 = Uuid.randomuuid (). toString (). Trim (). ReplaceAll ("-", "" ");
  43. PG.GETSRC (). Getmonitor (). setkiosk_id (UUID1);
  44. System.out.println (UUID1);
  45. System.out.println (UUID2);
  46. //////////////////////////////////////////////////////////////////////////  
  47. //////  
  48. //////kiosk Table Operation
  49. //////  
  50. ///////////////////////////////////////////////////////////////////////////      
  51. //Get the total number of records
  52. Service.getcountbymonitor (PG);
  53. Paging Query
  54. List<monitor> dd= Service.getmonitorbyfenye (PG);
  55. //Add kiosk
  56. int Fdf=service.addmonitor (PG.GETSRC (). Getmonitor ());
  57. //Modify Kiosk
  58. int umonitor= service.updatemonitor (PG.GETSRC (). Getmonitor ());
  59. //Delete kiosk
  60. //int aa= service.delmonitor (PG.GETSRC (). Getmonitor ());
  61. //////////////////////////////////////////////////////////////////////////  
  62. //////  
  63. //////kiosk_type Table Operation
  64. //////  
  65. ///////////////////////////////////////////////////////////////////////////     
  66. //Add Kiosk_type
  67. int Fdas=service.addmonitort (PG.GETSRC (). Getmonitor ());
  68. //Delete Kiosk_type
  69. //int Delky=service.delmonitort (PG.GETSRC (). Getmonitor ());
  70. //Modify Kiosk_type
  71. int uty= service.updatemonitort (PG.GETSRC (). Getmonitor ());
  72. //////////////////////////////////////////////////////////////////////////  
  73. //////  
  74. //////kiosk_type_detail Table Operation
  75. //////  
  76. ///////////////////////////////////////////////////////////////////////////     
  77. //Delete Kiosk_type_detail
  78. //int KTYD=SERVICE.DELMONITORTD (PG.GETSRC (). Getmonitor ());
  79. //Add Kiosk_type_detail
  80. int Ktyda=service.addmonitortd (PG.GETSRC (). Getmonitor ());
  81. //Modify Kiosk_type_detail
  82. int Ktyu=service.updatemonitortd (PG.GETSRC (). Getmonitor ());
  83. }
  84. }

Struts2+spring+mybatis+junit Test

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.