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/18 03:09:00 UTC

[shardingsphere-elasticjob] branch master updated: Add testcase for Spring Boot Starter (#1110)

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 26da06b  Add testcase for Spring Boot Starter (#1110)
26da06b is described below

commit 26da06b4628927c299a69d4d0873861d5552d03b
Author: 吴伟杰 <ro...@me.com>
AuthorDate: Sat Jul 18 11:08:50 2020 +0800

    Add testcase for Spring Boot Starter (#1110)
    
    * Add testcase for Spring Boot Starter
    
    * Format file which missing blank line
    
    * Replace System.out with logger in testcase
---
 .../pom.xml                                        |  5 ++
 .../reg/boot/RegistryCenterSpringBootTest.java     | 58 ++++++++++++++++++
 .../reg/boot/fixture/EmbedTestingServer.java       | 69 ++++++++++++++++++++++
 .../src/test/resources/application-elasticjob.yml  | 21 +++++++
 .../elasticjob-tracing-spring-boot-starter/pom.xml | 17 +++++-
 .../boot/TracingConfigurationSpringBootTest.java   | 56 ++++++++++++++++++
 .../tracing/boot/fixture/EmbedTestingServer.java   | 68 +++++++++++++++++++++
 .../src/test/resources/application-elasticjob.yml  | 29 +++++++++
 .../elasticjob-lite-spring-boot-starter/pom.xml    | 10 ++++
 .../lite/boot/ElasticJobSpringBootTest.java        | 55 +++++++++++++++++
 .../boot/executor/CustomClassedJobExecutor.java    | 40 +++++++++++++
 .../lite/boot/executor/PrintJobExecutor.java       | 42 +++++++++++++
 .../lite/boot/executor/PrintJobProperties.java     | 23 ++++++++
 .../lite/boot/fixture/EmbedTestingServer.java      | 68 +++++++++++++++++++++
 .../elasticjob/lite/boot/job/CustomJob.java        | 31 ++++++++++
 .../lite/boot/job/impl/CustomTestJob.java          | 48 +++++++++++++++
 .../lite/boot/repository/BarRepository.java        | 32 ++++++++++
 .../boot/repository/impl/BarRepositoryImpl.java    | 32 ++++++++++
 ...sphere.elasticjob.executor.item.JobItemExecutor | 18 ++++++
 .../src/test/resources/application-elasticjob.yml  | 41 +++++++++++++
 20 files changed, 762 insertions(+), 1 deletion(-)

diff --git a/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/pom.xml b/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/pom.xml
index 0e7294c..86412a2 100644
--- a/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/pom.xml
+++ b/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/pom.xml
@@ -52,6 +52,11 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-test</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
 </project>
diff --git a/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/reg/boot/RegistryCenterSpringBootTest.java b/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/reg/boot/RegistryCenterSpringBootTest.java
new file mode 100644
index 0000000..7c61d48
--- /dev/null
+++ b/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/reg/boot/RegistryCenterSpringBootTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.reg.boot;
+
+import org.apache.shardingsphere.elasticjob.reg.boot.fixture.EmbedTestingServer;
+import org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+@SpringBootTest
+@SpringBootApplication
+@ActiveProfiles("elasticjob")
+public class RegistryCenterSpringBootTest extends AbstractJUnit4SpringContextTests {
+
+    @BeforeClass
+    public static void init() {
+        EmbedTestingServer.start();
+    }
+
+    @Test
+    public void testZookeeperProperties() {
+        assertNotNull(applicationContext);
+        ZookeeperProperties zookeeperProperties = applicationContext.getBean(ZookeeperProperties.class);
+        assertEquals(EmbedTestingServer.getConnectionString(), zookeeperProperties.getServerLists());
+        assertEquals("elasticjob-registry-center-spring-boot-starter", zookeeperProperties.getNamespace());
+    }
+
+    @Test
+    public void testRegistryCenterCreation() {
+        assertNotNull(applicationContext);
+        ZookeeperRegistryCenter zookeeperRegistryCenter = applicationContext.getBean(ZookeeperRegistryCenter.class);
+        assertNotNull(zookeeperRegistryCenter);
+        zookeeperRegistryCenter.persist("/foo", "bar");
+        assertEquals("bar", zookeeperRegistryCenter.get("/foo"));
+    }
+}
diff --git a/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/reg/boot/fixture/EmbedTestingServer.java b/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/reg/boot/fixture/EmbedTestingServer.java
new file mode 100644
index 0000000..3e75e7a
--- /dev/null
+++ b/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/reg/boot/fixture/EmbedTestingServer.java
@@ -0,0 +1,69 @@
+/*
+ * 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.reg.boot.fixture;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.curator.test.TestingServer;
+import org.apache.shardingsphere.elasticjob.reg.exception.RegExceptionHandler;
+
+import java.io.File;
+import java.io.IOException;
+
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class EmbedTestingServer {
+
+    private static final int PORT = 16181;
+
+    private static volatile TestingServer testingServer;
+
+    /**
+     * Get the connection string.
+     *
+     * @return connection string
+     */
+    public static String getConnectionString() {
+        return "localhost:" + PORT;
+    }
+
+    /**
+     * Start the server.
+     */
+    public static void start() {
+        if (null != testingServer) {
+            return;
+        }
+        try {
+            testingServer = new TestingServer(PORT, new File(String.format("target/test_zk_data/%s/", System.nanoTime())));
+            // CHECKSTYLE:OFF
+        } catch (final Exception ex) {
+            // CHECKSTYLE:ON
+            RegExceptionHandler.handleException(ex);
+        } finally {
+            Runtime.getRuntime().addShutdownHook(new Thread(() -> {
+                try {
+                    Thread.sleep(1000);
+                    testingServer.close();
+                } catch (final IOException | InterruptedException ex) {
+                    RegExceptionHandler.handleException(ex);
+                }
+            }));
+        }
+    }
+}
+
diff --git a/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/test/resources/application-elasticjob.yml b/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/test/resources/application-elasticjob.yml
new file mode 100644
index 0000000..ad20bd2
--- /dev/null
+++ b/elasticjob-infra/elasticjob-registry-center-spring-boot-starter/src/test/resources/application-elasticjob.yml
@@ -0,0 +1,21 @@
+#
+# 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.
+#
+
+elasticjob:
+  regCenter:
+    serverLists: localhost:16181
+    namespace: elasticjob-registry-center-spring-boot-starter
diff --git a/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/pom.xml b/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/pom.xml
index b28ae1c..30a7919 100644
--- a/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/pom.xml
+++ b/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/pom.xml
@@ -57,6 +57,21 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>
         </dependency>
-    </dependencies>
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-jdbc</artifactId>
+            <scope>test</scope>
+        </dependency>
+ </dependencies>
 
 </project>
diff --git a/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/tracing/boot/TracingConfigurationSpringBootTest.java b/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/tracing/boot/TracingConfigurationSpringBootTest.java
new file mode 100644
index 0000000..8b49cf8
--- /dev/null
+++ b/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/tracing/boot/TracingConfigurationSpringBootTest.java
@@ -0,0 +1,56 @@
+/*
+ * 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.tracing.boot;
+
+import org.apache.shardingsphere.elasticjob.tracing.api.TracingConfiguration;
+import org.apache.shardingsphere.elasticjob.tracing.boot.fixture.EmbedTestingServer;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+
+import javax.sql.DataSource;
+import java.sql.SQLException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+@SpringBootTest
+@SpringBootApplication
+@ActiveProfiles("elasticjob")
+public class TracingConfigurationSpringBootTest extends AbstractJUnit4SpringContextTests {
+
+    @BeforeClass
+    public static void setUp() {
+        EmbedTestingServer.start();
+    }
+
+    @Test
+    public void testTracingConfigurationCreation() throws SQLException {
+        assertNotNull(applicationContext);
+        TracingConfiguration tracingConfiguration = applicationContext.getBean(TracingConfiguration.class);
+        assertNotNull(tracingConfiguration);
+        assertEquals("RDB", tracingConfiguration.getType());
+        assertTrue(tracingConfiguration.getStorage() instanceof DataSource);
+        DataSource dataSource = (DataSource) tracingConfiguration.getStorage();
+        assertNotNull(dataSource.getConnection());
+    }
+}
diff --git a/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/tracing/boot/fixture/EmbedTestingServer.java b/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/tracing/boot/fixture/EmbedTestingServer.java
new file mode 100644
index 0000000..09a001b
--- /dev/null
+++ b/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/tracing/boot/fixture/EmbedTestingServer.java
@@ -0,0 +1,68 @@
+/*
+ * 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.tracing.boot.fixture;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.curator.test.TestingServer;
+import org.apache.shardingsphere.elasticjob.reg.exception.RegExceptionHandler;
+
+import java.io.File;
+import java.io.IOException;
+
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class EmbedTestingServer {
+
+    private static final int PORT = 17181;
+
+    private static volatile TestingServer testingServer;
+
+    /**
+     * Get the connection string.
+     *
+     * @return connection string
+     */
+    public static String getConnectionString() {
+        return "localhost:" + PORT;
+    }
+
+    /**
+     * Start the server.
+     */
+    public static void start() {
+        if (null != testingServer) {
+            return;
+        }
+        try {
+            testingServer = new TestingServer(PORT, new File(String.format("target/test_zk_data/%s/", System.nanoTime())));
+            // CHECKSTYLE:OFF
+        } catch (final Exception ex) {
+            // CHECKSTYLE:ON
+            RegExceptionHandler.handleException(ex);
+        } finally {
+            Runtime.getRuntime().addShutdownHook(new Thread(() -> {
+                try {
+                    Thread.sleep(1000);
+                    testingServer.close();
+                } catch (final IOException | InterruptedException ex) {
+                    RegExceptionHandler.handleException(ex);
+                }
+            }));
+        }
+    }
+}
diff --git a/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/test/resources/application-elasticjob.yml b/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/test/resources/application-elasticjob.yml
new file mode 100644
index 0000000..fd69e73
--- /dev/null
+++ b/elasticjob-infra/elasticjob-tracing/elasticjob-tracing-spring-boot-starter/src/test/resources/application-elasticjob.yml
@@ -0,0 +1,29 @@
+#
+# 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.
+#
+
+spring:
+  datasource:
+    url: jdbc:h2:mem:job_event_storage
+    driver-class-name: org.h2.Driver
+    username: sa
+    password:
+elasticjob:
+  reg-center:
+    server-lists: localhost:17181
+    namespace: elasticjob-tracing-spring-boot-starter
+  tracing:
+    type: RDB
diff --git a/elasticjob-lite/elasticjob-lite-spring-boot-starter/pom.xml b/elasticjob-lite/elasticjob-lite-spring-boot-starter/pom.xml
index fa26ab6..c59091f 100644
--- a/elasticjob-lite/elasticjob-lite-spring-boot-starter/pom.xml
+++ b/elasticjob-lite/elasticjob-lite-spring-boot-starter/pom.xml
@@ -52,6 +52,16 @@
             <artifactId>elasticjob-registry-center-spring-boot-starter</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
 </project>
diff --git a/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/ElasticJobSpringBootTest.java b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/ElasticJobSpringBootTest.java
new file mode 100644
index 0000000..4ca0763
--- /dev/null
+++ b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/ElasticJobSpringBootTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.boot;
+
+import org.apache.shardingsphere.elasticjob.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.infra.concurrent.BlockUtils;
+import org.apache.shardingsphere.elasticjob.lite.api.bootstrap.impl.OneOffJobBootstrap;
+import org.apache.shardingsphere.elasticjob.lite.boot.fixture.EmbedTestingServer;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+
+import java.util.Map;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+@SpringBootTest
+@SpringBootApplication
+@ActiveProfiles("elasticjob")
+public class ElasticJobSpringBootTest extends AbstractJUnit4SpringContextTests {
+
+    @BeforeClass
+    public static void init() {
+        EmbedTestingServer.start();
+    }
+
+    @Test
+    public void testJobScheduleCreation() {
+        assertNotNull(applicationContext);
+        Map<String, ElasticJob> elasticJobBeans = applicationContext.getBeansOfType(ElasticJob.class);
+        assertFalse(elasticJobBeans.isEmpty());
+        Map<String, OneOffJobBootstrap> jobBootstrapBeans = applicationContext.getBeansOfType(OneOffJobBootstrap.class);
+        assertFalse(jobBootstrapBeans.isEmpty());
+        BlockUtils.waitingShortTime();
+    }
+}
diff --git a/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/executor/CustomClassedJobExecutor.java b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/executor/CustomClassedJobExecutor.java
new file mode 100644
index 0000000..5341ed6
--- /dev/null
+++ b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/executor/CustomClassedJobExecutor.java
@@ -0,0 +1,40 @@
+/*
+ * 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.boot.executor;
+
+import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
+import org.apache.shardingsphere.elasticjob.api.ShardingContext;
+import org.apache.shardingsphere.elasticjob.executor.JobFacade;
+import org.apache.shardingsphere.elasticjob.executor.item.impl.ClassedJobItemExecutor;
+import org.apache.shardingsphere.elasticjob.lite.boot.job.CustomJob;
+
+/**
+ * Custom Classed Executor.
+ */
+public class CustomClassedJobExecutor implements ClassedJobItemExecutor<CustomJob> {
+
+    @Override
+    public void process(final CustomJob elasticJob, final JobConfiguration jobConfig, final JobFacade jobFacade, final ShardingContext shardingContext) {
+        elasticJob.execute(shardingContext);
+    }
+
+    @Override
+    public Class<CustomJob> getElasticJobClass() {
+        return CustomJob.class;
+    }
+}
diff --git a/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/executor/PrintJobExecutor.java b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/executor/PrintJobExecutor.java
new file mode 100644
index 0000000..cdec753
--- /dev/null
+++ b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/executor/PrintJobExecutor.java
@@ -0,0 +1,42 @@
+/*
+ * 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.boot.executor;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.elasticjob.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
+import org.apache.shardingsphere.elasticjob.api.ShardingContext;
+import org.apache.shardingsphere.elasticjob.executor.JobFacade;
+import org.apache.shardingsphere.elasticjob.executor.item.impl.TypedJobItemExecutor;
+
+/**
+ * Print Job Executor.
+ */
+@Slf4j
+public class PrintJobExecutor implements TypedJobItemExecutor {
+
+    @Override
+    public void process(final ElasticJob elasticJob, final JobConfiguration jobConfig, final JobFacade jobFacade, final ShardingContext shardingContext) {
+        log.info(jobConfig.getProps().getProperty(PrintJobProperties.CONTENT_KEY));
+    }
+
+    @Override
+    public String getType() {
+        return "PRINT";
+    }
+}
diff --git a/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/executor/PrintJobProperties.java b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/executor/PrintJobProperties.java
new file mode 100644
index 0000000..6b13005
--- /dev/null
+++ b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/executor/PrintJobProperties.java
@@ -0,0 +1,23 @@
+/*
+ * 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.boot.executor;
+
+public class PrintJobProperties {
+
+    public static final String CONTENT_KEY = "print.content";
+}
diff --git a/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/fixture/EmbedTestingServer.java b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/fixture/EmbedTestingServer.java
new file mode 100644
index 0000000..87f32c0
--- /dev/null
+++ b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/fixture/EmbedTestingServer.java
@@ -0,0 +1,68 @@
+/*
+ * 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.boot.fixture;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.curator.test.TestingServer;
+import org.apache.shardingsphere.elasticjob.reg.exception.RegExceptionHandler;
+
+import java.io.File;
+import java.io.IOException;
+
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class EmbedTestingServer {
+
+    private static final int PORT = 18181;
+
+    private static volatile TestingServer testingServer;
+
+    /**
+     * Get the connection string.
+     *
+     * @return connection string
+     */
+    public static String getConnectionString() {
+        return "localhost:" + PORT;
+    }
+
+    /**
+     * Start the server.
+     */
+    public static void start() {
+        if (null != testingServer) {
+            return;
+        }
+        try {
+            testingServer = new TestingServer(PORT, new File(String.format("target/test_zk_data/%s/", System.nanoTime())));
+            // CHECKSTYLE:OFF
+        } catch (final Exception ex) {
+            // CHECKSTYLE:ON
+            RegExceptionHandler.handleException(ex);
+        } finally {
+            Runtime.getRuntime().addShutdownHook(new Thread(() -> {
+                try {
+                    Thread.sleep(1000);
+                    testingServer.close();
+                } catch (final IOException | InterruptedException ex) {
+                    RegExceptionHandler.handleException(ex);
+                }
+            }));
+        }
+    }
+}
diff --git a/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/job/CustomJob.java b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/job/CustomJob.java
new file mode 100644
index 0000000..0948fd3
--- /dev/null
+++ b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/job/CustomJob.java
@@ -0,0 +1,31 @@
+/*
+ * 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.boot.job;
+
+import org.apache.shardingsphere.elasticjob.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.api.ShardingContext;
+
+public interface CustomJob extends ElasticJob {
+
+    /**
+     * Execute custom job.
+     *
+     * @param shardingContext sharding context
+     */
+    void execute(ShardingContext shardingContext);
+}
diff --git a/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/job/impl/CustomTestJob.java b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/job/impl/CustomTestJob.java
new file mode 100644
index 0000000..e0d1e71
--- /dev/null
+++ b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/job/impl/CustomTestJob.java
@@ -0,0 +1,48 @@
+/*
+ * 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.boot.job.impl;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.elasticjob.api.ShardingContext;
+import org.apache.shardingsphere.elasticjob.lite.boot.job.CustomJob;
+import org.apache.shardingsphere.elasticjob.lite.boot.repository.BarRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Component
+@Slf4j
+public class CustomTestJob implements CustomJob {
+
+    @Autowired
+    private BarRepository barRepository;
+
+    @Override
+    public void execute(final ShardingContext shardingContext) {
+        int i = shardingContext.getShardingItem();
+        List<String> results = new ArrayList<>();
+        String data;
+        while (null != (data = barRepository.getById(i))) {
+            results.add(data);
+            i += shardingContext.getShardingTotalCount();
+        }
+        log.info("{}", results);
+    }
+}
diff --git a/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/repository/BarRepository.java b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/repository/BarRepository.java
new file mode 100644
index 0000000..6509555
--- /dev/null
+++ b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/repository/BarRepository.java
@@ -0,0 +1,32 @@
+/*
+ * 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.boot.repository;
+
+/**
+ * Bar Repository.
+ */
+public interface BarRepository {
+
+    /**
+     * Get data by id.
+     *
+     * @param id id
+     * @return data
+     */
+    String getById(int id);
+}
diff --git a/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/repository/impl/BarRepositoryImpl.java b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/repository/impl/BarRepositoryImpl.java
new file mode 100644
index 0000000..c462bd0
--- /dev/null
+++ b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/boot/repository/impl/BarRepositoryImpl.java
@@ -0,0 +1,32 @@
+/*
+ * 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.boot.repository.impl;
+
+import org.apache.shardingsphere.elasticjob.lite.boot.repository.BarRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class BarRepositoryImpl implements BarRepository {
+
+    private static final String[] DATA = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
+
+    @Override
+    public String getById(final int id) {
+        return id >= 0 && id < DATA.length ? DATA[id] : null;
+    }
+}
diff --git a/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/resources/META-INF/services/org.apache.shardingsphere.elasticjob.executor.item.JobItemExecutor b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/resources/META-INF/services/org.apache.shardingsphere.elasticjob.executor.item.JobItemExecutor
new file mode 100644
index 0000000..58a4ca0
--- /dev/null
+++ b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/resources/META-INF/services/org.apache.shardingsphere.elasticjob.executor.item.JobItemExecutor
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+org.apache.shardingsphere.elasticjob.lite.boot.executor.CustomClassedJobExecutor
+org.apache.shardingsphere.elasticjob.lite.boot.executor.PrintJobExecutor
diff --git a/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/resources/application-elasticjob.yml b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/resources/application-elasticjob.yml
new file mode 100644
index 0000000..e271de8
--- /dev/null
+++ b/elasticjob-lite/elasticjob-lite-spring-boot-starter/src/test/resources/application-elasticjob.yml
@@ -0,0 +1,41 @@
+#
+# 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.
+#
+
+spring:
+  datasource:
+    url: jdbc:h2:mem:job_event_storage
+    driver-class-name: org.h2.Driver
+    username: sa
+    password:
+
+elasticjob:
+  tracing:
+    type: RDB
+  regCenter:
+    serverLists: localhost:18181
+    namespace: elasticjob-lite-spring-boot-starter
+  jobs:
+    classed:
+      org.apache.shardingsphere.elasticjob.lite.boot.job.impl.CustomTestJob:
+        - jobName: customTestJob
+          shardingTotalCount: 3
+    typed:
+      PRINT:
+        - jobName: printTestJob
+          shardingTotalCount: 3
+          props:
+            print.content: "test print job"