Skip to content

Commit de864ed

Browse files
committed
Added integration test to basic example
1 parent e991f9a commit de864ed

File tree

4 files changed

+58
-20
lines changed

4 files changed

+58
-20
lines changed

basic_example/pom.xml

+18-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
<groupId>org.apache.logging.log4j</groupId>
3131
<artifactId>log4j-slf4j-impl</artifactId>
3232
</dependency>
33+
34+
<dependency>
35+
<groupId>tech.ydb.test</groupId>
36+
<artifactId>ydb-junit5-support</artifactId>
37+
<scope>test</scope>
38+
</dependency>
3339
</dependencies>
3440

3541
<build>
@@ -52,7 +58,18 @@
5258
<mainClass>tech.ydb.example.App</mainClass>
5359
</manifest>
5460
</archive>
55-
</configuration>
61+
</configuration>
62+
</plugin>
63+
64+
<plugin>
65+
<groupId>org.apache.maven.plugins</groupId>
66+
<artifactId>maven-surefire-plugin</artifactId>
67+
<configuration>
68+
<environmentVariables>
69+
<TESTCONTAINERS_REUSE_ENABLE>true</TESTCONTAINERS_REUSE_ENABLE>
70+
<YDB_ANONYMOUS_CREDENTIALS>1</YDB_ANONYMOUS_CREDENTIALS>
71+
</environmentVariables>
72+
</configuration>
5673
</plugin>
5774
</plugins>
5875
</build>

basic_example/src/main/java/tech/ydb/example/App.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public final class App implements Runnable, AutoCloseable {
4141
private final String database;
4242
private final SessionRetryContext retryCtx;
4343

44-
private App(String connectionString) {
44+
App(String connectionString) {
4545
this.transport = GrpcTransport.forConnectionString(connectionString)
4646
.withAuthProvider(CloudAuthHelper.getAuthProviderFromEnviron())
4747
.build();

basic_example/src/main/resources/log4j2.xml

+9-18
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,21 @@
22
<Configuration status="WARN" shutdownHook="disable">
33
<Appenders>
44
<Console name="Console" target="SYSTEM_OUT">
5-
<PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %logger{1} - %msg%n"/>
5+
<PatternLayout pattern="[%level] %d{HH:mm:ss.SSS} %logger - %msg%n"/>
66
</Console>
77
</Appenders>
88

99
<Loggers>
10-
<Logger name="io.netty" level="warn" additivity="false">
11-
<AppenderRef ref="Console"/>
12-
</Logger>
13-
<Logger name="io.grpc.netty" level="warn" additivity="false">
14-
<AppenderRef ref="Console"/>
15-
</Logger>
16-
<Logger name="tech.ydb.core.grpc" level="info" additivity="false">
17-
<AppenderRef ref="Console"/>
18-
</Logger>
19-
<Logger name="tech.ydb.table" level="info" additivity="false">
20-
<AppenderRef ref="Console"/>
21-
</Logger>
22-
<Logger name="tech.ydb.table.SessionRetryContext" level="info" additivity="false">
23-
<AppenderRef ref="Console"/>
24-
</Logger>
25-
<Logger name="tech.ydb.table.Session" level="info" additivity="false">
10+
<!-- https://www.testcontainers.org/supported_docker_environment/logging_config/ -->
11+
<Logger name="org.testcontainers" level="warn" />
12+
<Logger name="com.github.dockerjava" level="warn"/>
13+
<Logger name="com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.wire" level="off"/>
14+
15+
<Logger name="io.grpc" level="warn" additivity="false">
2616
<AppenderRef ref="Console"/>
2717
</Logger>
28-
<Logger name="tech.ydb.topic" level="info" additivity="false">
18+
19+
<Logger name="tech.ydb" level="info" additivity="false">
2920
<AppenderRef ref="Console"/>
3021
</Logger>
3122

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package tech.ydb.example;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.junit.jupiter.api.extension.RegisterExtension;
5+
6+
import tech.ydb.test.junit5.YdbHelperExtension;
7+
8+
/**
9+
*
10+
* @author Aleksandr Gorshenin
11+
*/
12+
public class BasicExampleTest {
13+
@RegisterExtension
14+
private static final YdbHelperExtension ydb = new YdbHelperExtension();
15+
16+
private static String connectionString() {
17+
StringBuilder sb = new StringBuilder();
18+
sb.append(ydb.useTls() ? "grpcs://" : "grpc://" );
19+
sb.append(ydb.endpoint());
20+
sb.append(ydb.database());
21+
return sb.toString();
22+
}
23+
24+
@Test
25+
public void testBasicApp() {
26+
App app = new App(connectionString());
27+
app.run();
28+
app.close();
29+
}
30+
}

0 commit comments

Comments
 (0)