diff --git a/.classpath b/.classpath index 73f9ce3..653dfd7 100644 --- a/.classpath +++ b/.classpath @@ -9,13 +9,21 @@ + - + + + + + + + + @@ -26,7 +34,23 @@ - + + + + + + + + + + + + + + + + + diff --git a/.github/ISSUE_TEMPLATE/amendment_request.yml b/.github/ISSUE_TEMPLATE/amendment_request.yml deleted file mode 100644 index de9c4ec..0000000 --- a/.github/ISSUE_TEMPLATE/amendment_request.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: 개발가이드 수정 요청 Requesting changes to the development guide -description: 개발가이드 수정 요청하는 템플릿입니다. Template for requesting changes to the dev guide. -title: "[Guide]: " -labels: ["guide"] -assignees: - - yongfire38 -body: - - type: markdown - attributes: - value: | - 시간을 내어 개발가이드 수정 요청을 작성해 주셔서 감사합니다. Thank you for taking the time to fill out a DevGuide correction request. (공유하고 싶은 기술문서나 노하우는 github wiki에 남겨 주세요. If you have any documentation or know-how you'd like to share, please leave it on our github wiki.) - - type: input - id: url - attributes: - label: 개발가이드 URL Dev Guide URL - description: 수정해야할 개발가이드 URL을 적어 주세요. Please write down the dev guide URL that needs to be modified. - placeholder: Example) https://www.egovframe.go.kr/wiki/doku.php?id=egovframework:rte4.1:fdl:aop:aspectj - validations: - required: true - - type: textarea - id: where-to-amend - attributes: - label: 수정 대상 내용 What to fix - description: 수정해야할 대상 내용을 기입해 주세요. Fill in what you need to fix. - placeholder: 수정해야할 대상은 다음과 같습니다. Here's what you'll need to modify - validations: - required: true - - type: textarea - id: amendment - attributes: - label: 수정 문구 Corrective Wording - description: 어떻게 수정되어야 하는지 적어주세요. Please write down how it should be fixed. - placeholder: 다음과 같이 수정되어야 합니다. It should be modified as follows - validations: - required: true diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 6815026..8a8967d 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -3,7 +3,7 @@ description: 오류 내용을 이슈로 등록하는 템플릿입니다. Templat title: "[Bug]: " labels: ["bug", "triage"] assignees: - - yongfire38 + - rukegithub body: - type: markdown attributes: diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index d26f66a..b1323f1 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -1,9 +1,9 @@ -name: 기능 요구 및 의견 Feature Request -description: 기능 요구나 기타 의견을 이슈로 등록하는 템플릿입니다. Suggest an idea for improving eGovFrame. +name: 기능 요구 Feature Request +description: 기능 요구를 이슈로 등록하는 템플릿입니다. Suggest a new feature for improving eGovFrame. title: "[기능요구(Feature)]: " labels: ["feature"] assignees: - - yongfire38 + - rukegithub body: - type: markdown attributes: diff --git a/.github/ISSUE_TEMPLATE/improvement_plan.yml b/.github/ISSUE_TEMPLATE/improvement_plan.yml new file mode 100644 index 0000000..c0e796b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/improvement_plan.yml @@ -0,0 +1,55 @@ +name: 발전 방안 제안 Improvement Plan +description: 발전 방안을 이슈로 등록하는 템플릿입니다. Suggest a new plan for improving eGovFrame. +title: "[발전 방안 제안(Improvement Plan)]: " +labels: ["Improvement"] +assignees: + - yongfire38 +body: + - type: markdown + attributes: + value: | + 시간을 내어 의견을 작성해 주셔서 감사합니다. Thank you for taking the time to fill out a request. + - type: input + id: idea-name + attributes: + label: 아이디어명 Idea Name + validations: + required: true + - type: textarea + id: idea-summary + attributes: + label: 아이디어 요약 Idea Summary + description: 과제 내용을 300자 이내로 간결하게 요약 및 정의해 주세요 Please summarize and define your content in 300 characters or less + placeholder: 예) 게시판 첨부기능 추가 Example) Adding a bulletin board attachment + validations: + required: true + - type: textarea + id: suggestion-background + attributes: + label: 제안배경 Suggestion Background + description: 아이디어를 제안하게 된 배경 및 필요성을 기술해 주세요. Please describe the background and need for the idea. + placeholder: 아이디어를 제안하게 된 배경은 다음과 같습니다. The background to suggesting the idea is as follows. + validations: + required: true + - type: textarea + id: expectations + attributes: + label: 기대효과 Expectations + description: 아이디어의 실현 가능성과 예상되는 기대효과를 제시하여 주세요. Please describe the expected impact and outcome of the idea. + placeholder: 해당 아이디어의 기대효과는 다음과 같습니다. Here are the expected effects of this idea. + validations: + required: false + - type: textarea + id: free-writing + attributes: + label: 자유기술 Free Writing + description: 추가 기재하고 싶은 항목 및 내용을 자유롭게 기재하여 주세요. Please feel free to add anything else you'd like to include. + validations: + required: false + - type: textarea + id: reference + attributes: + label: 참고문헌 Reference + description: 참고문헌이 있는 경우 작성하여 주세요. If you have references, please include them. + validations: + required: false diff --git a/Docs/context-hierarchy.md b/Docs/context-hierarchy.md index c0b57e9..0a06a45 100644 --- a/Docs/context-hierarchy.md +++ b/Docs/context-hierarchy.md @@ -7,7 +7,7 @@ 아래 처럼 Servlet Context 가 Root Context를 참조한다고 생각하면 되겠다. -![Context Hierarchy](https://docs.spring.io/spring-framework/docs/current/reference/html/images/mvc-context-hierarchy.png) +![Context Hierarchy](https://docs.spring.io/spring-framework/reference/_images/mvc-context-hierarchy.png) ## Root WebApplicationContext diff --git a/README.md b/README.md index 8595bb5..e1cc9c3 100644 --- a/README.md +++ b/README.md @@ -31,17 +31,17 @@ __프로젝트 우클릭 > Run As > Spring Boot App__ 을 통해 구동한다. ### 구동 후 확인 구동 후, 브라우저에서 `http://localhost:포트번호/` 로 확인이 가능하다. -초기 포트번호는 8080이며 `src/main/resources/application.yml` 파일의 port 항목에서 변경 가능하다. +초기 포트번호는 8080이며 `src/main/resources/application.properties` 파일의 `server.port` 항목에서 변경 가능하다. ## 참조 화면 ### 목록 화면 -![4th_new_web4](https://user-images.githubusercontent.com/3771788/229034000-be8e116b-01ec-4a13-ab17-4c8e85956f8a.jpg) +![4th_new_web4](https://github.com/user-attachments/assets/199c6964-1aa1-42bc-a3d2-0234d037057a) ### 게시글 등록 화면 -![4th_new_web5](https://user-images.githubusercontent.com/3771788/229034017-68edf6c3-aeee-441c-bff8-9405626a277c.jpg) +![4th_new_web5](https://github.com/user-attachments/assets/91c1b668-cb59-45ea-8b13-0e3f34ea9078) ## 변경 사항 diff --git a/pom.xml b/pom.xml index 178d3e9..b2fae3f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,44 +1,45 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 - egov + egovframework boot-example jar 1.0.0 - boot-example + egovframework http://www.egovframe.go.kr - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - - + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + org.springframework.boot spring-boot-starter-parent - 2.7.12 + 2.7.18 - 5.3.27 - 4.2.0 + 5.3.37 + 4.3.0 + 4.13.0 - - mvn2s - https://repo1.maven.org/maven2/ - - true - - - true - - - + + mvn2s + https://repo1.maven.org/maven2/ + + true + + + true + + + egovframe https://maven.egovframe.go.kr/maven/ @@ -48,7 +49,7 @@ false - + @@ -106,13 +107,13 @@ org.hsqldb hsqldb - 2.7.2 + 2.7.3 jdk8 org.projectlombok lombok - 1.18.28 + 1.18.34 true @@ -125,6 +126,12 @@ spring-boot-starter-test test + + + org.seleniumhq.selenium + selenium-java + test + @@ -143,5 +150,4 @@ - diff --git a/src/main/java/egovframework/example/sample/service/impl/EgovSampleServiceImpl.java b/src/main/java/egovframework/example/sample/service/impl/EgovSampleServiceImpl.java index 7dd1800..0cf5110 100644 --- a/src/main/java/egovframework/example/sample/service/impl/EgovSampleServiceImpl.java +++ b/src/main/java/egovframework/example/sample/service/impl/EgovSampleServiceImpl.java @@ -1,29 +1,29 @@ package egovframework.example.sample.service.impl; -import egovframework.example.sample.service.EgovSampleService; -import egovframework.example.sample.service.SampleDefaultVO; -import egovframework.example.sample.service.SampleVO; +import java.util.List; + import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; import org.egovframe.rte.fdl.idgnr.EgovIdGnrService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import java.util.List; +import egovframework.example.sample.service.EgovSampleService; +import egovframework.example.sample.service.SampleDefaultVO; +import egovframework.example.sample.service.SampleVO; +import lombok.RequiredArgsConstructor; -@Service("sampleService") +@Service +@RequiredArgsConstructor public class EgovSampleServiceImpl extends EgovAbstractServiceImpl implements EgovSampleService { private static final Logger LOGGER = LoggerFactory.getLogger(EgovSampleServiceImpl.class); /** SampleDAO */ - @Resource(name="sampleMapper") - private SampleMapper sampleDAO; + private final SampleMapper sampleDAO; /** ID Generation */ - @Resource(name = "egovIdGnrService") - private EgovIdGnrService egovIdGnrService; + private final EgovIdGnrService egovIdGnrService; /** * 글을 등록한다. diff --git a/src/main/java/egovframework/example/sample/service/impl/SampleMapper.java b/src/main/java/egovframework/example/sample/service/impl/SampleMapper.java index e404226..f7a88dd 100644 --- a/src/main/java/egovframework/example/sample/service/impl/SampleMapper.java +++ b/src/main/java/egovframework/example/sample/service/impl/SampleMapper.java @@ -36,7 +36,7 @@ * * */ -@Mapper("sampleMapper") +@Mapper public interface SampleMapper { /** diff --git a/src/main/java/egovframework/example/sample/web/EgovSampleController.java b/src/main/java/egovframework/example/sample/web/EgovSampleController.java index 4bf2152..f07517a 100644 --- a/src/main/java/egovframework/example/sample/web/EgovSampleController.java +++ b/src/main/java/egovframework/example/sample/web/EgovSampleController.java @@ -1,7 +1,7 @@ package egovframework.example.sample.web; -import egovframework.example.sample.service.EgovSampleService; -import egovframework.example.sample.service.SampleVO; +import javax.validation.Valid; + import org.egovframe.rte.fdl.property.EgovPropertyService; import org.egovframe.rte.ptl.mvc.tags.ui.pagination.PaginationInfo; import org.springframework.stereotype.Controller; @@ -12,19 +12,19 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; -import javax.annotation.Resource; -import javax.validation.Valid; +import egovframework.example.sample.service.EgovSampleService; +import egovframework.example.sample.service.SampleVO; +import lombok.RequiredArgsConstructor; @Controller +@RequiredArgsConstructor public class EgovSampleController { /** EgovSampleService */ - @Resource(name = "sampleService") - private EgovSampleService sampleService; + private final EgovSampleService sampleService; /** EgovPropertyService */ - @Resource(name = "propertiesService") - protected EgovPropertyService propertiesService; + private final EgovPropertyService propertiesService; @GetMapping("/") public String search(@ModelAttribute SampleVO sampleVO, Model model) throws Exception { diff --git a/src/test/java/egovframework/example/sample/service/impl/EgovSampleServiceImplTestInsertSampleTest.java b/src/test/java/egovframework/example/sample/service/impl/EgovSampleServiceImplTestInsertSampleTest.java new file mode 100644 index 0000000..d1d0e9a --- /dev/null +++ b/src/test/java/egovframework/example/sample/service/impl/EgovSampleServiceImplTestInsertSampleTest.java @@ -0,0 +1,85 @@ +package egovframework.example.sample.service.impl; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.time.LocalDateTime; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import egovframework.example.sample.service.EgovSampleService; +import egovframework.example.sample.service.SampleVO; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +/** + * [게시판][EgovSampleServiceImpl.insertSample] ServiceImpl 단위 테스트 + * + * @author 이백행 + * @since 2024-09-19 + * + */ + +@SpringBootTest + +@RequiredArgsConstructor +@Slf4j +class EgovSampleServiceImplTestInsertSampleTest { + + /** + * + */ + @Autowired + private EgovSampleService egovSampleService; + + @Test + void test() throws Exception { + // given + final SampleVO sampleVO = new SampleVO(); + + final String now = LocalDateTime.now().toString(); +// final String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSS")); + + // 카테고리명 + sampleVO.setName("test 이백행 카테고리명 " + now); + + // 설명 + sampleVO.setDescription("test 이백행 설명 " + now); + + // 사용여부 + sampleVO.setUseYn("Y"); + + // 등록자 + sampleVO.setRegUser("eGov"); + + // when + String id = egovSampleService.insertSample(sampleVO); + + // then + final SampleVO resultSampleVO = egovSampleService.selectSample(sampleVO); + + if (log.isDebugEnabled()) { + log.debug("sampleVO={}", sampleVO); + log.debug("id={}", id); + log.debug("resultSampleVO={}", resultSampleVO); + + log.debug("getId={}, {}", sampleVO.getId(), resultSampleVO.getId()); + log.debug("getName={}, {}", sampleVO.getName(), resultSampleVO.getName()); + log.debug("getDescription={}, {}", sampleVO.getDescription(), resultSampleVO.getDescription()); + log.debug("getUseYn={}, {}", sampleVO.getUseYn(), resultSampleVO.getUseYn()); + log.debug("getRegUser={}, {}", sampleVO.getRegUser(), resultSampleVO.getRegUser()); + } + + asserts(sampleVO, resultSampleVO); + } + + private void asserts(final SampleVO sampleVO, final SampleVO resultSampleVO) { + assertEquals(sampleVO.getId(), resultSampleVO.getId(), "글을 등록한다. getId"); + assertEquals(sampleVO.getName(), resultSampleVO.getName(), "글을 등록한다. 카테고리명"); + assertEquals(sampleVO.getDescription(), resultSampleVO.getDescription(), "글을 등록한다. 설명"); + assertEquals(sampleVO.getUseYn(), resultSampleVO.getUseYn(), "글을 등록한다. 카테사용여부고리명"); + assertEquals(sampleVO.getRegUser(), resultSampleVO.getRegUser(), "글을 등록한다. 등록자"); + } + +} \ No newline at end of file diff --git a/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestInsertSampleTest.java b/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestInsertSampleTest.java new file mode 100644 index 0000000..d847a43 --- /dev/null +++ b/src/test/java/egovframework/example/sample/service/impl/SampleMapperTestInsertSampleTest.java @@ -0,0 +1,91 @@ +package egovframework.example.sample.service.impl; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.time.LocalDateTime; + +import org.egovframe.rte.fdl.idgnr.EgovIdGnrService; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import egovframework.example.sample.service.SampleVO; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +/** + * [게시판][SampleMapper.insertSample] DAO 단위 테스트 + * + * @author 이백행 + * @since 2024-09-19 + * + */ + +@SpringBootTest + +@RequiredArgsConstructor +@Slf4j +class SampleMapperTestInsertSampleTest { + + /** + * + */ + @Autowired + private SampleMapper sampleMapper; + + /** + * + */ + @Autowired + private EgovIdGnrService egovIdGnrService; + + @Test + void test() throws Exception { + // given + final SampleVO sampleVO = new SampleVO(); + sampleVO.setId(egovIdGnrService.getNextStringId()); + + final String now = LocalDateTime.now().toString(); +// final String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSS")); + + // 카테고리명 + sampleVO.setName("test 이백행 카테고리명 " + now); + + // 설명 + sampleVO.setDescription("test 이백행 설명 " + now); + + // 사용여부 + sampleVO.setUseYn("Y"); + + // 등록자 + sampleVO.setRegUser("eGov"); + + // when + sampleMapper.insertSample(sampleVO); + + // then + final SampleVO resultSampleVO = sampleMapper.selectSample(sampleVO); + + if (log.isDebugEnabled()) { + log.debug("sampleVO={}", sampleVO); + log.debug("resultSampleVO={}", resultSampleVO); + + log.debug("getId={}, {}", sampleVO.getId(), resultSampleVO.getId()); + log.debug("getName={}, {}", sampleVO.getName(), resultSampleVO.getName()); + log.debug("getDescription={}, {}", sampleVO.getDescription(), resultSampleVO.getDescription()); + log.debug("getUseYn={}, {}", sampleVO.getUseYn(), resultSampleVO.getUseYn()); + log.debug("getRegUser={}, {}", sampleVO.getRegUser(), resultSampleVO.getRegUser()); + } + + asserts(sampleVO, resultSampleVO); + } + + private void asserts(final SampleVO sampleVO, final SampleVO resultSampleVO) { + assertEquals(sampleVO.getId(), resultSampleVO.getId(), "글을 등록한다. getId"); + assertEquals(sampleVO.getName(), resultSampleVO.getName(), "글을 등록한다. 카테고리명"); + assertEquals(sampleVO.getDescription(), resultSampleVO.getDescription(), "글을 등록한다. 설명"); + assertEquals(sampleVO.getUseYn(), resultSampleVO.getUseYn(), "글을 등록한다. 카테사용여부고리명"); + assertEquals(sampleVO.getRegUser(), resultSampleVO.getRegUser(), "글을 등록한다. 등록자"); + } + +} \ No newline at end of file diff --git a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestAddTest.java b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestAddTest.java new file mode 100644 index 0000000..d9bc5cd --- /dev/null +++ b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestAddTest.java @@ -0,0 +1,116 @@ +package egovframework.example.sample.web; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; + +import java.time.LocalDateTime; +import java.util.List; + +import org.egovframe.rte.psl.dataaccess.util.EgovMap; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.web.servlet.MockMvc; + +import egovframework.example.sample.service.EgovSampleService; +import egovframework.example.sample.service.SampleVO; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +/** + * [게시판][EgovSampleController.add] Controller 단위 테스트 + * + * @author 이백행 + * @since 2024-09-19 + * + */ + +@SpringBootTest +@AutoConfigureMockMvc + +@RequiredArgsConstructor +@Slf4j +class EgovSampleControllerTestAddTest { + + @Autowired + private MockMvc mockMvc; + + /** + * + */ + @Autowired + private EgovSampleService egovSampleService; + + @Test + void test() throws Exception { + // given + final SampleVO sampleVO = new SampleVO(); + + final String now = LocalDateTime.now().toString(); +// final String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSS")); + + // 카테고리명 + sampleVO.setName("test 이백행 카테고리명 " + now); + + // 설명 + sampleVO.setDescription("test 이백행 설명 " + now); + + // 사용여부 + sampleVO.setUseYn("Y"); + + // 등록자 + sampleVO.setRegUser("eGov"); + + // when + mockMvc.perform( + + post("/sample/add") + + .param("name", sampleVO.getName()) + + .param("description", sampleVO.getDescription()) + + .param("useYn", sampleVO.getUseYn()) + + .param("regUser", sampleVO.getRegUser()) + + ).andDo(print()); + + // then + sampleVO.setRecordCountPerPage(10); + sampleVO.setFirstIndex(0); + sampleVO.setSearchCondition("1"); + sampleVO.setSearchKeyword(sampleVO.getName()); + final List resultList = egovSampleService.selectSampleList(sampleVO); + EgovMap result = (EgovMap) resultList.get(0); + final SampleVO resultSampleVO = new SampleVO(); + resultSampleVO.setName((String) result.get("name")); + resultSampleVO.setDescription((String) result.get("description")); + resultSampleVO.setUseYn((String) result.get("useYn")); + resultSampleVO.setRegUser((String) result.get("regUser")); + + if (log.isDebugEnabled()) { + log.debug("sampleVO={}", sampleVO); + log.debug("resultList={}", resultList); + + log.debug("getId={}, {}", sampleVO.getId(), resultSampleVO.getId()); + log.debug("getName={}, {}", sampleVO.getName(), resultSampleVO.getName()); + log.debug("getDescription={}, {}", sampleVO.getDescription(), resultSampleVO.getDescription()); + log.debug("getUseYn={}, {}", sampleVO.getUseYn(), resultSampleVO.getUseYn()); + log.debug("getRegUser={}, {}", sampleVO.getRegUser(), resultSampleVO.getRegUser()); + } + + asserts(sampleVO, resultSampleVO); + } + + private void asserts(final SampleVO sampleVO, final SampleVO resultSampleVO) { +// assertEquals(sampleVO.getId(), resultSampleVO.getId(), "글을 등록한다. getId"); + assertEquals(sampleVO.getName(), resultSampleVO.getName(), "글을 등록한다. 카테고리명"); + assertEquals(sampleVO.getDescription(), resultSampleVO.getDescription(), "글을 등록한다. 설명"); + assertEquals(sampleVO.getUseYn(), resultSampleVO.getUseYn(), "글을 등록한다. 카테사용여부고리명"); + assertEquals(sampleVO.getRegUser(), resultSampleVO.getRegUser(), "글을 등록한다. 등록자"); + } + +} \ No newline at end of file diff --git a/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestSelenium.java b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestSelenium.java new file mode 100644 index 0000000..8553b82 --- /dev/null +++ b/src/test/java/egovframework/example/sample/web/EgovSampleControllerTestSelenium.java @@ -0,0 +1,79 @@ +package egovframework.example.sample.web; + +import static org.junit.jupiter.api.Assertions.fail; + +import java.time.LocalDateTime; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.Alert; +import org.openqa.selenium.By; +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.chrome.ChromeDriver; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +class EgovSampleControllerTestSelenium { + + WebDriver driver; + + @BeforeEach + public void setup() { + driver = new ChromeDriver(); + } + + @Test + void test() { + if (log.isDebugEnabled()) { + log.debug("test"); + } + + driver.get("http://localhost:8080/"); + + JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver; + + sleep(); + javascriptExecutor.executeScript("sampleCreate();"); + + sleep(); + WebElement name = driver.findElement(By.id("name")); + String now = LocalDateTime.now().toString(); + name.sendKeys("test 이백행 카테고리명 " + now); + + sleep(); + WebElement useYn = driver.findElement(By.id("useYn")); + useYn.sendKeys("N"); + + sleep(); + WebElement description = driver.findElement(By.id("description")); + description.sendKeys("test 이백행 설명 " + now); + + sleep(); + WebElement regUser = driver.findElement(By.id("regUser")); + regUser.sendKeys("test 이백행 등록자 " + now); + + sleep(); + javascriptExecutor.executeScript("sampleAdd();"); + + // Switch to the alert + Alert alert = driver.switchTo().alert(); + + // Accept the alert (click "Yes" or "OK") + alert.accept(); + + // or Dismiss the alert (click "No" or "Cancel") + // alert.dismiss(); + } + + private void sleep() { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + fail("InterruptedException: Thread.sleep"); + } + } + +} \ No newline at end of file diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties new file mode 100644 index 0000000..3b59fc5 --- /dev/null +++ b/src/test/resources/application.properties @@ -0,0 +1,9 @@ +server.port=8080 + +# \uc218\ub3d9 Bean\uc774 \uc790\ub3d9 Bean\uc744 \uc624\ubc84\ub77c\uc774\ub529\ud558\uac8c \uc124\uc815 +spring.main.allow-bean-definition-overriding=true + +# open-in-view(\ud639\uc740 Open-Session-In-View(OSIV)) +# true(\uae30\ubcf8\uac12) : \uc0ac\uc6a9\uc790\uc5d0\uac8c \uc751\ub2f5 \ub610\ub294 view\uac00 \ub80c\ub354\ub9c1\ub420 \ub54c\uae4c\uc9c0 \uc601\uc18d\uc131 \ucee8\ud14d\uc2a4\ud2b8 \uc720\uc9c0 +# false : \ud2b8\ub79c\uc81d\uc158\uc774 \uc885\ub8cc\ub420 \ub54c \uc601\uc18d\uc131 \ucee8\ud14d\uc2a4\ud2b8 \uc885\ub8cc +spring.jpa.open-in-view=false