Replace usage of deprecated jobOperator#start method with newer version

Related to #4303
This commit is contained in:
jinwoo-Bae
2023-02-18 01:37:49 +09:00
committed by Mahmoud Ben Hassine
parent b76993ca3d
commit 2cc0be4a0c
3 changed files with 27 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2022 the original author or authors.
* Copyright 2008-2023 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.
@@ -17,6 +17,7 @@ package org.springframework.batch.sample;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -61,8 +62,10 @@ class JobOperatorFunctionalTests {
@Test
void testStartStopResumeJob() throws Exception {
String params = "jobOperatorTestParam=7,java.lang.Long,true";
Properties properties = new Properties();
properties.setProperty("jobOperatorTestParam", "7,java.lang.Long,true");
long executionId = operator.start(job.getName(), params);
long executionId = operator.start(job.getName(), properties);
assertEquals(params, operator.getParameters(executionId));
stopAndCheckStatus(executionId);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-2023 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.
@@ -31,11 +31,13 @@ import javax.management.MalformedObjectNameException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import static org.junit.jupiter.api.Assertions.*;
/**
* @author Dave Syer
* @author Jinwoo Bae
*
*/
class RemoteLauncherTests {
@@ -61,11 +63,12 @@ class RemoteLauncherTests {
@Test
void testLaunchBadJob() throws Exception {
Properties properties = new Properties();
properties.setProperty("time", String.valueOf(new Date().getTime()));
assertEquals(0, errors.size());
assertTrue(isConnected());
Exception exception = assertThrows(RuntimeException.class,
() -> launcher.start("foo", "time=" + (new Date().getTime())));
Exception exception = assertThrows(RuntimeException.class, () -> launcher.start("foo", properties));
String message = exception.getMessage();
assertTrue(message.contains("NoSuchJobException"), "Wrong message: " + message);
}
@@ -84,7 +87,7 @@ class RemoteLauncherTests {
assertTrue(isConnected());
assertTrue(launcher.getJobNames().contains("loopJob"));
long executionId = launcher.start("loopJob", "");
long executionId = launcher.start("loopJob", new Properties());
// sleep long enough to avoid race conditions (serializable tx isolation
// doesn't work with HSQL)