├── .github ├── PULL_REQUEST_TEMPLATE.md └── ISSUE_TEMPLATE │ ├── 3-backport-issue.md │ ├── 2-reflect-issue.md │ └── 1-new-issue.md ├── parts ├── base │ └── src │ │ └── main │ │ ├── java │ │ └── xxxxxx │ │ │ └── yyyyyy │ │ │ └── zzzzzz │ │ │ ├── domain │ │ │ ├── model │ │ │ │ └── .gitkeep │ │ │ ├── service │ │ │ │ └── .gitkeep │ │ │ └── repository │ │ │ │ └── .gitkeep │ │ │ └── app │ │ │ └── welcome │ │ │ └── HelloController.java │ │ ├── resources │ │ ├── ValidationMessages.properties │ │ ├── commons-logging.properties │ │ ├── i18n │ │ │ └── application-messages.properties │ │ └── logback.xml │ │ └── webapp │ │ └── resources │ │ └── app │ │ └── css │ │ └── styles.css ├── UseORM │ └── projectName-env │ │ └── src │ │ └── main │ │ └── resources │ │ ├── database │ │ ├── H2-schema.sql │ │ └── H2-dataload.sql │ │ └── META-INF │ │ └── spring │ │ └── projectName-infra.properties ├── JSP │ └── projectName-web │ │ └── src │ │ └── main │ │ └── webapp │ │ └── WEB-INF │ │ └── views │ │ ├── layout │ │ └── footer.jsp │ │ ├── common │ │ ├── include.jsp │ │ └── error │ │ │ ├── unhandledSystemError.html │ │ │ ├── systemError.jsp │ │ │ ├── accessDeniedError.jsp │ │ │ ├── invalidCsrfTokenError.jsp │ │ │ ├── missingCsrfTokenError.jsp │ │ │ ├── transactionTokenError.jsp │ │ │ ├── dataAccessError.jsp │ │ │ ├── resourceNotFoundError.jsp │ │ │ └── businessError.jsp │ │ └── welcome │ │ └── home.jsp ├── JavaConfig-NoORM │ └── projectName-domain │ │ └── src │ │ └── main │ │ └── java │ │ └── xxxxxx │ │ └── yyyyyy │ │ └── zzzzzz │ │ └── config │ │ └── app │ │ ├── ProjectNameInfraConfig.java │ │ ├── ProjectNameCodeListConfig.java │ │ └── ProjectNameDomainConfig.java ├── XMLConfig-NoORM │ └── projectName-domain │ │ └── src │ │ └── main │ │ └── resources │ │ └── META-INF │ │ └── spring │ │ ├── projectName-infra.xml │ │ ├── projectName-codelist.xml │ │ └── projectName-domain.xml ├── Thymeleaf │ └── projectName-web │ │ └── src │ │ └── main │ │ ├── webapp │ │ └── WEB-INF │ │ │ └── views │ │ │ ├── welcome │ │ │ └── home.html │ │ │ └── common │ │ │ └── error │ │ │ ├── unhandledSystemError.html │ │ │ ├── systemError.html │ │ │ ├── accessDeniedError.html │ │ │ ├── invalidCsrfTokenError.html │ │ │ ├── missingCsrfTokenError.html │ │ │ ├── transactionTokenError.html │ │ │ ├── dataAccessError.html │ │ │ ├── businessError.html │ │ │ └── resourceNotFoundError.html │ │ └── java │ │ └── xxxxxx │ │ └── yyyyyy │ │ └── zzzzzz │ │ └── app │ │ └── common │ │ └── error │ │ └── CommonErrorController.java ├── XMLConfig-MyBatis3 │ └── projectName-domain │ │ └── src │ │ └── main │ │ └── resources │ │ └── META-INF │ │ ├── spring │ │ └── projectName-infra.xml │ │ └── mybatis │ │ └── mybatis-config.xml ├── JavaConfig-MyBatis3 │ └── projectName-domain │ │ └── src │ │ └── main │ │ └── java │ │ └── xxxxxx │ │ └── yyyyyy │ │ └── zzzzzz │ │ └── config │ │ └── app │ │ ├── ProjectNameInfraConfig.java │ │ └── mybatis │ │ └── MybatisConfig.java ├── XMLConfig │ ├── projectName-domain │ │ └── src │ │ │ └── main │ │ │ └── resources │ │ │ └── META-INF │ │ │ └── spring │ │ │ ├── projectName-codelist.xml │ │ │ └── projectName-domain.xml │ ├── projectName-env │ │ └── src │ │ │ └── main │ │ │ └── resources │ │ │ └── META-INF │ │ │ └── spring │ │ │ └── projectName-env.xml │ └── projectName-web │ │ └── src │ │ └── main │ │ └── resources │ │ └── META-INF │ │ └── spring │ │ └── applicationContext.xml ├── XMLConfig-JPA │ └── projectName-domain │ │ └── src │ │ └── main │ │ └── resources │ │ └── META-INF │ │ └── spring │ │ └── projectName-infra.xml ├── JavaConfig │ ├── projectName-domain │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── xxxxxx │ │ │ └── yyyyyy │ │ │ └── zzzzzz │ │ │ └── config │ │ │ └── app │ │ │ ├── ProjectNameCodeListConfig.java │ │ │ └── ProjectNameDomainConfig.java │ ├── projectName-env │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── xxxxxx │ │ │ └── yyyyyy │ │ │ └── zzzzzz │ │ │ └── config │ │ │ └── app │ │ │ └── ProjectNameEnvConfig.java │ └── projectName-web │ │ └── src │ │ └── main │ │ └── java │ │ └── xxxxxx │ │ └── yyyyyy │ │ └── zzzzzz │ │ └── config │ │ └── app │ │ └── ApplicationContextConfig.java ├── XMLConfig-Thymeleaf │ └── projectName-web │ │ └── src │ │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── spring │ │ │ └── spring-security.xml │ │ └── webapp │ │ └── WEB-INF │ │ └── web.xml ├── XMLConfig-JSP │ └── projectName-web │ │ └── src │ │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── spring │ │ │ ├── spring-security.xml │ │ │ └── spring-mvc.xml │ │ └── webapp │ │ └── WEB-INF │ │ └── web.xml ├── JavaConfig-JPA │ └── projectName-domain │ │ └── src │ │ └── main │ │ └── java │ │ └── xxxxxx │ │ └── yyyyyy │ │ └── zzzzzz │ │ └── config │ │ └── app │ │ └── ProjectNameInfraConfig.java ├── MyBatis3 │ └── projectName-domain │ │ └── src │ │ └── main │ │ └── resources │ │ └── xxxxxx │ │ └── yyyyyy │ │ └── zzzzzz │ │ └── domain │ │ └── repository │ │ └── sample │ │ └── SampleRepository.xml ├── JavaConfig-Thymeleaf │ └── projectName-web │ │ └── src │ │ └── main │ │ ├── java │ │ └── xxxxxx │ │ │ └── yyyyyy │ │ │ └── zzzzzz │ │ │ └── config │ │ │ └── web │ │ │ └── SpringSecurityConfig.java │ │ └── webapp │ │ └── WEB-INF │ │ └── web.xml └── JavaConfig-JSP │ └── projectName-web │ └── src │ └── main │ ├── java │ └── xxxxxx │ │ └── yyyyyy │ │ └── zzzzzz │ │ └── config │ │ └── web │ │ └── SpringSecurityConfig.java │ └── webapp │ └── WEB-INF │ └── web.xml ├── .gitignore ├── create-maven-archetype-xmlconfig-jsp-jpa.sh ├── create-maven-archetype-javaconfig-jsp-jpa.sh ├── create-maven-archetype-xmlconfig-jsp-noorm.sh ├── create-maven-archetype-javaconfig-jsp-noorm.sh ├── create-maven-archetype-xmlconfig-jsp-mybatis3.sh ├── create-maven-archetype-javaconfig-jsp-mybatis3.sh ├── create-maven-archetype-javaconfig-thymeleaf-jpa.sh ├── create-maven-archetype-xmlconfig-thymeleaf-jpa.sh ├── create-maven-archetype-javaconfig-thymeleaf-noorm.sh ├── create-maven-archetype-xmlconfig-thymeleaf-noorm.sh ├── create-maven-archetype-javaconfig-thymeleaf-mybatis3.sh ├── create-maven-archetype-xmlconfig-thymeleaf-mybatis3.sh ├── testScript ├── parts │ ├── base │ │ ├── projectName-domain │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── xxxxxx │ │ │ │ └── yyyyyy │ │ │ │ └── zzzzzz │ │ │ │ └── domain │ │ │ │ └── service │ │ │ │ └── errortest │ │ │ │ ├── MockTestService.java │ │ │ │ └── MockTestServiceImpl.java │ │ ├── projectName-selenium │ │ │ └── src │ │ │ │ └── test │ │ │ │ ├── resources │ │ │ │ ├── META-INF │ │ │ │ │ └── spring │ │ │ │ │ │ └── selenium.properties │ │ │ │ └── wdm.properties │ │ │ │ └── java │ │ │ │ └── xxxxxx │ │ │ │ └── yyyyyy │ │ │ │ └── zzzzzz │ │ │ │ └── selenium │ │ │ │ ├── webdrivers │ │ │ │ ├── WebDriverType.java │ │ │ │ ├── EdgeDriverFactoryBean.java │ │ │ │ ├── ChromeDriverFactoryBean.java │ │ │ │ ├── HeadlessWebDriverManagerFactoryBean.java │ │ │ │ ├── FirefoxDriverFactoryBean.java │ │ │ │ └── WebDriverManagerFactoryBean.java │ │ │ │ ├── welcome │ │ │ │ └── HelloIT.java │ │ │ │ ├── WebDriverOperations.java │ │ │ │ └── FunctionTestSupport.java │ │ └── projectName-web │ │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── xxxxxx │ │ │ └── yyyyyy │ │ │ └── zzzzzz │ │ │ └── app │ │ │ └── errortest │ │ │ ├── MockTestController.java │ │ │ └── TestErrorController.java │ ├── Thymeleaf │ │ └── projectName-web │ │ │ └── src │ │ │ ├── test │ │ │ └── resources │ │ │ │ └── META-INF │ │ │ │ └── spring │ │ │ │ └── mockmvc.properties │ │ │ └── main │ │ │ └── webapp │ │ │ └── WEB-INF │ │ │ └── views │ │ │ └── errortest │ │ │ └── otherError.html │ ├── JSP │ │ └── projectName-web │ │ │ └── src │ │ │ ├── main │ │ │ └── webapp │ │ │ │ └── WEB-INF │ │ │ │ └── views │ │ │ │ └── errortest │ │ │ │ └── otherError.jsp │ │ │ └── test │ │ │ └── resources │ │ │ └── META-INF │ │ │ └── spring │ │ │ └── mockmvc.properties │ ├── XMLConfig │ │ ├── projectName-web │ │ │ └── src │ │ │ │ └── test │ │ │ │ ├── resources │ │ │ │ └── META-INF │ │ │ │ │ └── spring │ │ │ │ │ └── spring-mvc-mockmvc.xml │ │ │ │ └── java │ │ │ │ └── xxxxxx │ │ │ │ └── yyyyyy │ │ │ │ └── zzzzzz │ │ │ │ └── mocktest │ │ │ │ ├── error │ │ │ │ ├── CsrfTokenErrorTest.java │ │ │ │ └── AccessDeniedErrorTest.java │ │ │ │ ├── welcome │ │ │ │ └── HelloTest.java │ │ │ │ └── interceptor │ │ │ │ └── InterceptorTest.java │ │ └── projectName-selenium │ │ │ └── src │ │ │ └── test │ │ │ ├── java │ │ │ └── xxxxxx │ │ │ │ └── yyyyyy │ │ │ │ └── zzzzzz │ │ │ │ └── selenium │ │ │ │ └── welcome │ │ │ │ └── HelloIT.java │ │ │ └── resources │ │ │ └── META-INF │ │ │ └── spring │ │ │ └── seleniumContext.xml │ └── JavaConfig │ │ ├── projectName-web │ │ └── src │ │ │ └── test │ │ │ └── java │ │ │ └── xxxxxx │ │ │ └── yyyyyy │ │ │ └── zzzzzz │ │ │ ├── config │ │ │ └── SpringMvcMockMvcConfig.java │ │ │ └── mocktest │ │ │ ├── error │ │ │ ├── CsrfTokenErrorTest.java │ │ │ └── AccessDeniedErrorTest.java │ │ │ ├── welcome │ │ │ └── HelloTest.java │ │ │ └── interceptor │ │ │ └── InterceptorTest.java │ │ └── projectName-selenium │ │ └── src │ │ └── test │ │ └── java │ │ └── xxxxxx │ │ └── yyyyyy │ │ └── zzzzzz │ │ ├── selenium │ │ └── welcome │ │ │ └── HelloIT.java │ │ └── config │ │ └── SeleniumContextConfig.java └── addTestResource.sh ├── create-blank-zip-jpa.sh ├── create-blank-zip-mybatis3.sh ├── create-maven-archetype-all.sh ├── create-blank-zip.sh ├── convert-camelclass.sh └── CONTRIBUTING.md /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Please review #XXX. 2 | -------------------------------------------------------------------------------- /parts/base/src/main/java/xxxxxx/yyyyyy/zzzzzz/domain/model/.gitkeep: -------------------------------------------------------------------------------- 1 | you can remove this file -------------------------------------------------------------------------------- /parts/base/src/main/java/xxxxxx/yyyyyy/zzzzzz/domain/service/.gitkeep: -------------------------------------------------------------------------------- 1 | you can remove this file -------------------------------------------------------------------------------- /parts/UseORM/projectName-env/src/main/resources/database/H2-schema.sql: -------------------------------------------------------------------------------- 1 | /* define the schemas. */ -------------------------------------------------------------------------------- /parts/base/src/main/java/xxxxxx/yyyyyy/zzzzzz/domain/repository/.gitkeep: -------------------------------------------------------------------------------- 1 | you can remove this file -------------------------------------------------------------------------------- /parts/UseORM/projectName-env/src/main/resources/database/H2-dataload.sql: -------------------------------------------------------------------------------- 1 | /* load the records. */ 2 | commit; -------------------------------------------------------------------------------- /parts/base/src/main/resources/ValidationMessages.properties: -------------------------------------------------------------------------------- 1 | # jakarta.validation.constraints.NotNull.message = must not be null 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .settings 3 | .classpath 4 | .project 5 | .springBeans 6 | .factorypath 7 | *~ 8 | .idea 9 | .DS_Store 10 | tmp 11 | *.iml 12 | .vscode 13 | -------------------------------------------------------------------------------- /parts/JSP/projectName-web/src/main/webapp/WEB-INF/views/layout/footer.jsp: -------------------------------------------------------------------------------- 1 |
2 |

Copyright © 20XX CompanyName

3 | -------------------------------------------------------------------------------- /parts/base/src/main/resources/commons-logging.properties: -------------------------------------------------------------------------------- 1 | # Force Slf4jLogFactory when JCL logs are invoked 2 | org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.Slf4jLogFactory 3 | -------------------------------------------------------------------------------- /create-maven-archetype-xmlconfig-jsp-jpa.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | CONFIG=XMLConfig 5 | VIEW=JSP 6 | ORM=JPA 7 | DEPLOY=$1 8 | REPOSITORY=$2 9 | 10 | sh create-maven-archetype.sh $CONFIG $VIEW $ORM "$DEPLOY" "$REPOSITORY" 11 | -------------------------------------------------------------------------------- /create-maven-archetype-javaconfig-jsp-jpa.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | CONFIG=JavaConfig 5 | VIEW=JSP 6 | ORM=JPA 7 | DEPLOY=$1 8 | REPOSITORY=$2 9 | 10 | sh create-maven-archetype.sh $CONFIG $VIEW $ORM "$DEPLOY" "$REPOSITORY" 11 | -------------------------------------------------------------------------------- /create-maven-archetype-xmlconfig-jsp-noorm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | CONFIG=XMLConfig 5 | VIEW=JSP 6 | ORM=NoORM 7 | DEPLOY=$1 8 | REPOSITORY=$2 9 | 10 | sh create-maven-archetype.sh $CONFIG $VIEW $ORM "$DEPLOY" "$REPOSITORY" 11 | -------------------------------------------------------------------------------- /create-maven-archetype-javaconfig-jsp-noorm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | CONFIG=JavaConfig 5 | VIEW=JSP 6 | ORM=NoORM 7 | DEPLOY=$1 8 | REPOSITORY=$2 9 | 10 | sh create-maven-archetype.sh $CONFIG $VIEW $ORM "$DEPLOY" "$REPOSITORY" 11 | -------------------------------------------------------------------------------- /create-maven-archetype-xmlconfig-jsp-mybatis3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | CONFIG=XMLConfig 5 | VIEW=JSP 6 | ORM=MyBatis3 7 | DEPLOY=$1 8 | REPOSITORY=$2 9 | 10 | sh create-maven-archetype.sh $CONFIG $VIEW $ORM "$DEPLOY" "$REPOSITORY" 11 | -------------------------------------------------------------------------------- /create-maven-archetype-javaconfig-jsp-mybatis3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | CONFIG=JavaConfig 5 | VIEW=JSP 6 | ORM=MyBatis3 7 | DEPLOY=$1 8 | REPOSITORY=$2 9 | 10 | sh create-maven-archetype.sh $CONFIG $VIEW $ORM "$DEPLOY" "$REPOSITORY" 11 | -------------------------------------------------------------------------------- /create-maven-archetype-javaconfig-thymeleaf-jpa.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | CONFIG=JavaConfig 5 | VIEW=Thymeleaf 6 | ORM=JPA 7 | DEPLOY=$1 8 | REPOSITORY=$2 9 | 10 | sh create-maven-archetype.sh $CONFIG $VIEW $ORM "$DEPLOY" "$REPOSITORY" 11 | -------------------------------------------------------------------------------- /create-maven-archetype-xmlconfig-thymeleaf-jpa.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | CONFIG=XMLConfig 5 | VIEW=Thymeleaf 6 | ORM=JPA 7 | DEPLOY=$1 8 | REPOSITORY=$2 9 | 10 | sh create-maven-archetype.sh $CONFIG $VIEW $ORM "$DEPLOY" "$REPOSITORY" 11 | -------------------------------------------------------------------------------- /create-maven-archetype-javaconfig-thymeleaf-noorm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | CONFIG=JavaConfig 5 | VIEW=Thymeleaf 6 | ORM=NoORM 7 | DEPLOY=$1 8 | REPOSITORY=$2 9 | 10 | sh create-maven-archetype.sh $CONFIG $VIEW $ORM "$DEPLOY" "$REPOSITORY" 11 | -------------------------------------------------------------------------------- /create-maven-archetype-xmlconfig-thymeleaf-noorm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | CONFIG=XMLConfig 5 | VIEW=Thymeleaf 6 | ORM=NoORM 7 | DEPLOY=$1 8 | REPOSITORY=$2 9 | 10 | sh create-maven-archetype.sh $CONFIG $VIEW $ORM "$DEPLOY" "$REPOSITORY" 11 | -------------------------------------------------------------------------------- /create-maven-archetype-javaconfig-thymeleaf-mybatis3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | CONFIG=JavaConfig 5 | VIEW=Thymeleaf 6 | ORM=MyBatis3 7 | DEPLOY=$1 8 | REPOSITORY=$2 9 | 10 | sh create-maven-archetype.sh $CONFIG $VIEW $ORM "$DEPLOY" "$REPOSITORY" 11 | -------------------------------------------------------------------------------- /create-maven-archetype-xmlconfig-thymeleaf-mybatis3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | CONFIG=XMLConfig 5 | VIEW=Thymeleaf 6 | ORM=MyBatis3 7 | DEPLOY=$1 8 | REPOSITORY=$2 9 | 10 | sh create-maven-archetype.sh $CONFIG $VIEW $ORM "$DEPLOY" "$REPOSITORY" 11 | -------------------------------------------------------------------------------- /testScript/parts/base/projectName-domain/src/main/java/xxxxxx/yyyyyy/zzzzzz/domain/service/errortest/MockTestService.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.domain.service.errortest; 2 | 3 | /** Services for mock testing */ 4 | public interface MockTestService { 5 | void testExecute(); 6 | } 7 | -------------------------------------------------------------------------------- /testScript/parts/Thymeleaf/projectName-web/src/test/resources/META-INF/spring/mockmvc.properties: -------------------------------------------------------------------------------- 1 | accessDeniedError.forwardedUrl=/common/error/accessDeniedError 2 | invalidCsrfTokenError.forwardedUrl=/common/error/invalidCsrfTokenError 3 | missingCsrfTokenError.forwardedUrl=/common/error/missingCsrfTokenError 4 | -------------------------------------------------------------------------------- /testScript/parts/JSP/projectName-web/src/main/webapp/WEB-INF/views/errortest/otherError.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /testScript/parts/JSP/projectName-web/src/test/resources/META-INF/spring/mockmvc.properties: -------------------------------------------------------------------------------- 1 | accessDeniedError.forwardedUrl=/WEB-INF/views/common/error/accessDeniedError.jsp 2 | invalidCsrfTokenError.forwardedUrl=/WEB-INF/views/common/error/invalidCsrfTokenError.jsp 3 | missingCsrfTokenError.forwardedUrl=/WEB-INF/views/common/error/missingCsrfTokenError.jsp 4 | -------------------------------------------------------------------------------- /testScript/parts/base/projectName-selenium/src/test/resources/META-INF/spring/selenium.properties: -------------------------------------------------------------------------------- 1 | selenium.serverUrl=http://localhost:8080 2 | selenium.contextName=projectName-web 3 | selenium.applicationContextUrl=${selenium.serverUrl}/${selenium.contextName} 4 | selenium.evidenceBaseDirectory=./evidence 5 | 6 | # Headless execution 7 | selenium.headless=true -------------------------------------------------------------------------------- /parts/UseORM/projectName-env/src/main/resources/META-INF/spring/projectName-infra.properties: -------------------------------------------------------------------------------- 1 | database=H2 2 | database.url=jdbc:h2:mem:projectName;DB_CLOSE_DELAY=-1 3 | database.username=sa 4 | database.password= 5 | database.driverClassName=org.h2.Driver 6 | # connection pool 7 | cp.maxActive=96 8 | cp.maxIdle=16 9 | cp.minIdle=0 10 | cp.maxWait=60000 11 | -------------------------------------------------------------------------------- /parts/JavaConfig-NoORM/projectName-domain/src/main/java/xxxxxx/yyyyyy/zzzzzz/config/app/ProjectNameInfraConfig.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.config.app; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | 5 | /** 6 | * Bean definitions for infrastructure layer. 7 | */ 8 | @Configuration 9 | public class ProjectNameInfraConfig { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /testScript/parts/base/projectName-domain/src/main/java/xxxxxx/yyyyyy/zzzzzz/domain/service/errortest/MockTestServiceImpl.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.domain.service.errortest; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class MockTestServiceImpl implements MockTestService { 7 | 8 | @Override 9 | public void testExecute() {} 10 | } 11 | -------------------------------------------------------------------------------- /parts/XMLConfig-NoORM/projectName-domain/src/main/resources/META-INF/spring/projectName-infra.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /testScript/parts/Thymeleaf/projectName-web/src/main/webapp/WEB-INF/views/errortest/otherError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 |

