[GitHub] [shardingsphere] sukumaar commented on a change in pull request #5614: Use YAML file instead of inline string in ConfigCenterTest.java

2020-05-24 Thread GitBox


sukumaar commented on a change in pull request #5614:
URL: https://github.com/apache/shardingsphere/pull/5614#discussion_r429648669



##
File path: 
sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-configcenter/src/test/java/org/apache/shardingsphere/orchestration/core/configcenter/ConfigCenterTest.java
##
@@ -552,4 +465,13 @@ private void 
assertDataSourceConfigurationWithConnectionInitSqls(final DataSourc
 assertThat(actual.getProperties().get("password"), 
is(expected.getProperties().get("password")));
 assertThat(actual.getProperties().get("connectionInitSqls"), 
is(expected.getProperties().get("connectionInitSqls")));
 }
+
+private static String readYamlFileIntoString(final String fileName) {
+try {
+return (new 
String(Files.readAllBytes(Paths.get(ClassLoader.getSystemResource(fileName).toURI().replaceAll("#.*\n",
 "");

Review comment:
   yes, YAML string and actual YAML file should be same. But build is 
failing because YAML file is not having licence information.
   If we add license information to the YAML file then actual YAML string and 
YAML file content could not be matched :-/





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:
us...@infra.apache.org




[GitHub] [shardingsphere] sukumaar commented on a change in pull request #5614: Use YAML file instead of inline string in ConfigCenterTest.java

2020-05-21 Thread GitBox


sukumaar commented on a change in pull request #5614:
URL: https://github.com/apache/shardingsphere/pull/5614#discussion_r428700878



##
File path: 
sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-configcenter/src/test/java/org/apache/shardingsphere/orchestration/core/configcenter/ConfigCenterTest.java
##
@@ -552,4 +465,13 @@ private void 
assertDataSourceConfigurationWithConnectionInitSqls(final DataSourc
 assertThat(actual.getProperties().get("password"), 
is(expected.getProperties().get("password")));
 assertThat(actual.getProperties().get("connectionInitSqls"), 
is(expected.getProperties().get("connectionInitSqls")));
 }
+
+private static String readYamlFileIntoString(final String fileName) {
+try {
+return (new 
String(Files.readAllBytes(Paths.get(ClassLoader.getSystemResource(fileName).toURI().replaceAll("#.*\n",
 "");

Review comment:
   Hey I referred to the PR you had asked me to refer.  
   if I use 
   ```java
   @SneakyThrows
   private String readYAML(final String yamlFile) {
   return 
Files.readAllLines(Paths.get(ClassLoader.getSystemResource(yamlFile).toURI())).stream().map(each
 -> each + System.lineSeparator()).collect(Collectors.joining());
   }
   ```
   or 
   ```java
   @SneakyThrows
   private static String readYamlFileIntoString(final String fileName) {
   return new 
String(Files.readAllBytes(Paths.get(ClassLoader.getSystemResource(fileName).toURI(;
   }
   ```
   
   then getting this error:
   ```java
   Argument(s) are different! Wanted:
   configCenterRepository.persist(
   "/test/config/schema/sharding_db/rule",
   "#
   # Licensed to the Apache Software Foundation (ASF) under one or more
   # contributor license agreements.  See the NOTICE file distributed with
   # this work for additional information regarding copyright ownership.
   # The ASF licenses this file to You under the Apache License, Version 2.0
   # (the "License"); you may not use this file except in compliance with
   # the License.  You may obtain a copy of the License at
   #
   # http://www.apache.org/licenses/LICENSE-2.0
   #
   # Unless required by applicable law or agreed to in writing, software
   # distributed under the License is distributed on an "AS IS" BASIS,
   # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   # See the License for the specific language governing permissions and
   # limitations under the License.
   #
   
   rules:
   - 
!!org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration
 tables:
   t_order:
 actualDataNodes: ds_${0..1}.t_order_${0..1}
 logicTable: t_order
 tableStrategy:
   standard:
 shardingAlgorithm:
   props:
 algorithm.expression: t_order_${order_id % 2}
   type: INLINE
 shardingColumn: order_id
   "
   );
   -> at 
org.apache.shardingsphere.orchestration.core.configcenter.ConfigCenterTest.assertPersistConfigurationForShardingRuleWithoutAuthenticationAndIsOverwrite(ConfigCenterTest.java:144)
   Actual invocation has different arguments:
   configCenterRepository.persist(
   "/test/config/schema/sharding_db/rule",
   "rules:
   - 
!!org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration
 tables:
   t_order:
 actualDataNodes: ds_${0..1}.t_order_${0..1}
 logicTable: t_order
 tableStrategy:
   standard:
 shardingAlgorithm:
   props:
 algorithm.expression: t_order_${order_id % 2}
   type: INLINE
 shardingColumn: order_id
   "
   );
   ```
   
   I guess `configCenterRepository.persist("someFilePath","some YAML string")` 
is expecting YAML string without Licence comments.
   that is why I earlier used:
   ```java
   "some yaml string".replaceAll("#.*\n", "")
   ```
   
   but you have pointed out to use snake YAML instead of the above code.
   And when I use snake YAML then I am getting an error which I have mentioned 
in the previous comment





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:
us...@infra.apache.org




[GitHub] [shardingsphere] sukumaar commented on a change in pull request #5614: Use YAML file instead of inline string in ConfigCenterTest.java

2020-05-21 Thread GitBox


sukumaar commented on a change in pull request #5614:
URL: https://github.com/apache/shardingsphere/pull/5614#discussion_r428700878



##
File path: 
sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-configcenter/src/test/java/org/apache/shardingsphere/orchestration/core/configcenter/ConfigCenterTest.java
##
@@ -552,4 +465,13 @@ private void 
assertDataSourceConfigurationWithConnectionInitSqls(final DataSourc
 assertThat(actual.getProperties().get("password"), 
is(expected.getProperties().get("password")));
 assertThat(actual.getProperties().get("connectionInitSqls"), 
is(expected.getProperties().get("connectionInitSqls")));
 }
+
+private static String readYamlFileIntoString(final String fileName) {
+try {
+return (new 
String(Files.readAllBytes(Paths.get(ClassLoader.getSystemResource(fileName).toURI().replaceAll("#.*\n",
 "");

Review comment:
   Hey I referred to the PR you had asked me to refer.  
   if I use 
   ```java
   @SneakyThrows
   private String readYAML(final String yamlFile) {
   return 
Files.readAllLines(Paths.get(ClassLoader.getSystemResource(yamlFile).toURI())).stream().map(each
 -> each + System.lineSeparator()).collect(Collectors.joining());
   }
   ```
   or 
   ```java
   @SneakyThrows
   private static String readYamlFileIntoString(final String fileName) {
   return new 
String(Files.readAllBytes(Paths.get(ClassLoader.getSystemResource(fileName).toURI(;
   }
   ```
   
   then getting this error:
   ```java
   Argument(s) are different! Wanted:
   configCenterRepository.persist(
   "/test/config/schema/sharding_db/rule",
   "#
   # Licensed to the Apache Software Foundation (ASF) under one or more
   # contributor license agreements.  See the NOTICE file distributed with
   # this work for additional information regarding copyright ownership.
   # The ASF licenses this file to You under the Apache License, Version 2.0
   # (the "License"); you may not use this file except in compliance with
   # the License.  You may obtain a copy of the License at
   #
   # http://www.apache.org/licenses/LICENSE-2.0
   #
   # Unless required by applicable law or agreed to in writing, software
   # distributed under the License is distributed on an "AS IS" BASIS,
   # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   # See the License for the specific language governing permissions and
   # limitations under the License.
   #
   
   rules:
   - 
!!org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration
 tables:
   t_order:
 actualDataNodes: ds_${0..1}.t_order_${0..1}
 logicTable: t_order
 tableStrategy:
   standard:
 shardingAlgorithm:
   props:
 algorithm.expression: t_order_${order_id % 2}
   type: INLINE
 shardingColumn: order_id
   "
   );
   -> at 
org.apache.shardingsphere.orchestration.core.configcenter.ConfigCenterTest.assertPersistConfigurationForShardingRuleWithoutAuthenticationAndIsOverwrite(ConfigCenterTest.java:144)
   Actual invocation has different arguments:
   configCenterRepository.persist(
   "/test/config/schema/sharding_db/rule",
   "rules:
   - 
!!org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration
 tables:
   t_order:
 actualDataNodes: ds_${0..1}.t_order_${0..1}
 logicTable: t_order
 tableStrategy:
   standard:
 shardingAlgorithm:
   props:
 algorithm.expression: t_order_${order_id % 2}
   type: INLINE
 shardingColumn: order_id
   "
   );
   ```
   
   I guess configCenterRepository.persist("someFilePath","some YAML string") is 
expecting YAML string without Licence comments.
   that is why I earlier used:
   ```java
   "some yaml string".replaceAll("#.*\n", "")
   ```
   
   but you have pointed out to use snake YAML instead of the above code.
   And when I use snake YAML then I am getting an error which I have mentioned 
in the previous comment





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:
us...@infra.apache.org




[GitHub] [shardingsphere] sukumaar commented on a change in pull request #5614: Use YAML file instead of inline string in ConfigCenterTest.java

2020-05-21 Thread GitBox


sukumaar commented on a change in pull request #5614:
URL: https://github.com/apache/shardingsphere/pull/5614#discussion_r428700878



##
File path: 
sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-configcenter/src/test/java/org/apache/shardingsphere/orchestration/core/configcenter/ConfigCenterTest.java
##
@@ -552,4 +465,13 @@ private void 
assertDataSourceConfigurationWithConnectionInitSqls(final DataSourc
 assertThat(actual.getProperties().get("password"), 
is(expected.getProperties().get("password")));
 assertThat(actual.getProperties().get("connectionInitSqls"), 
is(expected.getProperties().get("connectionInitSqls")));
 }
+
+private static String readYamlFileIntoString(final String fileName) {
+try {
+return (new 
String(Files.readAllBytes(Paths.get(ClassLoader.getSystemResource(fileName).toURI().replaceAll("#.*\n",
 "");

Review comment:
   Hey I referred to the PR you had asked me to refer.  
   if I use 
   ```
   @SneakyThrows
   private String readYAML(final String yamlFile) {
   return 
Files.readAllLines(Paths.get(ClassLoader.getSystemResource(yamlFile).toURI())).stream().map(each
 -> each + System.lineSeparator()).collect(Collectors.joining());
   }
   ```
   or 
   ```
   @SneakyThrows
   private static String readYamlFileIntoString(final String fileName) {
   return new 
String(Files.readAllBytes(Paths.get(ClassLoader.getSystemResource(fileName).toURI(;
   }
   ```
   
   then getting this error:
   ```
   Argument(s) are different! Wanted:
   configCenterRepository.persist(
   "/test/config/schema/sharding_db/rule",
   "#
   # Licensed to the Apache Software Foundation (ASF) under one or more
   # contributor license agreements.  See the NOTICE file distributed with
   # this work for additional information regarding copyright ownership.
   # The ASF licenses this file to You under the Apache License, Version 2.0
   # (the "License"); you may not use this file except in compliance with
   # the License.  You may obtain a copy of the License at
   #
   # http://www.apache.org/licenses/LICENSE-2.0
   #
   # Unless required by applicable law or agreed to in writing, software
   # distributed under the License is distributed on an "AS IS" BASIS,
   # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   # See the License for the specific language governing permissions and
   # limitations under the License.
   #
   
   rules:
   - 
!!org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration
 tables:
   t_order:
 actualDataNodes: ds_${0..1}.t_order_${0..1}
 logicTable: t_order
 tableStrategy:
   standard:
 shardingAlgorithm:
   props:
 algorithm.expression: t_order_${order_id % 2}
   type: INLINE
 shardingColumn: order_id
   "
   );
   -> at 
org.apache.shardingsphere.orchestration.core.configcenter.ConfigCenterTest.assertPersistConfigurationForShardingRuleWithoutAuthenticationAndIsOverwrite(ConfigCenterTest.java:144)
   Actual invocation has different arguments:
   configCenterRepository.persist(
   "/test/config/schema/sharding_db/rule",
   "rules:
   - 
!!org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration
 tables:
   t_order:
 actualDataNodes: ds_${0..1}.t_order_${0..1}
 logicTable: t_order
 tableStrategy:
   standard:
 shardingAlgorithm:
   props:
 algorithm.expression: t_order_${order_id % 2}
   type: INLINE
 shardingColumn: order_id
   "
   );
   ```
   
   I guess configCenterRepository.persist("someFilePath","some YAML string") is 
expecting YAML string without Licence comments.
   that is why I earlier used:
   ```
   "some yaml string".replaceAll("#.*\n", "")
   ```
   
   but you have pointed out to use snake YAML instead of the above code.
   And when I use snake YAML then I am getting an error which I have mentioned 
in the previous comment





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:
us...@infra.apache.org




[GitHub] [shardingsphere] sukumaar commented on a change in pull request #5614: Use YAML file instead of inline string in ConfigCenterTest.java

2020-05-20 Thread GitBox


sukumaar commented on a change in pull request #5614:
URL: https://github.com/apache/shardingsphere/pull/5614#discussion_r427829642



##
File path: 
sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-configcenter/src/test/java/org/apache/shardingsphere/orchestration/core/configcenter/ConfigCenterTest.java
##
@@ -552,4 +465,13 @@ private void 
assertDataSourceConfigurationWithConnectionInitSqls(final DataSourc
 assertThat(actual.getProperties().get("password"), 
is(expected.getProperties().get("password")));
 assertThat(actual.getProperties().get("connectionInitSqls"), 
is(expected.getProperties().get("connectionInitSqls")));
 }
+
+private static String readYamlFileIntoString(final String fileName) {
+try {
+return (new 
String(Files.readAllBytes(Paths.get(ClassLoader.getSystemResource(fileName).toURI().replaceAll("#.*\n",
 "");

Review comment:
   @terrymanu could you please reply??





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:
us...@infra.apache.org




[GitHub] [shardingsphere] sukumaar commented on a change in pull request #5614: Use YAML file instead of inline string in ConfigCenterTest.java

2020-05-17 Thread GitBox


sukumaar commented on a change in pull request #5614:
URL: https://github.com/apache/shardingsphere/pull/5614#discussion_r426256783



##
File path: 
sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-configcenter/src/test/java/org/apache/shardingsphere/orchestration/core/configcenter/ConfigCenterTest.java
##
@@ -552,4 +465,13 @@ private void 
assertDataSourceConfigurationWithConnectionInitSqls(final DataSourc
 assertThat(actual.getProperties().get("password"), 
is(expected.getProperties().get("password")));
 assertThat(actual.getProperties().get("connectionInitSqls"), 
is(expected.getProperties().get("connectionInitSqls")));
 }
+
+private static String readYamlFileIntoString(final String fileName) {
+try {
+return (new 
String(Files.readAllBytes(Paths.get(ClassLoader.getSystemResource(fileName).toURI().replaceAll("#.*\n",
 "");

Review comment:
   If I try to use snake YAML by any of these below way:
   
   ```
   return new Yaml().dumpAsMap(new Yaml().load(yamlString));
   return new Yaml().dump(yamlString)
   return new Yaml().dumpAsMap(yamlString)
   ```
   then I am getting error:
   
   ```
   Can't construct a java object for 
tag:yaml.org,2002:org.apache.shardingsphere.core.rule.DataSourceParameter; 
exception=Class not found: 
org.apache.shardingsphere.core.rule.DataSourceParameter
   ```
   
   this is happening for **data source parameter yaml**
   it is creating object with this class 
**org.apache.shardingsphere.core.rule.DataSourceParameter** but it is not 
present in the project so I changed it to 
**org.apache.shardingsphere.shardingproxy.config.yaml.YamlDataSourceParameter** 
which is present
   
   but getting this error:
   
   ```
   Can't construct a java object for 
tag:yaml.org,2002:org.apache.shardingsphere.shardingproxy.config.yaml.YamlDataSourceParameter;
 exception=Class not found: 
org.apache.shardingsphere.shardingproxy.config.yaml.YamlDataSourceParameter
   ```





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:
us...@infra.apache.org




[GitHub] [shardingsphere] sukumaar commented on a change in pull request #5614: Use YAML file instead of inline string in ConfigCenterTest.java

2020-05-17 Thread GitBox


sukumaar commented on a change in pull request #5614:
URL: https://github.com/apache/shardingsphere/pull/5614#discussion_r426256783



##
File path: 
sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-configcenter/src/test/java/org/apache/shardingsphere/orchestration/core/configcenter/ConfigCenterTest.java
##
@@ -552,4 +465,13 @@ private void 
assertDataSourceConfigurationWithConnectionInitSqls(final DataSourc
 assertThat(actual.getProperties().get("password"), 
is(expected.getProperties().get("password")));
 assertThat(actual.getProperties().get("connectionInitSqls"), 
is(expected.getProperties().get("connectionInitSqls")));
 }
+
+private static String readYamlFileIntoString(final String fileName) {
+try {
+return (new 
String(Files.readAllBytes(Paths.get(ClassLoader.getSystemResource(fileName).toURI().replaceAll("#.*\n",
 "");

Review comment:
   If I try to use YAML by any of these below way:
   
   ```
   return new Yaml().dumpAsMap(new Yaml().load(yamlString));
   return new Yaml().dump(yamlString)
   return new Yaml().dumpAsMap(yamlString)
   ```
   then I am getting error:
   
   ```
   Can't construct a java object for 
tag:yaml.org,2002:org.apache.shardingsphere.core.rule.DataSourceParameter; 
exception=Class not found: 
org.apache.shardingsphere.core.rule.DataSourceParameter
   ```
   
   this is happening for **data source parameter yaml**
   it is creating object with this class 
**org.apache.shardingsphere.core.rule.DataSourceParameter** but it is not 
present in the project so I changed it to 
**org.apache.shardingsphere.shardingproxy.config.yaml.YamlDataSourceParameter** 
which is present
   
   but getting this error:
   
   ```
   Can't construct a java object for 
tag:yaml.org,2002:org.apache.shardingsphere.shardingproxy.config.yaml.YamlDataSourceParameter;
 exception=Class not found: 
org.apache.shardingsphere.shardingproxy.config.yaml.YamlDataSourceParameter
   ```





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:
us...@infra.apache.org




[GitHub] [shardingsphere] sukumaar commented on a change in pull request #5614: Use YAML file instead of inline string in ConfigCenterTest.java

2020-05-14 Thread GitBox


sukumaar commented on a change in pull request #5614:
URL: https://github.com/apache/shardingsphere/pull/5614#discussion_r425566114



##
File path: 
sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-configcenter/src/test/java/org/apache/shardingsphere/orchestration/core/configcenter/ConfigCenterTest.java
##
@@ -552,4 +465,13 @@ private void 
assertDataSourceConfigurationWithConnectionInitSqls(final DataSourc
 assertThat(actual.getProperties().get("password"), 
is(expected.getProperties().get("password")));
 assertThat(actual.getProperties().get("connectionInitSqls"), 
is(expected.getProperties().get("connectionInitSqls")));
 }
+
+private static String readYamlFileIntoString(final String fileName) {
+try {
+return (new 
String(Files.readAllBytes(Paths.get(ClassLoader.getSystemResource(fileName).toURI().replaceAll("#.*\n",
 "");

Review comment:
   to remove commented license information after reading into a string 
object

##
File path: 
sharding-orchestration/sharding-orchestration-core/sharding-orchestration-core-configcenter/src/test/resources/yaml/authentication-yaml.yml
##
@@ -0,0 +1,23 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#

Review comment:
   done





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:
us...@infra.apache.org