You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by yx...@apache.org on 2022/04/13 13:50:59 UTC

[shardingsphere] branch master updated: add unit test for DefaultSourceWritingStopAlgorithm (#16769)

This is an automated email from the ASF dual-hosted git repository.

yx9o 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 7783209e763 add unit test for DefaultSourceWritingStopAlgorithm (#16769)
7783209e763 is described below

commit 7783209e763bc19b9d2bb265e28b84592457bd1f
Author: tianhao960 <ti...@users.noreply.github.com>
AuthorDate: Wed Apr 13 21:50:45 2022 +0800

    add unit test for DefaultSourceWritingStopAlgorithm (#16769)
    
    * add unit test for DefaultSourceWritingStopAlgorithm
    
    * add unit test for DefaultSourceWritingStopAlgorithm
    
    Co-authored-by: 何文斌 <he...@hualala.com>
---
 .../spi/DefaultSourceWritingStopAlgorithmTest.java | 61 ++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/spi/DefaultSourceWritingStopAlgorithmTest.java b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/spi/DefaultSourceWritingStopAlgorithmTest.java
new file mode 100644
index 00000000000..78ce0666512
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/spi/DefaultSourceWritingStopAlgorithmTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.data.pipeline.scenario.rulealtered.spi;
+
+import org.apache.shardingsphere.data.pipeline.core.util.PipelineContextUtil;
+import org.junit.Before;
+import org.junit.Test;
+
+public final class DefaultSourceWritingStopAlgorithmTest {
+
+    private final DefaultSourceWritingStopAlgorithm defaultSourceWritingStopAlgorithm = new DefaultSourceWritingStopAlgorithm();
+
+    private final String lockName = "lock1";
+
+    private final String jobId = "jobId1";
+
+    @Before
+    public void setup() {
+        PipelineContextUtil.mockModeConfigAndContextManager();
+    }
+
+    @Test
+    public void assertSuccessLockReleaseLock() {
+        defaultSourceWritingStopAlgorithm.lock(lockName, jobId);
+        defaultSourceWritingStopAlgorithm.releaseLock(lockName, jobId);
+    }
+
+    @Test
+    public void assertSuccessLockTwiceReleaseLock() {
+        defaultSourceWritingStopAlgorithm.lock(lockName, jobId);
+        defaultSourceWritingStopAlgorithm.lock(lockName, jobId);
+        defaultSourceWritingStopAlgorithm.releaseLock(lockName, jobId);
+    }
+
+    @Test
+    public void assertSuccessLockReleaseLockTwice() {
+        defaultSourceWritingStopAlgorithm.lock(lockName, jobId);
+        defaultSourceWritingStopAlgorithm.releaseLock(lockName, jobId);
+        defaultSourceWritingStopAlgorithm.releaseLock(lockName, jobId);
+    }
+
+    @Test
+    public void assertSuccessReleaseNullLock() {
+        defaultSourceWritingStopAlgorithm.releaseLock(lockName, jobId);
+    }
+}