Removed code that was marked as deprecated.
Also updated test that tested deprecated code. resolves #366
This commit is contained in:
committed by
Michael Minella
parent
1ae7930d09
commit
76309b89ff
@@ -32,6 +32,7 @@ import org.springframework.util.StringUtils;
|
||||
* {@link org.springframework.cloud.task.repository.TaskRepository}
|
||||
*
|
||||
* @author Michael Minella
|
||||
* @author Glenn Renfro
|
||||
*/
|
||||
public class JdbcTaskBatchDao implements TaskBatchDao {
|
||||
|
||||
@@ -70,18 +71,6 @@ public class JdbcTaskBatchDao implements TaskBatchDao {
|
||||
jdbcTemplate.update(getQuery(INSERT_STATEMENT), taskExecution.getExecutionId(), jobExecution.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* The table prefix for the task batch table.
|
||||
*
|
||||
* @param tablePrefix defaults to {@link TaskProperties#DEFAULT_TABLE_PREFIX}.
|
||||
* @deprecated Use the constructor to inject this value
|
||||
*/
|
||||
@Deprecated
|
||||
public void setTablePrefix(String tablePrefix) {
|
||||
Assert.notNull(tablePrefix, "Null is not allowed as a tablePrefix (use an empty string if you don't want a prefix at all).");
|
||||
this.tablePrefix = tablePrefix;
|
||||
}
|
||||
|
||||
private String getQuery(String base) {
|
||||
return StringUtils.replace(base, "%PREFIX%", tablePrefix);
|
||||
}
|
||||
|
||||
@@ -221,8 +221,10 @@ public class DeployerPartitionHandler implements PartitionHandler, EnvironmentAw
|
||||
this.taskExecution = taskExecution;
|
||||
|
||||
if(this.commandLineArgsProvider == null) {
|
||||
this.commandLineArgsProvider =
|
||||
new SimpleCommandLineArgsProvider(this.taskExecution);
|
||||
SimpleCommandLineArgsProvider provider = new
|
||||
SimpleCommandLineArgsProvider(taskExecution);
|
||||
this.commandLineArgsProvider = provider;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -28,6 +29,7 @@ import org.springframework.util.Assert;
|
||||
* appended with any additional arguments configured.
|
||||
*
|
||||
* @author Michael Minella
|
||||
* @author Glenn Renfro
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class SimpleCommandLineArgsProvider extends TaskExecutionListenerSupport implements CommandLineArgsProvider {
|
||||
@@ -41,10 +43,7 @@ public class SimpleCommandLineArgsProvider extends TaskExecutionListenerSupport
|
||||
|
||||
/**
|
||||
* @param taskExecution task execution
|
||||
* @deprecated use the {@link org.springframework.cloud.task.listener.TaskExecutionListener}
|
||||
* functionality to obtain the {@link TaskExecution}
|
||||
*/
|
||||
@Deprecated
|
||||
public SimpleCommandLineArgsProvider(TaskExecution taskExecution) {
|
||||
Assert.notNull(taskExecution, "A taskExecution is required");
|
||||
|
||||
|
||||
@@ -30,18 +30,12 @@ import static org.junit.Assert.assertEquals;
|
||||
*/
|
||||
public class SimpleCommandLineArgsProviderTests {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testNullConstructorArg() {
|
||||
new SimpleCommandLineArgsProvider(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
TaskExecution taskExecution = new TaskExecution();
|
||||
taskExecution.setArguments(Arrays.asList("foo", "bar", "baz"));
|
||||
|
||||
SimpleCommandLineArgsProvider provider = new SimpleCommandLineArgsProvider();
|
||||
provider.onTaskStartup(taskExecution);
|
||||
SimpleCommandLineArgsProvider provider = new SimpleCommandLineArgsProvider(taskExecution);
|
||||
|
||||
List<String> commandLineArgs = provider.getCommandLineArgs(null);
|
||||
|
||||
@@ -60,8 +54,7 @@ public class SimpleCommandLineArgsProviderTests {
|
||||
TaskExecution taskExecution = new TaskExecution();
|
||||
taskExecution.setArguments(Arrays.asList("foo", "bar", "baz"));
|
||||
|
||||
SimpleCommandLineArgsProvider provider = new SimpleCommandLineArgsProvider();
|
||||
provider.onTaskStartup(taskExecution);
|
||||
SimpleCommandLineArgsProvider provider = new SimpleCommandLineArgsProvider(taskExecution);
|
||||
provider.setAppendedArgs(appendedValues);
|
||||
|
||||
List<String> commandLineArgs = provider.getCommandLineArgs(null);
|
||||
@@ -80,8 +73,7 @@ public class SimpleCommandLineArgsProviderTests {
|
||||
TaskExecution taskExecution = new TaskExecution();
|
||||
taskExecution.setArguments(Arrays.asList("foo", "bar", "baz"));
|
||||
|
||||
SimpleCommandLineArgsProvider provider = new SimpleCommandLineArgsProvider();
|
||||
provider.onTaskStartup(taskExecution);
|
||||
SimpleCommandLineArgsProvider provider = new SimpleCommandLineArgsProvider(taskExecution);
|
||||
provider.setAppendedArgs(null);
|
||||
|
||||
List<String> commandLineArgs = provider.getCommandLineArgs(null);
|
||||
|
||||
@@ -100,28 +100,6 @@ public class TaskProperties {
|
||||
this.executionid = executionid;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated use getClosecontextEnabled()
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@Deprecated
|
||||
public Boolean getClosecontextEnable() {
|
||||
return closecontextEnabled;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated use setClosecontextEnabled()
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@Deprecated
|
||||
public void setClosecontextEnable(Boolean closecontextEnable) {
|
||||
logger.warn("'closecontextEnable' is deprecated. Use 'closeContextEnabled.'");
|
||||
this.closecontextEnabled = closecontextEnable;
|
||||
}
|
||||
|
||||
public Boolean getClosecontextEnabled() {
|
||||
return closecontextEnabled;
|
||||
}
|
||||
|
||||
@@ -244,18 +244,6 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
|
||||
completeTaskExecution(taskExecutionId, exitCode, endTime, exitMessage, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Public setter for the table prefix property. This will be prefixed to all
|
||||
* the table names before queries are executed. Defaults to
|
||||
* {@link TaskProperties#DEFAULT_TABLE_PREFIX}.
|
||||
*
|
||||
* @param tablePrefix the tablePrefix to set
|
||||
*/
|
||||
@Deprecated
|
||||
public void setTablePrefix(String tablePrefix) {
|
||||
this.tablePrefix = tablePrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskExecution getTaskExecution(long executionId) {
|
||||
try {
|
||||
|
||||
@@ -96,18 +96,6 @@ public class TaskExecutionDaoFactoryBean implements FactoryBean<TaskExecutionDao
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates a prefix for all of the task repository's tables if the jdbc option is
|
||||
* used.
|
||||
*
|
||||
* @param tablePrefix the string prefix for the task table names
|
||||
* @deprecated Use the constructor to inject
|
||||
*/
|
||||
@Deprecated
|
||||
public void setTablePrefix(String tablePrefix) {
|
||||
this.tablePrefix = tablePrefix;
|
||||
}
|
||||
|
||||
private void buildTaskExecutionDao(DataSource dataSource) {
|
||||
DataFieldMaxValueIncrementerFactory incrementerFactory = new DefaultDataFieldMaxValueIncrementerFactory(dataSource);
|
||||
this.dao = new JdbcTaskExecutionDao(dataSource, this.tablePrefix);
|
||||
|
||||
@@ -21,7 +21,6 @@ import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(Suite.class)
|
||||
@SuiteClasses({
|
||||
TaskPropertiesTests.CloseContextEnableTest.class,
|
||||
TaskPropertiesTests.CloseContextEnabledTest.class,
|
||||
|
||||
})
|
||||
@@ -35,12 +34,6 @@ public class TaskPropertiesTests {
|
||||
public void test() {
|
||||
assertThat(taskProperties.getClosecontextEnabled(), is(false));
|
||||
}
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes={TaskPropertiesTests.Config.class}, properties = { "spring.cloud.task.closecontextEnable=false" })
|
||||
@DirtiesContext
|
||||
public static class CloseContextEnableTest extends TaskPropertiesTests {
|
||||
}
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes={TaskPropertiesTests.Config.class}, properties = { "spring.cloud.task.closecontextEnabled=false" })
|
||||
|
||||
@@ -159,7 +159,7 @@ public class TaskLifecycleListenerTests {
|
||||
@Test
|
||||
public void testNoClosingOfContext() {
|
||||
ConfigurableApplicationContext applicationContext = SpringApplication.run(new Class[]{TestDefaultConfiguration.class, PropertyPlaceholderAutoConfiguration.class},
|
||||
new String[] {"--spring.cloud.task.closecontext_enable=false"});
|
||||
new String[] {"--spring.cloud.task.closecontext_enabled=false"});
|
||||
|
||||
try {
|
||||
assertTrue(applicationContext.isActive());
|
||||
|
||||
@@ -62,7 +62,7 @@ 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_enable=false",
|
||||
RabbitServiceAutoConfiguration.class}).build().run(new String[] {"--spring.cloud.task.closecontext_enabled=false",
|
||||
"--spring.cloud.task.name=" + TASK_NAME,
|
||||
"--spring.main.web-environment=false",
|
||||
"--spring.cloud.stream.defaultBinder=rabbit",
|
||||
|
||||
@@ -280,7 +280,7 @@ public class JobExecutionEventTests {
|
||||
EventJobExecutionConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
TestSupportBinderAutoConfiguration.class},
|
||||
new String[]{"--spring.cloud.task.closecontext_enable=false",
|
||||
new String[]{"--spring.cloud.task.closecontext_enabled=false",
|
||||
"--spring.main.web-environment=false",
|
||||
"--spring.cloud.task.batch.events.chunk-order=5",
|
||||
"--spring.cloud.task.batch.events.item-process-order=5",
|
||||
@@ -304,7 +304,7 @@ public class JobExecutionEventTests {
|
||||
EventJobExecutionConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
TestSupportBinderAutoConfiguration.class},
|
||||
new String[]{"--spring.cloud.task.closecontext_enable=false",
|
||||
new String[]{"--spring.cloud.task.closecontext_enabled=false",
|
||||
"--spring.main.web-environment=false",
|
||||
disabledPropertyArg});
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class TaskEventTests {
|
||||
SpringApplication.run(new Class[]{PropertyPlaceholderAutoConfiguration.class,EmbeddedDataSourceConfiguration.class,TaskEventsConfiguration.class,
|
||||
TaskEventAutoConfiguration.class,
|
||||
TestSupportBinderAutoConfiguration.class},
|
||||
new String[]{ "--spring.cloud.task.closecontext_enable=false",
|
||||
new String[]{ "--spring.cloud.task.closecontext_enabled=false",
|
||||
"--spring.main.web-environment=false"});
|
||||
|
||||
assertNotNull(applicationContext.getBean("taskEventListener"));
|
||||
|
||||
Reference in New Issue
Block a user