MyBatis331Test.java 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * The MIT License (MIT)
  3. *
  4. * Copyright (c) 2014-2016 abel533@gmail.com
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * THE SOFTWARE.
  23. */
  24. package tk.mybatis.springboot.mapper;
  25. import org.junit.Assert;
  26. import org.junit.Test;
  27. import org.junit.runner.RunWith;
  28. import org.slf4j.Logger;
  29. import org.slf4j.LoggerFactory;
  30. import org.springframework.beans.factory.annotation.Autowired;
  31. import org.springframework.boot.test.context.SpringBootTest;
  32. import org.springframework.test.annotation.Rollback;
  33. import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  34. import org.springframework.test.context.web.WebAppConfiguration;
  35. import org.springframework.transaction.annotation.Transactional;
  36. import tk.mybatis.springboot.Application;
  37. import tk.mybatis.springboot.model.City2;
  38. import java.util.ArrayList;
  39. import java.util.List;
  40. /**
  41. * @author liuzh
  42. * @since 2016-03-06 17:42
  43. */
  44. /*@RunWith(SpringJUnit4ClassRunner.class)
  45. @WebAppConfiguration
  46. @Transactional
  47. @SpringBootTest(classes = Application.class)*/
  48. public class MyBatis331Test {
  49. private Logger logger = LoggerFactory.getLogger(getClass());
  50. /* @Autowired
  51. private MyBatis331Mapper mapper;
  52. @Test
  53. @Rollback
  54. public void testInsertList() {
  55. List<City2> city2List = new ArrayList<City2>();
  56. city2List.add(new City2("石家庄", "河北"));
  57. city2List.add(new City2("邯郸", "河北"));
  58. city2List.add(new City2("秦皇岛", "河北"));
  59. Assert.assertEquals(3, mapper.insertCities(city2List));
  60. for (City2 c2 : city2List) {
  61. logger.info(c2.toString());
  62. Assert.assertNotNull(c2.getId());
  63. }
  64. }
  65. @Test
  66. public void testSelectById() {
  67. City2 city2 = mapper.selectByCityId(1);
  68. logger.info(city2.toString());
  69. Assert.assertNotNull(city2);
  70. Assert.assertNotNull(city2.getCityName());
  71. Assert.assertNotNull(city2.getCityState());
  72. }
  73. @Test
  74. public void testSelectAll() {
  75. List<City2> city2List = mapper.selectAll();
  76. for (City2 c2 : city2List) {
  77. logger.info(c2.toString());
  78. Assert.assertNotNull(c2);
  79. Assert.assertNotNull(c2.getCityName());
  80. Assert.assertNotNull(c2.getCityState());
  81. }
  82. }*/
  83. }