-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from COW-dev/main
Co-authored-by: doji <[email protected]> Co-authored-by: Bokyeom <[email protected]>
- Loading branch information
Showing
8 changed files
with
46 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/kotlin/com/mjucow/eatda/common/config/WebConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.mjucow.eatda.common.config | ||
|
||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.http.HttpMethod | ||
import org.springframework.web.servlet.config.annotation.CorsRegistry | ||
import org.springframework.web.servlet.config.annotation.EnableWebMvc | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer | ||
import java.time.Duration | ||
import java.time.temporal.ChronoUnit | ||
|
||
@Configuration | ||
@EnableWebMvc | ||
class WebConfig : WebMvcConfigurer { | ||
|
||
override fun addCorsMappings(registry: CorsRegistry) { | ||
registry.addMapping("/api/**") | ||
.allowedOriginPatterns("*") | ||
.allowedMethods( | ||
HttpMethod.GET.name(), | ||
HttpMethod.POST.name(), | ||
HttpMethod.DELETE.name(), | ||
HttpMethod.PATCH.name(), | ||
HttpMethod.HEAD.name(), | ||
HttpMethod.OPTIONS.name() | ||
) | ||
.allowedHeaders("*") | ||
.allowCredentials(true) | ||
.maxAge(Duration.of(60, ChronoUnit.MINUTES).toSeconds()) | ||
} | ||
} |
14 changes: 1 addition & 13 deletions
14
src/test/kotlin/com/mjucow/eatda/AbstractApplicationTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,10 @@ | ||
package com.mjucow.eatda | ||
|
||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection | ||
import org.springframework.test.context.ActiveProfiles | ||
import org.testcontainers.containers.PostgreSQLContainer | ||
import org.testcontainers.junit.jupiter.Container | ||
import org.testcontainers.junit.jupiter.Testcontainers | ||
|
||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) | ||
@Testcontainers | ||
@ActiveProfiles("test") | ||
abstract class AbstractApplicationTest { | ||
companion object { | ||
@Container | ||
@ServiceConnection | ||
val POSTGRESQL_CONTAINER = PostgreSQLContainer("postgres:15.4-alpine") | ||
.withUsername("test-user") | ||
.withPassword("test-password") | ||
.withDatabaseName("test_db")!! | ||
} | ||
} | ||
abstract class AbstractApplicationTest : AbstractSpringContextTest() |
6 changes: 6 additions & 0 deletions
6
src/test/kotlin/com/mjucow/eatda/AbstractSpringContextTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.mjucow.eatda | ||
|
||
import org.springframework.test.annotation.DirtiesContext | ||
|
||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) | ||
abstract class AbstractSpringContextTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 2 additions & 13 deletions
15
src/test/kotlin/com/mjucow/eatda/domain/AbstractDataTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,17 @@ | ||
package com.mjucow.eatda.domain | ||
|
||
import com.mjucow.eatda.AbstractSpringContextTest | ||
import com.mjucow.eatda.common.config.JacksonConfiguration | ||
import com.mjucow.eatda.common.config.JooqContextConfiguration | ||
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest | ||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection | ||
import org.springframework.context.annotation.Import | ||
import org.springframework.test.context.ActiveProfiles | ||
import org.testcontainers.containers.PostgreSQLContainer | ||
import org.testcontainers.junit.jupiter.Container | ||
import org.testcontainers.junit.jupiter.Testcontainers | ||
|
||
@Import(value = [JooqContextConfiguration::class, JacksonConfiguration::class]) | ||
@DataJpaTest | ||
@Testcontainers | ||
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) | ||
@ActiveProfiles("test") | ||
abstract class AbstractDataTest { | ||
companion object { | ||
@Container | ||
@ServiceConnection | ||
val POSTGRESQL_CONTAINER = PostgreSQLContainer("postgres:15.4-alpine") | ||
.withUsername("test-user") | ||
.withPassword("test-password") | ||
.withDatabaseName("test_db")!! | ||
} | ||
} | ||
abstract class AbstractDataTest : AbstractSpringContextTest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters