You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2022/07/05 04:17:22 UTC
[shardingsphere] branch master updated: Add InstanceMetaDataBuilderFactoryTest (#18853)
This is an automated email from the ASF dual-hosted git repository.
menghaoran 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 82bcd0c6faa Add InstanceMetaDataBuilderFactoryTest (#18853)
82bcd0c6faa is described below
commit 82bcd0c6faaf6a8a5a5e4ddfa77618758df49278
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Tue Jul 5 12:17:16 2022 +0800
Add InstanceMetaDataBuilderFactoryTest (#18853)
* Revise ShardingSphereMetaDataTest
* Add InstanceMetaDataBuilderFactoryTest
---
.../InstanceMetaDataBuilderFactoryTest.java | 67 ++++++++++++++++++++++
.../jdbc/JDBCInstanceMetaDataBuilderTest.java | 39 -------------
.../proxy/ProxyInstanceMetaDataBuilderTest.java | 40 -------------
3 files changed, 67 insertions(+), 79 deletions(-)
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/metadata/InstanceMetaDataBuilderFactoryTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/metadata/InstanceMetaDataBuilderFactoryTest.java
new file mode 100644
index 00000000000..e13775d96d1
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/metadata/InstanceMetaDataBuilderFactoryTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.infra.instance.metadata;
+
+import org.apache.shardingsphere.infra.instance.metadata.proxy.ProxyInstanceMetaData;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.endsWith;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+
+public final class InstanceMetaDataBuilderFactoryTest {
+
+ @Test
+ public void assertCreateJDBCInstanceMetaDataWithoutInstanceId() {
+ InstanceMetaData actual = InstanceMetaDataBuilderFactory.create("JDBC", -1);
+ assertNotNull(actual.getId());
+ assertNotNull(actual.getIp());
+ assertThat(actual.getAttributes(), is(""));
+ assertThat(actual.getType(), is(InstanceType.JDBC));
+ }
+
+ @Test
+ public void assertCreateProxyInstanceMetaDataWithoutInstanceId() {
+ ProxyInstanceMetaData actual = (ProxyInstanceMetaData) InstanceMetaDataBuilderFactory.create("Proxy", 3307);
+ assertNotNull(actual.getId());
+ assertNotNull(actual.getIp());
+ assertThat(actual.getPort(), is(3307));
+ assertThat(actual.getAttributes(), endsWith("@3307"));
+ assertThat(actual.getType(), is(InstanceType.PROXY));
+ }
+
+ @Test
+ public void assertCreateJDBCInstanceMetaDataWithInstanceId() {
+ InstanceMetaData actual = InstanceMetaDataBuilderFactory.create("foo_id", InstanceType.JDBC, "");
+ assertThat(actual.getId(), is("foo_id"));
+ assertNotNull(actual.getIp());
+ assertThat(actual.getAttributes(), is(""));
+ assertThat(actual.getType(), is(InstanceType.JDBC));
+ }
+
+ @Test
+ public void assertCreateProxyInstanceMetaDataWithInstanceId() {
+ ProxyInstanceMetaData actual = (ProxyInstanceMetaData) InstanceMetaDataBuilderFactory.create("foo_id", InstanceType.PROXY, "127.0.0.1@3307");
+ assertThat(actual.getId(), is("foo_id"));
+ assertThat(actual.getIp(), is("127.0.0.1"));
+ assertThat(actual.getPort(), is(3307));
+ assertThat(actual.getAttributes(), is("127.0.0.1@3307"));
+ assertThat(actual.getType(), is(InstanceType.PROXY));
+ }
+}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/metadata/jdbc/JDBCInstanceMetaDataBuilderTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/metadata/jdbc/JDBCInstanceMetaDataBuilderTest.java
deleted file mode 100644
index c6dd4f8ad06..00000000000
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/metadata/jdbc/JDBCInstanceMetaDataBuilderTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.infra.instance.metadata.jdbc;
-
-import org.apache.shardingsphere.infra.instance.metadata.InstanceMetaData;
-import org.apache.shardingsphere.infra.instance.metadata.InstanceMetaDataBuilderFactory;
-import org.apache.shardingsphere.infra.instance.metadata.InstanceType;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-
-public final class JDBCInstanceMetaDataBuilderTest {
-
- @Test
- public void assertNewInstance() {
- InstanceMetaData actual = InstanceMetaDataBuilderFactory.create("JDBC", -1);
- assertNotNull(actual.getId());
- assertNotNull(actual.getIp());
- assertThat(actual.getAttributes(), is(""));
- assertThat(actual.getType(), is(InstanceType.JDBC));
- }
-}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/metadata/proxy/ProxyInstanceMetaDataBuilderTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/metadata/proxy/ProxyInstanceMetaDataBuilderTest.java
deleted file mode 100644
index 731d3bd7733..00000000000
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/metadata/proxy/ProxyInstanceMetaDataBuilderTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.infra.instance.metadata.proxy;
-
-import org.apache.shardingsphere.infra.instance.metadata.InstanceMetaDataBuilderFactory;
-import org.apache.shardingsphere.infra.instance.metadata.InstanceType;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.endsWith;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-
-public final class ProxyInstanceMetaDataBuilderTest {
-
- @Test
- public void assertNewInstance() {
- ProxyInstanceMetaData actual = (ProxyInstanceMetaData) InstanceMetaDataBuilderFactory.create("Proxy", 3307);
- assertNotNull(actual.getId());
- assertNotNull(actual.getIp());
- assertThat(actual.getPort(), is(3307));
- assertThat(actual.getAttributes(), endsWith("@3307"));
- assertThat(actual.getType(), is(InstanceType.PROXY));
- }
-}