This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 26493e19d07 Add unit test for
ClusterContextManagerCoordinator.renew(final SchemaAddedEvent event) (#17923)
26493e19d07 is described below
commit 26493e19d077f11431ab860a0b07bc80bfb9b51b
Author: lusr <[email protected]>
AuthorDate: Wed May 25 15:23:59 2022 +0800
Add unit test for ClusterContextManagerCoordinator.renew(final
SchemaAddedEvent event) (#17923)
Co-authored-by: lushr <[email protected]>
---
.../coordinator/ClusterContextManagerCoordinatorTest.java | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
index 2b580125c2e..af8eb728c7a 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
@@ -56,6 +56,7 @@ import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.confi
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.version.SchemaVersionChangedEvent;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.event.DatabaseAddedEvent;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.event.DatabaseDeletedEvent;
+import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.event.SchemaAddedEvent;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.process.ShowProcessListManager;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.process.lock.ShowProcessListSimpleLock;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.event.InstanceOfflineEvent;
@@ -191,6 +192,14 @@ public final class ClusterContextManagerCoordinatorTest {
assertThat(contextManager.getMetaDataContexts().getProps().getProps().getProperty(ConfigurationPropertyKey.SQL_SHOW.getKey()),
is(Boolean.TRUE.toString()));
}
+ @Test
+ public void assertSchemaAdd() {
+
when(contextManager.getMetaDataContexts().getDatabaseMetaData("db").getSchemas().get("schema_1")).thenReturn(null);
+ SchemaAddedEvent event = new SchemaAddedEvent("db", "schema_1");
+ coordinator.renew(event);
+
verify(contextManager.getMetaDataContexts().getDatabaseMetaData("db").getSchemas(),
times(1)).put(argThat(argument -> argument.equals("schema_1")),
any(ShardingSphereSchema.class));
+ }
+
@Test
public void assertSchemaChanged() {
TableMetaData changedTableMetaData = new TableMetaData("t_order",
Collections.emptyList(), Collections.emptyList(), Collections.emptyList());