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/03 14:58:40 UTC

[shardingsphere] branch master updated: Added testcases for DataSourceState (#21309)

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 4784e1dda97 Added testcases for DataSourceState (#21309)
4784e1dda97 is described below

commit 4784e1dda97c8ea71b98261d6a337d3a61525166
Author: Harikesh Pallantla <p....@gmail.com>
AuthorDate: Mon Oct 3 20:28:25 2022 +0530

    Added testcases for DataSourceState (#21309)
    
    * Added testcases for DataSourceState
    
    * Added license header for DataSourceStateTest
    
    * Formatted code
---
 .../datasource/state/DataSourceStateTest.java      | 57 ++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/datasource/state/DataSourceStateTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/datasource/state/DataSourceStateTest.java
new file mode 100644
index 00000000000..4c8c91bb595
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/datasource/state/DataSourceStateTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.datasource.state;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
+
+public class DataSourceStateTest {
+
+    @Test
+    public void testDisabled() {
+        assertEquals(DataSourceState.DISABLED, DataSourceState.getDataSourceState("disabled"));
+    }
+
+    @Test
+    public void testEnabled() {
+        assertEquals(DataSourceState.ENABLED, DataSourceState.getDataSourceState("enabled"));
+    }
+
+    @Test
+    public void shouldThrowIllegalArgumentExceptionWhenStateIsEmpty() {
+        assertThrows("Illegal data source state ``", IllegalArgumentException.class, () -> {
+            DataSourceState.getDataSourceState("");
+        });
+    }
+
+    @Test
+    public void shouldThrowIllegalArgumentExceptionWhenStateIsNull() {
+        assertThrows("Illegal data source state ``", IllegalArgumentException.class, () -> {
+            DataSourceState.getDataSourceState(null);
+        });
+    }
+
+    @Test
+    public void shouldThrowIllegalArgumentExceptionWhenStateIsInvalid() {
+        assertThrows("Illegal data source state `invalid`", IllegalArgumentException.class, () -> {
+            DataSourceState.getDataSourceState("invalid");
+        });
+    }
+}