Skip to content

Reduce use of deprecated APIs #4120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2018 the original author or authors.
* Copyright 2006-2022 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.
Expand Down Expand Up @@ -226,13 +226,10 @@ public void testUnknownIsRunning() throws Exception {
}

@Test
public void testSerializable() throws Exception {
public void testSerializable() {
ExitStatus status = ExitStatus.EXECUTING.replaceExitCode("FOO");
byte[] bytes = SerializationUtils.serialize(status);
Object object = SerializationUtils.deserialize(bytes);
assertTrue(object instanceof ExitStatus);
ExitStatus restored = (ExitStatus) object;
assertEquals(status.getExitCode(), restored.getExitCode());
ExitStatus clone = SerializationUtils.clone(status);
assertEquals(status.getExitCode(), clone.getExitCode());
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2021 the original author or authors.
* Copyright 2006-2022 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.
Expand Down Expand Up @@ -193,13 +193,13 @@ public void testToStringWithNullJob() throws Exception {

@Test
public void testSerialization() {
byte[] serialized = SerializationUtils.serialize(execution);
JobExecution deserialize = (JobExecution) SerializationUtils.deserialize(serialized);
assertEquals(execution, deserialize);
assertNotNull(deserialize.createStepExecution("foo"));
assertNotNull(deserialize.getFailureExceptions());
JobExecution clone = SerializationUtils.clone(execution);
assertEquals(execution, clone);
assertNotNull(clone.createStepExecution("foo"));
assertNotNull(clone.getFailureExceptions());
}

@Test
public void testFailureExceptions() {

RuntimeException exception = new RuntimeException();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2021 the original author or authors.
* Copyright 2006-2022 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.
Expand Down Expand Up @@ -59,10 +59,7 @@ public void testCreateWithNulls() {
@Test
public void testSerialization() {
instance = new JobInstance(1L, "jobName");

byte[] serialized = SerializationUtils.serialize(instance);

assertEquals(instance, SerializationUtils.deserialize(serialized));
assertEquals(instance, SerializationUtils.clone(instance));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2021 the original author or authors.
* Copyright 2008-2022 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.
Expand All @@ -20,7 +20,6 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -184,10 +183,7 @@ public void testHashCodeEqualWhenNotEmpty() throws Exception {
@Test
public void testSerialization() {
JobParameters params = getNewParameters();

byte[] serialized = SerializationUtils.serialize(params);

assertEquals(params, SerializationUtils.deserialize(serialized));
assertEquals(params, SerializationUtils.clone(params));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,18 +259,17 @@ public void testHashCodeViaHashSet() throws Exception {
}

@Test
public void testSerialization() throws Exception {
public void testSerialization() {

ExitStatus status = ExitStatus.NOOP;
execution.setExitStatus(status);
execution.setExecutionContext(foobarEc);

byte[] serialized = SerializationUtils.serialize(execution);
StepExecution deserialized = (StepExecution) SerializationUtils.deserialize(serialized);
StepExecution clone = SerializationUtils.clone(execution);

assertEquals(execution, deserialized);
assertEquals(status, deserialized.getExitStatus());
assertNotNull(deserialized.getFailureExceptions());
assertEquals(execution, clone);
assertEquals(status, clone.getExitStatus());
assertNotNull(clone.getFailureExceptions());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2021 the original author or authors.
* Copyright 2020-2022 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.
Expand Down Expand Up @@ -97,7 +97,7 @@ public DataSource dataSource() throws Exception {
dataSource.setUser(db2.getUsername());
dataSource.setPassword(db2.getPassword());
dataSource.setDriverType(4);
dataSource.setServerName(db2.getContainerIpAddress());
dataSource.setServerName(db2.getHost());
dataSource.setPortNumber(db2.getMappedPort(Db2Container.DB2_PORT));
dataSource.setSslConnection(false);
return dataSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.springframework.core.io.ClassPathResource;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.EnabledIf;
import org.springframework.test.context.junit4.SpringRunner;

import org.testcontainers.containers.JdbcDatabaseContainer;
Expand Down Expand Up @@ -228,7 +227,7 @@ public String getTestQueryString() {

@Override
public String getJdbcUrl() {
return "jdbc:sap://" + getContainerIpAddress() + ":" + getMappedPort(PORT) + "/";
return "jdbc:sap://" + getHost() + ":" + getMappedPort(PORT) + "/";
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public DataSource dataSource() throws Exception {
oracleDataSource.setUser(oracle.getUsername());
oracleDataSource.setPassword(oracle.getPassword());
oracleDataSource.setDatabaseName(oracle.getDatabaseName());
oracleDataSource.setServerName(oracle.getContainerIpAddress());
oracleDataSource.setServerName(oracle.getHost());
oracleDataSource.setPortNumber(oracle.getOraclePort());
return oracleDataSource;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2021 the original author or authors.
* Copyright 2006-2022 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.
Expand All @@ -17,7 +17,6 @@

import static org.junit.Assert.assertEquals;

import java.util.concurrent.Callable;
import java.util.concurrent.CompletionService;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorCompletionService;
Expand All @@ -40,11 +39,11 @@
public class StepExecutionSerializationUtilsTests {

@Test
public void testCycle() throws Exception {
public void testCycle() {
StepExecution stepExecution = new StepExecution("step",
new JobExecution(new JobInstance(123L, "job"), 321L, new JobParameters()), 11L);
stepExecution.getExecutionContext().put("foo.bar.spam", 123);
StepExecution result = getCopy(stepExecution);
StepExecution result = SerializationUtils.clone(stepExecution);
assertEquals(stepExecution, result);
}

Expand All @@ -61,15 +60,12 @@ public void testMultipleCycles() throws Throwable {
for (int i = 0; i < repeats; i++) {
final JobExecution jobExecution = new JobExecution(new JobInstance(123L, "job"), 321L, new JobParameters());
for (int j = 0; j < threads; j++) {
completionService.submit(new Callable<StepExecution>() {
@Override
public StepExecution call() throws Exception {
final StepExecution stepExecution = jobExecution.createStepExecution("step");
stepExecution.getExecutionContext().put("foo.bar.spam", 123);
StepExecution result = getCopy(stepExecution);
assertEquals(stepExecution.getExecutionContext(), result.getExecutionContext());
return result;
}
completionService.submit(() -> {
final StepExecution stepExecution = jobExecution.createStepExecution("step");
stepExecution.getExecutionContext().put("foo.bar.spam", 123);
StepExecution result = SerializationUtils.clone(stepExecution);
assertEquals(stepExecution.getExecutionContext(), result.getExecutionContext());
return result;
});
}
for (int j = 0; j < threads; j++) {
Expand Down Expand Up @@ -97,8 +93,4 @@ public StepExecution call() throws Exception {
}
}

private StepExecution getCopy(StepExecution stepExecution) {
return (StepExecution) SerializationUtils.deserialize(SerializationUtils.serialize(stepExecution));
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2018 the original author or authors.
* Copyright 2006-2022 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.
Expand Down Expand Up @@ -153,12 +153,10 @@ public void testSerialization() {
context.put("5", s);
context.putInt("6", 6);

byte[] serialized = SerializationUtils.serialize(context);
ExecutionContext clone = SerializationUtils.clone(context);

ExecutionContext deserialized = (ExecutionContext) SerializationUtils.deserialize(serialized);

assertEquals(context, deserialized);
assertEquals(7, ((TestSerializable) deserialized.get("5")).value);
assertEquals(context, clone);
assertEquals(7, ((TestSerializable) clone.get("5")).value);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2022 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.
Expand Down Expand Up @@ -76,17 +76,6 @@ public static void main(String... args) {
DataSourceInitializer.class.getSimpleName() + "-context.xml"));
}

/**
* @throws Throwable
* @see java.lang.Object#finalize()
*/
@Override
protected void finalize() throws Throwable {
logger.debug("finalize called for " + dataSource);
super.finalize();
initialized = false;
}

@Override
public void destroy() {
logger.info("destroy called for " + dataSource);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2022 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.
Expand Down Expand Up @@ -54,10 +54,8 @@ public void testToString() {
}

@Test
public void testSerializable() throws Exception {
@SuppressWarnings("unchecked")
ChunkRequest<String> result = (ChunkRequest<String>) SerializationUtils
.deserialize(SerializationUtils.serialize(request));
public void testSerializable() {
ChunkRequest<String> result = SerializationUtils.clone(request);
assertNotNull(result.getStepContribution());
assertEquals(111L, result.getJobId());
assertEquals(2, result.getItems().size());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2021 the original author or authors.
* Copyright 2006-2022 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.
Expand Down Expand Up @@ -47,8 +47,8 @@ public void testToString() {
}

@Test
public void testSerializable() throws Exception {
ChunkResponse result = (ChunkResponse) SerializationUtils.deserialize(SerializationUtils.serialize(response));
public void testSerializable() {
ChunkResponse result = SerializationUtils.clone(response);
assertNotNull(result.getStepContribution());
assertEquals(Long.valueOf(111L), result.getJobId());
}
Expand Down