Skip to content

Commit 38bf06b

Browse files
author
Elifarley Cruz
committed
Initial commit
0 parents  commit 38bf06b

File tree

3 files changed

+303
-0
lines changed

3 files changed

+303
-0
lines changed

app-test/pom.xml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
6+
<modelVersion>4.0.0</modelVersion>
7+
8+
<parent>
9+
<groupId>com.orgecc.koin</groupId>
10+
<artifactId>koin-example-root</artifactId>
11+
<version>default-SNAPSHOT</version>
12+
<relativePath>..</relativePath>
13+
</parent>
14+
15+
<artifactId>koin-test</artifactId>
16+
17+
<build>
18+
<plugins>
19+
<plugin> <!-- See https://stackoverflow.com/questions/36970384/surefire-is-not-picking-up-junit-5-tests -->
20+
<artifactId>maven-surefire-plugin</artifactId>
21+
<configuration>
22+
<forkCount>1C</forkCount>
23+
<reuseForks>false</reuseForks>
24+
<workingDirectory>/tmp/stht-surefire-fork-dir-${surefire.forkNumber}</workingDirectory>
25+
<argLine>-Xmx500m</argLine>
26+
<includes>
27+
<include>%regex[.*(Tests|IT).class]</include>
28+
</includes>
29+
<environmentVariables>
30+
<DB_HOST>localhost:5432</DB_HOST>
31+
<DB_PW>123</DB_PW>
32+
<DB_ADMIN_PW>123admin</DB_ADMIN_PW>
33+
<flyway.delete-all>true</flyway.delete-all>
34+
<LOGBACK_JSON>true</LOGBACK_JSON>
35+
</environmentVariables>
36+
</configuration>
37+
</plugin>
38+
</plugins>
39+
</build>
40+
41+
<dependencies>
42+
43+
<dependency>
44+
<groupId>org.koin</groupId>
45+
<artifactId>koin-core</artifactId>
46+
</dependency>
47+
48+
<dependency>
49+
<groupId>org.koin</groupId>
50+
<artifactId>koin-test</artifactId>
51+
</dependency>
52+
53+
<dependency>
54+
<groupId>org.junit.jupiter</groupId>
55+
<artifactId>junit-jupiter-api</artifactId>
56+
<scope>test</scope>
57+
</dependency>
58+
59+
<dependency>
60+
<groupId>io.kotlintest</groupId>
61+
<artifactId>kotlintest-runner-junit5</artifactId>
62+
<scope>test</scope>
63+
</dependency>
64+
65+
<dependency>
66+
<groupId>io.kotlintest</groupId>
67+
<artifactId>kotlintest-extensions-koin</artifactId>
68+
<scope>test</scope>
69+
</dependency>
70+
71+
</dependencies>
72+
73+
</project>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package koinexample
2+
3+
import io.kotlintest.koin.KoinListener
4+
import io.kotlintest.shouldBe
5+
import io.kotlintest.specs.FreeSpec
6+
import org.koin.core.inject
7+
import org.koin.dsl.module
8+
import org.koin.test.KoinTest
9+
10+
data class Stats(var ok: Long = 0, var error: Long = 0)
11+
12+
interface StatsServer {
13+
fun newError(): Long
14+
}
15+
16+
class StatsServerSimple(private val stats: Stats) : StatsServer {
17+
override fun newError() = stats.error++
18+
}
19+
20+
val appModule = module {
21+
single { Stats() }
22+
single { StatsServerSimple(get()) as StatsServer }
23+
}
24+
25+
class KoinSampleTests : FreeSpec(), KoinTest {
26+
27+
private val modules = listOf(
28+
appModule
29+
)
30+
31+
override fun listeners() = listOf(KoinListener(modules))
32+
33+
val statsServer: StatsServer by inject()
34+
35+
init {
36+
37+
"Happy path" {
38+
statsServer.newError() shouldBe 1
39+
}
40+
}
41+
}

