@@ -39,10 +39,11 @@ class MaxObjectDepthControlTest : ProbeIntegrationTest() {
39
39
private fun doTest () {
40
40
val deepObject1 = DeepObject1 ()
41
41
val deepObject11 = DeepObject1 ()
42
+ val deeperObject1 = DeeperObject1 ()
42
43
}
43
44
44
45
@Test
45
- fun testVariableControl () = runBlocking {
46
+ fun `max depth variable control` (): Unit = runBlocking {
46
47
val testContext = VertxTestContext ()
47
48
val consumer = vertx.eventBus().localConsumer<JsonObject >(toLiveInstrumentSubscriberAddress(" system" ))
48
49
consumer.handler {
@@ -51,7 +52,57 @@ class MaxObjectDepthControlTest : ProbeIntegrationTest() {
51
52
if (event.eventType == LiveInstrumentEventType .BREAKPOINT_HIT ) {
52
53
val item = LiveBreakpointHit (JsonObject (event.data))
53
54
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)
55
106
56
107
// deepObject1 is not full depth
57
108
var deepObject1 = (vars.first { it.name == " deepObject1" }.value as JsonArray )
@@ -90,7 +141,7 @@ class MaxObjectDepthControlTest : ProbeIntegrationTest() {
90
141
)
91
142
)
92
143
),
93
- location = LiveSourceLocation (MaxObjectDepthControlTest ::class .qualifiedName!! , 41 ),
144
+ location = LiveSourceLocation (MaxObjectDepthControlTest ::class .qualifiedName!! , 43 ),
94
145
applyImmediately = true
95
146
)
96
147
).await()
@@ -127,4 +178,35 @@ class MaxObjectDepthControlTest : ProbeIntegrationTest() {
127
178
}
128
179
}
129
180
}
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
+ }
130
212
}
0 commit comments