Skip to content

Commit

Permalink
Revert ThreadPoolTest
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
  • Loading branch information
jbescos committed May 29, 2024
1 parent dcf3572 commit 048a5b1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
12 changes: 12 additions & 0 deletions common/configurable/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@
</path>
</annotationProcessorPaths>
</configuration>
<executions>
<execution>
<id>default-testCompile</id>
<configuration>
<!-- We use JUL from tests, need this for compilation -->
<compilerArgs>
<compilerArg>--add-modules</compilerArg>
<compilerArg>java.logging</compilerArg>
</compilerArgs>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>io.helidon.config</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.stream.IntStream;

import org.awaitility.core.ConditionTimeoutException;
Expand Down Expand Up @@ -276,6 +279,40 @@ void testNullRejectionPolicy() {
), "rejectionPolicy is null");
}

@Test
void testCannotChangeMaxPoolSize() {
pool = newPool(2, 2, 100, 25);
Logger log = Logger.getLogger(ThreadPool.class.getName());
assertThat(log.getHandlers().length, is(0));
assertThat(log.getUseParentHandlers(), is(true));
List<LogRecord> logRecords = new ArrayList<>();
Handler handler = new Handler() {
@Override
public void publish(LogRecord record) {
logRecords.add(record);
}

@Override
public void flush() {
}

@Override
public void close() throws SecurityException {
}
};

try {
log.addHandler(handler);
assertThat(pool.getMaximumPoolSize(), is(2));
pool.setMaximumPoolSize(4);
assertThat(pool.getMaximumPoolSize(), is(2));
assertThat(logRecords.size(), is(1));
assertThat(logRecords.get(0).getMessage(), containsString("cannot be changed"));
} finally {
log.removeHandler(handler);
}
}

@Test
void testSetRejectionHandlerRequiresRejectionPolicy() {
pool = newPool(2, 2, 100, 25);
Expand Down

0 comments on commit 048a5b1

Please sign in to comment.