-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTarantoolCallEvalAbstractExample.java
More file actions
50 lines (39 loc) · 1.38 KB
/
TarantoolCallEvalAbstractExample.java
File metadata and controls
50 lines (39 loc) · 1.38 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
/*
* Copyright (c) 2025 VK DIGITAL TECHNOLOGIES LIMITED LIABILITY COMPANY
* All Rights Reserved.
*/
package client;
// --8<-- [start:all]
import java.io.IOException;
import testcontainers.utils.TarantoolSingleNodeConfigUtils;
public abstract class TarantoolCallEvalAbstractExample
extends TarantoolSingleInstanceConnectionAbstractExample {
protected static String HELLO_WORLD_FUNCTION = "hello_world_function";
protected static String HELLO_WORLD_FUNCTION_RETURNS = "hello world";
protected static String SOME_MAP_FUNCTION = "some_map_function";
protected static final String LUA_FUNCTION =
String.format(
"""
%s = function()
return '%s'
end
%s = function(name, age)
return {
name = name,
age = age
}
end
""",
HELLO_WORLD_FUNCTION, HELLO_WORLD_FUNCTION_RETURNS, SOME_MAP_FUNCTION);
protected void loadFunctions() throws IOException, InterruptedException {
final String command =
"echo \"%s\" | tt connect %s:%s@localhost:3301"
.formatted(
LUA_FUNCTION,
TarantoolSingleNodeConfigUtils.LOGIN,
TarantoolSingleNodeConfigUtils.PWD);
CONTAINER.execInContainer("/bin/sh", "-c", command);
}
protected record TestUser(String name, Integer age) {}
}
// --8<-- [end:all]