diff --git a/build.gradle b/build.gradle index bac75c63..4515cf97 100644 --- a/build.gradle +++ b/build.gradle @@ -39,6 +39,11 @@ dependencies { testImplementation 'org.springframework.security:spring-security-test' implementation group: 'com.auth0', name: 'java-jwt', version: '4.3.0' + + implementation 'org.springframework.boot:spring-boot-devtools' + + // local, test : h2 + runtimeOnly 'com.h2database:h2' } tasks.named('test') { diff --git a/src/main/java/com/example/demo/account/dummy.txt b/src/main/java/com/example/demo/account/dummy.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/main/java/com/example/demo/mentoring/dummy.txt b/src/main/java/com/example/demo/mentoring/dummy.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/main/java/com/example/demo/watching/dummy.txt b/src/main/java/com/example/demo/watching/dummy.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 0cf70756..393ee035 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -4,7 +4,6 @@ server: charset: utf-8 force: true port: 8080 - spring: datasource: url: jdbc:h2:tcp://localhost/~/test;MODE=MySQL @@ -22,4 +21,4 @@ spring: hibernate: format_sql: true default_batch_fetch_size: 100 - open-in-view: false \ No newline at end of file + open-in-view: false diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml new file mode 100644 index 00000000..ce3e7f53 --- /dev/null +++ b/src/main/resources/application-test.yml @@ -0,0 +1,24 @@ +server: + servlet: + encoding: + charset: utf-8 + force: true + port: 8080 +spring: + datasource: + url: jdbc:h2:mem:test;MODE=MySQL + driver-class-name: org.h2.Driver + username: sa + password: + h2: + console: + enabled: true + jpa: + hibernate: + ddl-auto: create + show-sql: true + properties: + hibernate: + format_sql: true + default_batch_fetch_size: 100 + open-in-view: false diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index ef46c2ad..d74c444c 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,3 +1,3 @@ spring: profiles: - active: local \ No newline at end of file + active: local diff --git a/src/test/java/com/example/demo/AccountTest.java b/src/test/java/com/example/demo/AccountTest.java new file mode 100644 index 00000000..d6030dce --- /dev/null +++ b/src/test/java/com/example/demo/AccountTest.java @@ -0,0 +1,42 @@ +package com.example.demo; + +import com.example.demo.account.Account; +import com.example.demo.account.AccountJPARepository; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; + +@SpringBootTest +@ActiveProfiles("test") +public class AccountTest { + + @Autowired + private AccountJPARepository accountJPARepository; + + // saveTest + @Test + @DisplayName("account save test") + void test() { + Account account = Account.builder() + .uid(1) + .email("anjdal64@gmail.com") + .password("asdf1234!") + .firstname("Jin") + .lastname("Seung") + .country("Korea") + .age(21) + .role(Account.Role.MENTOR) + .build(); + + // account save + accountJPARepository.save(account); + + // find + Account account1 = accountJPARepository.findById(account.getUid()).get(); + Assertions.assertThat(account.getUid()) + .isEqualTo(account1.getUid()); + } +}