ranjeet-floyd commented on a change in pull request #4871: Fixed issue- #4645 |
Use YAML configuration for java AbstractEncrypt…
URL:
https://github.com/apache/incubator-shardingsphere/pull/4871#discussion_r396677045
##########
File path:
sharding-jdbc/sharding-jdbc-core/src/test/java/org/apache/shardingsphere/shardingjdbc/common/base/AbstractEncryptJDBCDatabaseAndTableTest.java
##########
@@ -17,87 +17,90 @@
package org.apache.shardingsphere.shardingjdbc.common.base;
+import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.sql.SQLException;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import javax.sql.DataSource;
import org.apache.shardingsphere.encrypt.api.EncryptColumnRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.EncryptTableRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.EncryptorRuleConfiguration;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
+import
org.apache.shardingsphere.encrypt.yaml.config.YamlEncryptColumnRuleConfiguration;
+import
org.apache.shardingsphere.encrypt.yaml.config.YamlEncryptRuleConfiguration;
+import
org.apache.shardingsphere.encrypt.yaml.config.YamlEncryptTableRuleConfiguration;
+import
org.apache.shardingsphere.encrypt.yaml.config.YamlEncryptorRuleConfiguration;
import
org.apache.shardingsphere.shardingjdbc.jdbc.core.connection.EncryptConnection;
import
org.apache.shardingsphere.shardingjdbc.jdbc.core.datasource.EncryptDataSource;
import
org.apache.shardingsphere.underlying.common.config.properties.ConfigurationPropertyKey;
+import org.apache.shardingsphere.underlying.common.yaml.engine.YamlEngine;
import org.h2.tools.RunScript;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
-import javax.sql.DataSource;
-import java.io.InputStreamReader;
-import java.sql.SQLException;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
public abstract class AbstractEncryptJDBCDatabaseAndTableTest extends
AbstractSQLTest {
-
+
private static EncryptDataSource encryptDataSource;
-
+
private static EncryptDataSource encryptDataSourceWithProps;
-
+
private static final List<String> ENCRYPT_DB_NAMES =
Collections.singletonList("encrypt");
-
+
+ private static YamlEncryptRuleConfiguration encryptRuleConfig;
+
@BeforeClass
- public static void initEncryptDataSource() throws SQLException {
+ public static void initEncryptDataSource() throws SQLException,
IOException {
+ encryptRuleConfig =
getEncryptRuleConfig(getFile("encrypt_config.yaml"));
+ System.out.println(encryptRuleConfig);
if (null != encryptDataSource && null != encryptDataSourceWithProps) {
return;
}
Map<String, DataSource> dataSources = getDataSources();
encryptDataSource = new
EncryptDataSource(dataSources.values().iterator().next(), new
EncryptRule(createEncryptRuleConfiguration()), new Properties());
encryptDataSourceWithProps = new
EncryptDataSource(dataSources.values().iterator().next(), new
EncryptRule(createEncryptRuleConfiguration()), createProperties());
}
-
+
private static Properties createProperties() {
Properties result = new Properties();
result.put(ConfigurationPropertyKey.SQL_SHOW.getKey(), true);
result.put(ConfigurationPropertyKey.QUERY_WITH_CIPHER_COLUMN.getKey(),
false);
return result;
}
Review comment:
Added properties in yaml config
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services