10 |

11 | 12 | 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/3-backport-issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 3.Backport Issue 3 | about: Backport a issue to other version. 4 | title: "Backport:" 5 | labels: "" 6 | assignees: "" 7 | --- 8 | 9 | ## Original Issue 10 | 11 | > Links to the original issues. 12 | 13 | - Backport #XXX 14 | 15 | ## Fix repositories 16 | 17 | > Repositories to fix with this issue. 18 | 19 | - [ ] terasoluna-gfw-web-blank 20 | - [ ] m-j 21 | - [ ] m-t 22 | -------------------------------------------------------------------------------- /create-blank-zip-jpa.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | #---------------------------------------- 5 | # change infra 6 | #---------------------------------------- 7 | sh change-infra.sh JPA 8 | 9 | #---------------------------------------- 10 | # create zip 11 | #---------------------------------------- 12 | sh create-blank-zip.sh 13 | 14 | #---------------------------------------- 15 | # move to destination 16 | #---------------------------------------- 17 | mv $FNAME*.zip $WORKSPACE/../../terasoluna-gfw-web-blank/workspace 18 | -------------------------------------------------------------------------------- /create-blank-zip-mybatis3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | #---------------------------------------- 5 | # change infra 6 | #---------------------------------------- 7 | sh change-infra.sh MyBatis3 8 | 9 | #---------------------------------------- 10 | # create zip 11 | #---------------------------------------- 12 | sh create-blank-zip.sh 13 | 14 | #---------------------------------------- 15 | # move to destination 16 | #---------------------------------------- 17 | mv $FNAME*.zip $WORKSPACE/../../terasoluna-gfw-web-blank/workspace 18 | -------------------------------------------------------------------------------- /testScript/parts/base/projectName-selenium/src/test/java/xxxxxx/yyyyyy/zzzzzz/selenium/webdrivers/WebDriverType.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.selenium.webdrivers; 2 | 3 | import org.openqa.selenium.WebDriver; 4 | 5 | /** 6 | * Supported {@link WebDriver} types. 7 | */ 8 | public enum WebDriverType { 9 | FIREFOX, CHROME, EDGE; 10 | 11 | /** 12 | * The default {@link WebDriver} type. 13 | * @return {@link #FIREFOX} 14 | */ 15 | public static WebDriverType DEFAULT() { 16 | return FIREFOX; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /parts/JSP/projectName-web/src/main/webapp/WEB-INF/views/common/include.jsp: -------------------------------------------------------------------------------- 1 | 2 | <%@ page session="false"%> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 4 | <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> 5 | <%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%> 6 | <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%> 7 | <%@ taglib uri="http://www.springframework.org/security/tags" prefix="sec"%> 8 | <%@ taglib uri="http://terasoluna.org/tags" prefix="t"%> 9 | <%@ taglib uri="http://terasoluna.org/functions" prefix="f"%> 10 | -------------------------------------------------------------------------------- /testScript/parts/base/projectName-selenium/src/test/resources/wdm.properties: -------------------------------------------------------------------------------- 1 | # If you do not specify a version, the latest version will be downloaded automatically. 2 | # If you want to fix the version, set it in this file or specify the version in the startup argument. 3 | # ex) mvn test -Dwdm.geckoDriverVersion=0.32.0 4 | 5 | # wdm.geckoDriverVersion=0.32.0 6 | wdm.geckoDriverVersion= 7 | # wdm.chromeDriverVersion=114.0.5735.90 8 | wdm.chromeDriverVersion= 9 | # wdm.edgeDriverVersion=114.0.1823.67 10 | wdm.edgeDriverVersion= 11 | 12 | wdm.forceCache=true 13 | 14 | wdm.proxy= 15 | wdm.proxyUser= 16 | wdm.proxyPass= 17 | -------------------------------------------------------------------------------- /parts/Thymeleaf/projectName-web/src/main/webapp/WEB-INF/views/welcome/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Home 6 | 7 | 8 | 9 |
10 |

Hello world!

11 |

The time on the server is 2018/01/01 00:00:00 JST.

12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /parts/JSP/projectName-web/src/main/webapp/WEB-INF/views/welcome/home.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Home 6 | 7 | 8 | 9 |
10 |
11 |

Hello world!

12 |

The time on the server is ${serverTime}.

