Skip to content

Commit

Permalink
Added param args to injectBreakpoint
Browse files Browse the repository at this point in the history
Added logging message on breakpoint trigger
  • Loading branch information
patsonluk committed Sep 12, 2023
1 parent 6b61ebb commit 53ee6f8
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ public static boolean injectDelay() {
*
* <p>Setting the breakpoint to null would remove the breakpoint
*
* @see CommonTestInjection#injectBreakpoint(String)
* @see CommonTestInjection#injectBreakpoint(String, Object...)
* @param key could simply be the fully qualified class name or more granular like class name +
* other id (such as method name). This should batch the key used in {@link
* CommonTestInjection#injectBreakpoint(String)}
* other id (such as method name). This should batch the key used in injectBreakpoint
* @param breakpoint The Breakpoint implementation, null to remove the breakpoint
*/
public static void setBreakpoint(String key, Breakpoint breakpoint) {
Expand Down Expand Up @@ -122,11 +121,14 @@ public static void setBreakpoint(String key, Breakpoint breakpoint) {
* @param key could simply be the fully qualified class name or more granular like class name +
* other id (such as method name). This should only be set by corresponding unit test cases
* with CommonTestInjection#setBreakpoint
* @param args optional arguments list to be passed to the Breakpoint
*/
public static boolean injectBreakpoint(String key) {
public static boolean injectBreakpoint(String key, Object... args) {
Breakpoint breakpoint = breakpoints.get(key);
if (breakpoint != null) {
breakpoint.executeAndResume();
log.info("Breakpoint with key {} is triggered", key);
breakpoint.executeAndResume(args);
log.info("Breakpoint with key {} was executed and normal code execution resumes", key);
}
return true;
}
Expand All @@ -136,6 +138,6 @@ public interface Breakpoint {
* Code execution should break at where the breakpoint was injected, then it would execute this
* method and resumes the execution afterwards.
*/
void executeAndResume();
void executeAndResume(Object... args);
}
}

0 comments on commit 53ee6f8

Please sign in to comment.