File tree 4 files changed +162
-0
lines changed
spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/testcontainers
4 files changed +162
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2012-2024 the original author or authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package org.springframework.boot.docs.testing.testcontainers.dynamicproperties ;
18
+
19
+ import org.junit.jupiter.api.Test
20
+ import org.springframework.boot.test.context.SpringBootTest
21
+ import org.springframework.test.context.DynamicPropertyRegistry
22
+ import org.springframework.test.context.DynamicPropertySource
23
+ import org.testcontainers.containers.Neo4jContainer
24
+ import org.testcontainers.junit.jupiter.Container
25
+ import org.testcontainers.junit.jupiter.Testcontainers
26
+
27
+ @Testcontainers
28
+ @SpringBootTest
29
+ class MyIntegrationTests {
30
+
31
+ @Test
32
+ fun myTest () {
33
+ // ...
34
+ }
35
+
36
+ companion object {
37
+ @Container
38
+ @JvmStatic
39
+ val neo4j = Neo4jContainer (" neo4j:5" );
40
+
41
+ @DynamicPropertySource
42
+ @JvmStatic
43
+ fun neo4jProperties (registry : DynamicPropertyRegistry ) {
44
+ registry.add(" spring.neo4j.uri" ) { neo4j.boltUrl }
45
+ }
46
+ }
47
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2012-2024 the original author or authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package org.springframework.boot.docs.testing.testcontainers.serviceconnections ;
18
+
19
+ import org.junit.jupiter.api.Test;
20
+ import org.testcontainers.containers.Neo4jContainer;
21
+ import org.testcontainers.junit.jupiter.Container;
22
+ import org.testcontainers.junit.jupiter.Testcontainers;
23
+
24
+ import org.springframework.boot.test.context.SpringBootTest;
25
+ import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
26
+
27
+ @Testcontainers
28
+ @SpringBootTest
29
+ class MyIntegrationTests {
30
+
31
+ @Test
32
+ fun myTest () {
33
+ // ...
34
+ }
35
+
36
+ companion object {
37
+ @Container
38
+ @ServiceConnection
39
+ @JvmStatic
40
+ val neo4j = Neo4jContainer (" neo4j:5" );
41
+ }
42
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2012-2024 the original author or authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package org.springframework.boot.docs.testing.testcontainers.serviceconnections ;
18
+
19
+ import org.springframework.boot.test.context.TestConfiguration
20
+ import org.springframework.boot.testcontainers.service.connection.ServiceConnection
21
+ import org.springframework.context.annotation.Bean
22
+ import org.testcontainers.containers.GenericContainer
23
+
24
+ @TestConfiguration(proxyBeanMethods = false )
25
+ class MyRedisConfiguration {
26
+ @Bean
27
+ @ServiceConnection(name = " redis" )
28
+ fun redisContainer (): GenericContainer <* > {
29
+ return GenericContainer (" redis:7" )
30
+ }
31
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2012-2024 the original author or authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package org.springframework.boot.docs.testing.testcontainers.vanilla ;
18
+
19
+ import org.junit.jupiter.api.Test;
20
+ import org.testcontainers.containers.Neo4jContainer;
21
+ import org.testcontainers.junit.jupiter.Container;
22
+ import org.testcontainers.junit.jupiter.Testcontainers;
23
+
24
+ import org.springframework.boot.test.context.SpringBootTest;
25
+ import org.springframework.boot.testcontainers.service.connection.ServiceConnection
26
+
27
+ @Testcontainers
28
+ @SpringBootTest
29
+ class MyIntegrationTests {
30
+
31
+ @Test
32
+ fun myTest () {
33
+ // ...
34
+ }
35
+
36
+ companion object {
37
+ @Container
38
+ @JvmStatic
39
+ val neo4j = Neo4jContainer (" neo4j:5" );
40
+ }
41
+ }
42
+
You can’t perform that action at this time.
0 commit comments