-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Testcontainers Service Connection in examples (#63)
Use Testcontainers OpenFGA Module to improve DevEx when starting the example. This is an alternative solution for #58 due to the current state of the project. I'm planning to add another PRs to add native integration where the DynamicPropertyRegistry is not needed.
- Loading branch information
Showing
4 changed files
with
48 additions
and
10 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
28 changes: 28 additions & 0 deletions
28
examples/servlet/src/test/java/dev/openfga/example/TestServletApp.java
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,28 @@ | ||
package dev.openfga.example; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.test.context.DynamicPropertyRegistry; | ||
import org.testcontainers.openfga.OpenFGAContainer; | ||
|
||
public class TestServletApp { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.from(ServletApp::main) | ||
.with(TestConfig.class) | ||
.run(args); | ||
} | ||
|
||
@TestConfiguration(proxyBeanMethods = false) | ||
static class TestConfig { | ||
|
||
@Bean | ||
OpenFGAContainer container(DynamicPropertyRegistry registry) { | ||
OpenFGAContainer container = new OpenFGAContainer("openfga/openfga:v1.4.3"); | ||
registry.add("openfga.api-url", container::getHttpEndpoint); | ||
return container; | ||
} | ||
|
||
} | ||
} |
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,16 @@ | ||
<configuration> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<!-- encoders are assigned the type | ||
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | ||
<encoder> | ||
<pattern>%d{HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="INFO"> | ||
<appender-ref ref="STDOUT"/> | ||
</root> | ||
|
||
<logger name="org.testcontainers" level="INFO"/> | ||
</configuration> |