배치작업 JUnit 테스트 케이스 작성

작성이 완료되 배치는 JUnit으로 테스트를 진행할 수 있다. JUnit 테스트 케이스 예제는 다음과 같다.

        /**
         *
         * Sample Db To Db Test
         *
         * @author sysadmin
         *
         */
        @RunWith(SpringRunner.class)
        @SpringBootTest(webEnvironment = WebEnvironment.NONE
                , classes = { BxmCloudBatchApplication.class}
                , properties = {"spring.config.name=bxframeworkBatchForTest"
                        , "logging.level.root=info"
                        })
        @ActiveProfiles({"local"})
        public class SampleDbToDbTest {

            private Logger logger = LoggerFactory.getLogger(this.getClass());

            @Autowired
            private BxmJobLauncherCommandLineRunner runner;

            @Autowired
            private ConfigurableApplicationContext context;

            @BeforeClass
            public static void setup() {
                System.setProperty(BxmcBatchConstants.FW_BATCH_JUNIT_TEST_INIT, "true");
                System.setProperty(Constants.BXMC_BATCH_APPLICATION, "true");
                String jobList = "sample-db-to-db";
                System.setProperty(BxmcBatchConstants.FW_BATCH_JUNIT_JOB_LIST, jobList);
            }

            @Test
            public void testDbToDb() throws Exception
            {
                String jobId = "sample-db-to-db";
                String[] args = new String[] { jobId, "deptNo=10", "execTime=" + System.currentTimeMillis() };

                JobExecution jobExecution = runner.runJob(args);
                logger.info("jobExecution : {}", jobExecution);
            }


            @After
            public void close() throws Exception
            {
                if(context != null)
                {
                    context.registerShutdownHook();
                }
            }
        }
SWLab Bankware Global
  • 전체
  • BXM
  • BXCM
  • BXCP
  • BXI
제품 선택 시 더 정확한 매뉴얼 가이드를 제공해드립니다.

Copyright© Bankwareglobal All Rights Reserved.