Lucas-307 commented on a change in pull request #9750:
URL: https://github.com/apache/shardingsphere/pull/9750#discussion_r598651461
##########
File path:
shardingsphere-scaling/shardingsphere-scaling-bootstrap/src/test/java/org/apache/shardingsphere/scaling/web/HttpServerInitializerTest.java
##########
@@ -45,9 +42,8 @@
private ChannelPipeline channelPipeline;
@Before
- @SneakyThrows(ReflectiveOperationException.class)
public void setUp() {
- ReflectionUtil.setFieldValue(ScalingContext.getInstance(),
"serverConfig", new ServerConfiguration());
+ ServerConfigurationInitializer.init();
Review comment:
Maybe mock ServerConfiguration and then reflect set into is better.
```java
ReflectionUtil.setFieldValue(ScalingContext.getInstance(), "serverConfig",
mockServerConfig());
```
```java
private ServerConfiguration mockServerConfig() {
ServerConfiguration result = new ServerConfiguration();
result.setGovernanceConfig(new GovernanceConfiguration("test", new
GovernanceCenterConfiguration("Zookeeper", "localhost:2181", null), false));
return result;
}
```
`ServerConfigurationInitializer.init()` will useless if
ScalingContext.serverConfig != null, that's why use reflection.
--
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]