13 |
14 | 15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /testScript/parts/XMLConfig/projectName-web/src/test/resources/META-INF/spring/spring-mvc-mockmvc.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 9 | xxxxxx.yyyyyy.zzzzzz.domain.service.errortest.MockTestService 10 | 11 | 12 | org.mockito.internal.creation.bytebuddy.MockMethodInterceptor 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /testScript/parts/base/projectName-selenium/src/test/java/xxxxxx/yyyyyy/zzzzzz/selenium/webdrivers/EdgeDriverFactoryBean.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.selenium.webdrivers; 2 | 3 | import org.openqa.selenium.edge.EdgeDriver; 4 | import org.openqa.selenium.edge.EdgeOptions; 5 | import io.github.bonigarcia.wdm.WebDriverManager; 6 | 7 | public class EdgeDriverFactoryBean extends HeadlessWebDriverManagerFactoryBean { 8 | 9 | @Override 10 | protected WebDriverManager getWebDriverManager() { 11 | return WebDriverManager.edgedriver(); 12 | } 13 | 14 | @Override 15 | protected EdgeDriver createWebDriver() { 16 | 17 | EdgeOptions options = new EdgeOptions(); 18 | 19 | if (super.headless) { 20 | options.addArguments("--headless=new"); 21 | } 22 | 23 | return new EdgeDriver(options); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testScript/parts/base/projectName-web/src/main/java/xxxxxx/yyyyyy/zzzzzz/app/errortest/MockTestController.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.app.errortest; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import jakarta.inject.Inject; 8 | 9 | import xxxxxx.yyyyyy.zzzzzz.domain.service.errortest.MockTestService; 10 | 11 | /** 12 | * Controller for Mock test 13 | */ 14 | @Controller 15 | @RequestMapping("/test/mock") 16 | public class MockTestController { 17 | 18 | @Inject 19 | MockTestService mockTestService; 20 | 21 | @GetMapping(value = "/success") 22 | public String test(Model model) { 23 | mockTestService.testExecute(); 24 | return "welcome/home"; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /testScript/parts/JavaConfig/projectName-web/src/test/java/xxxxxx/yyyyyy/zzzzzz/config/SpringMvcMockMvcConfig.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.config; 2 | 3 | import org.mockito.Mockito; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import xxxxxx.yyyyyy.zzzzzz.domain.service.errortest.MockTestService; 8 | 9 | /** 10 | * Bean definition of SpringMvc(MockMvc). 11 | */ 12 | @Configuration 13 | public class SpringMvcMockMvcConfig { 14 | 15 | /** 16 | * Mock definition of MockTestService. 17 | * @return MockTestService(Mock) bean definition 18 | */ 19 | @Bean(name = "mockTestService") 20 | public MockTestService mockTestService() { 21 | return Mockito.mock(MockTestService.class, 22 | "org.mockito.internal.creation.bytebuddy.MockMethodInterceptor"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testScript/parts/base/projectName-selenium/src/test/java/xxxxxx/yyyyyy/zzzzzz/selenium/webdrivers/ChromeDriverFactoryBean.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.selenium.webdrivers; 2 | 3 | import org.openqa.selenium.chrome.ChromeDriver; 4 | import org.openqa.selenium.chrome.ChromeOptions; 5 | import io.github.bonigarcia.wdm.WebDriverManager; 6 | 7 | public class ChromeDriverFactoryBean extends HeadlessWebDriverManagerFactoryBean { 8 | 9 | @Override 10 | protected WebDriverManager getWebDriverManager() { 11 | return WebDriverManager.chromedriver(); 12 | } 13 | 14 | @Override 15 | protected ChromeDriver createWebDriver() { 16 | 17 | ChromeOptions options = new ChromeOptions(); 18 | 19 | if (super.headless) { 20 | options.addArguments("--headless=new"); 21 | } 22 | 23 | return new ChromeDriver(options); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /parts/JavaConfig-NoORM/projectName-domain/src/main/java/xxxxxx/yyyyyy/zzzzzz/config/app/ProjectNameCodeListConfig.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.config.app; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | 5 | /** 6 | * Bean definition regarding CodeLists. 7 | */ 8 | @Configuration 9 | public class ProjectNameCodeListConfig { 10 | 11 | // /** 12 | // * Example for usage of {@link SimpleMapCodeList}. 13 | // * @return Bean of configured {@link SimpleMapCodeList} 14 | // */ 15 | // @Bean("CL_SAMPLE") 16 | // public CodeList CL_SAMPLE() { 17 | // SimpleMapCodeList bean = new SimpleMapCodeList(); 18 | // Map codeList = new HashMap<>(); 19 | // codeList.put("1", "Received"); 20 | // codeList.put("2", "Sent"); 21 | // codeList.put("3", "Cancelled"); 22 | // bean.setMap(codeList); 23 | // return bean; 24 | // } 25 | } 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/2-reflect-issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 2.Reflect Issue 3 | about: Reflect a issue to other repository. 4 | title: "Reflect:" 5 | labels: "" 6 | assignees: "" 7 | --- 8 | 9 | ## Original Issue 10 | 11 | > Links to the original issues. 12 | 13 | - Reflect terasolunaorg/[repository-name]#[issue-num] 14 | 15 | ## Description 16 | 17 | > Please write if the description of the original issue is not enough. 18 | > Please write based on facts as much as possible, and post links to references/Javadoc or stack traces. 19 | 20 | ## Possible Solution 21 | 22 | > Please write ideas or candidates of solutions for the problem if you have. 23 | > **If it is an example, please enter a description such as "For example".** 24 | 25 | ## Fix repositories 26 | 27 | > Repositories to fix with this issue. 28 | 29 | - [ ] terasoluna-gfw-web-blank 30 | - [ ] m-j 31 | - [ ] m-t 32 | 33 | ## Issue links 34 | 35 | > Links to related issues. 36 | 37 | - #xx 38 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/1-new-issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 1.New Issue 3 | about: Create a new issue. 4 | title: "" 5 | labels: "status: triage" 6 | assignees: "" 7 | --- 8 | 9 | ## Description 10 | 11 | > Please write the problem in detail. 12 | > Please write based on facts as much as possible, and post links to references/Javadoc or stack traces. 13 | 14 | ## Possible Solution 15 | 16 | > Please write ideas or candidates of solutions for the problem if you have. 17 | > **If it is an example, please enter a description such as "For example".** 18 | 19 | ## Affect versions 20 | 21 | > Version in which the problem occurs. **Current version if not known.** 22 | > If there is a feature suggestion, please delete it. 23 | 24 | - 5.x.x.RELEASE 25 | 26 | ## Fix repositories 27 | 28 | > Repositories to fix with this issue. 29 | 30 | - [ ] terasoluna-gfw-web-blank 31 | - [ ] m-j 32 | - [ ] m-t 33 | 34 | ## Issue links 35 | 36 | > Links to related issues. 37 | 38 | - #xx 39 | -------------------------------------------------------------------------------- /parts/JSP/projectName-web/src/main/webapp/WEB-INF/views/common/error/unhandledSystemError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Unhandled System Error! 6 | 7 | 8 |
9 |

Unhandled System Error!

10 |
Unhandled system error occurred!
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /parts/Thymeleaf/projectName-web/src/main/webapp/WEB-INF/views/common/error/unhandledSystemError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Unhandled System Error! 6 | 7 | 8 |
9 |

Unhandled System Error!

10 |
Unhandled system error occurred!
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /testScript/parts/base/projectName-selenium/src/test/java/xxxxxx/yyyyyy/zzzzzz/selenium/webdrivers/HeadlessWebDriverManagerFactoryBean.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.selenium.webdrivers; 2 | 3 | import org.openqa.selenium.WebDriver; 4 | import org.springframework.beans.factory.InitializingBean; 5 | import org.springframework.util.StringUtils; 6 | 7 | public abstract class HeadlessWebDriverManagerFactoryBean 8 | extends WebDriverManagerFactoryBean implements InitializingBean { 9 | 10 | protected boolean headless = true; 11 | 12 | public void setHeadless(boolean headless) { 13 | this.headless = headless; 14 | } 15 | 16 | @Override 17 | public void afterPropertiesSet() throws Exception { 18 | // Prioritize startup arguments 19 | String headlessProperty = System.getProperty("selenium.headless"); 20 | if (StringUtils.hasLength(headlessProperty)) { 21 | this.headless = Boolean.valueOf(headlessProperty); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testScript/parts/JavaConfig/projectName-selenium/src/test/java/xxxxxx/yyyyyy/zzzzzz/selenium/welcome/HelloIT.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.selenium.welcome; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import java.io.IOException; 5 | import org.junit.jupiter.api.Test; 6 | import org.openqa.selenium.By; 7 | import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; 8 | 9 | import xxxxxx.yyyyyy.zzzzzz.config.SeleniumContextConfig; 10 | import xxxxxx.yyyyyy.zzzzzz.selenium.FunctionTestSupport; 11 | 12 | /** 13 | * Executes the test for the application home page. 14 | */ 15 | @SpringJUnitConfig(classes = {SeleniumContextConfig.class}) 16 | public class HelloIT extends FunctionTestSupport { 17 | 18 | /** 19 | * Asserts that the content of the application home page is "Hello world!". 20 | */ 21 | @Test 22 | public void testHelloWorld() throws IOException { 23 | 24 | assertThat(webDriver.findElement(By.id("title")).getText()).isEqualTo("Hello world!"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /parts/XMLConfig-NoORM/projectName-domain/src/main/resources/META-INF/spring/projectName-codelist.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 19 | 20 | -------------------------------------------------------------------------------- /testScript/parts/base/projectName-selenium/src/test/java/xxxxxx/yyyyyy/zzzzzz/selenium/welcome/HelloIT.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.selenium.welcome; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import java.io.IOException; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | import org.openqa.selenium.By; 8 | import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; 9 | 10 | import xxxxxx.yyyyyy.zzzzzz.selenium.FunctionTestSupport; 11 | 12 | /** 13 | * Executes the test for the application home page. 14 | */ 15 | @SpringJUnitConfig(locations = {"classpath:META-INF/spring/seleniumContext.xml"}) 16 | public class HelloIT extends FunctionTestSupport { 17 | 18 | /** 19 | * Asserts that the content of the application home page is "Hello world!". 20 | */ 21 | @Test 22 | public void testHelloWorld() throws IOException { 23 | 24 | assertThat(webDriver.findElement(By.id("title")).getText()).isEqualTo("Hello world!"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /create-maven-archetype-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | DEPLOY=$1 5 | REPOSITORY=$2 6 | 7 | sh create-maven-archetype-javaconfig-jsp-jpa.sh "$DEPLOY" "$REPOSITORY" 8 | sh create-maven-archetype-javaconfig-jsp-mybatis3.sh "$DEPLOY" "$REPOSITORY" 9 | sh create-maven-archetype-javaconfig-jsp-noorm.sh "$DEPLOY" "$REPOSITORY" 10 | sh create-maven-archetype-javaconfig-thymeleaf-jpa.sh "$DEPLOY" "$REPOSITORY" 11 | sh create-maven-archetype-javaconfig-thymeleaf-mybatis3.sh "$DEPLOY" "$REPOSITORY" 12 | sh create-maven-archetype-javaconfig-thymeleaf-noorm.sh "$DEPLOY" "$REPOSITORY" 13 | sh create-maven-archetype-xmlconfig-jsp-jpa.sh "$DEPLOY" "$REPOSITORY" 14 | sh create-maven-archetype-xmlconfig-jsp-mybatis3.sh "$DEPLOY" "$REPOSITORY" 15 | sh create-maven-archetype-xmlconfig-jsp-noorm.sh "$DEPLOY" "$REPOSITORY" 16 | sh create-maven-archetype-xmlconfig-thymeleaf-jpa.sh "$DEPLOY" "$REPOSITORY" 17 | sh create-maven-archetype-xmlconfig-thymeleaf-mybatis3.sh "$DEPLOY" "$REPOSITORY" 18 | sh create-maven-archetype-xmlconfig-thymeleaf-noorm.sh "$DEPLOY" "$REPOSITORY" 19 | -------------------------------------------------------------------------------- /testScript/parts/XMLConfig/projectName-selenium/src/test/java/xxxxxx/yyyyyy/zzzzzz/selenium/welcome/HelloIT.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.selenium.welcome; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import java.io.IOException; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | import org.openqa.selenium.By; 8 | import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; 9 | 10 | import xxxxxx.yyyyyy.zzzzzz.selenium.FunctionTestSupport; 11 | 12 | /** 13 | * Executes the test for the application home page. 14 | */ 15 | @SpringJUnitConfig(locations = {"classpath:META-INF/spring/seleniumContext.xml"}) 16 | public class HelloIT extends FunctionTestSupport { 17 | 18 | /** 19 | * Asserts that the content of the application home page is "Hello world!". 20 | */ 21 | @Test 22 | public void testHelloWorld() throws IOException { 23 | 24 | assertThat(webDriver.findElement(By.id("title")).getText()).isEqualTo("Hello world!"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /parts/XMLConfig-MyBatis3/projectName-domain/src/main/resources/META-INF/spring/projectName-infra.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /testScript/parts/base/projectName-selenium/src/test/java/xxxxxx/yyyyyy/zzzzzz/selenium/webdrivers/FirefoxDriverFactoryBean.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.selenium.webdrivers; 2 | 3 | import org.openqa.selenium.firefox.FirefoxDriver; 4 | import org.openqa.selenium.firefox.FirefoxOptions; 5 | import org.openqa.selenium.firefox.FirefoxProfile; 6 | import io.github.bonigarcia.wdm.WebDriverManager; 7 | 8 | public class FirefoxDriverFactoryBean extends HeadlessWebDriverManagerFactoryBean { 9 | 10 | @Override 11 | protected WebDriverManager getWebDriverManager() { 12 | return WebDriverManager.firefoxdriver(); 13 | } 14 | 15 | @Override 16 | protected FirefoxDriver createWebDriver() { 17 | 18 | FirefoxProfile profile = new FirefoxProfile(); 19 | profile.setPreference("browser.startup.homepage_override.mstone", "ignore"); 20 | profile.setPreference("network.proxy.type", 0); 21 | FirefoxOptions options = new FirefoxOptions().setProfile(profile); 22 | 23 | if (super.headless) { 24 | options.addArguments("--headless"); 25 | } 26 | 27 | return new FirefoxDriver(options); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /parts/base/src/main/resources/i18n/application-messages.properties: -------------------------------------------------------------------------------- 1 | e.xx.fw.5001 = Resource not found. 2 | 3 | e.xx.fw.7001 = Illegal screen flow detected! 4 | e.xx.fw.7002 = CSRF attack detected! 5 | e.xx.fw.7003 = Access Denied detected! 6 | e.xx.fw.7004 = Missing CSRF detected! 7 | 8 | e.xx.fw.8001 = Business error occurred! 9 | 10 | e.xx.fw.9001 = System error occurred! 11 | e.xx.fw.9002 = Data Access error! 12 | 13 | # typemismatch 14 | typeMismatch="{0}" is invalid. 15 | typeMismatch.int="{0}" must be an integer. 16 | typeMismatch.double="{0}" must be a double. 17 | typeMismatch.float="{0}" must be a float. 18 | typeMismatch.long="{0}" must be a long. 19 | typeMismatch.short="{0}" must be a short. 20 | typeMismatch.boolean="{0}" must be a boolean. 21 | typeMismatch.java.lang.Integer="{0}" must be an integer. 22 | typeMismatch.java.lang.Double="{0}" must be a double. 23 | typeMismatch.java.lang.Float="{0}" must be a float. 24 | typeMismatch.java.lang.Long="{0}" must be a long. 25 | typeMismatch.java.lang.Short="{0}" must be a short. 26 | typeMismatch.java.lang.Boolean="{0}" is not a boolean. 27 | typeMismatch.java.time.LocalDateTime="{0}" is not a date. 28 | typeMismatch.java.lang.Enum="{0}" is not a valid value. -------------------------------------------------------------------------------- /parts/JSP/projectName-web/src/main/webapp/WEB-INF/views/common/error/systemError.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | System Error! 6 | 7 | 8 | 9 |
10 |

System Error!

11 |
12 | [${f:h(exceptionCode)}] 13 | 14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /parts/JSP/projectName-web/src/main/webapp/WEB-INF/views/common/error/accessDeniedError.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Access Denied Error! 6 | 7 | 8 | 9 |
10 |

Access Denied Error!

11 |
12 | [${f:h(exceptionCode)}] 13 | 14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /parts/JSP/projectName-web/src/main/webapp/WEB-INF/views/common/error/invalidCsrfTokenError.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CSRF Error! 6 | 7 | 8 | 9 |
10 |

CSRF Error! Invalid CSRF Token!

11 |
12 | [${f:h(exceptionCode)}] 13 | 14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /parts/JSP/projectName-web/src/main/webapp/WEB-INF/views/common/error/missingCsrfTokenError.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CSRF Error! 6 | 7 | 8 | 9 |
10 |

CSRF Error! Missing CSRF Token!

11 |
12 | [${f:h(exceptionCode)}] 13 | 14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /parts/JSP/projectName-web/src/main/webapp/WEB-INF/views/common/error/transactionTokenError.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Transaction Token Error! 6 | 7 | 8 | 9 |
10 |

Transaction Token Error!

11 |
12 | [${f:h(exceptionCode)}] 13 | 14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /parts/JSP/projectName-web/src/main/webapp/WEB-INF/views/common/error/dataAccessError.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Data Access Error! 6 | 7 | 8 | 9 |
10 |

Data Access Error!

11 |
12 | [${f:h(exceptionCode)}] 13 | 14 |
15 | 16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | 42 | 43 | -------------------------------------------------------------------------------- /create-blank-zip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | # export DIRNAME=`dirname \`pwd\``-`date '+%Y%m%d'` 5 | export DIRNAME=$(dirname $(pwd))-$VERSION 6 | export FNAME=$(basename $DIRNAME) 7 | export FNAME_D=$FNAME-with-dependencies 8 | 9 | #---------------------------------------- 10 | # remove metafiles 11 | #---------------------------------------- 12 | rm -rf $(find . -type d -name .svn) 13 | rm -rf $(find . -type d -name .git) 14 | rm -f $(find . -type f -name .gitkeep) 15 | rm -f $(find . -type f -name .gitignore) 16 | 17 | #---------------------------------------- 18 | # create directory to make zip for maven project 19 | #---------------------------------------- 20 | rm -rf $FNAME 21 | mkdir -p $FNAME 22 | cp -r src pom.xml $FNAME/ 23 | zip -r $FNAME.zip $FNAME 24 | 25 | #---------------------------------------- 26 | # maven project -> WTP project with dependencies 27 | #---------------------------------------- 28 | rm -rf $FNAME_D 29 | mkdir -p $FNAME_D 30 | cp -r src pom.xml *.sh $FNAME_D/ 31 | pushd $FNAME_D 32 | sh unmaven-project.sh $JOB_NAME 33 | rm -f *.sh 34 | popd 35 | zip -r $FNAME_D.zip $FNAME_D 36 | 37 | #---------------------------------------- 38 | # remove trash 39 | #---------------------------------------- 40 | rm -rf *.sh *.xml src infra 41 | rm -rf $FNAME $FNAME_D 42 | -------------------------------------------------------------------------------- /parts/JSP/projectName-web/src/main/webapp/WEB-INF/views/common/error/resourceNotFoundError.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Resource Not Found Error! 6 | 7 | 8 | 9 |
10 |

Resource Not Found Error!

11 |
12 | [${f:h(exceptionCode)}] 13 | 14 |
15 | 16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | 42 | 43 | -------------------------------------------------------------------------------- /parts/XMLConfig-MyBatis3/projectName-domain/src/main/resources/META-INF/mybatis/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 | 18 | 19 | 20 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /parts/Thymeleaf/projectName-web/src/main/webapp/WEB-INF/views/common/error/systemError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | System Error! 6 | 7 | 8 | 9 |
10 |

System Error!

11 |
12 | [e.xx.fw.9001] System error occurred! 13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /parts/Thymeleaf/projectName-web/src/main/webapp/WEB-INF/views/common/error/accessDeniedError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Access Denied Error! 6 | 7 | 8 | 9 |
10 |

Access Denied Error!

11 |
12 | [e.xx.fw.7003] Access Denied detected! 13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /parts/Thymeleaf/projectName-web/src/main/webapp/WEB-INF/views/common/error/invalidCsrfTokenError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CSRF Error! 6 | 7 | 8 | 9 |
10 |

CSRF Error! Invalid CSRF Token!

11 |
12 | [e.xx.fw.7002] CSRF attack detected! 13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /parts/Thymeleaf/projectName-web/src/main/webapp/WEB-INF/views/common/error/missingCsrfTokenError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CSRF Error! 6 | 7 | 8 | 9 |
10 |

CSRF Error! Missing CSRF Token!

11 |
12 | [e.xx.fw.7004] Missing CSRF detected! 13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /parts/Thymeleaf/projectName-web/src/main/webapp/WEB-INF/views/common/error/transactionTokenError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Transaction Token Error! 6 | 7 | 8 | 9 |
10 |

Transaction Token Error!

11 |
12 | [e.xx.fw.7001] Illegal screen flow detected! 13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /parts/JavaConfig-MyBatis3/projectName-domain/src/main/java/xxxxxx/yyyyyy/zzzzzz/config/app/ProjectNameInfraConfig.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.config.app; 2 | 3 | import javax.sql.DataSource; 4 | import org.mybatis.spring.SqlSessionFactoryBean; 5 | import org.mybatis.spring.annotation.MapperScan; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.context.annotation.Import; 9 | 10 | import xxxxxx.yyyyyy.zzzzzz.config.app.mybatis.MybatisConfig; 11 | 12 | /** 13 | * Bean definitions for infrastructure layer. 14 | */ 15 | @Configuration 16 | @MapperScan("xxxxxx.yyyyyy.zzzzzz.domain.repository") 17 | @Import({ProjectNameEnvConfig.class}) 18 | public class ProjectNameInfraConfig { 19 | 20 | /** 21 | * Configure {@link SqlSessionFactoryBean} bean. 22 | * @param dataSource DataSource 23 | * @see xxxxxx.yyyyyy.zzzzzz.config.app.ProjectNameEnvConfig#dataSource() 24 | * @return Bean of configured {@link SqlSessionFactoryBean} 25 | */ 26 | @Bean("sqlSessionFactory") 27 | public SqlSessionFactoryBean sqlSessionFactory(DataSource dataSource) { 28 | SqlSessionFactoryBean bean = new SqlSessionFactoryBean(); 29 | bean.setDataSource(dataSource); 30 | bean.setConfiguration(MybatisConfig.configuration()); 31 | return bean; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /parts/base/src/main/java/xxxxxx/yyyyyy/zzzzzz/app/welcome/HelloController.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.app.welcome; 2 | 3 | import java.time.LocalDateTime; 4 | import java.time.format.DateTimeFormatter; 5 | import java.time.format.FormatStyle; 6 | import java.util.Locale; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.GetMapping; 12 | 13 | /** 14 | * Handles requests for the application home page. 15 | */ 16 | @Controller 17 | public class HelloController { 18 | 19 | private static final Logger logger = LoggerFactory.getLogger(HelloController.class); 20 | 21 | /** 22 | * Simply selects the home view to render by returning its name. 23 | */ 24 | @GetMapping(value = "/") 25 | public String home(Locale locale, Model model) { 26 | logger.info("Welcome home! The client locale is {}.", locale); 27 | 28 | LocalDateTime dateTime = LocalDateTime.now(); 29 | DateTimeFormatter formatter = DateTimeFormatter 30 | .ofLocalizedDateTime(FormatStyle.LONG, FormatStyle.MEDIUM).withLocale(locale); 31 | 32 | String formattedDate = dateTime.format(formatter); 33 | 34 | model.addAttribute("serverTime", formattedDate); 35 | 36 | return "welcome/home"; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /testScript/parts/base/projectName-selenium/src/test/java/xxxxxx/yyyyyy/zzzzzz/selenium/webdrivers/WebDriverManagerFactoryBean.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.selenium.webdrivers; 2 | 3 | import org.openqa.selenium.WebDriver; 4 | import org.springframework.beans.factory.FactoryBean; 5 | import io.github.bonigarcia.wdm.WebDriverManager; 6 | 7 | public abstract class WebDriverManagerFactoryBean implements FactoryBean { 8 | 9 | protected String propertyFileLocation; 10 | 11 | public void setPropertyFileLocation(String propertyFileLocation) { 12 | this.propertyFileLocation = propertyFileLocation; 13 | } 14 | 15 | protected abstract WebDriverManager getWebDriverManager(); 16 | 17 | protected abstract T createWebDriver(); 18 | 19 | @Override 20 | public T getObject() { 21 | if (System.getenv("webdriver.driver") == null) { 22 | WebDriverManager manager = getWebDriverManager(); 23 | if (this.propertyFileLocation != null) { 24 | manager.config().setProperties(this.propertyFileLocation); 25 | } 26 | manager.setup(); 27 | } 28 | 29 | return createWebDriver(); 30 | } 31 | 32 | @Override 33 | public Class getObjectType() { 34 | return WebDriver.class; 35 | } 36 | 37 | @Override 38 | public boolean isSingleton() { 39 | return false; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /parts/JSP/projectName-web/src/main/webapp/WEB-INF/views/common/error/businessError.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Business Error! 6 | 7 | 8 | 9 |
10 |

Business Error!

11 |
12 | 13 | 14 | 15 | 16 | [${f:h(exceptionCode)}] 17 | 18 | 19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | 46 | 47 | -------------------------------------------------------------------------------- /parts/XMLConfig-NoORM/projectName-domain/src/main/resources/META-INF/spring/projectName-domain.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /parts/XMLConfig/projectName-domain/src/main/resources/META-INF/spring/projectName-codelist.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 19 | 20 | 27 | 28 | -------------------------------------------------------------------------------- /parts/Thymeleaf/projectName-web/src/main/java/xxxxxx/yyyyyy/zzzzzz/app/common/error/CommonErrorController.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.app.common.error; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | @Controller 7 | @RequestMapping("/common/error") 8 | public class CommonErrorController { 9 | 10 | @RequestMapping("/accessDeniedError") 11 | public String accessDeniedError() { 12 | return "common/error/accessDeniedError"; 13 | } 14 | 15 | @RequestMapping("/businessError") 16 | public String businessError() { 17 | return "common/error/businessError"; 18 | } 19 | 20 | @RequestMapping("/dataAccessError") 21 | public String dataAccessError() { 22 | return "common/error/dataAccessError"; 23 | } 24 | 25 | @RequestMapping("/invalidCsrfTokenError") 26 | public String invalidCsrfTokenError() { 27 | return "common/error/invalidCsrfTokenError"; 28 | } 29 | 30 | @RequestMapping("/missingCsrfTokenError") 31 | public String missingCsrfTokenError() { 32 | return "common/error/missingCsrfTokenError"; 33 | } 34 | 35 | @RequestMapping("/resourceNotFoundError") 36 | public String resourceNotFoundError() { 37 | return "common/error/resourceNotFoundError"; 38 | } 39 | 40 | @RequestMapping("/systemError") 41 | public String systemError() { 42 | return "common/error/systemError"; 43 | } 44 | 45 | @RequestMapping("/transactionTokenError") 46 | public String transactionTokenError() { 47 | return "common/error/transactionTokenError"; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /parts/XMLConfig/projectName-domain/src/main/resources/META-INF/spring/projectName-domain.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | 24 | 25 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /parts/Thymeleaf/projectName-web/src/main/webapp/WEB-INF/views/common/error/dataAccessError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Data Access Error! 6 | 7 | 8 | 9 |
10 |

Data Access Error!

11 |
12 | [e.xx.fw.9002] Data Access error! 13 |
14 |
15 |
    16 |
  • error detail message
  • 17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | 45 | 46 | -------------------------------------------------------------------------------- /parts/Thymeleaf/projectName-web/src/main/webapp/WEB-INF/views/common/error/businessError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Business Error! 6 | 7 | 8 | 9 |
10 |

Business Error!

11 |
12 | [e.xx.fw.8001] Business error occurred! 13 |
14 |
    15 |
  • error detail message
  • 16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | 45 | 46 | -------------------------------------------------------------------------------- /parts/Thymeleaf/projectName-web/src/main/webapp/WEB-INF/views/common/error/resourceNotFoundError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Resource Not Found Error! 6 | 7 | 8 | 9 |
10 |

Resource Not Found Error!

11 |
12 | [e.xx.fw.5001] Resource not found. 13 |
14 |
15 |
    16 |
  • error detail message
  • 17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | 45 | 46 | -------------------------------------------------------------------------------- /testScript/parts/XMLConfig/projectName-selenium/src/test/resources/META-INF/spring/seleniumContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /convert-camelclass.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | LF=$(printf '\\\012_') 5 | LF=${LF%_} 6 | REQUIRED_PROPERTIES="${LF} " 7 | REQUIRED_PROPERTIES="${REQUIRED_PROPERTIES}${LF} " 8 | REQUIRED_PROPERTIES="${REQUIRED_PROPERTIES}${LF} \${artifactId.replaceAll(\"^a|-a|_a\", \"A\").replaceAll(\"^b|-b|_b\", \"B\").replaceAll(\"^c|-c|_c\", \"C\").replaceAll(\"^d|-d|_d\", \"D\").replaceAll(\"^e|-e|_e\", \"E\").replaceAll(\"^f|-f|_f\", \"F\").replaceAll(\"^g|-g|_g\", \"G\").replaceAll(\"^h|-h|_h\", \"H\").replaceAll(\"^i|-i|_i\", \"I\").replaceAll(\"^j|-j|_j\", \"J\").replaceAll(\"^k|-k|_k\", \"K\").replaceAll(\"^l|-l|_l\", \"L\").replaceAll(\"^m|-m|_m\", \"M\").replaceAll(\"^n|-n|_n\", \"N\").replaceAll(\"^o|-o|_o\", \"O\").replaceAll(\"^p|-p|_p\", \"P\").replaceAll(\"^q|-q|_q\", \"Q\").replaceAll(\"^r|-r|_r\", \"R\").replaceAll(\"^s|-s|_s\", \"S\").replaceAll(\"^t|-t|_t\", \"T\").replaceAll(\"^u|-u|_u\", \"U\").replaceAll(\"^v|-v|_v\", \"V\").replaceAll(\"^w|-w|_w\", \"W\").replaceAll(\"^x|-x|_x\", \"X\").replaceAll(\"^y|-y|_y\", \"Y\").replaceAll(\"^z|-z|_z\", \"Z\")}<\/defaultValue>" 9 | REQUIRED_PROPERTIES="${REQUIRED_PROPERTIES}${LF} <\/requiredProperty>" 10 | REQUIRED_PROPERTIES="${REQUIRED_PROPERTIES}${LF} <\/requiredProperties>" 11 | sed -i -e "s/<\/fileSets>/<\/fileSets>${REQUIRED_PROPERTIES}/" src/main/resources/META-INF/maven/archetype-metadata.xml 12 | 13 | echo "ProjectName=basic" >>src/test/resources/projects/basic/archetype.properties 14 | 15 | sed -i -e "s/public class ProjectName/public class \${ProjectName}/" src/main/resources/archetype-resources/src/main/java/config/app/__ProjectName__*.java 16 | sed -i -e "s/config\.app\.ProjectName/config\.app\.\${ProjectName}/" src/main/resources/archetype-resources/src/main/java/config/app/__ProjectName__*.java 17 | sed -i -e "s/\(ProjectName\)\([A-Za-z]*Config\.class\)/\${ProjectName}\2/g" src/main/resources/archetype-resources/src/main/java/config/app/*.java 18 | -------------------------------------------------------------------------------- /parts/XMLConfig-JPA/projectName-domain/src/main/resources/META-INF/spring/projectName-infra.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /parts/JavaConfig/projectName-domain/src/main/java/xxxxxx/yyyyyy/zzzzzz/config/app/ProjectNameCodeListConfig.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.config.app; 2 | 3 | import javax.sql.DataSource; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.jdbc.core.JdbcTemplate; 8 | import jakarta.inject.Inject; 9 | 10 | /** 11 | * Bean definition regarding CodeLists. 12 | */ 13 | @Configuration 14 | public class ProjectNameCodeListConfig { 15 | 16 | /** 17 | * JDBC fetchSize property. 18 | */ 19 | @Value("${codelist.jdbc.fetchSize:1000}") 20 | private Integer fetchSize; 21 | 22 | /** 23 | * Bean of DataSource. 24 | */ 25 | @Inject 26 | private DataSource dataSource; 27 | 28 | /** 29 | * Configure {@link JdbcTemplate} bean. 30 | * @return Bean of configured {@link JdbcTemplate} 31 | */ 32 | @Bean("jdbcTemplateForCodeList") 33 | public JdbcTemplate jdbcTemplateForCodeList() { 34 | JdbcTemplate bean = new JdbcTemplate(); 35 | bean.setDataSource(dataSource); 36 | bean.setFetchSize(fetchSize); 37 | return bean; 38 | } 39 | 40 | // Example for usage of AbstractJdbcCodeList 41 | 42 | // /** 43 | // * Common processing of {@link JdbcCodeList}. 44 | // * @return Bean of configured {@link JdbcCodeList} 45 | // */ 46 | // private JdbcCodeList abstractJdbcCodeList() { 47 | // JdbcCodeList bean = new JdbcCodeList(); 48 | // bean.setJdbcTemplate(jdbcTemplateForCodeList()); 49 | // return bean; 50 | // } 51 | 52 | // /** 53 | // * Example for usage of {@link AbstractJdbcCodeList}. 54 | // * @return Bean of configured {@link JdbcCodeList} 55 | // */ 56 | // @Bean("CL_SAMPLE") 57 | // public JdbcCodeList clSample() { 58 | // JdbcCodeList jdbcCodeList = abstractJdbcCodeList(); 59 | // jdbcCodeList.setQuerySql( 60 | // "SELECT code, code_name FROM t_sample_codes ORDER BY code"); 61 | // jdbcCodeList.setValueColumn("code"); 62 | // jdbcCodeList.setLabelColumn("code_name"); 63 | // return jdbcCodeList; 64 | // } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /parts/JavaConfig-MyBatis3/projectName-domain/src/main/java/xxxxxx/yyyyyy/zzzzzz/config/app/mybatis/MybatisConfig.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.config.app.mybatis; 2 | 3 | import org.apache.ibatis.session.Configuration; 4 | import org.apache.ibatis.type.TypeAliasRegistry; 5 | import org.apache.ibatis.type.TypeHandlerRegistry; 6 | 7 | /** 8 | * Mybatis config. 9 | */ 10 | public class MybatisConfig { 11 | 12 | /** 13 | * Settings Mybatis config. 14 | * @return Configured {@link Configuration} 15 | */ 16 | public static Configuration configuration() { 17 | Configuration configuration = new Configuration(); 18 | setSettings(configuration); 19 | setTypeAliases(configuration.getTypeAliasRegistry()); 20 | setTypeHandlers(configuration.getTypeHandlerRegistry()); 21 | return configuration; 22 | } 23 | 24 | /** 25 | * Settings MyBatis behaves. 26 | * @param configuration Accepted at configuration 27 | */ 28 | private static void setSettings(Configuration configuration) { 29 | configuration.setMapUnderscoreToCamelCase(true); 30 | configuration.setLazyLoadingEnabled(true); 31 | configuration.setDefaultFetchSize(100); 32 | // configuration.setDefaultExecutorType(ExecutorType.REUSE); 33 | // configuration.setJdbcTypeForNull(JdbcType.NULL); 34 | // configuration.setLocalCacheScope(LocalCacheScope.STATEMENT); 35 | } 36 | 37 | /** 38 | * Settings type aliases. 39 | * @param typeAliasRegistry Accepted at configuration 40 | */ 41 | private static void setTypeAliases(TypeAliasRegistry typeAliasRegistry) { 42 | typeAliasRegistry.registerAliases("xxxxxx.yyyyyy.zzzzzz.domain.model"); 43 | typeAliasRegistry.registerAliases("xxxxxx.yyyyyy.zzzzzz.domain.repository"); 44 | // typeAliasRegistry.registerAliases("xxxxxx.yyyyyy.zzzzzz.infra.mybatis.typehandler"); 45 | } 46 | 47 | /** 48 | * Settings type handlers. 49 | * @param typeHandlerRegistry Accepted at configuration 50 | */ 51 | private static void setTypeHandlers(TypeHandlerRegistry typeHandlerRegistry) { 52 | // typeHandlerRegistry.register("xxxxxx.yyyyyy.zzzzzz.infra.mybatis.typehandler"); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /testScript/parts/base/projectName-selenium/src/test/java/xxxxxx/yyyyyy/zzzzzz/selenium/WebDriverOperations.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.selenium; 2 | 3 | import java.time.Duration; 4 | import org.openqa.selenium.By; 5 | import org.openqa.selenium.NoSuchElementException; 6 | import org.openqa.selenium.WebDriver; 7 | 8 | /** 9 | * Class that provides a (logic for WebDriver) browser operation. 10 | */ 11 | public class WebDriverOperations { 12 | protected final WebDriver webDriver; 13 | 14 | protected Duration defaultTimeoutSecForImplicitlyWait; 15 | 16 | public WebDriverOperations(WebDriver webDriver) { 17 | this.webDriver = webDriver; 18 | } 19 | 20 | /** 21 | * Set the default timeout value of the waiting process to find the element. 22 | * @param defaultTimeoutSecForImplicitlyWait The default timeout value of the waiting process to 23 | * find the element (s) 24 | */ 25 | public void setDefaultTimeoutForImplicitlyWait(Duration defaultTimeoutSecForImplicitlyWait) { 26 | this.defaultTimeoutSecForImplicitlyWait = defaultTimeoutSecForImplicitlyWait; 27 | } 28 | 29 | /** 30 | * Check the specified element exists. 31 | * @param by Identifier to look for elements 32 | * @return And returns true if the specified element is present. 33 | */ 34 | public boolean exists(By by) { 35 | webDriver.findElement(By.tagName("body")); 36 | setTimeoutForImplicitlyWait(Duration.ZERO); 37 | boolean existsElement = true; 38 | try { 39 | webDriver.findElement(by).getText(); 40 | } catch (NoSuchElementException e) { 41 | existsElement = false; 42 | } finally { 43 | setDefaultTimeoutForImplicitlyWait(); 44 | } 45 | return existsElement; 46 | } 47 | 48 | /** 49 | * Set to the default value of the timeout value waiting process to find the element. 50 | */ 51 | public void setDefaultTimeoutForImplicitlyWait() { 52 | setTimeoutForImplicitlyWait(this.defaultTimeoutSecForImplicitlyWait); 53 | } 54 | 55 | /** 56 | * Set the time-out value of the waiting process to find the element. 57 | */ 58 | public void setTimeoutForImplicitlyWait(Duration duration) { 59 | webDriver.manage().timeouts().implicitlyWait(duration); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /parts/JavaConfig-NoORM/projectName-domain/src/main/java/xxxxxx/yyyyyy/zzzzzz/config/app/ProjectNameDomainConfig.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.config.app; 2 | 3 | import org.springframework.aop.Advisor; 4 | import org.springframework.aop.aspectj.AspectJExpressionPointcut; 5 | import org.springframework.aop.support.DefaultPointcutAdvisor; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.context.annotation.Import; 10 | import org.terasoluna.gfw.common.exception.ExceptionLogger; 11 | import org.terasoluna.gfw.common.exception.ResultMessagesLoggingInterceptor; 12 | 13 | /** 14 | * Bean definitions for domain layer. 15 | */ 16 | @Configuration 17 | @ComponentScan(basePackages = {"xxxxxx.yyyyyy.zzzzzz.domain"}) 18 | @Import({ProjectNameInfraConfig.class, ProjectNameCodeListConfig.class}) 19 | public class ProjectNameDomainConfig { 20 | 21 | /** 22 | * Configure messages logging AOP. 23 | * @param exceptionLogger Bean defined by ApplicationContextConfig#exceptionLogger 24 | * @see xxxxxx.yyyyyy.zzzzzz.config.app.ApplicationContextConfig#exceptionLogger() 25 | * @return Bean of configured {@link ResultMessagesLoggingInterceptor} 26 | */ 27 | @Bean("resultMessagesLoggingInterceptor") 28 | public ResultMessagesLoggingInterceptor resultMessagesLoggingInterceptor( 29 | ExceptionLogger exceptionLogger) { 30 | ResultMessagesLoggingInterceptor bean = new ResultMessagesLoggingInterceptor(); 31 | bean.setExceptionLogger(exceptionLogger); 32 | return bean; 33 | } 34 | 35 | /** 36 | * Configure messages logging AOP advisor. 37 | * @param resultMessagesLoggingInterceptor Bean defined by #resultMessagesLoggingInterceptor 38 | * @see #resultMessagesLoggingInterceptor(ExceptionLogger) 39 | * @return Advisor configured for PointCut 40 | */ 41 | @Bean 42 | public Advisor resultMessagesLoggingInterceptorAdvisor( 43 | ResultMessagesLoggingInterceptor resultMessagesLoggingInterceptor) { 44 | AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut(); 45 | pointcut.setExpression("@within(org.springframework.stereotype.Service)"); 46 | return new DefaultPointcutAdvisor(pointcut, resultMessagesLoggingInterceptor); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /parts/JavaConfig/projectName-domain/src/main/java/xxxxxx/yyyyyy/zzzzzz/config/app/ProjectNameDomainConfig.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.config.app; 2 | 3 | import org.springframework.aop.Advisor; 4 | import org.springframework.aop.aspectj.AspectJExpressionPointcut; 5 | import org.springframework.aop.support.DefaultPointcutAdvisor; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.context.annotation.Import; 10 | import org.springframework.transaction.annotation.EnableTransactionManagement; 11 | import org.terasoluna.gfw.common.exception.ExceptionLogger; 12 | import org.terasoluna.gfw.common.exception.ResultMessagesLoggingInterceptor; 13 | 14 | /** 15 | * Bean definitions for domain layer. 16 | */ 17 | @Configuration 18 | @EnableTransactionManagement 19 | @ComponentScan(basePackages = {"xxxxxx.yyyyyy.zzzzzz.domain"}) 20 | @Import({ProjectNameInfraConfig.class, ProjectNameCodeListConfig.class}) 21 | public class ProjectNameDomainConfig { 22 | 23 | /** 24 | * Configure {@link ResultMessagesLoggingInterceptor} bean. 25 | * @param exceptionLogger Bean defined by ApplicationContextConfig#exceptionLogger 26 | * @see xxxxxx.yyyyyy.zzzzzz.config.app.ApplicationContextConfig#exceptionLogger() 27 | * @return Bean of configured {@link ResultMessagesLoggingInterceptor} 28 | */ 29 | @Bean("resultMessagesLoggingInterceptor") 30 | public ResultMessagesLoggingInterceptor resultMessagesLoggingInterceptor( 31 | ExceptionLogger exceptionLogger) { 32 | ResultMessagesLoggingInterceptor bean = new ResultMessagesLoggingInterceptor(); 33 | bean.setExceptionLogger(exceptionLogger); 34 | return bean; 35 | } 36 | 37 | /** 38 | * Configure messages logging AOP advisor. 39 | * @param resultMessagesLoggingInterceptor Bean defined by #resultMessagesLoggingInterceptor 40 | * @see #resultMessagesLoggingInterceptor(ExceptionLogger) 41 | * @return Advisor configured for PointCut 42 | */ 43 | @Bean 44 | public Advisor resultMessagesLoggingInterceptorAdvisor( 45 | ResultMessagesLoggingInterceptor resultMessagesLoggingInterceptor) { 46 | AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut(); 47 | pointcut.setExpression("@within(org.springframework.stereotype.Service)"); 48 | return new DefaultPointcutAdvisor(pointcut, resultMessagesLoggingInterceptor); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /parts/XMLConfig/projectName-env/src/main/resources/META-INF/spring/projectName-env.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 29 | 30 | 31 | 32 | 33 | 39 | 46 | -------------------------------------------------------------------------------- /parts/XMLConfig-Thymeleaf/projectName-web/src/main/resources/META-INF/spring/spring-security.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 27 | 29 | 31 | 32 | 33 | 35 | 37 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /parts/XMLConfig-JSP/projectName-web/src/main/resources/META-INF/spring/spring-security.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 27 | 29 | 31 | 32 | 33 | 35 | 37 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /testScript/parts/base/projectName-web/src/main/java/xxxxxx/yyyyyy/zzzzzz/app/errortest/TestErrorController.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.app.errortest; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import jakarta.servlet.http.HttpServletRequest; 8 | 9 | /** 10 | * Error page test controller 11 | */ 12 | @Controller 13 | @RequestMapping("/test/error") 14 | public class TestErrorController { 15 | 16 | @GetMapping("/accessDeniedError") 17 | public String accessDeniedError(HttpServletRequest request, Model model) { 18 | model.addAttribute("exceptionCode", "e.xx.fw.7003"); 19 | return "common/error/accessDeniedError"; 20 | } 21 | 22 | @GetMapping("/businessError") 23 | public String businessError(HttpServletRequest request, Model model) { 24 | model.addAttribute("exceptionCode", "e.xx.fw.8001"); 25 | return "common/error/businessError"; 26 | } 27 | 28 | @GetMapping("/dataAccessError") 29 | public String dataAccessError(HttpServletRequest request, Model model) { 30 | model.addAttribute("exceptionCode", "e.xx.fw.9002"); 31 | return "common/error/dataAccessError"; 32 | } 33 | 34 | @GetMapping("/invalidCsrfTokenError") 35 | public String invalidCsrfTokenError(HttpServletRequest request, Model model) { 36 | model.addAttribute("exceptionCode", "e.xx.fw.7002"); 37 | return "common/error/invalidCsrfTokenError"; 38 | } 39 | 40 | @GetMapping("/missingCsrfTokenError") 41 | public String missingCsrfTokenError(HttpServletRequest request, Model model) { 42 | model.addAttribute("exceptionCode", "e.xx.fw.7004"); 43 | return "common/error/missingCsrfTokenError"; 44 | } 45 | 46 | @GetMapping("/resourceNotFoundError") 47 | public String resourceNotFoundError(HttpServletRequest request, Model model) { 48 | model.addAttribute("exceptionCode", "e.xx.fw.5001"); 49 | return "common/error/resourceNotFoundError"; 50 | } 51 | 52 | @GetMapping("/systemError") 53 | public String systemError(HttpServletRequest request, Model model) { 54 | model.addAttribute("exceptionCode", "e.xx.fw.9001"); 55 | return "common/error/systemError"; 56 | } 57 | 58 | @GetMapping("/transactionTokenError") 59 | public String transactionTokenError(HttpServletRequest request, Model model) { 60 | model.addAttribute("exceptionCode", "e.xx.fw.7001"); 61 | return "common/error/transactionTokenError"; 62 | } 63 | 64 | @GetMapping("/other") 65 | public String unhandledSystemError(HttpServletRequest request) { 66 | return "errortest/otherError"; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /parts/JavaConfig-JPA/projectName-domain/src/main/java/xxxxxx/yyyyyy/zzzzzz/config/app/ProjectNameInfraConfig.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.config.app; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import javax.sql.DataSource; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.context.annotation.Import; 10 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 11 | import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; 12 | import org.springframework.orm.jpa.vendor.Database; 13 | import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; 14 | 15 | /** 16 | * Bean definitions for infrastructure layer. 17 | */ 18 | @Configuration 19 | @EnableJpaRepositories("xxxxxx.yyyyyy.zzzzzz.domain.repository") 20 | @Import({ProjectNameEnvConfig.class}) 21 | public class ProjectNameInfraConfig { 22 | 23 | /** 24 | * Database property. 25 | */ 26 | @Value("${database}") 27 | private Database database; 28 | 29 | /** 30 | * Configure {@link HibernateJpaVendorAdapter} bean. 31 | * @return Bean of configured {@link HibernateJpaVendorAdapter} 32 | */ 33 | @Bean("jpaVendorAdapter") 34 | public HibernateJpaVendorAdapter jpaVendorAdapter() { 35 | HibernateJpaVendorAdapter bean = new HibernateJpaVendorAdapter(); 36 | bean.setDatabase(database); 37 | return bean; 38 | } 39 | 40 | /** 41 | * Configure {@link LocalContainerEntityManagerFactoryBean} bean. 42 | * @param dataSource DataSource 43 | * @return Bean of configured {@link LocalContainerEntityManagerFactoryBean} 44 | */ 45 | @Bean("entityManagerFactory") 46 | public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) { 47 | LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean(); 48 | bean.setPackagesToScan("xxxxxx.yyyyyy.zzzzzz.domain.model"); 49 | bean.setDataSource(dataSource); 50 | bean.setJpaVendorAdapter(jpaVendorAdapter()); 51 | bean.setJpaPropertyMap(jpaPropertyMap()); 52 | return bean; 53 | } 54 | 55 | /** 56 | * Configure {@link LocalContainerEntityManagerFactoryBean}.JpaPropertyMap. 57 | * @return configured JpaPropertyMap 58 | */ 59 | private Map jpaPropertyMap() { 60 | Map jpaPropertyMap = new HashMap<>(); 61 | jpaPropertyMap.put("hibernate.connection.charSet", "UTF-8"); 62 | jpaPropertyMap.put("hibernate.format_sql", false); 63 | jpaPropertyMap.put("hibernate.use_sql_comments", true); 64 | jpaPropertyMap.put("hibernate.jdbc.batch_size", 30); 65 | jpaPropertyMap.put("hibernate.jdbc.fetch_size", 100); 66 | return jpaPropertyMap; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /parts/MyBatis3/projectName-domain/src/main/resources/xxxxxx/yyyyyy/zzzzzz/domain/repository/sample/SampleRepository.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 104 | 105 | -------------------------------------------------------------------------------- /testScript/parts/JavaConfig/projectName-selenium/src/test/java/xxxxxx/yyyyyy/zzzzzz/config/SeleniumContextConfig.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.config; 2 | 3 | import org.openqa.selenium.WebDriver; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.context.annotation.Profile; 8 | import org.springframework.context.annotation.Scope; 9 | import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; 10 | import org.springframework.core.io.Resource; 11 | 12 | import xxxxxx.yyyyyy.zzzzzz.selenium.webdrivers.ChromeDriverFactoryBean; 13 | import xxxxxx.yyyyyy.zzzzzz.selenium.webdrivers.EdgeDriverFactoryBean; 14 | import xxxxxx.yyyyyy.zzzzzz.selenium.webdrivers.FirefoxDriverFactoryBean; 15 | 16 | /** 17 | * Bean definition to SeleniumContext configure . 18 | */ 19 | @Configuration 20 | public class SeleniumContextConfig { 21 | 22 | /** 23 | * selenium.headless property. 24 | */ 25 | @Value("${selenium.headless}") 26 | private boolean headless; 27 | 28 | /** 29 | * Configure {@link PropertySourcesPlaceholderConfigurer} bean. 30 | * @param properties Path where the property file is located 31 | * @return Bean of configured {@link PropertySourcesPlaceholderConfigurer} 32 | */ 33 | @Bean 34 | public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer( 35 | @Value("classpath*:META-INF/spring/*.properties") Resource... properties) { 36 | PropertySourcesPlaceholderConfigurer bean = new PropertySourcesPlaceholderConfigurer(); 37 | bean.setLocations(properties); 38 | return bean; 39 | } 40 | 41 | /** 42 | * Configure {@link WebDriver} bean. 43 | * @return Bean of configured {@link FirefoxDriverFactoryBean} 44 | */ 45 | @Bean("webDriver") 46 | @Scope("prototype") 47 | @Profile({"firefox", "default"}) 48 | public FirefoxDriverFactoryBean firefoxDriverFactoryBean() { 49 | FirefoxDriverFactoryBean bean = new FirefoxDriverFactoryBean(); 50 | bean.setPropertyFileLocation("wdm.properties"); 51 | bean.setHeadless(this.headless); 52 | return bean; 53 | } 54 | 55 | /** 56 | * Configure {@link WebDriver} bean. 57 | * @return Bean of configured {@link ChromeDriverFactoryBean} 58 | */ 59 | @Bean("webDriver") 60 | @Scope("prototype") 61 | @Profile("chrome") 62 | public ChromeDriverFactoryBean chromeDriverFactoryBean() { 63 | ChromeDriverFactoryBean bean = new ChromeDriverFactoryBean(); 64 | bean.setPropertyFileLocation("wdm.properties"); 65 | bean.setHeadless(this.headless); 66 | return bean; 67 | } 68 | 69 | /** 70 | * Configure {@link WebDriver} bean. 71 | * @return Bean of configured {@link EdgeDriverFactoryBean} 72 | */ 73 | @Bean("webDriver") 74 | @Scope("prototype") 75 | @Profile("edge") 76 | public EdgeDriverFactoryBean edgeDriverFactoryBean() { 77 | EdgeDriverFactoryBean bean = new EdgeDriverFactoryBean(); 78 | bean.setPropertyFileLocation("wdm.properties"); 79 | bean.setHeadless(this.headless); 80 | return bean; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /parts/base/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | ${app.log.dir:-log}/projectName-application.log 13 | 14 | ${app.log.dir:-log}/projectName-application-%d{yyyyMMdd}.log 15 | 7 16 | 17 | 18 | UTF-8 19 | 20 | 21 | 22 | 23 | 24 | ${app.log.dir:-log}/projectName-monitoring.log 25 | 26 | ${app.log.dir:-log}/projectName-monitoring-%d{yyyyMMdd}.log 27 | 7 28 | 29 | 30 | UTF-8 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 62 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /parts/XMLConfig/projectName-web/src/main/resources/META-INF/spring/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 30 | 31 | 32 | 33 | 34 | 36 | 37 | 38 | 40 | 41 | 42 | i18n/application-messages 43 | 44 | 45 | 46 | 47 | 48 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 65 | 66 | 67 | 68 | 69 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /testScript/parts/XMLConfig/projectName-web/src/test/java/xxxxxx/yyyyyy/zzzzzz/mocktest/error/CsrfTokenErrorTest.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.mocktest.error; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; 5 | import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.log; 6 | import org.junit.jupiter.api.AfterEach; 7 | import org.junit.jupiter.api.BeforeEach; 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.springframework.beans.factory.annotation.Value; 13 | import org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers; 14 | import org.springframework.test.context.ContextConfiguration; 15 | import org.springframework.test.context.ContextHierarchy; 16 | import org.springframework.test.context.junit.jupiter.SpringExtension; 17 | import org.springframework.test.context.web.WebAppConfiguration; 18 | import org.springframework.test.web.servlet.assertj.MockMvcTester; 19 | import org.springframework.test.web.servlet.assertj.MvcTestResult; 20 | import org.springframework.web.context.WebApplicationContext; 21 | import jakarta.inject.Inject; 22 | 23 | /** 24 | * Run test for Csrf Token error. 25 | */ 26 | @ExtendWith(SpringExtension.class) 27 | @ContextHierarchy({ 28 | @ContextConfiguration({"classpath:META-INF/spring/applicationContext.xml", 29 | "classpath:META-INF/spring/spring-security.xml"}), 30 | @ContextConfiguration("classpath:META-INF/spring/spring-mvc.xml")}) 31 | @WebAppConfiguration 32 | public class CsrfTokenErrorTest { 33 | 34 | private static final Logger logger = LoggerFactory.getLogger(CsrfTokenErrorTest.class); 35 | 36 | @Inject 37 | private WebApplicationContext webApplicationContext; 38 | 39 | private MockMvcTester mockMvc; 40 | 41 | @Value("${invalidCsrfTokenError.forwardedUrl}") 42 | private String invalidCsrfTokenErrorForwardedUrl; 43 | 44 | @Value("${missingCsrfTokenError.forwardedUrl}") 45 | private String missingCsrfTokenErrorForwardedUrl; 46 | 47 | @BeforeEach 48 | public void setUp() { 49 | mockMvc = MockMvcTester.from(webApplicationContext, builder -> builder.alwaysDo(log()) 50 | .apply(SecurityMockMvcConfigurers.springSecurity()).build()); 51 | } 52 | 53 | /** 54 | * Invalid CSRF token error page. Confirm that you are transitioning to the above page. 55 | * @throws Exception 56 | */ 57 | @Test 58 | public void testInvalidCsrfTokenError() throws Exception { 59 | 60 | // Mockmvc test. 61 | MvcTestResult results = mockMvc.post().uri("/").with(csrf().useInvalidToken()).exchange(); 62 | 63 | logger.debug("testInvalidCsrfTokenError#status:" + results.getResponse().getStatus()); 64 | logger.debug("testInvalidCsrfTokenError#forwardedUrl:" 65 | + results.getResponse().getForwardedUrl()); 66 | 67 | assertThat(results).hasStatus(403).hasForwardedUrl(invalidCsrfTokenErrorForwardedUrl); 68 | } 69 | 70 | /** 71 | * CSRF token missing error page. Confirm that you are transitioning to the above page. 72 | * @throws Exception 73 | */ 74 | @Test 75 | public void testMissingCsrfTokenError() throws Exception { 76 | 77 | // Mockmvc test. 78 | MvcTestResult results = mockMvc.post().uri("/").exchange(); 79 | 80 | logger.debug("testMissingCsrfTokenError#status:" + results.getResponse().getStatus()); 81 | logger.debug("testMissingCsrfTokenError#forwardedUrl:" 82 | + results.getResponse().getForwardedUrl()); 83 | 84 | assertThat(results).hasStatus(403).hasForwardedUrl(missingCsrfTokenErrorForwardedUrl); 85 | } 86 | 87 | @AfterEach 88 | public void tearDown() {} 89 | } 90 | -------------------------------------------------------------------------------- /testScript/parts/JavaConfig/projectName-web/src/test/java/xxxxxx/yyyyyy/zzzzzz/mocktest/error/CsrfTokenErrorTest.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.mocktest.error; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; 5 | import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.log; 6 | import org.junit.jupiter.api.AfterEach; 7 | import org.junit.jupiter.api.BeforeEach; 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.springframework.beans.factory.annotation.Value; 13 | import org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers; 14 | import org.springframework.test.context.ContextConfiguration; 15 | import org.springframework.test.context.ContextHierarchy; 16 | import org.springframework.test.context.junit.jupiter.SpringExtension; 17 | import org.springframework.test.context.web.WebAppConfiguration; 18 | import org.springframework.test.web.servlet.assertj.MockMvcTester; 19 | import org.springframework.test.web.servlet.assertj.MvcTestResult; 20 | import org.springframework.web.context.WebApplicationContext; 21 | import jakarta.inject.Inject; 22 | 23 | import xxxxxx.yyyyyy.zzzzzz.config.app.ApplicationContextConfig; 24 | import xxxxxx.yyyyyy.zzzzzz.config.web.SpringMvcConfig; 25 | import xxxxxx.yyyyyy.zzzzzz.config.web.SpringSecurityConfig; 26 | 27 | /** 28 | * Run test for Csrf Token error. 29 | */ 30 | @ExtendWith(SpringExtension.class) 31 | @ContextHierarchy({ 32 | @ContextConfiguration( 33 | classes = {ApplicationContextConfig.class, SpringSecurityConfig.class}), 34 | @ContextConfiguration(classes = {SpringMvcConfig.class})}) 35 | @WebAppConfiguration 36 | public class CsrfTokenErrorTest { 37 | 38 | private static final Logger logger = LoggerFactory.getLogger(CsrfTokenErrorTest.class); 39 | 40 | @Inject 41 | private WebApplicationContext webApplicationContext; 42 | 43 | private MockMvcTester mockMvc; 44 | 45 | @Value("${invalidCsrfTokenError.forwardedUrl}") 46 | private String invalidCsrfTokenErrorForwardedUrl; 47 | 48 | @Value("${missingCsrfTokenError.forwardedUrl}") 49 | private String missingCsrfTokenErrorForwardedUrl; 50 | 51 | @BeforeEach 52 | public void setUp() { 53 | mockMvc = MockMvcTester.from(webApplicationContext, builder -> builder.alwaysDo(log()) 54 | .apply(SecurityMockMvcConfigurers.springSecurity()).build()); 55 | } 56 | 57 | /** 58 | * Invalid CSRF token error page. Confirm that you are transitioning to the above page. 59 | * @throws Exception 60 | */ 61 | @Test 62 | public void testInvalidCsrfTokenError() throws Exception { 63 | 64 | // Mockmvc test. 65 | MvcTestResult results = mockMvc.post().uri("/").with(csrf().useInvalidToken()).exchange(); 66 | 67 | logger.debug("testInvalidCsrfTokenError#status:" + results.getResponse().getStatus()); 68 | logger.debug("testInvalidCsrfTokenError#forwardedUrl:" 69 | + results.getResponse().getForwardedUrl()); 70 | 71 | assertThat(results).hasStatus(403).hasForwardedUrl(invalidCsrfTokenErrorForwardedUrl); 72 | } 73 | 74 | /** 75 | * CSRF token missing error page. Confirm that you are transitioning to the above page. 76 | * @throws Exception 77 | */ 78 | @Test 79 | public void testMissingCsrfTokenError() throws Exception { 80 | 81 | // Mockmvc test. 82 | MvcTestResult results = mockMvc.post().uri("/").exchange(); 83 | 84 | logger.debug("testMissingCsrfTokenError#status:" + results.getResponse().getStatus()); 85 | logger.debug("testMissingCsrfTokenError#forwardedUrl:" 86 | + results.getResponse().getForwardedUrl()); 87 | 88 | assertThat(results).hasStatus(403).hasForwardedUrl(missingCsrfTokenErrorForwardedUrl); 89 | } 90 | 91 | @AfterEach 92 | public void tearDown() {} 93 | } 94 | -------------------------------------------------------------------------------- /testScript/parts/XMLConfig/projectName-web/src/test/java/xxxxxx/yyyyyy/zzzzzz/mocktest/welcome/HelloTest.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.mocktest.welcome; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.mockito.Mockito.times; 5 | import static org.mockito.Mockito.verify; 6 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 7 | import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.log; 8 | import java.util.List; 9 | import java.util.Locale; 10 | import org.junit.jupiter.api.AfterEach; 11 | import org.junit.jupiter.api.BeforeEach; 12 | import org.junit.jupiter.api.Test; 13 | import org.junit.jupiter.api.extension.ExtendWith; 14 | import org.mockito.ArgumentCaptor; 15 | import org.mockito.Captor; 16 | import org.mockito.Mock; 17 | import org.mockito.junit.jupiter.MockitoExtension; 18 | import org.slf4j.LoggerFactory; 19 | import org.springframework.test.context.ContextConfiguration; 20 | import org.springframework.test.context.ContextHierarchy; 21 | import org.springframework.test.context.junit.jupiter.SpringExtension; 22 | import org.springframework.test.context.web.WebAppConfiguration; 23 | import org.springframework.test.web.servlet.MockMvc; 24 | import org.springframework.test.web.servlet.ResultActions; 25 | import org.springframework.test.web.servlet.setup.MockMvcBuilders; 26 | import org.springframework.web.context.WebApplicationContext; 27 | import org.springframework.web.servlet.ModelAndView; 28 | import ch.qos.logback.classic.Level; 29 | import ch.qos.logback.classic.Logger; 30 | import ch.qos.logback.classic.spi.ILoggingEvent; 31 | import ch.qos.logback.classic.spi.LoggingEvent; 32 | import ch.qos.logback.core.Appender; 33 | import jakarta.inject.Inject; 34 | 35 | import xxxxxx.yyyyyy.zzzzzz.app.welcome.HelloController; 36 | 37 | /** 38 | * Run a unit test on HelloController. 39 | */ 40 | @ExtendWith({SpringExtension.class, MockitoExtension.class}) 41 | @ContextHierarchy({ 42 | @ContextConfiguration({"classpath:META-INF/spring/applicationContext.xml", 43 | "classpath:META-INF/spring/spring-security.xml"}), 44 | @ContextConfiguration({"classpath:META-INF/spring/spring-mvc.xml"})}) 45 | @WebAppConfiguration 46 | public class HelloTest { 47 | 48 | @Inject 49 | private WebApplicationContext webApplicationContext; 50 | 51 | private MockMvc mockMvc; 52 | 53 | private Logger logger; 54 | 55 | @Mock 56 | private Appender mockAppender; 57 | 58 | @Captor 59 | private ArgumentCaptor captorLoggingEvent; 60 | 61 | @BeforeEach 62 | public void setUp() { 63 | mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).alwaysDo(log()).build(); 64 | } 65 | 66 | /** 67 | * Run the HelloController's internal tests. 68 | * @throws Exception 69 | */ 70 | @Test 71 | public void testTraceLoggingInterceptor() throws Exception { 72 | 73 | // Mock the Appender and capture the output contents. 74 | logger = (Logger) LoggerFactory.getLogger(HelloController.class); 75 | logger.addAppender(mockAppender); 76 | 77 | // Mockmvc test. 78 | ResultActions result = mockMvc.perform(get("/").header("Accept-Language", "en")); 79 | 80 | verify(mockAppender, times(1)).doAppend(captorLoggingEvent.capture()); 81 | List events = captorLoggingEvent.getAllValues(); 82 | 83 | // Confirmation of log output contents 84 | assertThat(events.get(0).getLevel()).isEqualTo(Level.INFO); 85 | assertThat(events.get(0).getFormattedMessage()) 86 | .isEqualTo("Welcome home! The client locale is " + Locale.ENGLISH + "."); 87 | // Confirmation of model settings 88 | ModelAndView mv = result.andReturn().getModelAndView(); 89 | String serverTime = (String) mv.getModel().get("serverTime"); 90 | assertThat(serverTime.matches( 91 | "^[a-zA-Z]{3,9}.\\d{1,2},.\\d{4},.\\d{1,2}:\\d{1,2}:\\d{1,2}.(AM|PM)$")) 92 | .isTrue(); 93 | } 94 | 95 | @AfterEach 96 | public void tearDown() {} 97 | } 98 | -------------------------------------------------------------------------------- /parts/JavaConfig-Thymeleaf/projectName-web/src/main/java/xxxxxx/yyyyyy/zzzzzz/config/web/SpringSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.config.web; 2 | 3 | import java.util.LinkedHashMap; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.security.access.AccessDeniedException; 7 | import org.springframework.security.config.Customizer; 8 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 9 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 10 | import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; 11 | import org.springframework.security.web.SecurityFilterChain; 12 | import org.springframework.security.web.access.AccessDeniedHandler; 13 | import org.springframework.security.web.access.AccessDeniedHandlerImpl; 14 | import org.springframework.security.web.access.DelegatingAccessDeniedHandler; 15 | import org.springframework.security.web.authentication.AnonymousAuthenticationFilter; 16 | import org.springframework.security.web.csrf.InvalidCsrfTokenException; 17 | import org.springframework.security.web.csrf.MissingCsrfTokenException; 18 | import org.terasoluna.gfw.security.web.logging.UserIdMDCPutFilter; 19 | 20 | /** 21 | * Bean definition to configure SpringSecurity. 22 | */ 23 | @Configuration 24 | @EnableWebSecurity 25 | public class SpringSecurityConfig { 26 | 27 | /** 28 | * Configure ignore security pattern. 29 | * @return Bean of configured {@link WebSecurityCustomizer} 30 | */ 31 | @Bean 32 | public WebSecurityCustomizer webSecurityCustomizer() { 33 | return web -> web.ignoring().requestMatchers("/resources/**"); 34 | } 35 | 36 | /** 37 | * Configure {@link SecurityFilterChain} bean. 38 | * @param http Builder class for setting up authentication and authorization 39 | * @return Bean of configured {@link SecurityFilterChain} 40 | * @throws Exception Exception that occurs when setting HttpSecurity 41 | */ 42 | @Bean 43 | public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { 44 | http.formLogin(Customizer.withDefaults()); 45 | http.logout(Customizer.withDefaults()); 46 | http.exceptionHandling(ex -> ex.accessDeniedHandler(accessDeniedHandler())); 47 | http.addFilterAfter(userIdMDCPutFilter(), AnonymousAuthenticationFilter.class); 48 | http.sessionManagement(Customizer.withDefaults()); 49 | http.authorizeHttpRequests(authz -> authz.requestMatchers("/**").permitAll()); 50 | 51 | return http.build(); 52 | } 53 | 54 | /** 55 | * Configure {@link AccessDeniedHandler} bean. 56 | * @return Bean of configured {@link AccessDeniedHandler} 57 | */ 58 | @Bean("accessDeniedHandler") 59 | public AccessDeniedHandler accessDeniedHandler() { 60 | LinkedHashMap, AccessDeniedHandler> errorHandlers = 61 | new LinkedHashMap<>(); 62 | 63 | // Invalid CSRF authenticator error handler 64 | AccessDeniedHandlerImpl invalidCsrfTokenErrorHandler = new AccessDeniedHandlerImpl(); 65 | invalidCsrfTokenErrorHandler.setErrorPage("/common/error/invalidCsrfTokenError"); 66 | errorHandlers.put(InvalidCsrfTokenException.class, invalidCsrfTokenErrorHandler); 67 | 68 | // Missing CSRF authenticator error handler 69 | AccessDeniedHandlerImpl missingCsrfTokenErrorHandler = new AccessDeniedHandlerImpl(); 70 | missingCsrfTokenErrorHandler.setErrorPage("/common/error/missingCsrfTokenError"); 71 | errorHandlers.put(MissingCsrfTokenException.class, missingCsrfTokenErrorHandler); 72 | 73 | // Default error handler 74 | AccessDeniedHandlerImpl defaultErrorHandler = new AccessDeniedHandlerImpl(); 75 | defaultErrorHandler.setErrorPage("/common/error/accessDeniedError"); 76 | 77 | return new DelegatingAccessDeniedHandler(errorHandlers, defaultErrorHandler); 78 | } 79 | 80 | /** 81 | * Configure {@link UserIdMDCPutFilter} bean. 82 | * @return Bean of configured {@link UserIdMDCPutFilter} 83 | */ 84 | @Bean("userIdMDCPutFilter") 85 | public UserIdMDCPutFilter userIdMDCPutFilter() { 86 | return new UserIdMDCPutFilter(); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /testScript/parts/JavaConfig/projectName-web/src/test/java/xxxxxx/yyyyyy/zzzzzz/mocktest/welcome/HelloTest.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.mocktest.welcome; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.mockito.Mockito.times; 5 | import static org.mockito.Mockito.verify; 6 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 7 | import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.log; 8 | import java.util.List; 9 | import java.util.Locale; 10 | import org.junit.jupiter.api.AfterEach; 11 | import org.junit.jupiter.api.BeforeEach; 12 | import org.junit.jupiter.api.Test; 13 | import org.junit.jupiter.api.extension.ExtendWith; 14 | import org.mockito.ArgumentCaptor; 15 | import org.mockito.Captor; 16 | import org.mockito.Mock; 17 | import org.mockito.junit.jupiter.MockitoExtension; 18 | import org.slf4j.LoggerFactory; 19 | import org.springframework.test.context.ContextConfiguration; 20 | import org.springframework.test.context.ContextHierarchy; 21 | import org.springframework.test.context.junit.jupiter.SpringExtension; 22 | import org.springframework.test.context.web.WebAppConfiguration; 23 | import org.springframework.test.web.servlet.MockMvc; 24 | import org.springframework.test.web.servlet.ResultActions; 25 | import org.springframework.test.web.servlet.setup.MockMvcBuilders; 26 | import org.springframework.web.context.WebApplicationContext; 27 | import org.springframework.web.servlet.ModelAndView; 28 | import ch.qos.logback.classic.Level; 29 | import ch.qos.logback.classic.Logger; 30 | import ch.qos.logback.classic.spi.ILoggingEvent; 31 | import ch.qos.logback.classic.spi.LoggingEvent; 32 | import ch.qos.logback.core.Appender; 33 | import jakarta.inject.Inject; 34 | 35 | import xxxxxx.yyyyyy.zzzzzz.app.welcome.HelloController; 36 | import xxxxxx.yyyyyy.zzzzzz.config.app.ApplicationContextConfig; 37 | import xxxxxx.yyyyyy.zzzzzz.config.web.SpringMvcConfig; 38 | import xxxxxx.yyyyyy.zzzzzz.config.web.SpringSecurityConfig; 39 | 40 | /** 41 | * Run a unit test on HelloController. 42 | */ 43 | @ExtendWith({SpringExtension.class, MockitoExtension.class}) 44 | @ContextHierarchy({ 45 | @ContextConfiguration( 46 | classes = {ApplicationContextConfig.class, SpringSecurityConfig.class}), 47 | @ContextConfiguration(classes = {SpringMvcConfig.class})}) 48 | @WebAppConfiguration 49 | public class HelloTest { 50 | 51 | @Inject 52 | private WebApplicationContext webApplicationContext; 53 | 54 | private MockMvc mockMvc; 55 | 56 | private Logger logger; 57 | 58 | @Mock 59 | private Appender mockAppender; 60 | 61 | @Captor 62 | private ArgumentCaptor captorLoggingEvent; 63 | 64 | @BeforeEach 65 | public void setUp() { 66 | mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).alwaysDo(log()).build(); 67 | } 68 | 69 | /** 70 | * Run the HelloController's internal tests. 71 | * @throws Exception 72 | */ 73 | @Test 74 | public void testTraceLoggingInterceptor() throws Exception { 75 | 76 | // Mock the Appender and capture the output contents. 77 | logger = (Logger) LoggerFactory.getLogger(HelloController.class); 78 | logger.addAppender(mockAppender); 79 | 80 | // Mockmvc test. 81 | ResultActions result = mockMvc.perform(get("/").header("Accept-Language", "en")); 82 | 83 | verify(mockAppender, times(1)).doAppend(captorLoggingEvent.capture()); 84 | List events = captorLoggingEvent.getAllValues(); 85 | 86 | // Confirmation of log output contents 87 | assertThat(events.get(0).getLevel()).isEqualTo(Level.INFO); 88 | assertThat(events.get(0).getFormattedMessage()) 89 | .isEqualTo("Welcome home! The client locale is " + Locale.ENGLISH + "."); 90 | // Confirmation of model settings 91 | ModelAndView mv = result.andReturn().getModelAndView(); 92 | String serverTime = (String) mv.getModel().get("serverTime"); 93 | assertThat(serverTime.matches( 94 | "^[a-zA-Z]{3,9}.\\d{1,2},.\\d{4},.\\d{1,2}:\\d{1,2}:\\d{1,2}.(AM|PM)$")) 95 | .isTrue(); 96 | } 97 | 98 | @AfterEach 99 | public void tearDown() {} 100 | } 101 | -------------------------------------------------------------------------------- /testScript/addTestResource.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #################################################### 4 | # Shell to apply after project generation. 5 | # Distribute additional test files. 6 | # 7 | # The parameters of this script are as follows. 8 | # $1:Generated blank project path 9 | #################################################### 10 | 11 | set -e 12 | cd $(dirname $0) 13 | WORK_DIR=$1 14 | PROJECT_NAME=$(basename "${WORK_DIR}") 15 | 16 | echo ">>>>> ARGS CHECK" 17 | 18 | if [ ! -n "${WORK_DIR}" ]; then 19 | echo "[Error] Destination directory not specified." 20 | exit -100 21 | fi 22 | 23 | if [ ! -d "${WORK_DIR}" ]; then 24 | echo "[Error] Destination directory does not exist." 25 | exit -101 26 | fi 27 | 28 | if [ ! -d "${WORK_DIR}/src" ]; then 29 | echo "[Error] It's not a single-project configuration." 30 | exit -102 31 | fi 32 | 33 | if [ -e "${WORK_DIR}/src/main/resources/META-INF/spring/applicationContext.xml" ]; then 34 | CONFIG_TYPE="XMLConfig" 35 | else 36 | CONFIG_TYPE="JavaConfig" 37 | fi 38 | 39 | if [ -e "${WORK_DIR}/src/main/webapp/WEB-INF/views/welcome/home.jsp" ]; then 40 | VIEW_TYPE="JSP" 41 | else 42 | VIEW_TYPE="Thymeleaf" 43 | fi 44 | 45 | APP_PATH=$(find "${WORK_DIR}" -name HelloController.java) 46 | PACKAGE_DIR=$(dirname "$APP_PATH") 47 | PACKAGE_DIR=${PACKAGE_DIR#*/java/} 48 | PACKAGE_DIR=${PACKAGE_DIR%/app/*} 49 | PACKAGE_NAME=${PACKAGE_DIR//\//.} 50 | 51 | echo "##########" 52 | echo "WORK_DIR=${WORK_DIR}" 53 | echo "CONFIG_TYPE=${CONFIG_TYPE}" 54 | echo "VIEW_TYPE=${VIEW_TYPE}" 55 | echo "PROJECT_NAME=${PROJECT_NAME}" 56 | echo "PACKAGE_NAME=${PACKAGE_NAME}" 57 | echo "#####################" 58 | 59 | echo ">>>>> CREATE TMP" 60 | rm -fr ./tmp 61 | mkdir -p ./tmp/${PROJECT_NAME} 62 | 63 | echo ">>>>> COPY PARTS" 64 | cp -fr ./parts/base/projectName-*/src ./tmp/${PROJECT_NAME} 65 | cp -fr ./parts/${CONFIG_TYPE}/projectName-*/src ./tmp/${PROJECT_NAME} 66 | cp -fr ./parts/${VIEW_TYPE}/projectName-*/src ./tmp/${PROJECT_NAME} 67 | 68 | echo ">>>>> CHANGE PACKAGE" 69 | mkdir -p ./tmp/${PROJECT_NAME}/src/main/java/${PACKAGE_DIR} 70 | mkdir -p ./tmp/${PROJECT_NAME}/src/test/java/${PACKAGE_DIR} 71 | 72 | mv ./tmp/${PROJECT_NAME}/src/main/java/xxxxxx/yyyyyy/zzzzzz/* ./tmp/${PROJECT_NAME}/src/main/java/${PACKAGE_DIR}/ 73 | mv ./tmp/${PROJECT_NAME}/src/test/java/xxxxxx/yyyyyy/zzzzzz/* ./tmp/${PROJECT_NAME}/src/test/java/${PACKAGE_DIR}/ 74 | rm -fr ./tmp/${PROJECT_NAME}/src/*/java/xxxxxx 75 | 76 | find ./tmp/${PROJECT_NAME} -type f | xargs sed -i -e "s/xxxxxx\.yyyyyy\.zzzzzz/${PACKAGE_NAME}/g" 77 | 78 | echo ">>>>> RENAME PROJECT NAME" 79 | 80 | find ./tmp/${PROJECT_NAME} -type f | xargs sed -i -e "s/projectName-web/${PROJECT_NAME}/g" 81 | 82 | echo ">>>>> ADD DEPENDENCIES" 83 | cp -f ${WORK_DIR}/pom.xml ./tmp/${PROJECT_NAME} 84 | 85 | LF=$(printf '\\\012_') 86 | LF=${LF%_} 87 | 88 | ASSERTJ_DEPENDENCIES_TAG="junit-jupiter<\/artifactId>${LF}" 89 | ASSERTJ_DEPENDENCIES_TAG="${ASSERTJ_DEPENDENCIES_TAG} test<\/scope>${LF}" 90 | ASSERTJ_DEPENDENCIES_TAG="${ASSERTJ_DEPENDENCIES_TAG} <\/dependency>${LF}" 91 | ASSERTJ_DEPENDENCIES_TAG="${ASSERTJ_DEPENDENCIES_TAG} ${LF}" 92 | ASSERTJ_DEPENDENCIES_TAG="${ASSERTJ_DEPENDENCIES_TAG} org.assertj<\/groupId>${LF}" 93 | ASSERTJ_DEPENDENCIES_TAG="${ASSERTJ_DEPENDENCIES_TAG} assertj-core<\/artifactId>" 94 | 95 | sed -i -e "s/junit-jupiter<\/artifactId>/${ASSERTJ_DEPENDENCIES_TAG}/" ./tmp/${PROJECT_NAME}/pom.xml 96 | 97 | SECURITY_DEPENDENCIES_TAG="${LF}" 98 | SECURITY_DEPENDENCIES_TAG="${SECURITY_DEPENDENCIES_TAG} org.springframework.security<\/groupId>${LF}" 99 | SECURITY_DEPENDENCIES_TAG="${SECURITY_DEPENDENCIES_TAG} spring-security-test<\/artifactId>${LF}" 100 | SECURITY_DEPENDENCIES_TAG="${SECURITY_DEPENDENCIES_TAG} test<\/scope>${LF}" 101 | SECURITY_DEPENDENCIES_TAG="${SECURITY_DEPENDENCIES_TAG} <\/dependency>${LF}" 102 | SECURITY_DEPENDENCIES_TAG="${SECURITY_DEPENDENCIES_TAG} " 103 | 104 | sed -i -e "s//${SECURITY_DEPENDENCIES_TAG}/" ./tmp/${PROJECT_NAME}/pom.xml 105 | 106 | echo ">>>>> COPY TMP" 107 | cp -fr ./tmp/${PROJECT_NAME}/* ${WORK_DIR} 108 | 109 | echo ">>>>> END" 110 | 111 | exit 0 112 | -------------------------------------------------------------------------------- /parts/JavaConfig-JSP/projectName-web/src/main/java/xxxxxx/yyyyyy/zzzzzz/config/web/SpringSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.config.web; 2 | 3 | import java.util.LinkedHashMap; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.security.access.AccessDeniedException; 7 | import org.springframework.security.config.Customizer; 8 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 9 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 10 | import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; 11 | import org.springframework.security.web.SecurityFilterChain; 12 | import org.springframework.security.web.access.AccessDeniedHandler; 13 | import org.springframework.security.web.access.AccessDeniedHandlerImpl; 14 | import org.springframework.security.web.access.DelegatingAccessDeniedHandler; 15 | import org.springframework.security.web.authentication.AnonymousAuthenticationFilter; 16 | import org.springframework.security.web.csrf.InvalidCsrfTokenException; 17 | import org.springframework.security.web.csrf.MissingCsrfTokenException; 18 | import org.terasoluna.gfw.security.web.logging.UserIdMDCPutFilter; 19 | 20 | /** 21 | * Bean definition to configure SpringSecurity. 22 | */ 23 | @Configuration 24 | @EnableWebSecurity 25 | public class SpringSecurityConfig { 26 | 27 | /** 28 | * Configure ignore security pattern. 29 | * @return Bean of configured {@link WebSecurityCustomizer} 30 | */ 31 | @Bean 32 | public WebSecurityCustomizer webSecurityCustomizer() { 33 | return web -> web.ignoring().requestMatchers("/resources/**"); 34 | } 35 | 36 | /** 37 | * Configure {@link SecurityFilterChain} bean. 38 | * @param http Builder class for setting up authentication and authorization 39 | * @return Bean of configured {@link SecurityFilterChain} 40 | * @throws Exception Exception that occurs when setting HttpSecurity 41 | */ 42 | @Bean 43 | public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { 44 | http.formLogin(Customizer.withDefaults()); 45 | http.logout(Customizer.withDefaults()); 46 | http.exceptionHandling(ex -> ex.accessDeniedHandler(accessDeniedHandler())); 47 | http.addFilterAfter(userIdMDCPutFilter(), AnonymousAuthenticationFilter.class); 48 | http.sessionManagement(Customizer.withDefaults()); 49 | http.authorizeHttpRequests(authz -> authz.requestMatchers("/**").permitAll()); 50 | 51 | return http.build(); 52 | } 53 | 54 | /** 55 | * Configure {@link AccessDeniedHandler} bean. 56 | * @return Bean of configured {@link AccessDeniedHandler} 57 | */ 58 | @Bean("accessDeniedHandler") 59 | public AccessDeniedHandler accessDeniedHandler() { 60 | LinkedHashMap, AccessDeniedHandler> errorHandlers = 61 | new LinkedHashMap<>(); 62 | 63 | // Invalid CSRF authenticator error handler 64 | AccessDeniedHandlerImpl invalidCsrfTokenErrorHandler = new AccessDeniedHandlerImpl(); 65 | invalidCsrfTokenErrorHandler 66 | .setErrorPage("/WEB-INF/views/common/error/invalidCsrfTokenError.jsp"); 67 | errorHandlers.put(InvalidCsrfTokenException.class, invalidCsrfTokenErrorHandler); 68 | 69 | // Missing CSRF authenticator error handler 70 | AccessDeniedHandlerImpl missingCsrfTokenErrorHandler = new AccessDeniedHandlerImpl(); 71 | missingCsrfTokenErrorHandler 72 | .setErrorPage("/WEB-INF/views/common/error/missingCsrfTokenError.jsp"); 73 | errorHandlers.put(MissingCsrfTokenException.class, missingCsrfTokenErrorHandler); 74 | 75 | // Default error handler 76 | AccessDeniedHandlerImpl defaultErrorHandler = new AccessDeniedHandlerImpl(); 77 | defaultErrorHandler.setErrorPage("/WEB-INF/views/common/error/accessDeniedError.jsp"); 78 | 79 | return new DelegatingAccessDeniedHandler(errorHandlers, defaultErrorHandler); 80 | } 81 | 82 | /** 83 | * Configure {@link UserIdMDCPutFilter} bean. 84 | * @return Bean of configured {@link UserIdMDCPutFilter} 85 | */ 86 | @Bean("userIdMDCPutFilter") 87 | public UserIdMDCPutFilter userIdMDCPutFilter() { 88 | return new UserIdMDCPutFilter(); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /parts/XMLConfig-Thymeleaf/projectName-web/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | logbackDisableServletContainerInitializer 9 | true 10 | 11 | 12 | 13 | ch.qos.logback.classic.servlet.LogbackServletContextListener 14 | 15 | 16 | 17 | org.springframework.web.context.ContextLoaderListener 18 | 19 | 20 | contextConfigLocation 21 | 22 | 23 | classpath*:META-INF/spring/applicationContext.xml 24 | classpath*:META-INF/spring/spring-security.xml 25 | 26 | 27 | 28 | 29 | org.terasoluna.gfw.web.logging.HttpSessionEventLoggingListener 30 | 31 | 32 | 33 | MDCClearFilter 34 | org.terasoluna.gfw.web.logging.mdc.MDCClearFilter 35 | 36 | 37 | MDCClearFilter 38 | /* 39 | 40 | 41 | 42 | exceptionLoggingFilter 43 | org.springframework.web.filter.DelegatingFilterProxy 44 | 45 | 46 | exceptionLoggingFilter 47 | /* 48 | 49 | 50 | 51 | XTrackMDCPutFilter 52 | org.terasoluna.gfw.web.logging.mdc.XTrackMDCPutFilter 53 | 54 | 55 | XTrackMDCPutFilter 56 | /* 57 | 58 | 59 | 60 | CharacterEncodingFilter 61 | org.springframework.web.filter.CharacterEncodingFilter 62 | 63 | encoding 64 | UTF-8 65 | 66 | 67 | forceEncoding 68 | true 69 | 70 | 71 | 72 | CharacterEncodingFilter 73 | /* 74 | 75 | 76 | 77 | springSecurityFilterChain 78 | org.springframework.web.filter.DelegatingFilterProxy 79 | 80 | 81 | springSecurityFilterChain 82 | /* 83 | 84 | 85 | 86 | appServlet 87 | org.springframework.web.servlet.DispatcherServlet 88 | 89 | contextConfigLocation 90 | 91 | classpath*:META-INF/spring/spring-mvc.xml 92 | 93 | 1 94 | 95 | 96 | appServlet 97 | / 98 | 99 | 100 | 101 | 500 102 | /common/error/systemError 103 | 104 | 105 | 106 | 404 107 | /common/error/resourceNotFoundError 108 | 109 | 110 | 111 | java.lang.Exception 112 | /WEB-INF/views/common/error/unhandledSystemError.html 113 | 114 | 115 | 116 | 117 | 30 118 | 119 | true 120 | 121 | 122 | COOKIE 123 | 124 | 125 | -------------------------------------------------------------------------------- /testScript/parts/XMLConfig/projectName-web/src/test/java/xxxxxx/yyyyyy/zzzzzz/mocktest/error/AccessDeniedErrorTest.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.mocktest.error; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.log; 5 | import java.io.IOException; 6 | import org.junit.jupiter.api.AfterEach; 7 | import org.junit.jupiter.api.BeforeEach; 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.springframework.beans.factory.annotation.Value; 13 | import org.springframework.security.access.AccessDeniedException; 14 | import org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers; 15 | import org.springframework.security.web.DefaultSecurityFilterChain; 16 | import org.springframework.security.web.FilterChainProxy; 17 | import org.springframework.security.web.SecurityFilterChain; 18 | import org.springframework.security.web.access.AccessDeniedHandler; 19 | import org.springframework.security.web.util.matcher.AnyRequestMatcher; 20 | import org.springframework.test.context.ContextConfiguration; 21 | import org.springframework.test.context.ContextHierarchy; 22 | import org.springframework.test.context.junit.jupiter.SpringExtension; 23 | import org.springframework.test.context.web.WebAppConfiguration; 24 | import org.springframework.test.web.servlet.assertj.MockMvcTester; 25 | import org.springframework.test.web.servlet.assertj.MvcTestResult; 26 | import org.springframework.web.context.WebApplicationContext; 27 | import org.springframework.web.filter.OncePerRequestFilter; 28 | import jakarta.inject.Inject; 29 | import jakarta.servlet.FilterChain; 30 | import jakarta.servlet.ServletException; 31 | import jakarta.servlet.http.HttpServletRequest; 32 | import jakarta.servlet.http.HttpServletResponse; 33 | 34 | /** 35 | * Run the access denied error test. 36 | */ 37 | @ExtendWith(SpringExtension.class) 38 | @ContextHierarchy({ 39 | @ContextConfiguration({"classpath:META-INF/spring/applicationContext.xml", 40 | "classpath:META-INF/spring/spring-security.xml"}), 41 | @ContextConfiguration("classpath:META-INF/spring/spring-mvc.xml")}) 42 | @WebAppConfiguration 43 | public class AccessDeniedErrorTest { 44 | 45 | private static final Logger logger = LoggerFactory.getLogger(AccessDeniedErrorTest.class); 46 | 47 | @Inject 48 | private WebApplicationContext webApplicationContext; 49 | 50 | private MockMvcTester mockMvc; 51 | 52 | @Inject 53 | private AccessDeniedHandler accessDeniedHandler; 54 | 55 | @Value("${accessDeniedError.forwardedUrl}") 56 | private String accessDeniedErrorForwardedUrl; 57 | 58 | @BeforeEach 59 | public void setUp() { 60 | // Set Filter for Test. 61 | DefaultSecurityFilterChain chain = 62 | new DefaultSecurityFilterChain(AnyRequestMatcher.INSTANCE, new TestFilter()); 63 | TestFilterChainProxy chainProxy = new TestFilterChainProxy(chain); 64 | 65 | mockMvc = MockMvcTester.from(webApplicationContext, builder -> builder.alwaysDo(log()) 66 | .apply(SecurityMockMvcConfigurers.springSecurity(chainProxy)).build()); 67 | } 68 | 69 | /** 70 | * access denied error page. Confirm that you are transitioning to the above page. 71 | * @throws Exception 72 | */ 73 | @Test 74 | public void testAccessDeniedErrorMockMvc() throws Exception { 75 | 76 | // Mockmvc test. 77 | MvcTestResult results = mockMvc.get().uri("/").exchange(); 78 | 79 | logger.debug("testAccessDeniedError#status:" + results.getResponse().getStatus()); 80 | logger.debug( 81 | "testAccessDeniedError#forwardedUrl:" + results.getResponse().getForwardedUrl()); 82 | 83 | assertThat(results).hasStatus(403).hasForwardedUrl(accessDeniedErrorForwardedUrl); 84 | } 85 | 86 | /** Test FilterChainProxy */ 87 | public class TestFilterChainProxy extends FilterChainProxy { 88 | 89 | public TestFilterChainProxy(SecurityFilterChain chain) { 90 | super(chain); 91 | } 92 | } 93 | 94 | /** Test filter */ 95 | public class TestFilter extends OncePerRequestFilter { 96 | 97 | public TestFilter() {} 98 | 99 | @Override 100 | protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, 101 | FilterChain filterChain) throws ServletException, IOException { 102 | // Since I can't reproduce the error, I run the handler directly. 103 | accessDeniedHandler.handle(request, response, 104 | new AccessDeniedException("Access Denied Error Test.")); 105 | } 106 | } 107 | 108 | @AfterEach 109 | public void tearDown() {} 110 | 111 | } 112 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute to the Development of terasoluna-gfw-web-blank repository. 2 | 3 | This document describes how to contribute the terasoluna-gfw-web-blank updates. 4 | 5 | The terasoluna-gfw-web-blank is a [Maven](https://maven.apache.org/) based blank java project template for a quick start. 6 | See [Building a Project with Maven](https://maven.apache.org/run-maven/index.html) 7 | 8 | Contribution procedures are follows: 9 | 10 | ## Create a new issue 11 | 12 | Create a new issue from [here](https://github.com/terasolunaorg/terasoluna-gfw-web-blank/issues/new?body=%23%23%20Description%0D%0A%28%2A%2ARequired%2A%2A%3A%20Please%20write%20issue%20description%29%0D%0A%0D%0A%23%23%20Possible%20Solutions%0D%0A%28Optional%3A%20Please%20write%20solutions%20of%20this%20issue%20you%20think%29%0D%0A%0D%0A%23%23%20Affects%20Version%2Fs%0D%0A%28%2A%2ARequired%2A%2A%3A%20Please%20select%20affected%20versions%29%0D%0A%2A%205.0.0.RELEASE%0D%0A%2A%201.0.2.RELEASE%0D%0A%0D%0A%23%23%20Fix%20Version%2Fs%0D%0A%28To%20be%20written%20later%20by%20project%20member%29%0D%0A%0D%0A%23%23%20Issue%20Links%0D%0A%28Optional%3A%20Please%20link%20to%20related%20issues%29%0D%0A%2A%20%23%7Bissue%20no%7D%0D%0A%2A%20or%20external%20url) for contributing(bug report, improvement or new content), and get an issue number(tracking id). 13 | 14 | > **Note: Supported language** 15 | > 16 | > English only. 17 | 18 | - Write the contribution overview into the title area. 19 | - Write the contribution detail into the comment area. 20 | 21 | e.g.) 22 | 23 | ``` 24 | ## Description 25 | In pom.xml file, there is a mistake in the below sentence. 26 | 27 | `"projctName"` 28 | 29 | ## Possible Solutions 30 | Modify to `"projectName"` 31 | 32 | ## Affects Version/s 33 | * 5.0.0.RELEASE 34 | * 1.0.2.RELEASE 35 | 36 | ## Fix Version/s 37 | (To be written later by project member) 38 | 39 | ## Issue Links 40 | * https://github.com/terasolunaorg/terasoluna-gfw-web-blank/issues/999 41 | ``` 42 | 43 | ## Fork a repository 44 | 45 | Fork the `terasolunaorg/terasoluna-gfw-web-blank` into your account repository of GitHub. 46 | 47 | - Click a "Fork" button on GitHub web user interface. 48 | 49 | ## Clone a repository 50 | 51 | Clone a forked repository into your local machine. 52 | 53 | e.g.) 54 | 55 | ``` 56 | git clone https://github.com/{your account}/terasoluna-gfw-web-blank.git 57 | ``` 58 | 59 | ## Create a work branch 60 | 61 | Create a work branch on the master branch into your local repository. 62 | 63 | > **Note: Recommended work branch name** 64 | > 65 | > issues/{issue number}\_{short description} 66 | 67 | e.g.) 68 | 69 | ``` 70 | git checkout master 71 | git checkout -b issues/999_typo-in-POM 72 | ``` 73 | 74 | ## Modify the terasoluna-gfw-web-blank 75 | 76 | Modify the terasoluna-gfw-web-blank for contributing, and confirm if other projects using the terasoluna-gfw-web-blank needs modification. 77 | 78 | ## Build projects and execute tests 79 | 80 | Build all projects using the [Maven](https://maven.apache.org/), and execute tests. 81 | 82 | ``` 83 | cd {root directory of your local repository} 84 | mvn clean install -f pom.xml 85 | ``` 86 | 87 | If a maven build fails or there is an error(s) in the application then modify the source code to remove the failure(s)/error(s). 88 | 89 | Deploy the projectName project to application server, and access to "http://{Application Server IP}:{Port}/projectName/" on web browser. 90 | 91 | Then, develop a sample application and confirm the execution result as needed. 92 | If the result fails, modify the source code again. 93 | 94 | ## Commit the modification 95 | 96 | Commit the modification. 97 | 98 | > **Note: Commit comment format** 99 | > 100 | > "{modification overview} #{issue number}" 101 | 102 | > **Note: Supported language** 103 | > 104 | > English only. 105 | 106 | e.g.) 107 | 108 | ``` 109 | git commit -a -m "Fixes typos in POM #999" 110 | ``` 111 | 112 | ## Push the work branch 113 | 114 | Push the work branch to the GitHub. 115 | 116 | e.g.) 117 | 118 | ``` 119 | git push origin issues/999_typo-in-POM 120 | ``` 121 | 122 | ## Create a pull request 123 | 124 | Create a pull request via GitHub web user interface. 125 | For details, refer to the [GitHub document-Creating a pull request-](https://help.github.com/articles/creating-a-pull-request/). 126 | 127 | > **Note: Supported language** 128 | > 129 | > English only. 130 | 131 | - Write the modification overview into the title area and add the #{issue number} at its end. (Default is commit comment or work branch name) 132 | - Write the modification detail into the comment area. (If needed) 133 | - Include the issue number(`#{issue number}` format) to track the modification into the comment area. 134 | 135 | e.g.) 136 | 137 | | Area | Content | 138 | | ------- | ----------------------- | 139 | | Title | Fixes typos in POM #999 | 140 | | Comment | Please review #999 . | 141 | -------------------------------------------------------------------------------- /testScript/parts/JavaConfig/projectName-web/src/test/java/xxxxxx/yyyyyy/zzzzzz/mocktest/error/AccessDeniedErrorTest.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.mocktest.error; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.log; 5 | import java.io.IOException; 6 | import org.junit.jupiter.api.AfterEach; 7 | import org.junit.jupiter.api.BeforeEach; 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.springframework.beans.factory.annotation.Value; 13 | import org.springframework.security.access.AccessDeniedException; 14 | import org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers; 15 | import org.springframework.security.web.DefaultSecurityFilterChain; 16 | import org.springframework.security.web.FilterChainProxy; 17 | import org.springframework.security.web.SecurityFilterChain; 18 | import org.springframework.security.web.access.AccessDeniedHandler; 19 | import org.springframework.security.web.util.matcher.AnyRequestMatcher; 20 | import org.springframework.test.context.ContextConfiguration; 21 | import org.springframework.test.context.ContextHierarchy; 22 | import org.springframework.test.context.junit.jupiter.SpringExtension; 23 | import org.springframework.test.context.web.WebAppConfiguration; 24 | import org.springframework.test.web.servlet.assertj.MockMvcTester; 25 | import org.springframework.test.web.servlet.assertj.MvcTestResult; 26 | import org.springframework.web.context.WebApplicationContext; 27 | import org.springframework.web.filter.OncePerRequestFilter; 28 | import jakarta.inject.Inject; 29 | import jakarta.servlet.FilterChain; 30 | import jakarta.servlet.ServletException; 31 | import jakarta.servlet.http.HttpServletRequest; 32 | import jakarta.servlet.http.HttpServletResponse; 33 | 34 | import xxxxxx.yyyyyy.zzzzzz.config.app.ApplicationContextConfig; 35 | import xxxxxx.yyyyyy.zzzzzz.config.web.SpringMvcConfig; 36 | import xxxxxx.yyyyyy.zzzzzz.config.web.SpringSecurityConfig; 37 | 38 | /** 39 | * Run the access denied error test. 40 | */ 41 | @ExtendWith(SpringExtension.class) 42 | @ContextHierarchy({ 43 | @ContextConfiguration( 44 | classes = {ApplicationContextConfig.class, SpringSecurityConfig.class}), 45 | @ContextConfiguration(classes = {SpringMvcConfig.class})}) 46 | @WebAppConfiguration 47 | public class AccessDeniedErrorTest { 48 | 49 | private static final Logger logger = LoggerFactory.getLogger(AccessDeniedErrorTest.class); 50 | 51 | @Inject 52 | private WebApplicationContext webApplicationContext; 53 | 54 | private MockMvcTester mockMvc; 55 | 56 | @Inject 57 | private AccessDeniedHandler accessDeniedHandler; 58 | 59 | @Value("${accessDeniedError.forwardedUrl}") 60 | private String accessDeniedErrorForwardedUrl; 61 | 62 | @BeforeEach 63 | public void setUp() { 64 | // Set Filter for Test. 65 | DefaultSecurityFilterChain chain = 66 | new DefaultSecurityFilterChain(AnyRequestMatcher.INSTANCE, new TestFilter()); 67 | TestFilterChainProxy chainProxy = new TestFilterChainProxy(chain); 68 | 69 | mockMvc = MockMvcTester.from(webApplicationContext, builder -> builder.alwaysDo(log()) 70 | .apply(SecurityMockMvcConfigurers.springSecurity(chainProxy)).build()); 71 | } 72 | 73 | /** 74 | * access denied error page. Confirm that you are transitioning to the above page. 75 | * @throws Exception 76 | */ 77 | @Test 78 | public void testAccessDeniedErrorMockMvc() throws Exception { 79 | 80 | // Mockmvc test. 81 | MvcTestResult results = mockMvc.get().uri("/").exchange(); 82 | 83 | logger.debug("testAccessDeniedError#status:" + results.getResponse().getStatus()); 84 | logger.debug( 85 | "testAccessDeniedError#forwardedUrl:" + results.getResponse().getForwardedUrl()); 86 | 87 | assertThat(results).hasStatus(403).hasForwardedUrl(accessDeniedErrorForwardedUrl); 88 | } 89 | 90 | /** Test FilterChainProxy */ 91 | public class TestFilterChainProxy extends FilterChainProxy { 92 | 93 | public TestFilterChainProxy(SecurityFilterChain chain) { 94 | super(chain); 95 | } 96 | } 97 | 98 | /** Test filter */ 99 | public class TestFilter extends OncePerRequestFilter { 100 | 101 | public TestFilter() {} 102 | 103 | @Override 104 | protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, 105 | FilterChain filterChain) throws ServletException, IOException { 106 | // Since I can't reproduce the error, I run the handler directly. 107 | accessDeniedHandler.handle(request, response, 108 | new AccessDeniedException("Access Denied Error Test.")); 109 | } 110 | } 111 | 112 | @AfterEach 113 | public void tearDown() {} 114 | 115 | } 116 | -------------------------------------------------------------------------------- /parts/XMLConfig-JSP/projectName-web/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | logbackDisableServletContainerInitializer 9 | true 10 | 11 | 12 | 13 | ch.qos.logback.classic.servlet.LogbackServletContextListener 14 | 15 | 16 | 17 | org.springframework.web.context.ContextLoaderListener 18 | 19 | 20 | contextConfigLocation 21 | 22 | 23 | classpath*:META-INF/spring/applicationContext.xml 24 | classpath*:META-INF/spring/spring-security.xml 25 | 26 | 27 | 28 | 29 | org.terasoluna.gfw.web.logging.HttpSessionEventLoggingListener 30 | 31 | 32 | 33 | MDCClearFilter 34 | org.terasoluna.gfw.web.logging.mdc.MDCClearFilter 35 | 36 | 37 | MDCClearFilter 38 | /* 39 | 40 | 41 | 42 | exceptionLoggingFilter 43 | org.springframework.web.filter.DelegatingFilterProxy 44 | 45 | 46 | exceptionLoggingFilter 47 | /* 48 | 49 | 50 | 51 | XTrackMDCPutFilter 52 | org.terasoluna.gfw.web.logging.mdc.XTrackMDCPutFilter 53 | 54 | 55 | XTrackMDCPutFilter 56 | /* 57 | 58 | 59 | 60 | CharacterEncodingFilter 61 | org.springframework.web.filter.CharacterEncodingFilter 62 | 63 | encoding 64 | UTF-8 65 | 66 | 67 | forceEncoding 68 | true 69 | 70 | 71 | 72 | CharacterEncodingFilter 73 | /* 74 | 75 | 76 | 77 | springSecurityFilterChain 78 | org.springframework.web.filter.DelegatingFilterProxy 79 | 80 | 81 | springSecurityFilterChain 82 | /* 83 | 84 | 85 | 86 | appServlet 87 | org.springframework.web.servlet.DispatcherServlet 88 | 89 | contextConfigLocation 90 | 91 | classpath*:META-INF/spring/spring-mvc.xml 92 | 93 | 1 94 | 95 | 96 | appServlet 97 | / 98 | 99 | 100 | 101 | 102 | *.jsp 103 | false 104 | UTF-8 105 | false 106 | /WEB-INF/views/common/include.jsp 107 | 108 | 109 | 110 | 111 | 500 112 | /WEB-INF/views/common/error/systemError.jsp 113 | 114 | 115 | 116 | 404 117 | /WEB-INF/views/common/error/resourceNotFoundError.jsp 118 | 119 | 120 | 121 | java.lang.Exception 122 | /WEB-INF/views/common/error/unhandledSystemError.html 123 | 124 | 125 | 126 | 127 | 30 128 | 129 | true 130 | 131 | 132 | COOKIE 133 | 134 | 135 | -------------------------------------------------------------------------------- /parts/JavaConfig-Thymeleaf/projectName-web/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | logbackDisableServletContainerInitializer 9 | true 10 | 11 | 12 | 13 | contextClass 14 | 15 | org.springframework.web.context.support.AnnotationConfigWebApplicationContext 16 | 17 | 18 | 19 | 20 | ch.qos.logback.classic.servlet.LogbackServletContextListener 21 | 22 | 23 | 24 | org.springframework.web.context.ContextLoaderListener 25 | 26 | 27 | contextConfigLocation 28 | 29 | 30 | xxxxxx.yyyyyy.zzzzzz.config.app.ApplicationContextConfig 31 | xxxxxx.yyyyyy.zzzzzz.config.web.SpringSecurityConfig 32 | 33 | 34 | 35 | 36 | org.terasoluna.gfw.web.logging.HttpSessionEventLoggingListener 37 | 38 | 39 | 40 | MDCClearFilter 41 | org.terasoluna.gfw.web.logging.mdc.MDCClearFilter 42 | 43 | 44 | MDCClearFilter 45 | /* 46 | 47 | 48 | 49 | exceptionLoggingFilter 50 | org.springframework.web.filter.DelegatingFilterProxy 51 | 52 | 53 | exceptionLoggingFilter 54 | /* 55 | 56 | 57 | 58 | XTrackMDCPutFilter 59 | org.terasoluna.gfw.web.logging.mdc.XTrackMDCPutFilter 60 | 61 | 62 | XTrackMDCPutFilter 63 | /* 64 | 65 | 66 | 67 | CharacterEncodingFilter 68 | org.springframework.web.filter.CharacterEncodingFilter 69 | 70 | encoding 71 | UTF-8 72 | 73 | 74 | forceEncoding 75 | true 76 | 77 | 78 | 79 | CharacterEncodingFilter 80 | /* 81 | 82 | 83 | 84 | springSecurityFilterChain 85 | org.springframework.web.filter.DelegatingFilterProxy 86 | 87 | 88 | springSecurityFilterChain 89 | /* 90 | 91 | 92 | 93 | appServlet 94 | org.springframework.web.servlet.DispatcherServlet 95 | 96 | contextClass 97 | 98 | org.springframework.web.context.support.AnnotationConfigWebApplicationContext 99 | 100 | 101 | 102 | contextConfigLocation 103 | 104 | xxxxxx.yyyyyy.zzzzzz.config.web.SpringMvcConfig 105 | 106 | 1 107 | 108 | 109 | appServlet 110 | / 111 | 112 | 113 | 114 | 500 115 | /common/error/systemError 116 | 117 | 118 | 119 | 404 120 | /common/error/resourceNotFoundError 121 | 122 | 123 | 124 | java.lang.Exception 125 | /WEB-INF/views/common/error/unhandledSystemError.html 126 | 127 | 128 | 129 | 130 | 30 131 | 132 | true 133 | 134 | 135 | COOKIE 136 | 137 | 138 | -------------------------------------------------------------------------------- /parts/base/src/main/webapp/resources/app/css/styles.css: -------------------------------------------------------------------------------- 1 | /* @import url(https://fonts.googleapis.com/css?family=Lato:300italic,700italic,300,700); */ 2 | 3 | body { 4 | padding: 50px; 5 | font: 14px/1.5 Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; 6 | color: #777; 7 | font-weight: 300; 8 | } 9 | 10 | h1, 11 | h2, 12 | h3, 13 | h4, 14 | h5, 15 | h6 { 16 | color: #222; 17 | margin: 0 0 20px; 18 | } 19 | 20 | p, 21 | ul, 22 | ol, 23 | table, 24 | pre, 25 | dl { 26 | margin: 0 0 20px; 27 | } 28 | 29 | h1, 30 | h2, 31 | h3 { 32 | line-height: 1.1; 33 | } 34 | 35 | h1 { 36 | font-size: 28px; 37 | } 38 | 39 | h2 { 40 | color: #393939; 41 | } 42 | 43 | h3, 44 | h4, 45 | h5, 46 | h6 { 47 | color: #494949; 48 | } 49 | 50 | a { 51 | color: #39c; 52 | font-weight: 400; 53 | text-decoration: none; 54 | } 55 | 56 | a small { 57 | font-size: 11px; 58 | color: #777; 59 | margin-top: -0.6em; 60 | display: block; 61 | } 62 | 63 | .wrapper { 64 | width: 860px; 65 | margin: 0 auto; 66 | } 67 | 68 | blockquote { 69 | border-left: 1px solid #e5e5e5; 70 | margin: 0; 71 | padding: 0 0 0 20px; 72 | font-style: italic; 73 | } 74 | 75 | code, 76 | pre { 77 | font-family: Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; 78 | color: #333; 79 | font-size: 12px; 80 | } 81 | 82 | pre { 83 | padding: 8px 15px; 84 | background: #f8f8f8; 85 | border-radius: 5px; 86 | border: 1px solid #e5e5e5; 87 | overflow-x: auto; 88 | } 89 | 90 | table { 91 | width: 100%; 92 | border-collapse: collapse; 93 | } 94 | 95 | th, 96 | td { 97 | text-align: left; 98 | padding: 5px 10px; 99 | border-bottom: 1px solid #e5e5e5; 100 | } 101 | 102 | dt { 103 | color: #444; 104 | font-weight: 700; 105 | } 106 | 107 | th { 108 | color: #444; 109 | } 110 | 111 | img { 112 | max-width: 100%; 113 | } 114 | 115 | header { 116 | width: 270px; 117 | float: left; 118 | position: fixed; 119 | } 120 | 121 | header ul { 122 | list-style: none; 123 | height: 40px; 124 | 125 | padding: 0; 126 | 127 | background: #eee; 128 | background: -moz-linear-gradient(top, #f8f8f8 0%, #dddddd 100%); 129 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #f8f8f8), color-stop(100%, #dddddd)); 130 | background: -webkit-linear-gradient(top, #f8f8f8 0%, #dddddd 100%); 131 | background: -o-linear-gradient(top, #f8f8f8 0%, #dddddd 100%); 132 | background: -ms-linear-gradient(top, #f8f8f8 0%, #dddddd 100%); 133 | background: linear-gradient(top, #f8f8f8 0%, #dddddd 100%); 134 | 135 | border-radius: 5px; 136 | border: 1px solid #d2d2d2; 137 | box-shadow: inset #fff 0 1px 0, inset rgba(0, 0, 0, 0.03) 0 -1px 0; 138 | width: 270px; 139 | } 140 | 141 | header li { 142 | width: 89px; 143 | float: left; 144 | border-right: 1px solid #d2d2d2; 145 | height: 40px; 146 | } 147 | 148 | header ul a { 149 | line-height: 1; 150 | font-size: 11px; 151 | color: #999; 152 | display: block; 153 | text-align: center; 154 | padding-top: 6px; 155 | height: 40px; 156 | } 157 | 158 | strong { 159 | color: #222; 160 | font-weight: 700; 161 | } 162 | 163 | header ul li + li { 164 | width: 88px; 165 | border-left: 1px solid #fff; 166 | } 167 | 168 | header ul li + li + li { 169 | border-right: none; 170 | width: 89px; 171 | } 172 | 173 | header ul a strong { 174 | font-size: 14px; 175 | display: block; 176 | color: #222; 177 | } 178 | 179 | section { 180 | width: 500px; 181 | float: right; 182 | padding-bottom: 50px; 183 | } 184 | 185 | small { 186 | font-size: 11px; 187 | } 188 | 189 | hr { 190 | border: 0; 191 | background: #e5e5e5; 192 | height: 1px; 193 | margin: 0 0 20px; 194 | } 195 | 196 | footer { 197 | width: 270px; 198 | float: left; 199 | position: fixed; 200 | bottom: 50px; 201 | } 202 | 203 | @media print, screen and (max-width: 960px) { 204 | div.wrapper { 205 | width: auto; 206 | margin: 0; 207 | } 208 | 209 | header, 210 | section, 211 | footer { 212 | float: none; 213 | position: static; 214 | width: auto; 215 | } 216 | 217 | header { 218 | padding-right: 320px; 219 | } 220 | 221 | section { 222 | border: 1px solid #e5e5e5; 223 | border-width: 1px 0; 224 | padding: 20px 0; 225 | margin: 0 0 20px; 226 | } 227 | 228 | header a small { 229 | display: inline; 230 | } 231 | 232 | header ul { 233 | position: absolute; 234 | right: 50px; 235 | top: 52px; 236 | } 237 | } 238 | 239 | @media print, screen and (max-width: 720px) { 240 | body { 241 | word-wrap: break-word; 242 | } 243 | 244 | header { 245 | padding: 0; 246 | } 247 | 248 | header ul, 249 | header p.view { 250 | position: static; 251 | } 252 | 253 | pre, 254 | code { 255 | word-wrap: normal; 256 | } 257 | } 258 | 259 | @media print, screen and (max-width: 480px) { 260 | body { 261 | padding: 15px; 262 | } 263 | 264 | header ul { 265 | display: none; 266 | } 267 | } 268 | 269 | @media print { 270 | body { 271 | padding: 0.4in; 272 | font-size: 12pt; 273 | color: #444; 274 | } 275 | } 276 | -------------------------------------------------------------------------------- /testScript/parts/base/projectName-selenium/src/test/java/xxxxxx/yyyyyy/zzzzzz/selenium/FunctionTestSupport.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.selenium; 2 | 3 | import java.io.File; 4 | import java.time.Duration; 5 | import java.util.HashSet; 6 | import java.util.Set; 7 | import org.junit.jupiter.api.AfterAll; 8 | import org.junit.jupiter.api.BeforeEach; 9 | import org.openqa.selenium.WebDriver; 10 | import org.openqa.selenium.remote.RemoteWebDriver; 11 | import org.openqa.selenium.support.ui.WebDriverWait; 12 | import org.slf4j.Logger; 13 | import org.slf4j.LoggerFactory; 14 | import org.springframework.beans.factory.annotation.Value; 15 | import org.springframework.context.support.ApplicationObjectSupport; 16 | 17 | import xxxxxx.yyyyyy.zzzzzz.selenium.webdrivers.WebDriverType; 18 | 19 | public class FunctionTestSupport extends ApplicationObjectSupport { 20 | 21 | private static final Logger logger = LoggerFactory.getLogger(FunctionTestSupport.class); 22 | 23 | protected static WebDriver webDriver; 24 | 25 | private static final Set webDrivers = new HashSet(); 26 | 27 | protected static WebDriverType driverType; 28 | 29 | @Value("${selenium.serverUrl}") 30 | protected String serverUrl; 31 | 32 | @Value("${selenium.contextName}") 33 | protected String contextName; 34 | 35 | @Value("${selenium.applicationContextUrl}") 36 | protected String applicationContextUrl; 37 | 38 | @Value("${selenium.evidenceBaseDirectory}") 39 | protected String evidenceBaseDirectory; 40 | 41 | protected WebDriverOperations webDriverOperations; 42 | 43 | protected WebDriverWait webDriverWait; 44 | 45 | protected File evidenceSavingDirectory; 46 | 47 | private boolean useSetupDefaultWebDriver = true; 48 | 49 | protected Duration defaultTimeoutSecForImplicitlyWait; 50 | 51 | @Value("${selenium.defaultTimeoutSecForImplicitlyWait:5}") 52 | public void setDefaultTimeoutSecForImplicitlyWait(long defaultTimeoutSecForImplicitlyWait) { 53 | this.defaultTimeoutSecForImplicitlyWait = 54 | Duration.ofSeconds(defaultTimeoutSecForImplicitlyWait); 55 | } 56 | 57 | @AfterAll 58 | public final static void tearDownWebDrivers() { 59 | quitWebDrivers(); 60 | webDriver = null; 61 | } 62 | 63 | @BeforeEach 64 | public final void setUpDefaultWebDriver() { 65 | if (!useSetupDefaultWebDriver) { 66 | return; 67 | } 68 | bootDefaultWebDriver(); 69 | } 70 | 71 | @BeforeEach 72 | public final void setUpWebDriverType() { 73 | if (driverType != null) { 74 | return; 75 | } 76 | for (String activeProfile : getApplicationContext().getEnvironment().getActiveProfiles()) { 77 | for (WebDriverType type : WebDriverType.values()) { 78 | if (type.toString().equalsIgnoreCase(activeProfile)) { 79 | driverType = type; 80 | return; 81 | } 82 | } 83 | } 84 | driverType = WebDriverType.DEFAULT(); 85 | } 86 | 87 | @BeforeEach 88 | public final void logUserAgent() { 89 | if (webDriver instanceof RemoteWebDriver remoteWebDriver) { 90 | Object agent = remoteWebDriver.executeScript("return navigator.userAgent"); 91 | if (agent != null) { 92 | logger.info("userAgent:" + agent.toString()); 93 | } 94 | } 95 | } 96 | 97 | protected void bindWebDriver(WebDriver webDriver) { 98 | webDrivers.add(webDriver); 99 | } 100 | 101 | protected void unbindWebDriver(WebDriver webDriver) { 102 | webDrivers.remove(webDriver); 103 | } 104 | 105 | protected void bootDefaultWebDriver() { 106 | if (webDriver == null) { 107 | webDriver = newWebDriver(); 108 | } 109 | webDriver.manage().timeouts().implicitlyWait(this.defaultTimeoutSecForImplicitlyWait); 110 | webDriver.get(getPackageRootUrl()); 111 | 112 | this.webDriverOperations = new WebDriverOperations(webDriver); 113 | this.webDriverOperations 114 | .setDefaultTimeoutForImplicitlyWait(this.defaultTimeoutSecForImplicitlyWait); 115 | this.webDriverWait = new WebDriverWait(webDriver, this.defaultTimeoutSecForImplicitlyWait); 116 | } 117 | 118 | private WebDriver newWebDriver() { 119 | WebDriver webDriver = getApplicationContext().getBean(WebDriver.class); 120 | webDrivers.add(webDriver); 121 | return webDriver; 122 | } 123 | 124 | protected void quitDefaultWebDriver() { 125 | if (webDriver != null) { 126 | try { 127 | webDriver.quit(); 128 | } finally { 129 | webDriver = null; 130 | } 131 | } 132 | } 133 | 134 | protected WebDriver getDefaultWebDriver() { 135 | return webDriver; 136 | } 137 | 138 | protected String getPackageRootUrl() { 139 | return applicationContextUrl + "/"; 140 | } 141 | 142 | protected void disableSetupDefaultWebDriver() { 143 | this.useSetupDefaultWebDriver = false; 144 | } 145 | 146 | protected void enableSetupDefaultWebDriver() { 147 | this.useSetupDefaultWebDriver = true; 148 | } 149 | 150 | private static void quitWebDrivers() { 151 | for (WebDriver webDriver : webDrivers) { 152 | try { 153 | webDriver.quit(); 154 | } catch (Throwable t) { 155 | logger.error("failed quit.", t); 156 | } 157 | } 158 | webDrivers.clear(); 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /parts/JavaConfig-JSP/projectName-web/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | logbackDisableServletContainerInitializer 9 | true 10 | 11 | 12 | 13 | contextClass 14 | 15 | org.springframework.web.context.support.AnnotationConfigWebApplicationContext 16 | 17 | 18 | 19 | 20 | ch.qos.logback.classic.servlet.LogbackServletContextListener 21 | 22 | 23 | 24 | org.springframework.web.context.ContextLoaderListener 25 | 26 | 27 | contextConfigLocation 28 | 29 | 30 | xxxxxx.yyyyyy.zzzzzz.config.app.ApplicationContextConfig 31 | xxxxxx.yyyyyy.zzzzzz.config.web.SpringSecurityConfig 32 | 33 | 34 | 35 | 36 | org.terasoluna.gfw.web.logging.HttpSessionEventLoggingListener 37 | 38 | 39 | 40 | MDCClearFilter 41 | org.terasoluna.gfw.web.logging.mdc.MDCClearFilter 42 | 43 | 44 | MDCClearFilter 45 | /* 46 | 47 | 48 | 49 | exceptionLoggingFilter 50 | org.springframework.web.filter.DelegatingFilterProxy 51 | 52 | 53 | exceptionLoggingFilter 54 | /* 55 | 56 | 57 | 58 | XTrackMDCPutFilter 59 | org.terasoluna.gfw.web.logging.mdc.XTrackMDCPutFilter 60 | 61 | 62 | XTrackMDCPutFilter 63 | /* 64 | 65 | 66 | 67 | CharacterEncodingFilter 68 | org.springframework.web.filter.CharacterEncodingFilter 69 | 70 | encoding 71 | UTF-8 72 | 73 | 74 | forceEncoding 75 | true 76 | 77 | 78 | 79 | CharacterEncodingFilter 80 | /* 81 | 82 | 83 | 84 | springSecurityFilterChain 85 | org.springframework.web.filter.DelegatingFilterProxy 86 | 87 | 88 | springSecurityFilterChain 89 | /* 90 | 91 | 92 | 93 | appServlet 94 | org.springframework.web.servlet.DispatcherServlet 95 | 96 | contextClass 97 | 98 | org.springframework.web.context.support.AnnotationConfigWebApplicationContext 99 | 100 | 101 | 102 | contextConfigLocation 103 | 104 | xxxxxx.yyyyyy.zzzzzz.config.web.SpringMvcConfig 105 | 106 | 1 107 | 108 | 109 | appServlet 110 | / 111 | 112 | 113 | 114 | 115 | *.jsp 116 | false 117 | UTF-8 118 | false 119 | /WEB-INF/views/common/include.jsp 120 | 121 | 122 | 123 | 124 | 500 125 | /WEB-INF/views/common/error/systemError.jsp 126 | 127 | 128 | 129 | 404 130 | /WEB-INF/views/common/error/resourceNotFoundError.jsp 131 | 132 | 133 | 134 | java.lang.Exception 135 | /WEB-INF/views/common/error/unhandledSystemError.html 136 | 137 | 138 | 139 | 140 | 30 141 | 142 | true 143 | 144 | 145 | COOKIE 146 | 147 | 148 | -------------------------------------------------------------------------------- /parts/JavaConfig/projectName-env/src/main/java/xxxxxx/yyyyyy/zzzzzz/config/app/ProjectNameEnvConfig.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.config.app; 2 | 3 | import java.time.Duration; 4 | import javax.sql.DataSource; 5 | import org.apache.commons.dbcp2.BasicDataSource; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.core.io.ClassPathResource; 10 | /* REMOVE THIS LINE IF YOU USE MyBatis3 11 | import org.springframework.jdbc.datasource.DataSourceTransactionManager; 12 | REMOVE THIS LINE IF YOU USE MyBatis3 */ 13 | import org.springframework.jdbc.datasource.init.DataSourceInitializer; 14 | import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; 15 | /* REMOVE THIS LINE IF YOU USE JPA 16 | import org.springframework.orm.jpa.JpaTransactionManager; 17 | REMOVE THIS LINE IF YOU USE JPA */ 18 | import org.springframework.transaction.TransactionManager; 19 | import org.terasoluna.gfw.common.time.ClockFactory; 20 | import org.terasoluna.gfw.common.time.DefaultClockFactory; 21 | /* REMOVE THIS LINE IF YOU USE JPA 22 | import jakarta.persistence.EntityManagerFactory; 23 | REMOVE THIS LINE IF YOU USE JPA */ 24 | 25 | /** 26 | * Define settings for the environment. 27 | */ 28 | @Configuration 29 | public class ProjectNameEnvConfig { 30 | 31 | /** 32 | * DataSource.driverClassName property. 33 | */ 34 | @Value("${database.driverClassName}") 35 | private String driverClassName; 36 | 37 | /** 38 | * DataSource.url property. 39 | */ 40 | @Value("${database.url}") 41 | private String url; 42 | 43 | /** 44 | * DataSource.username property. 45 | */ 46 | @Value("${database.username}") 47 | private String username; 48 | 49 | /** 50 | * DataSource.password property. 51 | */ 52 | @Value("${database.password}") 53 | private String password; 54 | 55 | /** 56 | * DataSource.maxTotal property. 57 | */ 58 | @Value("${cp.maxActive}") 59 | private Integer maxActive; 60 | 61 | /** 62 | * DataSource.maxIdle property. 63 | */ 64 | @Value("${cp.maxIdle}") 65 | private Integer maxIdle; 66 | 67 | /** 68 | * DataSource.minIdle property. 69 | */ 70 | @Value("${cp.minIdle}") 71 | private Integer minIdle; 72 | 73 | /** 74 | * DataSource.maxWaitMillis property. 75 | */ 76 | @Value("${cp.maxWait}") 77 | private Integer maxWait; 78 | 79 | /** 80 | * Property databaseName. 81 | */ 82 | @Value("${database}") 83 | private String database; 84 | 85 | /** 86 | * Configure {@link ClockFactory}. 87 | * @return Bean of configured {@link DefaultClockFactory} 88 | */ 89 | @Bean("dateFactory") 90 | public ClockFactory dateFactory() { 91 | return new DefaultClockFactory(); 92 | } 93 | 94 | /** 95 | * Configure {@link DataSource} bean. 96 | * @return Bean of configured {@link BasicDataSource} 97 | */ 98 | @Bean(name = "dataSource", destroyMethod = "close") 99 | public DataSource dataSource() { 100 | BasicDataSource bean = new BasicDataSource(); 101 | bean.setDriverClassName(driverClassName); 102 | bean.setUrl(url); 103 | bean.setUsername(username); 104 | bean.setPassword(password); 105 | bean.setDefaultAutoCommit(false); 106 | bean.setMaxTotal(maxActive); 107 | bean.setMaxIdle(maxIdle); 108 | bean.setMinIdle(minIdle); 109 | bean.setMaxWait(Duration.ofMillis(maxWait)); 110 | return bean; 111 | } 112 | 113 | /** 114 | * Configuration to set up database during initialization. 115 | * @return Bean of configured {@link DataSourceInitializer} 116 | */ 117 | @Bean 118 | public DataSourceInitializer dataSourceInitializer() { 119 | DataSourceInitializer bean = new DataSourceInitializer(); 120 | bean.setDataSource(dataSource()); 121 | 122 | ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator(); 123 | databasePopulator.addScript(new ClassPathResource("/database/" + database + "-schema.sql")); 124 | databasePopulator 125 | .addScript(new ClassPathResource("/database/" + database + "-dataload.sql")); 126 | databasePopulator.setSqlScriptEncoding("UTF-8"); 127 | databasePopulator.setIgnoreFailedDrops(true); 128 | bean.setDatabasePopulator(databasePopulator); 129 | return bean; 130 | } 131 | 132 | // @formatter:off 133 | /* REMOVE THIS LINE IF YOU USE JPA 134 | /** 135 | * Configure {@link TransactionManager} bean for use with JPA. 136 | * @param entityManagerFactory EntityManager used within a transaction 137 | * @return Bean of configured {@link JpaTransactionManager} 138 | *REMOVE THIS COMMENT IF YOU USE JPA/ 139 | @Bean("transactionManager") 140 | public TransactionManager transactionManager(EntityManagerFactory entityManagerFactory) { 141 | JpaTransactionManager bean = new JpaTransactionManager(); 142 | bean.setEntityManagerFactory(entityManagerFactory); 143 | return bean; 144 | } 145 | REMOVE THIS LINE IF YOU USE JPA */ 146 | 147 | /* REMOVE THIS LINE IF YOU USE MyBatis3 148 | /** 149 | * Configure {@link TransactionManager} bean. 150 | * @return Bean of configured {@link DataSourceTransactionManager} 151 | *REMOVE THIS COMMENT IF YOU USE MyBatis3/ 152 | @Bean("transactionManager") 153 | public TransactionManager transactionManager() { 154 | DataSourceTransactionManager bean = new DataSourceTransactionManager(); 155 | bean.setDataSource(dataSource()); 156 | bean.setRollbackOnCommitFailure(true); 157 | return bean; 158 | } 159 | REMOVE THIS LINE IF YOU USE MyBatis3 */ 160 | // @formatter:on 161 | } 162 | -------------------------------------------------------------------------------- /parts/XMLConfig-JSP/projectName-web/src/main/resources/META-INF/spring/spring-mvc.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 31 | 32 | 33 | 34 | 35 | 36 | 38 | 39 | 40 | 41 | 42 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 69 | 70 | 71 | 73 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 113 | 114 | 115 | 116 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /parts/JavaConfig/projectName-web/src/main/java/xxxxxx/yyyyyy/zzzzzz/config/app/ApplicationContextConfig.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.config.app; 2 | 3 | import java.util.HashMap; 4 | import java.util.LinkedHashMap; 5 | import java.util.Map; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.context.MessageSource; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.context.annotation.EnableAspectJAutoProxy; 11 | import org.springframework.context.annotation.Import; 12 | import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; 13 | import org.springframework.context.support.ResourceBundleMessageSource; 14 | import org.springframework.core.io.Resource; 15 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 16 | import org.springframework.security.crypto.password.DelegatingPasswordEncoder; 17 | import org.springframework.security.crypto.password.PasswordEncoder; 18 | import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder; 19 | import org.terasoluna.gfw.common.exception.ExceptionCodeResolver; 20 | import org.terasoluna.gfw.common.exception.ExceptionLogger; 21 | import org.terasoluna.gfw.common.exception.SimpleMappingExceptionCodeResolver; 22 | import org.terasoluna.gfw.web.exception.ExceptionLoggingFilter; 23 | 24 | /** 25 | * Application context. 26 | */ 27 | @Configuration 28 | @EnableAspectJAutoProxy 29 | @Import({ProjectNameDomainConfig.class}) 30 | public class ApplicationContextConfig { 31 | 32 | // @formatter:off 33 | /** 34 | * Configure {@link PasswordEncoder} bean. 35 | * @return Bean of configured {@link DelegatingPasswordEncoder} 36 | */ 37 | @Bean("passwordEncoder") 38 | public PasswordEncoder passwordEncoder() { 39 | Map idToPasswordEncoder = new HashMap<>(); 40 | idToPasswordEncoder.put("pbkdf2", pbkdf2PasswordEncoder()); 41 | idToPasswordEncoder.put("bcrypt", bCryptPasswordEncoder()); 42 | /* When using commented out PasswordEncoders, you need to add bcprov-jdk18on.jar to the dependency. 43 | idToPasswordEncoder.put("argon2", argon2PasswordEncoder()); 44 | idToPasswordEncoder.put("scrypt", sCryptPasswordEncoder()); 45 | */ 46 | return new DelegatingPasswordEncoder("pbkdf2", idToPasswordEncoder); 47 | } 48 | // @formatter:on 49 | 50 | /** 51 | * Configure {@link Pbkdf2PasswordEncoder} bean. 52 | * @return Bean of configured {@link Pbkdf2PasswordEncoder} 53 | */ 54 | @Bean 55 | public Pbkdf2PasswordEncoder pbkdf2PasswordEncoder() { 56 | return Pbkdf2PasswordEncoder.defaultsForSpringSecurity_v5_8(); 57 | } 58 | 59 | /** 60 | * Configure {@link BCryptPasswordEncoder} bean. 61 | * @return Bean of configured {@link BCryptPasswordEncoder} 62 | */ 63 | @Bean 64 | public BCryptPasswordEncoder bCryptPasswordEncoder() { 65 | return new BCryptPasswordEncoder(); 66 | } 67 | 68 | // @formatter:off 69 | /* When using commented out PasswordEncoders, you need to add bcprov-jdk18on.jar to the dependency. 70 | @Bean 71 | public Argon2PasswordEncoder argon2PasswordEncoder() { 72 | return Argon2PasswordEncoder.defaultsForSpringSecurity_v5_8(); 73 | } 74 | @Bean 75 | public SCryptPasswordEncoder sCryptPasswordEncoder() { 76 | return SCryptPasswordEncoder.defaultsForSpringSecurity_v5_8(); 77 | } 78 | */ 79 | // @formatter:on 80 | 81 | /** 82 | * Configure {@link PropertySourcesPlaceholderConfigurer} bean. 83 | * @param properties Property files to be read 84 | * @return Bean of configured {@link PropertySourcesPlaceholderConfigurer} 85 | */ 86 | @Bean 87 | public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer( 88 | @Value("classpath*:/META-INF/spring/*.properties") Resource... properties) { 89 | PropertySourcesPlaceholderConfigurer bean = new PropertySourcesPlaceholderConfigurer(); 90 | bean.setLocations(properties); 91 | return bean; 92 | } 93 | 94 | /** 95 | * Configure {@link MessageSource} bean. 96 | * @return Bean of configured {@link ResourceBundleMessageSource} 97 | */ 98 | @Bean("messageSource") 99 | public MessageSource messageSource() { 100 | ResourceBundleMessageSource bean = new ResourceBundleMessageSource(); 101 | bean.setBasenames("i18n/application-messages"); 102 | return bean; 103 | } 104 | 105 | /** 106 | * Configure {@link ExceptionCodeResolver} bean. 107 | * @return Bean of configured {@link SimpleMappingExceptionCodeResolver} 108 | */ 109 | @Bean("exceptionCodeResolver") 110 | public ExceptionCodeResolver exceptionCodeResolver() { 111 | LinkedHashMap map = new LinkedHashMap<>(); 112 | map.put("ResourceNotFoundException", "e.xx.fw.5001"); 113 | map.put("InvalidTransactionTokenException", "e.xx.fw.7001"); 114 | map.put("BusinessException", "e.xx.fw.8001"); 115 | map.put(".DataAccessException", "e.xx.fw.9002"); 116 | SimpleMappingExceptionCodeResolver bean = new SimpleMappingExceptionCodeResolver(); 117 | bean.setExceptionMappings(map); 118 | bean.setDefaultExceptionCode("e.xx.fw.9001"); 119 | return bean; 120 | } 121 | 122 | /** 123 | * Configure {@link ExceptionLogger} bean. 124 | * @return Bean of configured {@link ExceptionLogger} 125 | */ 126 | @Bean("exceptionLogger") 127 | public ExceptionLogger exceptionLogger() { 128 | ExceptionLogger bean = new ExceptionLogger(); 129 | bean.setExceptionCodeResolver(exceptionCodeResolver()); 130 | return bean; 131 | } 132 | 133 | /** 134 | * Configure {@link ExceptionLoggingFilter} bean. 135 | * @return Bean of configured {@link ExceptionLoggingFilter} 136 | */ 137 | @Bean("exceptionLoggingFilter") 138 | public ExceptionLoggingFilter exceptionLoggingFilter() { 139 | ExceptionLoggingFilter bean = new ExceptionLoggingFilter(); 140 | bean.setExceptionLogger(exceptionLogger()); 141 | return bean; 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /testScript/parts/XMLConfig/projectName-web/src/test/java/xxxxxx/yyyyyy/zzzzzz/mocktest/interceptor/InterceptorTest.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.mocktest.interceptor; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.mockito.Mockito.doThrow; 5 | import static org.mockito.Mockito.times; 6 | import static org.mockito.Mockito.verify; 7 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 8 | import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.log; 9 | import java.util.List; 10 | import org.junit.jupiter.api.AfterEach; 11 | import org.junit.jupiter.api.BeforeEach; 12 | import org.junit.jupiter.api.Test; 13 | import org.junit.jupiter.api.extension.ExtendWith; 14 | import org.mockito.ArgumentCaptor; 15 | import org.mockito.Captor; 16 | import org.mockito.Mock; 17 | import org.mockito.Mockito; 18 | import org.mockito.junit.jupiter.MockitoExtension; 19 | import org.slf4j.LoggerFactory; 20 | import org.springframework.test.context.ContextConfiguration; 21 | import org.springframework.test.context.ContextHierarchy; 22 | import org.springframework.test.context.junit.jupiter.SpringExtension; 23 | import org.springframework.test.context.web.WebAppConfiguration; 24 | import org.springframework.test.web.servlet.MockMvc; 25 | import org.springframework.test.web.servlet.setup.MockMvcBuilders; 26 | import org.springframework.web.context.WebApplicationContext; 27 | import org.terasoluna.gfw.common.exception.ExceptionLogger; 28 | import org.terasoluna.gfw.common.exception.SystemException; 29 | import org.terasoluna.gfw.web.logging.TraceLoggingInterceptor; 30 | import ch.qos.logback.classic.Level; 31 | import ch.qos.logback.classic.Logger; 32 | import ch.qos.logback.classic.spi.ILoggingEvent; 33 | import ch.qos.logback.classic.spi.LoggingEvent; 34 | import ch.qos.logback.core.Appender; 35 | import jakarta.inject.Inject; 36 | 37 | import xxxxxx.yyyyyy.zzzzzz.domain.service.errortest.MockTestService; 38 | 39 | /** 40 | * Run the interceptor test. 41 | */ 42 | @ExtendWith({SpringExtension.class, MockitoExtension.class}) 43 | @ContextHierarchy({ 44 | @ContextConfiguration({"classpath:META-INF/spring/applicationContext.xml", 45 | "classpath:META-INF/spring/spring-security.xml", 46 | "classpath:META-INF/spring/spring-mvc-mockmvc.xml"}), 47 | @ContextConfiguration({"classpath:META-INF/spring/spring-mvc.xml"})}) 48 | @WebAppConfiguration 49 | public class InterceptorTest { 50 | 51 | @Inject 52 | private WebApplicationContext webApplicationContext; 53 | 54 | private MockMvc mockMvc; 55 | 56 | private Logger logger; 57 | 58 | @Inject 59 | MockTestService mockTestService; 60 | 61 | @Mock 62 | private Appender mockAppender; 63 | 64 | @Captor 65 | private ArgumentCaptor captorLoggingEvent; 66 | 67 | @BeforeEach 68 | public void setUp() { 69 | Mockito.reset(mockTestService); 70 | mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).alwaysDo(log()).build(); 71 | } 72 | 73 | /** 74 | * Test whether the log is output by TraceLoggingInterceptor. 75 | * @throws Exception 76 | */ 77 | @Test 78 | public void testTraceLoggingInterceptor() throws Exception { 79 | 80 | // Mock the Appender and capture the output contents. 81 | logger = (Logger) LoggerFactory.getLogger(TraceLoggingInterceptor.class); 82 | logger.addAppender(mockAppender); 83 | 84 | // Mockmvc test. 85 | mockMvc.perform(get("/test/mock/success")); 86 | 87 | // Capture logs for 3 runs. 88 | verify(mockAppender, times(3)).doAppend(captorLoggingEvent.capture()); 89 | List events = captorLoggingEvent.getAllValues(); 90 | 91 | assertThat(events.get(0).getLevel()).isEqualTo(Level.TRACE); 92 | assertThat(events.get(0).getLoggerName()) 93 | .isEqualTo("org.terasoluna.gfw.web.logging.TraceLoggingInterceptor"); 94 | assertThat(events.get(0).getFormattedMessage()) 95 | .isEqualTo("[START CONTROLLER] MockTestController.test(Model)"); 96 | 97 | assertThat(events.get(1).getLevel()).isEqualTo(Level.TRACE); 98 | assertThat(events.get(1).getLoggerName()) 99 | .isEqualTo("org.terasoluna.gfw.web.logging.TraceLoggingInterceptor"); 100 | assertThat(events.get(1).getFormattedMessage()).isEqualTo( 101 | "[END CONTROLLER ] MockTestController.test(Model)-> view=welcome/home, model={}"); 102 | 103 | assertThat(events.get(2).getLevel()).isEqualTo(Level.TRACE); 104 | assertThat(events.get(2).getLoggerName()) 105 | .isEqualTo("org.terasoluna.gfw.web.logging.TraceLoggingInterceptor"); 106 | assertThat(events.get(2).getFormattedMessage() 107 | .matches("^\\[HANDLING TIME \\] MockTestController\\.test\\(Model\\)-> .+")) 108 | .isTrue(); 109 | } 110 | 111 | /** 112 | * Test whether the log is output by ExceptionResolverLoggingInterceptor. 113 | * @throws Exception 114 | */ 115 | @Test 116 | public void testExceptionResolverLoggingInterceptor() throws Exception { 117 | 118 | // Mock the Appender and capture the output contents. 119 | logger = (Logger) LoggerFactory.getLogger(ExceptionLogger.class); 120 | logger.addAppender(mockAppender); 121 | 122 | doThrow(new SystemException("e.xx.fw.9001", "SystemError Test.")).when(mockTestService) 123 | .testExecute(); 124 | 125 | // Mockmvc test. 126 | mockMvc.perform(get("/test/mock/success")); 127 | 128 | // Capture logs for 1 runs. 129 | verify(mockAppender, times(1)).doAppend(captorLoggingEvent.capture()); 130 | LoggingEvent event = captorLoggingEvent.getValue(); 131 | 132 | assertThat(event.getLevel()).isEqualTo(Level.ERROR); 133 | assertThat(event.getLoggerName()) 134 | .isEqualTo("org.terasoluna.gfw.common.exception.ExceptionLogger"); 135 | assertThat(event.getFormattedMessage()).isEqualTo("[e.xx.fw.9001] SystemError Test."); 136 | assertThat(event.getThrowableProxy().getClassName()) 137 | .isEqualTo("org.terasoluna.gfw.common.exception.SystemException"); 138 | } 139 | 140 | @AfterEach 141 | public void tearDown() {} 142 | } 143 | -------------------------------------------------------------------------------- /testScript/parts/JavaConfig/projectName-web/src/test/java/xxxxxx/yyyyyy/zzzzzz/mocktest/interceptor/InterceptorTest.java: -------------------------------------------------------------------------------- 1 | package xxxxxx.yyyyyy.zzzzzz.mocktest.interceptor; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.mockito.Mockito.doThrow; 5 | import static org.mockito.Mockito.times; 6 | import static org.mockito.Mockito.verify; 7 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 8 | import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.log; 9 | import java.util.List; 10 | import org.junit.jupiter.api.AfterEach; 11 | import org.junit.jupiter.api.BeforeEach; 12 | import org.junit.jupiter.api.Test; 13 | import org.junit.jupiter.api.extension.ExtendWith; 14 | import org.mockito.ArgumentCaptor; 15 | import org.mockito.Captor; 16 | import org.mockito.Mock; 17 | import org.mockito.Mockito; 18 | import org.mockito.junit.jupiter.MockitoExtension; 19 | import org.slf4j.LoggerFactory; 20 | import org.springframework.test.context.ContextConfiguration; 21 | import org.springframework.test.context.ContextHierarchy; 22 | import org.springframework.test.context.junit.jupiter.SpringExtension; 23 | import org.springframework.test.context.web.WebAppConfiguration; 24 | import org.springframework.test.web.servlet.MockMvc; 25 | import org.springframework.test.web.servlet.setup.MockMvcBuilders; 26 | import org.springframework.web.context.WebApplicationContext; 27 | import org.terasoluna.gfw.common.exception.ExceptionLogger; 28 | import org.terasoluna.gfw.common.exception.SystemException; 29 | import org.terasoluna.gfw.web.logging.TraceLoggingInterceptor; 30 | import ch.qos.logback.classic.Level; 31 | import ch.qos.logback.classic.Logger; 32 | import ch.qos.logback.classic.spi.ILoggingEvent; 33 | import ch.qos.logback.classic.spi.LoggingEvent; 34 | import ch.qos.logback.core.Appender; 35 | import jakarta.inject.Inject; 36 | 37 | import xxxxxx.yyyyyy.zzzzzz.config.SpringMvcMockMvcConfig; 38 | import xxxxxx.yyyyyy.zzzzzz.config.app.ApplicationContextConfig; 39 | import xxxxxx.yyyyyy.zzzzzz.config.web.SpringMvcConfig; 40 | import xxxxxx.yyyyyy.zzzzzz.config.web.SpringSecurityConfig; 41 | import xxxxxx.yyyyyy.zzzzzz.domain.service.errortest.MockTestService; 42 | 43 | /** 44 | * Run the interceptor test. 45 | */ 46 | @ExtendWith({SpringExtension.class, MockitoExtension.class}) 47 | @ContextHierarchy({ 48 | @ContextConfiguration(classes = {ApplicationContextConfig.class, SpringSecurityConfig.class, 49 | SpringMvcMockMvcConfig.class}), 50 | @ContextConfiguration(classes = {SpringMvcConfig.class})}) 51 | @WebAppConfiguration 52 | public class InterceptorTest { 53 | 54 | @Inject 55 | private WebApplicationContext webApplicationContext; 56 | 57 | private MockMvc mockMvc; 58 | 59 | private Logger logger; 60 | 61 | @Inject 62 | MockTestService mockTestService; 63 | 64 | @Mock 65 | private Appender mockAppender; 66 | 67 | @Captor 68 | private ArgumentCaptor captorLoggingEvent; 69 | 70 | @BeforeEach 71 | public void setUp() { 72 | Mockito.reset(mockTestService); 73 | mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).alwaysDo(log()).build(); 74 | } 75 | 76 | /** 77 | * Test whether the log is output by TraceLoggingInterceptor. 78 | * @throws Exception 79 | */ 80 | @Test 81 | public void testTraceLoggingInterceptor() throws Exception { 82 | 83 | // Mock the Appender and capture the output contents. 84 | logger = (Logger) LoggerFactory.getLogger(TraceLoggingInterceptor.class); 85 | logger.addAppender(mockAppender); 86 | 87 | // Mockmvc test. 88 | mockMvc.perform(get("/test/mock/success")); 89 | 90 | // Capture logs for 3 runs. 91 | verify(mockAppender, times(3)).doAppend(captorLoggingEvent.capture()); 92 | List events = captorLoggingEvent.getAllValues(); 93 | 94 | assertThat(events.get(0).getLevel()).isEqualTo(Level.TRACE); 95 | assertThat(events.get(0).getLoggerName()) 96 | .isEqualTo("org.terasoluna.gfw.web.logging.TraceLoggingInterceptor"); 97 | assertThat(events.get(0).getFormattedMessage()) 98 | .isEqualTo("[START CONTROLLER] MockTestController.test(Model)"); 99 | 100 | assertThat(events.get(1).getLevel()).isEqualTo(Level.TRACE); 101 | assertThat(events.get(1).getLoggerName()) 102 | .isEqualTo("org.terasoluna.gfw.web.logging.TraceLoggingInterceptor"); 103 | assertThat(events.get(1).getFormattedMessage()).isEqualTo( 104 | "[END CONTROLLER ] MockTestController.test(Model)-> view=welcome/home, model={}"); 105 | 106 | assertThat(events.get(2).getLevel()).isEqualTo(Level.TRACE); 107 | assertThat(events.get(2).getLoggerName()) 108 | .isEqualTo("org.terasoluna.gfw.web.logging.TraceLoggingInterceptor"); 109 | assertThat(events.get(2).getFormattedMessage() 110 | .matches("^\\[HANDLING TIME \\] MockTestController\\.test\\(Model\\)-> .+")) 111 | .isTrue(); 112 | } 113 | 114 | /** 115 | * Test whether the log is output by ExceptionResolverLoggingInterceptor. 116 | * @throws Exception 117 | */ 118 | @Test 119 | public void testExceptionResolverLoggingInterceptor() throws Exception { 120 | 121 | // Mock the Appender and capture the output contents. 122 | logger = (Logger) LoggerFactory.getLogger(ExceptionLogger.class); 123 | logger.addAppender(mockAppender); 124 | 125 | doThrow(new SystemException("e.xx.fw.9001", "SystemError Test.")).when(mockTestService) 126 | .testExecute(); 127 | 128 | // Mockmvc test. 129 | mockMvc.perform(get("/test/mock/success")); 130 | 131 | // Capture logs for 1 runs. 132 | verify(mockAppender, times(1)).doAppend(captorLoggingEvent.capture()); 133 | LoggingEvent event = captorLoggingEvent.getValue(); 134 | 135 | assertThat(event.getLevel()).isEqualTo(Level.ERROR); 136 | assertThat(event.getLoggerName()) 137 | .isEqualTo("org.terasoluna.gfw.common.exception.ExceptionLogger"); 138 | assertThat(event.getFormattedMessage()).isEqualTo("[e.xx.fw.9001] SystemError Test."); 139 | assertThat(event.getThrowableProxy().getClassName()) 140 | .isEqualTo("org.terasoluna.gfw.common.exception.SystemException"); 141 | } 142 | 143 | @AfterEach 144 | public void tearDown() {} 145 | } 146 | --------------------------------------------------------------------------------