You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/10/28 11:39:47 UTC
[shardingsphere] branch master updated: [ISSUE #21175] Add tests for PluginConfiguration class (#21787)
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 5f3109f2fbc [ISSUE #21175] Add tests for PluginConfiguration class (#21787)
5f3109f2fbc is described below
commit 5f3109f2fbcec30f43a36df3c9097ca58f0300c2
Author: Karthick Balathandayuthapani <78...@users.noreply.github.com>
AuthorDate: Fri Oct 28 17:09:41 2022 +0530
[ISSUE #21175] Add tests for PluginConfiguration class (#21787)
* [ISSUE #21573] Update datatype specifier in the input parameter to match the imeplementation in the guava library
* [ISSUE #21175] Add tests for PluginConfiguration class
---
.../agent/config/PluginConfigurationTest.java | 43 ++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/agent/api/src/test/java/org/apache/shardingsphere/agent/config/PluginConfigurationTest.java b/agent/api/src/test/java/org/apache/shardingsphere/agent/config/PluginConfigurationTest.java
new file mode 100644
index 00000000000..82e261ff7d5
--- /dev/null
+++ b/agent/api/src/test/java/org/apache/shardingsphere/agent/config/PluginConfigurationTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.agent.config;
+
+import static org.junit.Assert.assertThrows;
+
+import org.junit.Test;
+
+public final class PluginConfigurationTest {
+
+ private PluginConfiguration pluginConfiguration;
+
+ @Test
+ public void assertValidateWhenHostIsNullOrEmpty() {
+ pluginConfiguration = new PluginConfiguration("", 8080, "passkey", null);
+ assertThrows("Hostname of host1 is required", IllegalArgumentException.class, () -> pluginConfiguration.validate("host1"));
+ pluginConfiguration = new PluginConfiguration(null, 8080, "passkey", null);
+ assertThrows("Hostname of host2 is required", IllegalArgumentException.class, () -> pluginConfiguration.validate("host2"));
+ }
+
+ @Test
+ public void assertValidateWhenPortLessThanOne() {
+ pluginConfiguration = new PluginConfiguration("localhost", 0, "passkey", null);
+ assertThrows("Port `0` of host1 must be a positive number", IllegalArgumentException.class, () -> pluginConfiguration.validate("host1"));
+ pluginConfiguration = new PluginConfiguration("localhost", -1, "passkey", null);
+ assertThrows("Port `-1` of host2 must be a positive number", IllegalArgumentException.class, () -> pluginConfiguration.validate("host2"));
+ }
+}