BAEL-7670: Introduction to DuckDB (#16430)

This commit is contained in:
Manfred 2024-04-17 01:31:20 +01:00 committed by GitHub
parent afe0ff1351
commit 1f2c8a5c3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 13 deletions

View File

@ -6,18 +6,6 @@
<groupId>org.baeldung</groupId>
<artifactId>duckdb</artifactId>
<name>duckdb</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>9</source>
<target>9</target>
</configuration>
</plugin>
</plugins>
</build>
<version>0.0.1-SNAPSHOT</version>
<parent>

View File

@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
@ -18,6 +19,7 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
@ -167,7 +169,20 @@ class DuckDbAccessIntegrationTest {
}
private String getResourceAbsolutePath(String name) {
return this.getClass().getResource(name).getPath().replaceFirst("/", "");
return Optional.ofNullable(this.getClass()
.getResource(name))
.map(URL::getPath)
.map(this::removeSlashFromPathIfWindows)
.orElseThrow(IllegalArgumentException::new);
}
private String removeSlashFromPathIfWindows(String path) {
if (System.getProperty("os.name")
.toLowerCase()
.contains("win")) {
return path.replaceFirst("/", "");
}
return path;
}
private int getTableRowCount(Connection conn, String tableName) throws SQLException {