17
17
18
18
package org .dromara .dynamictp .agent ;
19
19
20
+ import org .dromara .dynamictp .common .util .ReflectionUtil ;
20
21
import org .dromara .dynamictp .core .support .ThreadPoolBuilder ;
21
- import org .dromara .dynamictp .extension .agent .AgentAware ;
22
22
import org .dromara .dynamictp .core .support .task .runnable .DtpRunnable ;
23
+ import org .dromara .dynamictp .extension .agent .AgentAware ;
23
24
import org .junit .Assert ;
24
25
import org .junit .Test ;
25
26
import org .junit .jupiter .api .Assertions ;
26
- import org .springframework .util .ReflectionUtils ;
27
27
28
28
import java .lang .reflect .InvocationTargetException ;
29
29
import java .lang .reflect .Method ;
@@ -36,7 +36,7 @@ public class AgentAwareTest {
36
36
37
37
@ Test
38
38
public void testDirectOnlyOneDtpRunnable () throws InvocationTargetException , IllegalAccessException {
39
- Method getDtpRunnableInstance = ReflectionUtils .findMethod (AgentAware .class , "getDtpRunnableInstance" , Runnable .class );
39
+ Method getDtpRunnableInstance = ReflectionUtil .findMethod (AgentAware .class , "getDtpRunnableInstance" , Runnable .class );
40
40
Assertions .assertNotNull (getDtpRunnableInstance );
41
41
42
42
getDtpRunnableInstance .setAccessible (true );
@@ -45,7 +45,6 @@ public void testDirectOnlyOneDtpRunnable() throws InvocationTargetException, Ill
45
45
46
46
};
47
47
48
-
49
48
MyAgentWrapper myAgentWrapper = new MyAgentWrapper (runnable , new Object ());
50
49
Object result = getDtpRunnableInstance .invoke (new AgentAware (), myAgentWrapper );
51
50
Assertions .assertTrue (result == myAgentWrapper );
@@ -64,7 +63,7 @@ public void testDirectTwoRunnable() throws InvocationTargetException, IllegalAcc
64
63
DtpRunnable dtpRunnable = new DtpRunnable (runnable , runnable , "test" );
65
64
MyAgentWrapperTwoRunnable myAgentWrapper = new MyAgentWrapperTwoRunnable (dtpRunnable , runnable , "test" );
66
65
67
- Method getDtpRunnableInstance = ReflectionUtils .findMethod (AgentAware .class , "getDtpRunnableInstance" , Runnable .class );
66
+ Method getDtpRunnableInstance = ReflectionUtil .findMethod (AgentAware .class , "getDtpRunnableInstance" , Runnable .class );
68
67
Assertions .assertNotNull (getDtpRunnableInstance );
69
68
getDtpRunnableInstance .setAccessible (true );
70
69
@@ -85,7 +84,7 @@ public void testNotDirectRunnable() throws InvocationTargetException, IllegalAcc
85
84
MyAgentWrapper myAgentWrapper = new MyAgentWrapper (dtpRunnable , new Object ());
86
85
87
86
MyAgentTwoPathRunnableWrapper twoPathRunnableWrapper = new MyAgentTwoPathRunnableWrapper (myAgentWrapper , new Object ());
88
- Method getDtpRunnableInstance = ReflectionUtils .findMethod (AgentAware .class , "getDtpRunnableInstance" , Runnable .class );
87
+ Method getDtpRunnableInstance = ReflectionUtil .findMethod (AgentAware .class , "getDtpRunnableInstance" , Runnable .class );
89
88
Assertions .assertNotNull (getDtpRunnableInstance );
90
89
getDtpRunnableInstance .setAccessible (true );
91
90
@@ -102,7 +101,7 @@ public void testExtendRunnable() throws InvocationTargetException, IllegalAccess
102
101
MyAgentWrapper myAgentWrapper = new MyAgentWrapper (dtpRunnable , new Object ());
103
102
MyAgentWrapperChild myAgentWrapperChild = new MyAgentWrapperChild (myAgentWrapper , new Object ());
104
103
105
- Method getDtpRunnableInstance = ReflectionUtils .findMethod (AgentAware .class , "getDtpRunnableInstance" , Runnable .class );
104
+ Method getDtpRunnableInstance = ReflectionUtil .findMethod (AgentAware .class , "getDtpRunnableInstance" , Runnable .class );
106
105
Assertions .assertNotNull (getDtpRunnableInstance );
107
106
getDtpRunnableInstance .setAccessible (true );
108
107
@@ -123,7 +122,7 @@ public void testDeepRunnable() throws InvocationTargetException, IllegalAccessEx
123
122
MyAgentTwoPathRunnableChildWrapper myAgentTwoPathRunnableChildWrapper = new MyAgentTwoPathRunnableChildWrapper (myAgentWrapperChild ,
124
123
myAgentWrapper , new Object ());
125
124
126
- Method getDtpRunnableInstance = ReflectionUtils .findMethod (AgentAware .class , "getDtpRunnableInstance" , Runnable .class );
125
+ Method getDtpRunnableInstance = ReflectionUtil .findMethod (AgentAware .class , "getDtpRunnableInstance" , Runnable .class );
127
126
Assertions .assertNotNull (getDtpRunnableInstance );
128
127
getDtpRunnableInstance .setAccessible (true );
129
128
Object result = getDtpRunnableInstance .invoke (new AgentAware (), myAgentTwoPathRunnableChildWrapper );
@@ -137,7 +136,7 @@ public void testNestRunnable() throws InvocationTargetException, IllegalAccessEx
137
136
Runnable runnable = () -> System .out .println ("test" );
138
137
DtpRunnable dtpRunnable = new DtpRunnable (runnable , runnable , "test" );
139
138
MyAgentNestWrapper myAgentNestWrapper = new MyAgentNestWrapper (dtpRunnable );
140
- Method getDtpRunnableInstance = ReflectionUtils .findMethod (AgentAware .class , "getDtpRunnableInstance" , Runnable .class );
139
+ Method getDtpRunnableInstance = ReflectionUtil .findMethod (AgentAware .class , "getDtpRunnableInstance" , Runnable .class );
141
140
getDtpRunnableInstance .setAccessible (true );
142
141
Object result = getDtpRunnableInstance .invoke (new AgentAware (), myAgentNestWrapper );
143
142
Assertions .assertTrue (dtpRunnable == dtpRunnable );
@@ -152,7 +151,7 @@ public void testContainNestRunnable() throws InvocationTargetException, IllegalA
152
151
153
152
MyAgentContainNestWrapper myAgentContainNestWrapper = new MyAgentContainNestWrapper (myAgentNestWrapper );
154
153
155
- Method getDtpRunnableInstance = ReflectionUtils .findMethod (AgentAware .class , "getDtpRunnableInstance" , Runnable .class );
154
+ Method getDtpRunnableInstance = ReflectionUtil .findMethod (AgentAware .class , "getDtpRunnableInstance" , Runnable .class );
156
155
getDtpRunnableInstance .setAccessible (true );
157
156
Object result = getDtpRunnableInstance .invoke (new AgentAware (), myAgentContainNestWrapper );
158
157
Assertions .assertTrue (dtpRunnable == dtpRunnable );
0 commit comments