/** * Create an {@link AssertionError} with {@link Latency}, thread name and message. * * @param latency The latency for this exception. * @param message The message associated with this exception. */ protected ReactiveAuditException(Latency latency, String message) { super(message); this.threadName = Thread.currentThread().getName(); this.latency = latency; updateStackTraceElements(); }
private static Level convLevelLatency(String level) { if (Latency.HIGH.name().equals(level)) { return Level.SEVERE; } if (Latency.MEDIUM.name().equals(level)) { return Level.WARNING; } if (Latency.LOW.name().equals(level)) { return Level.INFO; } return Level.parse(level); } public static String convLevelString(Level level)
public Transaction latencyFile(String level) { final Latency latency = (level.length()) == 0 ? null : Latency.valueOf(level.toUpperCase()); add(new Runnable() { @Override public void run() { latencyFile = latency; } }); return this; }
baseLatency = latencyCPU; if (baseLatency == null) return; if (e.getLatency().ordinal() < baseLatency.ordinal()) return; if (!history.isAlreadyLogged(e.getStackTrace())) logger.log(level, e.getMessage(), e);
@Test(expected = ReactiveAuditException.class) public void readLine() { if (System.console() != null) System.console().readLine(); else throw new FileReactiveAuditException(Latency.LOW, "No console"); }
@Test @TolerateLatency("Direct call") public void directCall() { assertTrue(ReactiveAudit.config.isSuppressAudit()); }
@Override protected ReactiveAuditException newException(Latency latency, JoinPoint thisJoinPoint) { return new CPUReactiveAuditException(latency, thisJoinPoint.getSignature().toString()); } }
@Before("execution(@com.octo.reactive.audit.lib.WithLatency * *(..) )") public void with(JoinPoint thisJoinPoint) throws ReactiveAuditException { WithLatency withLatency = ((MethodSignature) thisJoinPoint.getSignature()).getMethod().getAnnotation( WithLatency.class); latency(withLatency.value(), thisJoinPoint); } }
public static NetworkReactiveAuditException newNetwork(Latency latency, JoinPoint thisJoinPoint, CharSequence msg) { return new NetworkReactiveAuditException(latency, (msg == null) ? thisJoinPoint.getSignature().toString() : thisJoinPoint.getSignature().toString() + " " + msg); }
@Test(expected = ReactiveAuditException.class) public void readPassword() { if (System.console() != null) System.console().readPassword(); else throw new FileReactiveAuditException(Latency.LOW, "No console"); }
/** * Create an {@link AssertionError} with {@link Latency}, thread name and message. * * @param latency The latency for this exception. * @param message The message associated with this exception. */ protected ReactiveAuditException(Latency latency, String message) { super(message); this.threadName = Thread.currentThread().getName(); this.latency = latency; updateStackTraceElements(); }
@TolerateLatency @Override public void run() { assertTrue(ReactiveAudit.config.isSuppressAudit()); assertEquals(2, ReactiveAudit.config.getSuppress()); } };
public Transaction latencyCPU(String level) { final Latency latency = (level.length()) == 0 ? null : Latency.valueOf(level.toUpperCase()); add(new Runnable() { @Override public void run() { latencyCPU = latency; } }); return this; }
@Test(expected = ReactiveAuditException.class) public void readPassword_String() { if (System.console() != null) System.console().readPassword("", ""); else throw new FileReactiveAuditException(Latency.LOW, "No console"); }
/** * Create an {@link AssertionError} with {@link Latency}, thread name and formatted message. * * @param latency The latency for this exception. * @param format The format message associated with this exception. * @param args The arguments to generate the message with the format. */ protected ReactiveAuditException(Latency latency, String format, Object... args) { super(String.format(format, args)); this.threadName = Thread.currentThread().getName(); updateStackTraceElements(); }
@Test @TolerateLatency("Indirect call") public void indirectCall() { Runnable r = new Runnable() { @Override public void run() { assertTrue(ReactiveAudit.config.isSuppressAudit()); assertEquals(1, ReactiveAudit.config.getSuppress()); } }; r.run(); assertTrue(ReactiveAudit.config.isSuppressAudit()); assertEquals(1, ReactiveAudit.config.getSuppress()); }
public Transaction latencyNetwork(String level) { final Latency latency = (level.length()) == 0 ? null : Latency.valueOf(level.toUpperCase()); add(new Runnable() { @Override public void run() { latencyNetwork = latency; } }); return this; }
@Test(expected = ReactiveAuditException.class) public void readLine_String() { if (System.console() != null) System.console().readLine("", ""); else throw new FileReactiveAuditException(Latency.LOW, "No console"); }
/** * Create an {@link AssertionError} with {@link Latency}, thread name and formatted message. * * @param latency The latency for this exception. * @param format The format message associated with this exception. * @param args The arguments to generate the message with the format. */ protected ReactiveAuditException(Latency latency, String format, Object... args) { super(String.format(format, args)); this.threadName = Thread.currentThread().getName(); updateStackTraceElements(); }
public static FileReactiveAuditException newFile(Latency latency, JoinPoint thisJoinPoint, CharSequence msg) { return new FileReactiveAuditException(latency, (msg == null) ? thisJoinPoint.getSignature().toString() : thisJoinPoint.getSignature().toString() + " " + msg); } }