diff --git a/spring-cloud-task-core/pom.xml b/spring-cloud-task-core/pom.xml index 702ac861..3a5c3455 100755 --- a/spring-cloud-task-core/pom.xml +++ b/spring-cloud-task-core/pom.xml @@ -18,6 +18,11 @@ Spring Cloud Task + + junit + junit + test + org.springframework.boot spring-boot-starter-aop diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/DefaultTaskConfigurer.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/DefaultTaskConfigurer.java index ff5ceab3..05bb8a38 100644 --- a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/DefaultTaskConfigurer.java +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/DefaultTaskConfigurer.java @@ -16,7 +16,7 @@ package org.springframework.cloud.task.configuration; -import org.springframework.cloud.task.repository.LoggerTaskRepository; +import org.springframework.cloud.task.repository.support.LoggerTaskRepository; import org.springframework.cloud.task.repository.TaskRepository; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/LoggerTaskRepository.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/support/LoggerTaskRepository.java similarity index 85% rename from spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/LoggerTaskRepository.java rename to spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/support/LoggerTaskRepository.java index 4fb85f7c..c7197681 100644 --- a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/LoggerTaskRepository.java +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/support/LoggerTaskRepository.java @@ -14,12 +14,15 @@ * limitations under the License. */ -package org.springframework.cloud.task.repository; +package org.springframework.cloud.task.repository.support; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.cloud.task.repository.TaskExecution; +import org.springframework.cloud.task.repository.TaskRepository; + /** * @author Glenn Renfro */ diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/support/NoOpTaskExplorer.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/support/NoOpTaskExplorer.java new file mode 100644 index 00000000..7a609e56 --- /dev/null +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/support/NoOpTaskExplorer.java @@ -0,0 +1,52 @@ +/* + * Copyright 2015 the original author or authors. + * + * Licensed 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.springframework.cloud.task.repository.support; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.springframework.cloud.task.repository.TaskExecution; +import org.springframework.cloud.task.repository.TaskExplorer; + +/** + * Provides a no-op TaskExplorer for development purposes. + * + * @author Michael Minella + */ +public class NoOpTaskExplorer implements TaskExplorer { + + public TaskExecution getTaskExecution(Long executionId) { + return null; + } + + public Set findRunningTaskExecutions(String taskName) { + return new HashSet(0); + } + + public List getTaskNames() { + return new ArrayList(0); + } + + public long getTaskExecutionCount(String taskName) { + return 0; + } + + public List getTaskExecutionsByName(String taskName, int start, int count) { + return new ArrayList(0); + } +} diff --git a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/support/NoOpTaskExplorerTest.java b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/support/NoOpTaskExplorerTest.java new file mode 100644 index 00000000..c0321931 --- /dev/null +++ b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/support/NoOpTaskExplorerTest.java @@ -0,0 +1,59 @@ +/* + * Copyright 2015 the original author or authors. + * + * Licensed 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.springframework.cloud.task.repository.support; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import org.junit.Before; +import org.junit.Test; + +import org.springframework.cloud.task.repository.TaskExplorer; + +public class NoOpTaskExplorerTest { + + private TaskExplorer taskExplorer; + + @Before + public void setUp() throws Exception { + taskExplorer = new NoOpTaskExplorer(); + } + + @Test + public void testGetTaskExecution() throws Exception { + assertNull(taskExplorer.getTaskExecution(3l)); + } + + @Test + public void testFindRunningTaskExecutions() throws Exception { + assertEquals(taskExplorer.findRunningTaskExecutions("foo").size(), 0); + } + + @Test + public void testGetTaskNames() throws Exception { + assertEquals(taskExplorer.getTaskNames().size(), 0); + } + + @Test + public void testGetTaskExecutionCount() throws Exception { + assertEquals(taskExplorer.getTaskExecutionCount("foo"), 0); + } + + @Test + public void testGetTaskExecutionsByName() throws Exception { + assertEquals(taskExplorer.getTaskExecutionsByName("foo", 0, 100).size(), 0); + } +}