From 98e77f8e39f2ad161fa529647545916f1738a6b6 Mon Sep 17 00:00:00 2001 From: rnmb <19276209+rnmb@users.noreply.github.com> Date: Fri, 26 May 2023 15:01:11 +0800 Subject: [PATCH] feat(infra): SyncPutQueuePolicyTest #1336 1. Add the open source agreement to the top, and leave a blank line with package Co-authored-by: rnmb<19276209+rnmb@users.noreply.github.com> --- .../support/SyncPutQueuePolicyTest.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/infra/common/src/test/java/cn/hippo4j/common/executor/support/SyncPutQueuePolicyTest.java b/infra/common/src/test/java/cn/hippo4j/common/executor/support/SyncPutQueuePolicyTest.java index fba4941d..c2f0a359 100644 --- a/infra/common/src/test/java/cn/hippo4j/common/executor/support/SyncPutQueuePolicyTest.java +++ b/infra/common/src/test/java/cn/hippo4j/common/executor/support/SyncPutQueuePolicyTest.java @@ -1,10 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package cn.hippo4j.common.executor.support; import cn.hippo4j.common.toolkit.ThreadUtil; import org.junit.Assert; import org.junit.Test; -import java.util.concurrent.*; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; import java.util.stream.IntStream; /** @@ -16,7 +35,7 @@ public class SyncPutQueuePolicyTest { * test thread pool rejected execution */ @Test - public void testRejectedExecution() throws InterruptedException { + public void testRejectedExecution() { SyncPutQueuePolicy syncPutQueuePolicy = new SyncPutQueuePolicy(); ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 2, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(1), syncPutQueuePolicy); @@ -24,7 +43,7 @@ public class SyncPutQueuePolicyTest { Assert.assertSame(syncPutQueuePolicy, threadPoolExecutor.getRejectedExecutionHandler()); IntStream.range(0, 4).forEach(s -> { - threadPoolExecutor.execute(() -> ThreadUtil.sleep(500L)); + threadPoolExecutor.execute(() -> ThreadUtil.sleep(200L)); }); threadPoolExecutor.shutdown(); while (!threadPoolExecutor.isTerminated()) {