|
49 | 49 | import org.apache.commons.io.FileUtils;
|
50 | 50 | import org.junit.jupiter.api.Tag;
|
51 | 51 | import org.junit.jupiter.api.Test;
|
| 52 | +import org.junit.jupiter.api.io.TempDir; |
52 | 53 |
|
53 | 54 | /** Tests for SnowflakeFileTransferAgent that require an active connection */
|
54 | 55 | @Tag(TestTags.OTHERS)
|
@@ -885,4 +886,32 @@ public void testUploadWithTildeInPath() throws SQLException, IOException {
|
885 | 886 | FileUtils.deleteDirectory(subDir.toFile());
|
886 | 887 | }
|
887 | 888 | }
|
| 889 | + |
| 890 | + @Test |
| 891 | + public void testUploadWithTripleSlashFilePrefix(@TempDir File tempDir) |
| 892 | + throws SQLException, IOException { |
| 893 | + String stageName = "testStage" + SnowflakeUtil.randomAlphaNumeric(10); |
| 894 | + try (Connection connection = getConnection(); |
| 895 | + Statement statement = connection.createStatement()) { |
| 896 | + try { |
| 897 | + statement.execute("CREATE OR REPLACE STAGE " + stageName); |
| 898 | + SFSession sfSession = connection.unwrap(SnowflakeConnectionV1.class).getSfSession(); |
| 899 | + |
| 900 | + String command = |
| 901 | + "PUT file:///" + getFullPathFileInResource(TEST_DATA_FILE) + " @" + stageName; |
| 902 | + SnowflakeFileTransferAgent sfAgent = |
| 903 | + new SnowflakeFileTransferAgent(command, sfSession, new SFStatement(sfSession)); |
| 904 | + assertTrue(sfAgent.execute()); |
| 905 | + |
| 906 | + String tempDirPath = tempDir.getCanonicalPath().replace("\\", "/"); |
| 907 | + String getCommand = "GET @" + stageName + " file:///" + tempDirPath; |
| 908 | + SnowflakeFileTransferAgent sfAgent1 = |
| 909 | + new SnowflakeFileTransferAgent(getCommand, sfSession, new SFStatement(sfSession)); |
| 910 | + assertTrue(sfAgent1.execute()); |
| 911 | + assertEquals(1, sfAgent1.statusRows.size()); |
| 912 | + } finally { |
| 913 | + statement.execute("DROP STAGE if exists " + stageName); |
| 914 | + } |
| 915 | + } |
| 916 | + } |
888 | 917 | }
|
0 commit comments