From 6426cfea7e737f57c82c9a1d2c96486c9e1dfe02 Mon Sep 17 00:00:00 2001 From: Michael Minella Date: Tue, 13 Feb 2018 09:27:08 -0600 Subject: [PATCH] Polish --- .../batch/listener/support/JdbcTaskBatchDao.java | 2 +- .../partition/DeployerPartitionHandler.java | 2 +- .../partition/SimpleCommandLineArgsProvider.java | 3 +-- .../TaskBatchExecutionListenerTests.java | 2 +- .../SimpleCommandLineArgsProviderTests.java | 2 +- .../cloud/task/configuration/TaskProperties.java | 2 +- .../repository/dao/JdbcTaskExecutionDao.java | 2 +- .../support/TaskExecutionDaoFactoryBean.java | 2 +- .../listener/TaskLifecycleListenerTests.java | 16 ++++++---------- .../cloud/task/listener/TaskEventTests.java | 6 +++--- .../batch/listener/JobExecutionEventTests.java | 10 +++++----- .../cloud/task/listener/TaskEventTests.java | 2 +- 12 files changed, 23 insertions(+), 28 deletions(-) diff --git a/spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/listener/support/JdbcTaskBatchDao.java b/spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/listener/support/JdbcTaskBatchDao.java index 685572a2..c058d378 100644 --- a/spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/listener/support/JdbcTaskBatchDao.java +++ b/spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/listener/support/JdbcTaskBatchDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2018 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. diff --git a/spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/partition/DeployerPartitionHandler.java b/spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/partition/DeployerPartitionHandler.java index ed765787..1cfa92d1 100644 --- a/spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/partition/DeployerPartitionHandler.java +++ b/spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/partition/DeployerPartitionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2016-2018 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. diff --git a/spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/partition/SimpleCommandLineArgsProvider.java b/spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/partition/SimpleCommandLineArgsProvider.java index a8e62619..e19cfd9b 100644 --- a/spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/partition/SimpleCommandLineArgsProvider.java +++ b/spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/partition/SimpleCommandLineArgsProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2018 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. @@ -21,7 +21,6 @@ import java.util.List; import org.springframework.batch.item.ExecutionContext; import org.springframework.cloud.task.listener.TaskExecutionListenerSupport; import org.springframework.cloud.task.repository.TaskExecution; -import org.springframework.core.env.SimpleCommandLinePropertySource; import org.springframework.util.Assert; /** diff --git a/spring-cloud-task-batch/src/test/java/org/springframework/cloud/task/batch/listener/TaskBatchExecutionListenerTests.java b/spring-cloud-task-batch/src/test/java/org/springframework/cloud/task/batch/listener/TaskBatchExecutionListenerTests.java index 6c613cd4..83827b55 100644 --- a/spring-cloud-task-batch/src/test/java/org/springframework/cloud/task/batch/listener/TaskBatchExecutionListenerTests.java +++ b/spring-cloud-task-batch/src/test/java/org/springframework/cloud/task/batch/listener/TaskBatchExecutionListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2018 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. diff --git a/spring-cloud-task-batch/src/test/java/org/springframework/cloud/task/batch/partition/SimpleCommandLineArgsProviderTests.java b/spring-cloud-task-batch/src/test/java/org/springframework/cloud/task/batch/partition/SimpleCommandLineArgsProviderTests.java index 4bb51319..4855db57 100644 --- a/spring-cloud-task-batch/src/test/java/org/springframework/cloud/task/batch/partition/SimpleCommandLineArgsProviderTests.java +++ b/spring-cloud-task-batch/src/test/java/org/springframework/cloud/task/batch/partition/SimpleCommandLineArgsProviderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2018 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. diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/TaskProperties.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/TaskProperties.java index 53ec488e..1db95f77 100644 --- a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/TaskProperties.java +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/TaskProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2016-2018 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. diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/JdbcTaskExecutionDao.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/JdbcTaskExecutionDao.java index 8a8de2e8..1f2dbbc5 100644 --- a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/JdbcTaskExecutionDao.java +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/JdbcTaskExecutionDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 the original author or authors. + * Copyright 2015-2018 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. diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/support/TaskExecutionDaoFactoryBean.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/support/TaskExecutionDaoFactoryBean.java index cb72f20c..f45f843c 100644 --- a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/support/TaskExecutionDaoFactoryBean.java +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/support/TaskExecutionDaoFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2018 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. diff --git a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/listener/TaskLifecycleListenerTests.java b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/listener/TaskLifecycleListenerTests.java index 55d30526..4e04e378 100644 --- a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/listener/TaskLifecycleListenerTests.java +++ b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/listener/TaskLifecycleListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 the original author or authors. + * Copyright 2015-2018 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. @@ -158,22 +158,18 @@ public class TaskLifecycleListenerTests { @Test public void testNoClosingOfContext() { - ConfigurableApplicationContext applicationContext = SpringApplication.run(new Class[]{TestDefaultConfiguration.class, PropertyPlaceholderAutoConfiguration.class}, - new String[] {"--spring.cloud.task.closecontext_enabled=false"}); - try { + try (ConfigurableApplicationContext applicationContext = SpringApplication.run(new Class[] {TestDefaultConfiguration.class, PropertyPlaceholderAutoConfiguration.class}, + new String[] {"--spring.cloud.task.closecontext_enabled=false"})) { assertTrue(applicationContext.isActive()); } - finally { - applicationContext.close(); - } } @Test(expected = ApplicationContextException.class) public void testInvalidTaskExecutionId() { ConfigurableEnvironment environment = new StandardEnvironment(); MutablePropertySources propertySources = environment.getPropertySources(); - Map myMap = new HashMap(); + Map myMap = new HashMap<>(); myMap.put("spring.cloud.task.executionid", "55"); propertySources.addFirst(new MapPropertySource("EnvrionmentTestPropsource", myMap)); context.setEnvironment(environment); @@ -195,7 +191,7 @@ public class TaskLifecycleListenerTests { public void testExternalExecutionId() { ConfigurableEnvironment environment = new StandardEnvironment(); MutablePropertySources propertySources = environment.getPropertySources(); - Map myMap = new HashMap(); + Map myMap = new HashMap<>(); myMap.put("spring.cloud.task.external-execution-id", "myid"); propertySources.addFirst(new MapPropertySource("EnvrionmentTestPropsource", myMap)); context.setEnvironment(environment); @@ -209,7 +205,7 @@ public class TaskLifecycleListenerTests { public void testParentExecutionId() { ConfigurableEnvironment environment = new StandardEnvironment(); MutablePropertySources propertySources = environment.getPropertySources(); - Map myMap = new HashMap(); + Map myMap = new HashMap<>(); myMap.put("spring.cloud.task.parentExecutionId", 789); propertySources.addFirst(new MapPropertySource("EnvrionmentTestPropsource", myMap)); context.setEnvironment(environment); diff --git a/spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/listener/TaskEventTests.java b/spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/listener/TaskEventTests.java index 80950c4c..f88b094b 100644 --- a/spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/listener/TaskEventTests.java +++ b/spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/listener/TaskEventTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2018 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. @@ -62,11 +62,11 @@ public class TaskEventTests { ConfigurableApplicationContext applicationContext = new SpringApplicationBuilder().sources(new Class[] {TaskEventsConfiguration.class, TaskEventAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, - RabbitServiceAutoConfiguration.class}).build().run(new String[] {"--spring.cloud.task.closecontext_enabled=false", + RabbitServiceAutoConfiguration.class}).build().run("--spring.cloud.task.closecontext_enabled=false", "--spring.cloud.task.name=" + TASK_NAME, "--spring.main.web-environment=false", "--spring.cloud.stream.defaultBinder=rabbit", - "--spring.cloud.stream.bindings.task-events.destination=test"}); + "--spring.cloud.stream.bindings.task-events.destination=test"); assertNotNull(applicationContext.getBean("taskEventListener")); assertNotNull(applicationContext.getBean(TaskEventAutoConfiguration.TaskEventChannels.class)); assertTrue(latch.await(1, TimeUnit.SECONDS)); diff --git a/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/JobExecutionEventTests.java b/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/JobExecutionEventTests.java index 17deb99c..e0770cb7 100644 --- a/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/JobExecutionEventTests.java +++ b/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/JobExecutionEventTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2018 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. @@ -58,8 +58,8 @@ import static org.junit.Assert.assertTrue; public class JobExecutionEventTests { private static final String JOB_NAME = "FOODJOB"; - private static final Long JOB_INSTANCE_ID = 1l; - private static final Long JOB_EXECUTION_ID = 2l; + private static final Long JOB_INSTANCE_ID = 1L; + private static final Long JOB_EXECUTION_ID = 2L; private static final String JOB_CONFIGURATION_NAME = "FOO_JOB_CONFIG"; private static final String[] LISTENER_BEAN_NAMES = {BatchEventAutoConfiguration.JOB_EXECUTION_EVENTS_LISTENER, BatchEventAutoConfiguration.STEP_EXECUTION_EVENTS_LISTENER, BatchEventAutoConfiguration.CHUNK_EVENTS_LISTENER, @@ -97,7 +97,7 @@ public class JobExecutionEventTests { JobParameter[] PARAMETERS = {new JobParameter("FOO", true), new JobParameter(1L, true), new JobParameter(1D, true), new JobParameter(testDate, false)}; - Map jobParamMap = new LinkedHashMap<>(); + Map jobParamMap = new LinkedHashMap<>(); for (int paramCount = 0; paramCount < JOB_PARAM_KEYS.length; paramCount++) { jobParamMap.put(JOB_PARAM_KEYS[paramCount], PARAMETERS[paramCount]); } @@ -296,7 +296,7 @@ public class JobExecutionEventTests { } } - public void testDisabledConfiguration(String property, String disabledListener) { + private void testDisabledConfiguration(String property, String disabledListener) { boolean exceptionThrown = false; String disabledPropertyArg = (property != null) ? "--" + property + "=false" : ""; ConfigurableApplicationContext applicationContext = diff --git a/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/listener/TaskEventTests.java b/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/listener/TaskEventTests.java index 5c6ee430..6baaccb4 100644 --- a/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/listener/TaskEventTests.java +++ b/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/listener/TaskEventTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2018 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.