zhaojinchao95 commented on code in PR #24267: URL: https://github.com/apache/shardingsphere/pull/24267#discussion_r1113095129
########## mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/ClusterModeContextManagerTest.java: ########## @@ -0,0 +1,526 @@ +/* + * 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. + */ + +package org.apache.shardingsphere.mode.manager.cluster; + +import static org.junit.Assert.assertNull; +import static org.mockito.Mockito.mock; + +import java.util.Map; +import java.util.Properties; +import java.util.TreeMap; +import java.util.LinkedList; +import java.util.Collection; +import java.util.HashMap; + +import org.apache.shardingsphere.infra.config.mode.ModeConfiguration; +import org.apache.shardingsphere.infra.config.props.ConfigurationProperties; +import org.apache.shardingsphere.infra.config.rule.RuleConfiguration; +import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType; +import org.apache.shardingsphere.infra.datasource.props.DataSourceProperties; +import org.apache.shardingsphere.infra.instance.ComputeNodeInstance; +import org.apache.shardingsphere.infra.instance.InstanceContext; +import org.apache.shardingsphere.infra.instance.metadata.jdbc.JDBCInstanceMetaData; +import org.apache.shardingsphere.infra.instance.workerid.WorkerIdGenerator; +import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; +import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; +import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData; +import org.apache.shardingsphere.infra.metadata.database.schema.pojo.AlterSchemaMetaDataPOJO; +import org.apache.shardingsphere.infra.metadata.database.schema.pojo.AlterSchemaPOJO; +import org.apache.shardingsphere.infra.util.eventbus.EventBusContext; +import org.apache.shardingsphere.mode.manager.ContextManager; +import org.apache.shardingsphere.mode.manager.cluster.coordinator.fixture.ClusterPersistRepositoryFixture; +import org.apache.shardingsphere.mode.manager.cluster.coordinator.fixture.RuleConfigurationFixture; +import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.process.ProcessListClusterPersistRepositoryFixture; +import org.apache.shardingsphere.mode.metadata.MetaDataContexts; +import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService; +import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepositoryConfiguration; +import org.junit.Test; + +public class ClusterModeContextManagerTest { + + @Test + public void assertTestCreateDatabase() { + ClusterModeContextManager clusterModeContextManager = new ClusterModeContextManager(); + MetaDataPersistService persistService = new MetaDataPersistService(new ClusterPersistRepositoryFixture()); + MetaDataContexts metaDataContexts = new MetaDataContexts(persistService, new ShardingSphereMetaData()); + ComputeNodeInstance instance = new ComputeNodeInstance(new JDBCInstanceMetaData("42")); + WorkerIdGenerator workerIdGenerator = mock(WorkerIdGenerator.class); + ModeConfiguration modeConfiguration = new ModeConfiguration("Type", + new ClusterPersistRepositoryConfiguration("Type", "Namespace", "Server Lists", new Properties())); + ClusterModeContextManager modeContextManager = new ClusterModeContextManager(); + clusterModeContextManager + .setContextManagerAware(new ContextManager(metaDataContexts, new InstanceContext(instance, workerIdGenerator, + modeConfiguration, modeContextManager, null, new EventBusContext()))); + clusterModeContextManager.createDatabase("Database Name"); + } + + @Test + public void assertTestDropDatabase() { Review Comment: Maybe you can remove Test, suck as : assertDropDatabase. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
