SQL: Fix more JDK vs Joda TZ issues (elastic/x-pack-elasticsearch#3137)
Adds a random timezone known to both JDK and Joda as a connection parameter to all JdbcIntegrationTestCase-based tests. Original commit: elastic/x-pack-elasticsearch@6be6a3b69b
This commit is contained in:
parent
c08eb56238
commit
6fceb2fdde
|
@ -18,6 +18,8 @@ public class JdbcConnectionIT extends ConnectionTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Properties connectionProperties() {
|
protected Properties connectionProperties() {
|
||||||
return JdbcSecurityIT.adminProperties();
|
Properties properties = super.connectionProperties();
|
||||||
|
properties.putAll(JdbcSecurityIT.adminProperties());
|
||||||
|
return properties;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ public class JdbcDatabaseMetaDataIT extends DatabaseMetaDataTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Properties connectionProperties() {
|
protected Properties connectionProperties() {
|
||||||
return JdbcSecurityIT.adminProperties();
|
Properties properties = super.connectionProperties();
|
||||||
|
properties.putAll(JdbcSecurityIT.adminProperties());
|
||||||
|
return properties;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ public class JdbcErrorsIT extends ErrorsTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Properties connectionProperties() {
|
protected Properties connectionProperties() {
|
||||||
return JdbcSecurityIT.adminProperties();
|
Properties properties = super.connectionProperties();
|
||||||
|
properties.putAll(JdbcSecurityIT.adminProperties());
|
||||||
|
return properties;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ public class JdbcFetchSizeIT extends FetchSizeTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Properties connectionProperties() {
|
protected Properties connectionProperties() {
|
||||||
return JdbcSecurityIT.adminProperties();
|
Properties properties = super.connectionProperties();
|
||||||
|
properties.putAll(JdbcSecurityIT.adminProperties());
|
||||||
|
return properties;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import java.util.Properties;
|
||||||
|
|
||||||
import static org.elasticsearch.xpack.qa.sql.jdbc.JdbcAssert.assertResultSets;
|
import static org.elasticsearch.xpack.qa.sql.jdbc.JdbcAssert.assertResultSets;
|
||||||
import static org.elasticsearch.xpack.qa.sql.jdbc.JdbcIntegrationTestCase.elasticsearchAddress;
|
import static org.elasticsearch.xpack.qa.sql.jdbc.JdbcIntegrationTestCase.elasticsearchAddress;
|
||||||
|
import static org.elasticsearch.xpack.qa.sql.jdbc.JdbcIntegrationTestCase.randomKnownTimeZone;
|
||||||
import static org.hamcrest.Matchers.contains;
|
import static org.hamcrest.Matchers.contains;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
|
||||||
|
@ -33,7 +34,10 @@ public class JdbcSecurityIT extends SqlSecurityTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Connection es(Properties properties) throws SQLException {
|
static Connection es(Properties properties) throws SQLException {
|
||||||
return DriverManager.getConnection("jdbc:es://" + elasticsearchAddress(), properties);
|
Properties props = new Properties();
|
||||||
|
props.put("timezone", randomKnownTimeZone());
|
||||||
|
props.putAll(properties);
|
||||||
|
return DriverManager.getConnection("jdbc:es://" + elasticsearchAddress(), props);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Properties userProperties(String user) {
|
static Properties userProperties(String user) {
|
||||||
|
|
|
@ -18,6 +18,8 @@ public class JdbcSimpleExampleIT extends SimpleExampleTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Properties connectionProperties() {
|
protected Properties connectionProperties() {
|
||||||
return JdbcSecurityIT.adminProperties();
|
Properties properties = super.connectionProperties();
|
||||||
|
properties.putAll(JdbcSecurityIT.adminProperties());
|
||||||
|
return properties;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,8 +74,10 @@ public abstract class JdbcIntegrationTestCase extends ESRestTestCase {
|
||||||
// tag::connect-dm
|
// tag::connect-dm
|
||||||
String address = "jdbc:es://" + elasticsearchAddress(); // <1>
|
String address = "jdbc:es://" + elasticsearchAddress(); // <1>
|
||||||
Properties connectionProperties = connectionProperties(); // <2>
|
Properties connectionProperties = connectionProperties(); // <2>
|
||||||
return DriverManager.getConnection(address, connectionProperties);
|
Connection connection = DriverManager.getConnection(address, connectionProperties);
|
||||||
// end::connect-dm
|
// end::connect-dm
|
||||||
|
assertNotNull("The timezone should be specified", connectionProperties.getProperty(JdbcConfiguration.TIME_ZONE));
|
||||||
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Connection useDataSource() throws SQLException {
|
protected Connection useDataSource() throws SQLException {
|
||||||
|
@ -85,8 +87,10 @@ public abstract class JdbcIntegrationTestCase extends ESRestTestCase {
|
||||||
dataSource.setUrl(address);
|
dataSource.setUrl(address);
|
||||||
Properties connectionProperties = connectionProperties(); // <2>
|
Properties connectionProperties = connectionProperties(); // <2>
|
||||||
dataSource.setProperties(connectionProperties);
|
dataSource.setProperties(connectionProperties);
|
||||||
return dataSource.getConnection();
|
Connection connection = dataSource.getConnection();
|
||||||
// end::connect-ds
|
// end::connect-ds
|
||||||
|
assertNotNull("The timezone should be specified", connectionProperties.getProperty(JdbcConfiguration.TIME_ZONE));
|
||||||
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void index(String index, CheckedConsumer<XContentBuilder, IOException> body) throws IOException {
|
public static void index(String index, CheckedConsumer<XContentBuilder, IOException> body) throws IOException {
|
||||||
|
|
Loading…
Reference in New Issue