pom.xml

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
6+
<modelVersion>4.0.0</modelVersion>
7+
8+
<groupId>com.orgecc.koin</groupId>
9+
<artifactId>koin-example-root</artifactId>
10+
<version>default-SNAPSHOT</version>
11+
<packaging>pom</packaging>
12+
<name>koin-example</name>
13+
<inceptionYear>2020</inceptionYear>
14+
15+
<properties>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
18+
<java.version>11</java.version>
19+
<kotlin.version>1.3.61</kotlin.version>
20+
<kotlin.compiler.jvmTarget>${java.version}</kotlin.compiler.jvmTarget>
21+
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
22+
<kotlin.code.style>official</kotlin.code.style>
23+
<maven.compiler.source>1.8</maven.compiler.source>
24+
<maven.compiler.target>1.8</maven.compiler.target>
25+
<koin.version>2.0.1</koin.version>
26+
<slf4j.version>1.7.28</slf4j.version>
27+
<logback.version>1.2.3</logback.version>
28+
<http4k.version>3.231.0</http4k.version>
29+
<junit.version>5.6.0</junit.version>
30+
<kotlintest.version>3.4.2</kotlintest.version>
31+
32+
</properties>
33+
34+
<modules>
35+
<module>app-test</module>
36+
</modules>
37+
38+
<repositories>
39+
<repository>
40+
<id>JCenter</id>
41+
<url>https://jcenter.bintray.com/</url>
42+
</repository>
43+
</repositories>
44+
45+
<build>
46+
47+
<defaultGoal>install</defaultGoal>
48+
49+
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
50+
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
51+
52+
<pluginManagement>
53+
<plugins>
54+
<plugin>
55+
<groupId>org.apache.maven.plugins</groupId>
56+
<artifactId>maven-surefire-plugin</artifactId>
57+
<version>2.19.1</version> <!-- See https://github.com/junit-team/junit5/issues/809 -->
58+
<!-- <version>2.22.2</version>-->
59+
<dependencies>
60+
<dependency>
61+
<groupId>org.junit.platform</groupId>
62+
<artifactId>junit-platform-surefire-provider</artifactId>
63+
<version>1.1.0</version>
64+
</dependency>
65+
</dependencies>
66+
</plugin>
67+
</plugins>
68+
</pluginManagement>
69+
70+
<plugins>
71+
72+
<plugin>
73+
<groupId>org.jetbrains.kotlin</groupId>
74+
<artifactId>kotlin-maven-plugin</artifactId>
75+
<version>${kotlin.version}</version>
76+
<executions>
77+
<execution>
78+
<id>compile</id>
79+
<phase>process-sources</phase>
80+
<goals>
81+
<goal>compile</goal>
82+
</goals>
83+
</execution>
84+
<execution>
85+
<id>test-compile</id>
86+
<phase>process-test-sources</phase>
87+
<goals>
88+
<goal>test-compile</goal>
89+
</goals>
90+
</execution>
91+
</executions>
92+
</plugin>
93+
94+
<plugin>
95+
<groupId>org.apache.maven.plugins</groupId>
96+
<artifactId>maven-compiler-plugin</artifactId>
97+
<version>3.7.0</version>
98+
</plugin>
99+
100+
</plugins>
101+
102+
</build>
103+
104+
<dependencyManagement>
105+
<dependencies>
106+
107+
<dependency>
108+
<groupId>org.jetbrains.kotlin</groupId>
109+
<artifactId>kotlin-stdlib-jdk8</artifactId>
110+
<version>${kotlin.version}</version>
111+
</dependency>
112+
<dependency>
113+
<groupId>org.jetbrains.kotlin</groupId>
114+
<artifactId>kotlin-stdlib</artifactId>
115+
<version>${kotlin.version}</version>
116+
</dependency>
117+
118+
<dependency>
119+
<groupId>org.slf4j</groupId>
120+
<artifactId>slf4j-api</artifactId>
121+
<version>${slf4j.version}</version>
122+
</dependency>
123+
124+
<dependency>
125+
<groupId>ch.qos.logback</groupId>
126+
<artifactId>logback-classic</artifactId>
127+
<version>${logback.version}</version>
128+
<exclusions>
129+
<exclusion>
130+
<groupId>com.sun.mail</groupId>
131+
<artifactId>javax.mail</artifactId>
132+
</exclusion>
133+
</exclusions>
134+
</dependency>
135+
136+
<dependency>
137+
<groupId>org.koin</groupId>
138+
<artifactId>koin-core</artifactId>
139+
<version>${koin.version}</version>
140+
</dependency>
141+
<dependency>
142+
<groupId>org.koin</groupId>
143+
<artifactId>koin-test</artifactId>
144+
<version>${koin.version}</version>
145+
</dependency>
146+
147+
<dependency>
148+
<groupId>org.jooq</groupId>
149+
<artifactId>jooq</artifactId>
150+
<version>3.12.4</version>
151+
</dependency>
152+
153+
<dependency>
154+
<groupId>org.junit.jupiter</groupId>
155+
<artifactId>junit-jupiter-api</artifactId>
156+
<version>${junit.version}</version>
157+
</dependency>
158+
159+
<dependency>
160+
<groupId>io.kotlintest</groupId>
161+
<artifactId>kotlintest-runner-junit5</artifactId>
162+
<version>${kotlintest.version}</version>
163+
</dependency>
164+
<dependency>
165+
<groupId>io.kotlintest</groupId>
166+
<artifactId>kotlintest-extensions-koin</artifactId>
167+
<version>${kotlintest.version}</version>
168+
</dependency>
169+
170+
</dependencies>
171+
</dependencyManagement>
172+
173+
<dependencies>
174+
175+
<dependency>
176+
<groupId>org.jetbrains.kotlin</groupId>
177+
<artifactId>kotlin-stdlib-jdk8</artifactId>
178+
</dependency>
179+
180+
<dependency>
181+
<groupId>ch.qos.logback</groupId>
182+
<artifactId>logback-classic</artifactId>
183+
</dependency>
184+
185+
</dependencies>
186+
187+
</project>
188+
189+

0 commit comments

Comments
 (0)