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 3154a89  Fix unit test (#15297)
3154a89 is described below

commit 3154a897ed116d368560ce82db6df5560faa8afc
Author: Haoran Meng <[email protected]>
AuthorDate: Tue Feb 8 19:48:11 2022 +0800

    Fix unit test (#15297)
---
 .../ClusterContextManagerCoordinatorTest.java            |  7 ++-----
 .../metadata/watcher/MetaDataChangedWatcherTest.java     | 16 +++++++++++-----
 2 files changed, 13 insertions(+), 10 deletions(-)

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 7f17635..0f6dcbe 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
@@ -66,7 +66,6 @@ import org.apache.shardingsphere.test.mock.MockedDataSource;
 import org.apache.shardingsphere.transaction.context.TransactionContexts;
 import org.apache.shardingsphere.transaction.rule.TransactionRule;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Answers;
@@ -162,8 +161,6 @@ public final class ClusterContextManagerCoordinatorTest {
     }
     
     @Test
-    // TODO Fix me.
-    @Ignore
     public void assertSchemaChanged() {
         TableMetaData changedTableMetaData = new TableMetaData("t_order");
         SchemaChangedEvent event = new SchemaChangedEvent("schema", 
changedTableMetaData, null);
@@ -248,8 +245,8 @@ public final class ClusterContextManagerCoordinatorTest {
         when(metaData.getResource()).thenReturn(resource);
         ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
         when(metaData.getSchema()).thenReturn(schema);
-        
when(metaData.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
-        
when(metaData.getRuleMetaData().getConfigurations()).thenReturn(Collections.emptyList());
+        when(metaData.getRuleMetaData().getRules()).thenReturn(new 
LinkedList<>());
+        when(metaData.getRuleMetaData().getConfigurations()).thenReturn(new 
LinkedList<>());
         return new HashMap<>(Collections.singletonMap("schema", metaData));
     }
     
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/registry/metadata/watcher/MetaDataChangedWatcherTest.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/metadata/watcher/MetaDataChangedWatcherTest.java
index 1f943a8..6502a36 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/metadata/watcher/MetaDataChangedWatcherTest.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/metadata/watcher/MetaDataChangedWatcherTest.java
@@ -19,9 +19,9 @@ package 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.meta
 
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceEvent;
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.rule.RuleConfigurationCachedEvent;
+import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.schema.SchemaChangedEvent;
 import 
org.apache.shardingsphere.mode.repository.cluster.listener.DataChangedEvent;
 import 
org.apache.shardingsphere.mode.repository.cluster.listener.DataChangedEvent.Type;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import java.util.Optional;
@@ -100,15 +100,21 @@ public final class MetaDataChangedWatcherTest {
         assertThat(event.getCacheId(), is("cacheId"));
     }
     
-    // TODO fix it
     @Test
-    @Ignore
-    public void assertCreateSchemaChangedEvent() {
-        String key = "/metadata/sharding_db/schema";
+    public void assertCreateTableSchemaChangedEvent() {
+        String key = "/metadata/sharding_db/tables/t_order";
         Optional<GovernanceEvent> actual = createEvent(key, "{}", 
Type.UPDATED);
         assertTrue(actual.isPresent());
     }
     
+    @Test
+    public void assertCreateTableSchemaDeletedEvent() {
+        String key = "/metadata/sharding_db/tables/t_order";
+        Optional<GovernanceEvent> actual = createEvent(key, "{}", 
Type.DELETED);
+        assertTrue(actual.isPresent());
+        assertThat(((SchemaChangedEvent) actual.get()).getDeletedTable(), 
is("t_order"));
+    }
+    
     private Optional<GovernanceEvent> createEvent(final String key, final 
String value, final Type type) {
         DataChangedEvent dataChangedEvent = new DataChangedEvent(key, value, 
type);
         return new 
MetaDataChangedWatcher().createGovernanceEvent(dataChangedEvent);

Reply via email to