Skip to content

Commit

Permalink
net-sf-ucanaccess-fork: Update unit test resources
Browse files Browse the repository at this point in the history
  • Loading branch information
spannm committed Jan 25, 2024
1 parent 8ae7579 commit deac7fd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/test/java/net/ucanaccess/jdbc/BlobOleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected void init(AccessVersion _accessVersion) throws SQLException {
void testBlobOle(AccessVersion _accessVersion) throws SQLException, IOException {
init(_accessVersion);

String imgFileName = String.join(File.separator, getClass().getSimpleName(), "blobOleTest.jpeg");
String imgFileName = getFileResource("blobOleTest.jpg"); // media file (c) Markus Spann

Blob blob = ucanaccess.createBlob();
try (InputStream is = getClass().getClassLoader().getResourceAsStream(imgFileName.replace(File.separatorChar, '/'));
Expand Down Expand Up @@ -67,8 +67,11 @@ void testBlobOle(AccessVersion _accessVersion) throws SQLException, IOException
}
}

// media file found here: https://commons.wikimedia.org/wiki/File:Animhorse.gif
// (licensed under the Creative Commons Attribution-Share Alike 2.5 Generic license)
String binFileName = getFileResource("blobOleTest.gif");

try (PreparedStatement ps = ucanaccess.prepareStatement("UPDATE t_ole_test SET c_ole=? WHERE c_descr=?")) {
String binFileName = String.join(File.separator, getClass().getSimpleName(), "blobOleTest.mp4");
File file = createTempFileName(binFileName, null);
try (InputStream is = getClass().getClassLoader().getResourceAsStream(binFileName.replace('/', File.separatorChar))) {
copyFile(is, file).deleteOnExit();
Expand Down Expand Up @@ -98,14 +101,21 @@ void testBlobOle(AccessVersion _accessVersion) throws SQLException, IOException
}
}

private String getFileResource(String fileName) {
String folder = getClass().getSimpleName();
folder = folder.substring(0, 1).toLowerCase() + folder.substring(1);
return String.join(File.separator, folder, fileName);
}

// It only works with JRE 1.6 and later (JDBC 3)
@ParameterizedTest(name = "[{index}] {0}")
@EnumSource(value = AccessVersion.class)
void testBlobPackaged(AccessVersion _accessVersion) throws SQLException, IOException {
init(_accessVersion);

String binFileName = "BlobOleTest/blobOleTest.mp4";
String binFileName = getFileResource("blobOleTest.mp4");
File file = createTempFileName(binFileName.replace('/', File.separatorChar), null);

try (InputStream is = getClass().getClassLoader().getResourceAsStream(binFileName)) {
copyFile(is, file).deleteOnExit();
}
Expand Down
Binary file removed src/test/resources/BlobOleTest/blobOleTest.jpeg
Binary file not shown.
Binary file removed src/test/resources/BlobOleTest/blobOleTest.mp4
Binary file not shown.
Binary file added src/test/resources/blobOleTest/blobOleTest.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/test/resources/blobOleTest/blobOleTest.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit deac7fd

Please sign in to comment.