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 2020/07/21 11:15:03 UTC

[shardingsphere-elasticjob] branch master updated: add test case (#1222)

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-elasticjob.git


The following commit(s) were added to refs/heads/master by this push:
     new 9eea1fc  add test case (#1222)
9eea1fc is described below

commit 9eea1fcd51c201056084f217c43aa18c8ae35d7e
Author: zhyee <30...@users.noreply.github.com>
AuthorDate: Tue Jul 21 19:14:52 2020 +0800

    add test case (#1222)
---
 .../CPUUsageJobExecutorServiceHandlerTest.java     | 34 ++++++++++++++++++++++
 .../SingleThreadJobExecutorServiceHandlerTest.java | 34 ++++++++++++++++++++++
 2 files changed, 68 insertions(+)

diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/handler/threadpool/impl/CPUUsageJobExecutorServiceHandlerTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/handler/threadpool/impl/CPUUsageJobExecutorServiceHandlerTest.java
new file mode 100644
index 0000000..bafc247
--- /dev/null
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/handler/threadpool/impl/CPUUsageJobExecutorServiceHandlerTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.elasticjob.lite.handler.threadpool.impl;
+
+import org.apache.shardingsphere.elasticjob.lite.handler.threadpool.JobExecutorServiceHandlerFactory;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public final class CPUUsageJobExecutorServiceHandlerTest {
+    
+    @Test
+    public void assertGetPoolSizeAndType() {
+        CPUUsageJobExecutorServiceHandler cpuUsageJobExecutorServiceHandler = (CPUUsageJobExecutorServiceHandler) JobExecutorServiceHandlerFactory.getHandler("CPU");
+        assertThat(cpuUsageJobExecutorServiceHandler.getPoolSize(), is(Runtime.getRuntime().availableProcessors() * 2));
+        assertThat(cpuUsageJobExecutorServiceHandler.getType(), is("CPU"));
+    }
+}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/handler/threadpool/impl/SingleThreadJobExecutorServiceHandlerTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/handler/threadpool/impl/SingleThreadJobExecutorServiceHandlerTest.java
new file mode 100644
index 0000000..2d833dc
--- /dev/null
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/handler/threadpool/impl/SingleThreadJobExecutorServiceHandlerTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.elasticjob.lite.handler.threadpool.impl;
+
+import org.apache.shardingsphere.elasticjob.lite.handler.threadpool.JobExecutorServiceHandlerFactory;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public final class SingleThreadJobExecutorServiceHandlerTest {
+    
+    @Test
+    public void assertGetPoolSizeAndType() {
+        SingleThreadJobExecutorServiceHandler singleThreadJobExecutorServiceHandler = (SingleThreadJobExecutorServiceHandler) JobExecutorServiceHandlerFactory.getHandler("SINGLE_THREAD");
+        assertThat(singleThreadJobExecutorServiceHandler.getPoolSize(), is(1));
+        assertThat(singleThreadJobExecutorServiceHandler.getType(), is("SINGLE_THREAD"));
+    }
+}