-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/origin/main' into feat-merge-dy…
…namic-record
- Loading branch information
Showing
11 changed files
with
132 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
arex-agent-bootstrap/src/main/java/io/arex/agent/bootstrap/DecorateControl.java
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
arex-agent-bootstrap/src/test/java/io/arex/agent/bootstrap/InstrumentationHolderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.arex.agent.bootstrap; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import java.lang.instrument.Instrumentation; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
/** | ||
* @since 2024/1/15 | ||
*/ | ||
@ExtendWith(MockitoExtension.class) | ||
class InstrumentationHolderTest { | ||
|
||
@Mock | ||
Instrumentation instrumentation; | ||
@Mock | ||
ClassLoader agentClassLoader; | ||
|
||
@Test | ||
void getInstrumentation() { | ||
InstrumentationHolder.setInstrumentation(instrumentation); | ||
assertEquals(instrumentation, InstrumentationHolder.getInstrumentation()); | ||
} | ||
|
||
@Test | ||
void getAgentClassLoader() { | ||
InstrumentationHolder.setAgentClassLoader(agentClassLoader); | ||
assertEquals(agentClassLoader, InstrumentationHolder.getAgentClassLoader()); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
arex-agent-bootstrap/src/test/java/io/arex/agent/bootstrap/TraceContextManagerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.arex.agent.bootstrap; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* @since 2024/1/15 | ||
*/ | ||
class TraceContextManagerTest { | ||
|
||
@Test | ||
void test() { | ||
TraceContextManager.init("test-ip"); | ||
String get1 = TraceContextManager.get(true); | ||
String get2 = TraceContextManager.get(); | ||
assertEquals(get1, get2); | ||
|
||
TraceContextManager.set(get2 + "-1"); | ||
String get3 = TraceContextManager.get(); | ||
assertEquals(get2 + "-1", get3); | ||
|
||
String get4 = TraceContextManager.remove(); | ||
assertEquals(get3, get4); | ||
|
||
String get5 = TraceContextManager.generateId(); | ||
assertTrue(get5.startsWith("AREX-test-ip-")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...nstrumentation-foundation/src/test/java/io/arex/foundation/services/TimerServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.arex.foundation.services; | ||
|
||
import java.util.concurrent.ScheduledFuture; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* @since 2024/1/15 | ||
*/ | ||
class TimerServiceTest { | ||
|
||
@Test | ||
void schedule() { | ||
ScheduledFuture<?> scheduleTest = TimerService.schedule(() -> System.out.println("schedule test"), 0, | ||
TimeUnit.MILLISECONDS); | ||
Assertions.assertNotNull(scheduleTest); | ||
scheduleTest.cancel(true); | ||
} | ||
|
||
@Test | ||
void scheduleAtFixedRate() throws InterruptedException { | ||
AtomicInteger runs = new AtomicInteger(); | ||
ScheduledFuture<?> scheduleTest = TimerService.scheduleAtFixedRate(() -> { | ||
if (runs.get() >= 1) { | ||
throw new RuntimeException("scheduleAtFixedRate test stop"); | ||
} | ||
System.out.println("scheduleAtFixedRate test"); | ||
runs.getAndIncrement(); | ||
}, 0, | ||
50, TimeUnit.MILLISECONDS); | ||
Assertions.assertNotNull(scheduleTest); | ||
scheduleTest.cancel(true); | ||
TimeUnit.MILLISECONDS.sleep(150); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../inst/dynamic/common/DynamiConstants.java → ...inst/dynamic/common/DynamicConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters