-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SNOW-565154: Test download stream should fail fast on not existing fi…
…le (#1566)
- Loading branch information
1 parent
d047760
commit 119f72b
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/test/java/net/snowflake/client/jdbc/cloud/storage/CloudStorageClientLatestIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package net.snowflake.client.jdbc.cloud.storage; | ||
|
||
import static org.hamcrest.CoreMatchers.instanceOf; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.io.InputStream; | ||
import java.sql.Connection; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
import java.util.UUID; | ||
import net.snowflake.client.category.TestCategoryOthers; | ||
import net.snowflake.client.jdbc.BaseJDBCTest; | ||
import net.snowflake.client.jdbc.SnowflakeConnection; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
|
||
@Category(TestCategoryOthers.class) | ||
public class CloudStorageClientLatestIT extends BaseJDBCTest { | ||
|
||
/** | ||
* Test for SNOW-565154 - it was waiting for ~5 minutes so the test is waiting much shorter time | ||
*/ | ||
@Test(timeout = 30000L) | ||
public void testDownloadStreamShouldFailFastOnNotExistingFile() throws Throwable { | ||
String stageName = | ||
"testDownloadStream_stage_" + UUID.randomUUID().toString().replaceAll("-", "_"); | ||
try (Connection connection = getConnection(); | ||
Statement statement = connection.createStatement()) { | ||
try { | ||
statement.execute("CREATE OR REPLACE TEMP STAGE " + stageName); | ||
|
||
try (InputStream out = | ||
connection | ||
.unwrap(SnowflakeConnection.class) | ||
.downloadStream("@" + stageName, "/fileNotExist.gz", true)) { | ||
fail("file should not exist"); | ||
} catch (Throwable e) { | ||
assertThat(e, instanceOf(SQLException.class)); | ||
} | ||
} finally { | ||
statement.execute("DROP STAGE IF EXISTS " + stageName); | ||
} | ||
} | ||
} | ||
} |