Advertisement
Guest User

Untitled

a guest
Sep 7th, 2017
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. = junit
  2. [2017-07-18 19:01]
  3.  
  4. * spring本体
  5. ** @RunWith(SpringRunner.class)
  6. ** @ContextConfiguration
  7. nested @Configuration classes within your test
  8. ** @WebAppConfiguration
  9. WebApplicationContext
  10. file:src/main/webapp
  11.  
  12. ** @TestExecutionListeners
  13. ** @TestPropertySource
  14. ** @ActiveProfiles("unittest")
  15. * springboot
  16. Spring Boot application is just a Spring ApplicationContext
  17. ** @SpringBootTest
  18. @ContextConfiguration の代わり
  19. SpringApplication のテスト用
  20. ** Spring Boot’s @*Test annotations will search for your primary configuration automatically
  21. テストクラスのパッケージ配下の @SpringBootApplication, @SpringBootConfiguration を探す
  22. ** nested @TestConfiguration class
  23. テスト固有設定追加用
  24. ** @TestComponent @TestConfiguration annotation
  25. src/test/java に置く
  26. テスト用に除外する場合に使用する
  27. ** @WebMvcTest
  28. spring mvc controller テスト用
  29. ** stdout キャプチャ
  30. @Rule
  31. public OutputCapture capture = newOutputCapture();
  32. * bootなし dbunit spock
  33. @DbUnitConfiguration(dataSetLoader=XlsDataSetLoader.class)
  34. @ContextConfiguration(classes = TestWebApplication.class)
  35. @TestExecutionListeners([ DependencyInjectionTestExecutionListener.class,
  36. DirtiesContextTestExecutionListener.class,
  37. TransactionalTestExecutionListener.class,
  38. DbUnitTestExecutionListener.class ])
  39.  
  40. class KokyakuInfoRegistryInitInsertInputTest001 extends AbstractDBExportBaseSpec{
  41. @ExpectedDatabase(value = "KokyakuInfoRegistryTest001_expected.xlsx", table = "local.t_kokyaku", columnFilters=[MyFilter.class], assertionMode=DatabaseAssertionMode.NON_STRICT,
  42. query = "select * from local.t_kokyaku where kokyaku_no = (select max(kokyaku_no) from local.t_kokyaku)")
  43. okyaku where kokyaku_no = (select max(kokyaku_no) from local.t_kokyaku)")
  44. @Unroll("case001_001顧客情報新規入力")
  45. def "顧客情報新規入力を行う"() {
  46. * boot transaction dbunit mockuser
  47. @RunWith(SpringRunner.class)
  48. // ここからだとテスト環境DBをアクセスしてしまうのでローカルに設定
  49. @SpringBootTest(properties = { "spring.datasource.url=jdbc:postgresql://localhost/postgres",
  50. "spring.datasource.password=postgres" })
  51. // 以下だけでは設定不足のため上記 SpringBootTestをつかう
  52. // @ContextConfiguration(classes = {TestWebApplication.class, ShitenUserSearchServiceTest.Config.class})
  53. // @SpringBootApplication(scanBasePackages = { "jp.co.nii", "jp.co.livemax" })
  54. @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class,
  55. TransactionalTestExecutionListener.class, DbUnitTestExecutionListener.class,
  56. WithSecurityContextTestExecutionListener.class })
  57. @DbUnitConfiguration(dataSetLoader = XlsDataSetLoader.class)
  58. @Transactional
  59. @Rollback(true)
  60.  
  61. @Test
  62. @WithMockCustomUser(userId = "1")
  63. // @WithUserDetails(value = "sakuma", userDetailsServiceBeanName = "kikanUserDetailsService")
  64. // @Sql("ShitenUserSearchServiceTest.sql")
  65. @DatabaseSetup(value = "ShitenUserSearchServiceTest.xlsx", type = DatabaseOperation.REFRESH)
  66.  
  67. * bootなし inner config
  68. @Configuration
  69. @ComponentScan(basePackages = { "jp.co.nii.fw", "jp.co.livemax.common" })
  70. @PropertySource("classpath:application.properties")
  71. public static class Config {
  72. @Bean
  73. public ShitenUserSearchService shitenUserSearchService() {
  74. return new ShitenUserSearchService();
  75. }
  76.  
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement