@@ -39,10 +39,11 @@ class MaxObjectDepthControlTest : ProbeIntegrationTest() {
3939 private fun doTest () {
4040 val deepObject1 = DeepObject1 ()
4141 val deepObject11 = DeepObject1 ()
42+ val deeperObject1 = DeeperObject1 ()
4243 }
4344
4445 @Test
45- fun testVariableControl () = runBlocking {
46+ fun `max depth variable control` (): Unit = runBlocking {
4647 val testContext = VertxTestContext ()
4748 val consumer = vertx.eventBus().localConsumer<JsonObject >(toLiveInstrumentSubscriberAddress(" system" ))
4849 consumer.handler {
@@ -51,7 +52,57 @@ class MaxObjectDepthControlTest : ProbeIntegrationTest() {
5152 if (event.eventType == LiveInstrumentEventType .BREAKPOINT_HIT ) {
5253 val item = LiveBreakpointHit (JsonObject (event.data))
5354 val vars = item.stackTrace.first().variables
54- assertEquals(3 , vars.size)
55+ assertEquals(4 , vars.size)
56+
57+ // deeperObject1 is full depth
58+ var deeperObject1 = (vars.first { it.name == " deeperObject1" }.value as JsonArray )
59+ .first() as JsonObject
60+ deeperObject1 = deeperObject1.getJsonArray(" value" ).first() as JsonObject
61+ deeperObject1 = deeperObject1.getJsonArray(" value" ).first() as JsonObject
62+ deeperObject1 = deeperObject1.getJsonArray(" value" ).first() as JsonObject
63+ deeperObject1 = deeperObject1.getJsonArray(" value" ).first() as JsonObject
64+ deeperObject1 = deeperObject1.getJsonArray(" value" ).first() as JsonObject
65+ deeperObject1 = deeperObject1.getJsonArray(" value" ).first() as JsonObject
66+ assertEquals(0 , deeperObject1.getJsonArray(" value" ).size())
67+
68+ consumer.unregister()
69+ testContext.completeNow()
70+ }
71+ }
72+ }.completionHandler().await()
73+
74+ assertNotNull(
75+ instrumentService.addLiveInstrument(
76+ LiveBreakpoint (
77+ variableControl = LiveVariableControl (
78+ maxObjectDepth = 8
79+ ),
80+ location = LiveSourceLocation (MaxObjectDepthControlTest ::class .qualifiedName!! , 43 ),
81+ applyImmediately = true
82+ )
83+ ).await()
84+ )
85+
86+ // trigger breakpoint
87+ doTest()
88+
89+ errorOnTimeout(testContext)
90+
91+ // clean up
92+ consumer.unregister()
93+ }
94+
95+ @Test
96+ fun `max depth variable control by name` (): Unit = runBlocking {
97+ val testContext = VertxTestContext ()
98+ val consumer = vertx.eventBus().localConsumer<JsonObject >(toLiveInstrumentSubscriberAddress(" system" ))
99+ consumer.handler {
100+ testContext.verify {
101+ val event = LiveInstrumentEvent (it.body())
102+ if (event.eventType == LiveInstrumentEventType .BREAKPOINT_HIT ) {
103+ val item = LiveBreakpointHit (JsonObject (event.data))
104+ val vars = item.stackTrace.first().variables
105+ assertEquals(4 , vars.size)
55106
56107 // deepObject1 is not full depth
57108 var deepObject1 = (vars.first { it.name == " deepObject1" }.value as JsonArray )
@@ -90,7 +141,7 @@ class MaxObjectDepthControlTest : ProbeIntegrationTest() {
90141 )
91142 )
92143 ),
93- location = LiveSourceLocation (MaxObjectDepthControlTest ::class .qualifiedName!! , 41 ),
144+ location = LiveSourceLocation (MaxObjectDepthControlTest ::class .qualifiedName!! , 43 ),
94145 applyImmediately = true
95146 )
96147 ).await()
@@ -127,4 +178,35 @@ class MaxObjectDepthControlTest : ProbeIntegrationTest() {
127178 }
128179 }
129180 }
181+
182+ class DeeperObject1 {
183+ val deeperObject2 = DeeperObject2 ()
184+
185+ class DeeperObject2 {
186+ val deeperObject3 = DeeperObject3 ()
187+
188+ class DeeperObject3 {
189+ val deeperObject4 = DeeperObject4 ()
190+
191+ class DeeperObject4 {
192+ val deeperObject5 = DeeperObject5 ()
193+
194+ class DeeperObject5 {
195+ val deeperObject6 = DeeperObject6 ()
196+
197+ class DeeperObject6 {
198+ val deeperObject7 = DeeperObject7 ()
199+
200+ class DeeperObject7 {
201+ val deeperObject8 = DeeperObject8 ()
202+
203+ class DeeperObject8 {
204+ }
205+ }
206+ }
207+ }
208+ }
209+ }
210+ }
211+ }
130212}
0 commit comments