mirror of
https://github.com/valitydev/wb-list-manager.git
synced 2024-11-06 01:35:17 +00:00
modify riak extension
This commit is contained in:
parent
05d501db7e
commit
a5a823b16f
@ -15,8 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
import org.springframework.test.context.DynamicPropertySource;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@ -41,11 +39,6 @@ public class RiakTest {
|
||||
@Autowired
|
||||
private RiakClient client;
|
||||
|
||||
@DynamicPropertySource
|
||||
static void connectionConfigs(DynamicPropertyRegistry registry) {
|
||||
registry.add("riak.port", () -> RiakContainerExtension.RIAK.getMappedPort(8087));
|
||||
}
|
||||
|
||||
@Test
|
||||
void riakTest() throws ExecutionException, InterruptedException {
|
||||
sleep(10000);
|
||||
|
@ -16,8 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
import org.springframework.test.context.DynamicPropertySource;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
@ -62,11 +60,6 @@ public class WbListManagerApplicationTest {
|
||||
|
||||
private WbListServiceSrv.Iface handler;
|
||||
|
||||
@DynamicPropertySource
|
||||
static void connectionConfigs(DynamicPropertyRegistry registry) {
|
||||
registry.add("riak.port", () -> RiakContainerExtension.RIAK.getMappedPort(8087));
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void setUp() throws URISyntaxException {
|
||||
THClientBuilder clientBuilder = new THClientBuilder()
|
||||
|
@ -14,8 +14,6 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
import org.springframework.test.context.DynamicPropertySource;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
@ -36,11 +34,6 @@ public class WbListSafetyApplicationTest {
|
||||
@MockBean
|
||||
private ListRepository listRepository;
|
||||
|
||||
@DynamicPropertySource
|
||||
static void connectionConfigs(DynamicPropertyRegistry registry) {
|
||||
registry.add("riak.port", () -> RiakContainerExtension.RIAK.getMappedPort(8087));
|
||||
}
|
||||
|
||||
@Test
|
||||
void kafkaRowTestException() throws Exception {
|
||||
doThrow(new RiakExecutionException(),
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.rbkmoney.wb.list.manager.extension;
|
||||
|
||||
import org.junit.jupiter.api.extension.AfterAllCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeAllCallback;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.testcontainers.containers.GenericContainer;
|
||||
@ -7,18 +8,24 @@ import org.testcontainers.containers.wait.strategy.WaitAllStrategy;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public class RiakContainerExtension implements BeforeAllCallback {
|
||||
public class RiakContainerExtension implements BeforeAllCallback, AfterAllCallback {
|
||||
|
||||
public static GenericContainer RIAK;
|
||||
public static GenericContainer riak;
|
||||
|
||||
@Override
|
||||
public void beforeAll(ExtensionContext extensionContext) throws Exception {
|
||||
RIAK = new GenericContainer("basho/riak-kv")
|
||||
riak = new GenericContainer("basho/riak-kv")
|
||||
.withExposedPorts(8098, 8087)
|
||||
.withPrivilegedMode(true)
|
||||
.waitingFor(new WaitAllStrategy()
|
||||
.withStartupTimeout(Duration.ofMinutes(2)));
|
||||
|
||||
RIAK.start();
|
||||
riak.start();
|
||||
System.setProperty("riak.port", String.valueOf(riak.getMappedPort(8087)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterAll(ExtensionContext extensionContext) throws Exception {
|
||||
riak.stop();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user