Skip to content

Commit

Permalink
Attempted fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-astachowski committed Oct 25, 2024
1 parent 2a8d4da commit 070ce8c
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public void testJDK14LoggingWithClientConfig() throws IOException {
statement.executeQuery("select 1");

File file = new File(Paths.get(logFolderPath.toString(), "jdbc").toString());
System.out.println("Expected: " + file.toPath());
System.out.print("Actual: ");
for (File f : logFolder.listFiles()) {
System.out.println(f.toPath());
}
assertTrue(file.exists());
}
} catch (IOException e) {
Expand Down Expand Up @@ -87,11 +92,14 @@ public void testJDK14LoggingWithClientConfigPermissionError() throws IOException
System.out.println("Perms before: " + Files.getPosixFilePermissions(directoryPath));
Files.setPosixFilePermissions(directoryPath, perms);
System.out.println("Perms after: " + Files.getPosixFilePermissions(directoryPath));
Files.createDirectories(Paths.get(directoryPath.toString(), "jdbc"));
System.out.println("Created subfolder without permissions");

Files.write(configFilePath, configJson.getBytes());
Properties properties = new Properties();
properties.put("client_config_file", configFilePath.toString());
assertThrows(SQLException.class, () -> getConnection(properties));
Exception e = assertThrows(SQLException.class, () -> getConnection(properties));
System.out.println(e.getMessage());
}

@Test
Expand All @@ -115,8 +123,10 @@ public void testJDK14LoggingWithMissingLogPathClientConfig() throws Exception {
File configFile = tmpFolder.newFile("config.json");
Path configFilePath = configFile.toPath();
String configJson = "{\"common\":{\"log_level\":\"debug\"}}";
Path home = tmpFolder.getRoot().toPath();
System.setProperty("user.home", home.toString());

Path homeLogPath = Paths.get(homePath, "jdbc");
Path homeLogPath = Paths.get(home.toString(), "jdbc");
Files.write(configFilePath, configJson.getBytes());
Properties properties = new Properties();
properties.put("client_config_file", configFilePath.toString());
Expand All @@ -132,6 +142,8 @@ public void testJDK14LoggingWithMissingLogPathClientConfig() throws Exception {
Files.deleteIfExists(configFilePath);
FileUtils.deleteDirectory(new File(homeLogPath.toString()));
}
} finally {
System.setProperty("user.home", homePath);
}
}

Expand All @@ -145,8 +157,7 @@ public void testJDK14LoggingWithMissingLogPathNoHomeDirClientConfig() throws Exc
Files.write(configFilePath, configJson.getBytes());
Properties properties = new Properties();
properties.put("client_config_file", configFilePath.toString());
try (Connection connection = getConnection(properties);
Statement statement = connection.createStatement()) {
try (Connection connection = getConnection(properties)) {

fail("testJDK14LoggingWithMissingLogPathNoHomeDirClientConfig failed");
} catch (SnowflakeSQLLoggedException e) {
Expand Down

0 comments on commit 070ce8c

Please sign in to comment.