Skip to content

Commit 637b261

Browse files
authored
Refactor/15 remove testcontainer (#19)
* #11: Removed exasol-testconatiner compile dependency
1 parent c856274 commit 637b261

File tree

4 files changed

+80
-41
lines changed

4 files changed

+80
-41
lines changed

doc/changes/changes_0.4.0.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,25 @@ Code name:
66

77
* #15: Add API for host port proxy
88

9+
## Refactoring:
10+
11+
* #11: Removed exasol-testconatiner compile dependency
12+
913
## Dependency Updates
1014

1115
### Compile Dependency Updates
1216

17+
* Added `com.exasol:bucketfs-java:1.0.0`
1318
* Updated `com.exasol:error-reporting-java:0.2.0` to `0.4.0`
14-
* Updated `com.exasol:exasol-testcontainers:3.3.1` to `3.5.1`
19+
* Removed `com.exasol:exasol-testcontainers:3.3.1`
1520
* Updated `com.exasol:test-db-builder-java:2.0.0` to `3.1.1`
1621

1722
### Test Dependency Updates
1823

24+
* Added `com.exasol:exasol-testcontainers:3.5.2`
1925
* Updated `org.junit.jupiter:junit-jupiter-engine:5.6.2` to `5.7.1`
2026
* Updated `org.junit.jupiter:junit-jupiter-params:5.6.2` to `5.7.1`
21-
* Updated `org.junit.platform:junit-platform-runner:1.6.2` to `1.7.1`
27+
* Removed `org.junit.platform:junit-platform-runner:1.6.2`
2228
* Updated `org.mockito:mockito-core:3.6.0` to `3.8.0`
2329
* Updated `org.testcontainers:junit-jupiter:1.14.3` to `1.15.2`
2430

pom.xml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,10 @@
9393
<classifier>runtime</classifier>
9494
<scope>test</scope>
9595
</dependency>
96-
<!-- This is a compile dependency for accessing Bucket from testcontainers.
97-
It is planned to move it out there: -->
9896
<dependency>
9997
<groupId>com.exasol</groupId>
100-
<artifactId>exasol-testcontainers</artifactId>
101-
<version>3.5.1</version>
98+
<artifactId>bucketfs-java</artifactId>
99+
<version>1.0.0</version>
102100
</dependency>
103101
<!-- test dependencies -->
104102
<dependency>
@@ -107,12 +105,6 @@
107105
<version>${junit.version}</version>
108106
<scope>test</scope>
109107
</dependency>
110-
<dependency>
111-
<groupId>org.junit.platform</groupId>
112-
<artifactId>junit-platform-runner</artifactId>
113-
<version>${junit.platform.version}</version>
114-
<scope>test</scope>
115-
</dependency>
116108
<dependency>
117109
<groupId>org.junit.jupiter</groupId>
118110
<artifactId>junit-jupiter-params</artifactId>
@@ -132,6 +124,12 @@
132124
<scope>test</scope>
133125
</dependency>
134126
<!--Integration test dependencies-->
127+
<dependency>
128+
<groupId>com.exasol</groupId>
129+
<artifactId>exasol-testcontainers</artifactId>
130+
<version>3.5.2</version>
131+
<scope>test</scope>
132+
</dependency>
135133
<dependency>
136134
<groupId>org.testcontainers</groupId>
137135
<artifactId>junit-jupiter</artifactId>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.exasol.udfdebugging.modules;
2+
3+
import java.io.Closeable;
4+
import java.sql.*;
5+
import java.util.stream.Stream;
6+
7+
import com.exasol.bucketfs.Bucket;
8+
import com.exasol.containers.ExasolContainer;
9+
import com.exasol.dbbuilder.dialects.exasol.*;
10+
import com.exasol.dbbuilder.dialects.exasol.udf.UdfScript;
11+
import com.exasol.udfdebugging.ExposedServiceAddress;
12+
import com.exasol.udfdebugging.LocalServiceExposer;
13+
14+
/**
15+
* This class contains common integration test setup.
16+
*/
17+
public class TestSetup implements Closeable, AutoCloseable {
18+
private static final String SCHEMA_NAME = "TEST";
19+
private static final String UDF_NAME = "HELLO_WORLD";
20+
21+
private final ExasolContainer<? extends ExasolContainer<?>> exasol = new ExasolContainer<>().withReuse(true);
22+
23+
public TestSetup() {
24+
this.exasol.start();
25+
}
26+
27+
public LocalServiceExposer getHostPortProxy() {
28+
return port -> new ExposedServiceAddress(this.exasol.getHostIp(), port);
29+
}
30+
31+
public Bucket getDefaultBucket() {
32+
return this.exasol.getDefaultBucket();
33+
}
34+
35+
public ExasolContainer<? extends ExasolContainer<?>> getExasolContainer() {
36+
return this.exasol;
37+
}
38+
39+
public void runJavaUdf(final Stream<String> jvmOptions) throws SQLException {
40+
try (final Connection connection = this.exasol.createConnection();
41+
final Statement statement = connection.createStatement()) {
42+
final ExasolObjectFactory exasolObjectFactory = new ExasolObjectFactory(connection,
43+
ExasolObjectConfiguration.builder().withJvmOptions(jvmOptions.toArray(String[]::new)).build());
44+
final ExasolSchema schema = exasolObjectFactory.createSchema(SCHEMA_NAME);
45+
schema.createUdfBuilder(UDF_NAME).inputType(UdfScript.InputType.SCALAR).language(UdfScript.Language.JAVA)
46+
.content("class HELLO_WORLD {\n"
47+
+ " static String run(ExaMetadata exa, ExaIterator ctx) throws Exception {\n"
48+
+ " \treturn \"\";\n" + " }\n" + "}")
49+
.returns("VARCHAR(2000)").build();
50+
statement.executeQuery("SELECT " + SCHEMA_NAME + "." + UDF_NAME + "()").close();
51+
}
52+
}
53+
54+
@Override
55+
public void close() {
56+
this.exasol.stop();
57+
}
58+
}

src/test/java/com/exasol/udfdebugging/modules/coverage/CoverageModuleIT.java

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,24 @@
44
import static org.hamcrest.MatcherAssert.assertThat;
55

66
import java.io.*;
7-
import java.sql.Connection;
87
import java.sql.SQLException;
98
import java.util.concurrent.atomic.AtomicInteger;
109

1110
import org.jacoco.core.data.ExecutionDataReader;
1211
import org.junit.jupiter.api.Test;
13-
import org.testcontainers.junit.jupiter.Container;
14-
import org.testcontainers.junit.jupiter.Testcontainers;
1512

16-
import com.exasol.containers.ExasolContainer;
17-
import com.exasol.dbbuilder.dialects.exasol.*;
18-
import com.exasol.dbbuilder.dialects.exasol.udf.UdfScript;
1913
import com.exasol.errorreporting.ExaError;
20-
import com.exasol.udfdebugging.ExposedServiceAddress;
21-
import com.exasol.udfdebugging.LocalServiceExposer;
14+
import com.exasol.udfdebugging.modules.TestSetup;
2215

23-
@Testcontainers
2416
class CoverageModuleIT {
25-
@Container
26-
private static final ExasolContainer<? extends ExasolContainer<?>> EXASOL = new ExasolContainer<>().withReuse(true);
27-
private static final String SCHEMA_NAME = "TEST";
28-
private static final String UDF_NAME = "HELLO_WORLD";
29-
30-
private static LocalServiceExposer getHostPortProxy() {
31-
return port -> new ExposedServiceAddress(EXASOL.getHostIp(), port);
32-
}
3317

3418
@Test
35-
void testCoverageReportIsWritten() throws SQLException, IOException, InterruptedException {
19+
void testCoverageReportIsWritten() throws SQLException, IOException {
3620
deleteExecutionFile();
37-
final Connection connection = EXASOL.createConnection();
38-
final CoverageModule coverageModule = new CoverageModule(getHostPortProxy(), EXASOL.getDefaultBucket());
39-
final ExasolObjectFactory exasolObjectFactory = new ExasolObjectFactory(connection, ExasolObjectConfiguration
40-
.builder().withJvmOptions(coverageModule.getJvmOptions().toArray(String[]::new)).build());
41-
final ExasolSchema schema = exasolObjectFactory.createSchema(SCHEMA_NAME);
42-
schema.createUdfBuilder(UDF_NAME).inputType(UdfScript.InputType.SCALAR).language(UdfScript.Language.JAVA)
43-
.content("class HELLO_WORLD {\n"
44-
+ " static String run(ExaMetadata exa, ExaIterator ctx) throws Exception {\n"
45-
+ " \treturn \"hello world\";\n" + " }\n" + "}")
46-
.returns("VARCHAR(2000)").build();
47-
connection.createStatement().executeQuery("SELECT " + SCHEMA_NAME + "." + UDF_NAME + "()");
21+
final TestSetup udfSetup = new TestSetup();
22+
final CoverageModule coverageModule = new CoverageModule(udfSetup.getHostPortProxy(),
23+
udfSetup.getDefaultBucket());
24+
udfSetup.runJavaUdf(coverageModule.getJvmOptions());
4825
assertThat(countReportedJacocoSessions(), equalTo(1));
4926
}
5027

0 commit comments

Comments
 (0)