-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTarantoolSingleInstanceConnectionCartridgeDriverExample.java
More file actions
54 lines (42 loc) · 1.8 KB
/
TarantoolSingleInstanceConnectionCartridgeDriverExample.java
File metadata and controls
54 lines (42 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* Copyright (c) 2025 VK DIGITAL TECHNOLOGIES LIMITED LIABILITY COMPANY
* All Rights Reserved.
*/
package client;
// --8<-- [start:tarantool-single-instance-cartridge-driver]
import java.net.InetSocketAddress;
import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import testcontainers.utils.TarantoolSingleNodeConfigUtils;
import io.tarantool.driver.api.TarantoolClient;
import io.tarantool.driver.api.TarantoolClientFactory;
import io.tarantool.driver.api.TarantoolResult;
import io.tarantool.driver.api.tuple.TarantoolTuple;
public class TarantoolSingleInstanceConnectionCartridgeDriverExample
extends TarantoolSingleInstanceConnectionAbstractExample {
@Test
@Override
protected void simpleConnection() {
try (TarantoolClient<TarantoolTuple, TarantoolResult<TarantoolTuple>> client = setupClient()) {
final List<?> result = client.eval("return _TARANTOOL").join();
Assertions.assertEquals(1, result.size());
final Object object = result.get(0);
Assertions.assertInstanceOf(String.class, object);
Assertions.assertTrue(((String) object).contains(TARANTOOL_TAG));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private static TarantoolClient<TarantoolTuple, TarantoolResult<TarantoolTuple>> setupClient() {
// Получаем адрес и порт из докера
// Gets address and port from docker
final InetSocketAddress nodeAddress = CONTAINER.mappedAddress();
return TarantoolClientFactory.createClient()
.withAddress(nodeAddress.getHostName(), nodeAddress.getPort())
.withCredentials(
TarantoolSingleNodeConfigUtils.LOGIN, TarantoolSingleNodeConfigUtils.PWD.toString())
.build();
}
}
// --8<-- [end:tarantool-single-instance-cartridge-driver]