Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/dromara/dynamic-tp
Browse files Browse the repository at this point in the history
  • Loading branch information
yanhom1314 committed Nov 10, 2024
2 parents 91c98d0 + 8ae462b commit c7e4130
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.dromara.dynamictp.example;

import org.dromara.dynamictp.core.spring.EnableDynamicTp;
import org.dromara.dynamictp.spring.EnableDynamicTp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

package org.dromara.dynamictp.agent;

import org.dromara.dynamictp.common.util.ReflectionUtil;
import org.dromara.dynamictp.core.support.ThreadPoolBuilder;
import org.dromara.dynamictp.extension.agent.AgentAware;
import org.dromara.dynamictp.core.support.task.runnable.DtpRunnable;
import org.dromara.dynamictp.extension.agent.AgentAware;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.util.ReflectionUtils;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand All @@ -36,7 +36,7 @@ public class AgentAwareTest {

@Test
public void testDirectOnlyOneDtpRunnable() throws InvocationTargetException, IllegalAccessException {
Method getDtpRunnableInstance = ReflectionUtils.findMethod(AgentAware.class, "getDtpRunnableInstance", Runnable.class);
Method getDtpRunnableInstance = ReflectionUtil.findMethod(AgentAware.class, "getDtpRunnableInstance", Runnable.class);
Assertions.assertNotNull(getDtpRunnableInstance);

getDtpRunnableInstance.setAccessible(true);
Expand All @@ -45,7 +45,6 @@ public void testDirectOnlyOneDtpRunnable() throws InvocationTargetException, Ill

};


MyAgentWrapper myAgentWrapper = new MyAgentWrapper(runnable, new Object());
Object result = getDtpRunnableInstance.invoke(new AgentAware(), myAgentWrapper);
Assertions.assertTrue(result == myAgentWrapper);
Expand All @@ -64,7 +63,7 @@ public void testDirectTwoRunnable() throws InvocationTargetException, IllegalAcc
DtpRunnable dtpRunnable = new DtpRunnable(runnable, runnable, "test");
MyAgentWrapperTwoRunnable myAgentWrapper = new MyAgentWrapperTwoRunnable(dtpRunnable, runnable, "test");

Method getDtpRunnableInstance = ReflectionUtils.findMethod(AgentAware.class, "getDtpRunnableInstance", Runnable.class);
Method getDtpRunnableInstance = ReflectionUtil.findMethod(AgentAware.class, "getDtpRunnableInstance", Runnable.class);
Assertions.assertNotNull(getDtpRunnableInstance);
getDtpRunnableInstance.setAccessible(true);

Expand All @@ -85,7 +84,7 @@ public void testNotDirectRunnable() throws InvocationTargetException, IllegalAcc
MyAgentWrapper myAgentWrapper = new MyAgentWrapper(dtpRunnable, new Object());

MyAgentTwoPathRunnableWrapper twoPathRunnableWrapper = new MyAgentTwoPathRunnableWrapper(myAgentWrapper, new Object());
Method getDtpRunnableInstance = ReflectionUtils.findMethod(AgentAware.class, "getDtpRunnableInstance", Runnable.class);
Method getDtpRunnableInstance = ReflectionUtil.findMethod(AgentAware.class, "getDtpRunnableInstance", Runnable.class);
Assertions.assertNotNull(getDtpRunnableInstance);
getDtpRunnableInstance.setAccessible(true);

Expand All @@ -102,7 +101,7 @@ public void testExtendRunnable() throws InvocationTargetException, IllegalAccess
MyAgentWrapper myAgentWrapper = new MyAgentWrapper(dtpRunnable, new Object());
MyAgentWrapperChild myAgentWrapperChild = new MyAgentWrapperChild(myAgentWrapper, new Object());

Method getDtpRunnableInstance = ReflectionUtils.findMethod(AgentAware.class, "getDtpRunnableInstance", Runnable.class);
Method getDtpRunnableInstance = ReflectionUtil.findMethod(AgentAware.class, "getDtpRunnableInstance", Runnable.class);
Assertions.assertNotNull(getDtpRunnableInstance);
getDtpRunnableInstance.setAccessible(true);

Expand All @@ -123,7 +122,7 @@ public void testDeepRunnable() throws InvocationTargetException, IllegalAccessEx
MyAgentTwoPathRunnableChildWrapper myAgentTwoPathRunnableChildWrapper = new MyAgentTwoPathRunnableChildWrapper(myAgentWrapperChild,
myAgentWrapper, new Object());

Method getDtpRunnableInstance = ReflectionUtils.findMethod(AgentAware.class, "getDtpRunnableInstance", Runnable.class);
Method getDtpRunnableInstance = ReflectionUtil.findMethod(AgentAware.class, "getDtpRunnableInstance", Runnable.class);
Assertions.assertNotNull(getDtpRunnableInstance);
getDtpRunnableInstance.setAccessible(true);
Object result = getDtpRunnableInstance.invoke(new AgentAware(), myAgentTwoPathRunnableChildWrapper);
Expand All @@ -137,7 +136,7 @@ public void testNestRunnable() throws InvocationTargetException, IllegalAccessEx
Runnable runnable = () -> System.out.println("test");
DtpRunnable dtpRunnable = new DtpRunnable(runnable, runnable, "test");
MyAgentNestWrapper myAgentNestWrapper = new MyAgentNestWrapper(dtpRunnable);
Method getDtpRunnableInstance = ReflectionUtils.findMethod(AgentAware.class, "getDtpRunnableInstance", Runnable.class);
Method getDtpRunnableInstance = ReflectionUtil.findMethod(AgentAware.class, "getDtpRunnableInstance", Runnable.class);
getDtpRunnableInstance.setAccessible(true);
Object result = getDtpRunnableInstance.invoke(new AgentAware(), myAgentNestWrapper);
Assertions.assertTrue(dtpRunnable == dtpRunnable);
Expand All @@ -152,7 +151,7 @@ public void testContainNestRunnable() throws InvocationTargetException, IllegalA

MyAgentContainNestWrapper myAgentContainNestWrapper = new MyAgentContainNestWrapper(myAgentNestWrapper);

Method getDtpRunnableInstance = ReflectionUtils.findMethod(AgentAware.class, "getDtpRunnableInstance", Runnable.class);
Method getDtpRunnableInstance = ReflectionUtil.findMethod(AgentAware.class, "getDtpRunnableInstance", Runnable.class);
getDtpRunnableInstance.setAccessible(true);
Object result = getDtpRunnableInstance.invoke(new AgentAware(), myAgentContainNestWrapper);
Assertions.assertTrue(dtpRunnable == dtpRunnable);
Expand Down

0 comments on commit c7e4130

Please sign in to comment.