diff --git a/src/test/java/net/snowflake/client/log/JDK14LoggerWithClientLatestIT.java b/src/test/java/net/snowflake/client/log/JDK14LoggerWithClientLatestIT.java index c4ac27082..32dbd738a 100644 --- a/src/test/java/net/snowflake/client/log/JDK14LoggerWithClientLatestIT.java +++ b/src/test/java/net/snowflake/client/log/JDK14LoggerWithClientLatestIT.java @@ -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) { @@ -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 @@ -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()); @@ -132,6 +142,8 @@ public void testJDK14LoggingWithMissingLogPathClientConfig() throws Exception { Files.deleteIfExists(configFilePath); FileUtils.deleteDirectory(new File(homeLogPath.toString())); } + } finally { + System.setProperty("user.home", homePath); } } @@ -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) {