Skip to content

Commit

Permalink
Remove ElasticJobServiceLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Oct 23, 2023
1 parent 088f535 commit 7664666
Showing 1 changed file with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,17 @@ class ExecutorServiceReloadableTest {

@Test
void assertInitialize() {
ExecutorServiceReloadable executorServiceReloadable = new ExecutorServiceReloadable();
String jobExecutorServiceHandlerType = "SINGLE_THREAD";
JobConfiguration jobConfig = JobConfiguration.newBuilder("job", 1).jobExecutorServiceHandlerType(jobExecutorServiceHandlerType).build();
assertNull(executorServiceReloadable.getInstance());
executorServiceReloadable.init(jobConfig);
ExecutorService actual = executorServiceReloadable.getInstance();
assertNotNull(actual);
assertFalse(actual.isShutdown());
assertFalse(actual.isTerminated());
actual.shutdown();
try (ExecutorServiceReloadable executorServiceReloadable = new ExecutorServiceReloadable()) {
String jobExecutorServiceHandlerType = "SINGLE_THREAD";
JobConfiguration jobConfig = JobConfiguration.newBuilder("job", 1).jobExecutorServiceHandlerType(jobExecutorServiceHandlerType).build();
assertNull(executorServiceReloadable.getInstance());
executorServiceReloadable.init(jobConfig);
ExecutorService actual = executorServiceReloadable.getInstance();
assertNotNull(actual);
assertFalse(actual.isShutdown());
assertFalse(actual.isTerminated());
actual.shutdown();
}
}

@Test
Expand All @@ -75,14 +76,15 @@ void assertReload() {

@Test
void assertUnnecessaryToReload() {
ExecutorServiceReloadable executorServiceReloadable = new ExecutorServiceReloadable();
JobConfiguration jobConfig = JobConfiguration.newBuilder("job", 1).jobExecutorServiceHandlerType("CPU").build();
executorServiceReloadable.init(jobConfig);
ExecutorService expected = executorServiceReloadable.getInstance();
executorServiceReloadable.reloadIfNecessary(jobConfig);
ExecutorService actual = executorServiceReloadable.getInstance();
assertThat(actual, is(expected));
actual.shutdown();
try (ExecutorServiceReloadable executorServiceReloadable = new ExecutorServiceReloadable()) {
JobConfiguration jobConfig = JobConfiguration.newBuilder("job", 1).jobExecutorServiceHandlerType("CPU").build();
executorServiceReloadable.init(jobConfig);
ExecutorService expected = executorServiceReloadable.getInstance();
executorServiceReloadable.reloadIfNecessary(jobConfig);
ExecutorService actual = executorServiceReloadable.getInstance();
assertThat(actual, is(expected));
actual.shutdown();
}
}

@Test
Expand Down

0 comments on commit 7664666

Please sign in to comment.