ContainerResourceMonitoringTracer { public static void initEventHandler(TriConsumer<Long, Header, Object> eventHandler) { ContainerResourceMonitoringTracer.eventHandler = eventHandler; } protected  ContainerResourceMonitoringTracer(); static void setup(Header baseHeader, Instrumentation instrumentation, AsyncEventProcessor eventProcessor); static void initEventHandler(TriConsumer<Long, Header, Object> eventHandler);  }
@Test @AgentAttachmentRule.Enforce public void ContainerResourceMonitoringModule_should_attach_to_isProcessTreeOverLimit() throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException { assertThat(ByteBuddyAgent.install(), instanceOf(Instrumentation.class)); final Header[] header = new Header[1]; final Object[] event = new Object[1]; ContainerResourceMonitoringTracer.initEventHandler((t, h, o) -> { header[0] = h; event[0] = o; }); ClassFileTransformer classFileTransformer = new ContainerResourceMonitoringTracer.MemorySizeTracer().installOnByteBuddyAgent(); try { ContainerExecutor exec = mock(ContainerExecutor.class); AsyncDispatcher dispatcher = mock(AsyncDispatcher.class); Context ctx = mock(Context.class); Class<?> clazz = classLoader.loadClass(ContainersMonitorImpl.class.getName()); Method m = clazz.getDeclaredMethod("isProcessTreeOverLimit", String.class, long.class, long.class, long.class); Object inFormat = clazz.getConstructor(ContainerExecutor.class, AsyncDispatcher.class, Context.class).newInstance(exec, dispatcher, ctx); m.setAccessible(true); m.invoke(inFormat, "container_e600_1516870220739_0069_01_000032", 2000, 1000, 3000); assertNotNull(header[0]); assertNotNull(event[0]); } finally { ByteBuddyAgent.getInstrumentation().removeTransformer(classFileTransformer); } }