Skip to content

Commit d46509a

Browse files
committed
fix test case
1 parent 59f41eb commit d46509a

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

test/test-core/src/test/java/org/dromara/dynamictp/test/core/thread/OrderedDtpExecutorTest.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
package org.dromara.dynamictp.test.core.thread;
1919

2020
import com.alibaba.ttl.TransmittableThreadLocal;
21-
import org.dromara.dynamictp.core.support.task.Ordered;
22-
import org.dromara.dynamictp.core.support.task.callable.OrderedCallable;
23-
import org.dromara.dynamictp.core.executor.OrderedDtpExecutor;
2421
import com.google.common.collect.Lists;
2522
import lombok.AllArgsConstructor;
2623
import lombok.Data;
2724
import lombok.extern.slf4j.Slf4j;
25+
import org.dromara.dynamictp.core.DtpRegistry;
26+
import org.dromara.dynamictp.core.executor.OrderedDtpExecutor;
27+
import org.dromara.dynamictp.core.support.task.Ordered;
28+
import org.dromara.dynamictp.core.support.task.callable.OrderedCallable;
2829
import org.dromara.dynamictp.spring.annotation.EnableDynamicTp;
2930
import org.dromara.dynamictp.spring.support.YamlPropertySourceFactory;
3031
import org.junit.jupiter.api.Test;
@@ -35,30 +36,30 @@
3536
import org.springframework.context.annotation.PropertySource;
3637
import org.springframework.test.context.junit.jupiter.SpringExtension;
3738

38-
import javax.annotation.Resource;
3939
import java.util.ArrayList;
4040
import java.util.List;
4141
import java.util.concurrent.Future;
4242
import java.util.concurrent.ThreadLocalRandom;
4343
import java.util.concurrent.TimeUnit;
4444

4545
@Slf4j
46-
@PropertySource(value = "classpath:/dynamic-tp-nacos-demo-dtp-dev.yml", factory = YamlPropertySourceFactory.class)
4746
@SpringBootTest(classes = OrderedDtpExecutorTest.class)
4847
@ExtendWith(SpringExtension.class)
4948
@EnableDynamicTp
5049
@EnableAutoConfiguration
50+
@PropertySource(value = "classpath:/dynamic-tp-nacos-demo-dtp-dev.yml", factory = YamlPropertySourceFactory.class)
5151
class OrderedDtpExecutorTest {
5252

53-
@Resource
54-
private OrderedDtpExecutor orderedDtpExecutor;
55-
5653
private final TransmittableThreadLocal<String> threadLocal = new TransmittableThreadLocal<>();
5754

5855
private final List<String> TABLES = Lists.newArrayList("table1", "table2", "table3");
5956

6057
@Test
6158
void orderedExecute() throws InterruptedException {
59+
OrderedDtpExecutor orderedDtpExecutor = (OrderedDtpExecutor) DtpRegistry.getExecutor("orderedDtpExecutor");
60+
if (orderedDtpExecutor == null) {
61+
return;
62+
}
6263
for (int i = 0; i < 1000; i++) {
6364
if (i == 500) {
6465
TimeUnit.MILLISECONDS.sleep(2000L);
@@ -71,6 +72,10 @@ void orderedExecute() throws InterruptedException {
7172

7273
@Test
7374
void orderedSubmit() {
75+
OrderedDtpExecutor orderedDtpExecutor = (OrderedDtpExecutor) DtpRegistry.getExecutor("orderedDtpExecutor");
76+
if (orderedDtpExecutor == null) {
77+
return;
78+
}
7479
List<Future<?>> futures = new ArrayList<>();
7580
for (int i = 0; i < 100; i++) {
7681
threadLocal.set("ttl" + i);

0 commit comments

Comments
 (0)