|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2018 the original author or authors. |
| 2 | + * Copyright 2012-2019 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
22 | 22 | import org.junit.Before;
|
23 | 23 | import org.junit.ClassRule;
|
24 | 24 | import org.junit.Test;
|
| 25 | +import org.testcontainers.containers.CassandraContainer; |
25 | 26 |
|
26 | 27 | import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
|
27 | 28 | import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
|
28 | 29 | import org.springframework.boot.autoconfigure.data.cassandra.city.City;
|
29 | 30 | import org.springframework.boot.test.util.TestPropertyValues;
|
30 |
| -import org.springframework.boot.testsupport.testcontainers.CassandraContainer; |
31 | 31 | import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
32 | 32 | import org.springframework.data.cassandra.config.CassandraSessionFactoryBean;
|
33 | 33 | import org.springframework.data.cassandra.config.SchemaAction;
|
|
43 | 43 | public class CassandraDataAutoConfigurationIntegrationTests {
|
44 | 44 |
|
45 | 45 | @ClassRule
|
46 |
| - public static CassandraContainer cassandra = new CassandraContainer(); |
| 46 | + public static CassandraContainer<?> cassandra = new CassandraContainer<>(); |
47 | 47 |
|
48 | 48 | private AnnotationConfigApplicationContext context;
|
49 | 49 |
|
50 | 50 | @Before
|
51 | 51 | public void setUp() {
|
52 | 52 | this.context = new AnnotationConfigApplicationContext();
|
53 | 53 | TestPropertyValues
|
54 |
| - .of("spring.data.cassandra.port=" + cassandra.getMappedPort(), |
| 54 | + .of("spring.data.cassandra.port=" + cassandra.getFirstMappedPort(), |
55 | 55 | "spring.data.cassandra.read-timeout=24000",
|
56 | 56 | "spring.data.cassandra.connect-timeout=10000")
|
57 | 57 | .applyTo(this.context.getEnvironment());
|
@@ -96,7 +96,8 @@ public void hasRecreateSchemaActionSet() {
|
96 | 96 |
|
97 | 97 | private void createTestKeyspaceIfNotExists() {
|
98 | 98 | Cluster cluster = Cluster.builder().withoutJMXReporting()
|
99 |
| - .withPort(cassandra.getMappedPort()).addContactPoint("localhost").build(); |
| 99 | + .withPort(cassandra.getFirstMappedPort()).addContactPoint("localhost") |
| 100 | + .build(); |
100 | 101 | try (Session session = cluster.connect()) {
|
101 | 102 | session.execute("CREATE KEYSPACE IF NOT EXISTS boot_test"
|
102 | 103 | + " WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };");
|
|
0 commit comments