Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1094021: Add Properties setters in SnowflakeBasicDataSource #1800

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,12 @@ public void setPrivateKeyFile(String location, String password) {
public void setTracing(String tracing) {
this.properties.put("tracing", tracing);
}

public Properties getProperties() {
return this.properties;
}

public void setProperties(Properties props) {
sfc-gh-wfateem marked this conversation as resolved.
Show resolved Hide resolved
this.properties.putAll(props);
}
}
35 changes: 35 additions & 0 deletions src/test/java/net/snowflake/client/jdbc/ConnectionLatestIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -1367,4 +1367,39 @@ public void testDataSourceOktaGenerates429StatusCode() throws Exception {
thread.join();
}
}

@Test
sfc-gh-wfateem marked this conversation as resolved.
Show resolved Hide resolved
@ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
sfc-gh-wfateem marked this conversation as resolved.
Show resolved Hide resolved
public void testDataSourceGetProperties() {
Map<String, String> params = getConnectionParameters();
SnowflakeBasicDataSource ds = new SnowflakeBasicDataSource();
ds.setAccount(params.get("account"));
ds.setAuthenticator("snowflake");
ds.setTracing("all");
Properties props = ds.getProperties();
assertEquals(params.get("account"), props.get("account"));
assertEquals("snowflake", props.get("authenticator"));
assertEquals("all", props.get("tracing"));
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
public void testDataSourceSetProperties() {
Map<String, String> params = getConnectionParameters();
SnowflakeBasicDataSource ds = new SnowflakeBasicDataSource();
ds.setAccount(params.get("account"));
ds.setAuthenticator("snowflake");
ds.setTracing("all");
Properties props = new Properties();
props.put("role", "test_role");
props.put("connection_property_key_1", "connection_property_value_1");
props.put("connection_property_key_2", "connection_property_value_2");
ds.setProperties(props);
Properties mergedProps = ds.getProperties();
assertEquals(params.get("account"), mergedProps.get("account"));
assertEquals("snowflake", mergedProps.get("authenticator"));
assertEquals("all", mergedProps.get("tracing"));
assertEquals("connection_property_value_1", mergedProps.get("connection_property_key_1"));
assertEquals("connection_property_value_2", mergedProps.get("connection_property_key_2"));
}
}
Loading