Skip to content

Commit fdb4d73

Browse files
committed
Refactor LiveView implementation and Service object structure
1 parent deab9f2 commit fdb4d73

25 files changed

+93
-58
lines changed

boot/src/test/groovy/integration/breakpoint/GroovyBreakpointTest.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import spp.protocol.instrument.event.LiveInstrumentEvent
2525
import spp.protocol.instrument.event.LiveInstrumentEventType
2626
import spp.protocol.instrument.location.LiveSourceLocation
2727
import spp.protocol.instrument.throttle.InstrumentThrottle
28+
import spp.protocol.platform.general.Service
2829

2930
import static org.junit.jupiter.api.Assertions.assertEquals
3031
import static org.junit.jupiter.api.Assertions.assertNotNull
@@ -73,8 +74,8 @@ class GroovyBreakpointTest extends ProbeIntegrationTest {
7374
null,
7475
new LiveSourceLocation(
7576
GroovyBreakpointTest.class.name,
76-
42, //todo: breaks if bp on return
77-
"spp-test-probe"
77+
43, //todo: breaks if bp on return
78+
Service.fromName("spp-test-probe")
7879
),
7980
null,
8081
null,

boot/src/test/kotlin/integration/breakpoint/AtomicValueLiveBreakpointTest.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import spp.protocol.instrument.event.LiveInstrumentEvent
3030
import spp.protocol.instrument.event.LiveInstrumentEventType
3131
import spp.protocol.instrument.location.LiveSourceLocation
3232
import spp.protocol.instrument.variable.LiveVariable
33+
import spp.protocol.platform.general.Service
3334
import java.util.concurrent.atomic.AtomicInteger
3435
import java.util.concurrent.atomic.AtomicReference
3536

@@ -40,10 +41,15 @@ class AtomicValueLiveBreakpointTest : ProbeIntegrationTest() {
4041
val atomicMap = AtomicReference(mapOf("test" to "test"))
4142
val atomicString = AtomicReference<String>().apply { set("test") }
4243
val atomicInteger = AtomicInteger(1)
44+
addLineLabel("done") { Throwable().stackTrace[0].lineNumber }
4345
}
4446

4547
@Test
4648
fun `atomic value`(): Unit = runBlocking {
49+
setupLineLabels {
50+
atomicValue()
51+
}
52+
4753
val testContext = VertxTestContext()
4854
getLiveInstrumentSubscription(testNameAsInstrumentId).handler {
4955
val event = LiveInstrumentEvent.fromJson(it.body())
@@ -112,8 +118,8 @@ class AtomicValueLiveBreakpointTest : ProbeIntegrationTest() {
112118
id = testNameAsInstrumentId,
113119
location = LiveSourceLocation(
114120
source = AtomicValueLiveBreakpointTest::class.java.name,
115-
line = 43,
116-
service = "spp-test-probe"
121+
line = getLineNumber("done"),
122+
service = Service.fromName("spp-test-probe")
117123
),
118124
applyImmediately = true
119125
)

boot/src/test/kotlin/integration/breakpoint/BreakpointReturnValueTest.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import spp.protocol.instrument.event.LiveBreakpointHit
2828
import spp.protocol.instrument.event.LiveInstrumentEvent
2929
import spp.protocol.instrument.event.LiveInstrumentEventType
3030
import spp.protocol.instrument.location.LiveSourceLocation
31+
import spp.protocol.platform.general.Service
3132

3233
class BreakpointReturnValueTest : ProbeIntegrationTest() {
3334

@@ -63,8 +64,8 @@ class BreakpointReturnValueTest : ProbeIntegrationTest() {
6364
LiveBreakpoint(
6465
location = LiveSourceLocation(
6566
source = BreakpointReturnValueTest::class.java.name,
66-
line = 37,
67-
service = "spp-test-probe"
67+
line = 38,
68+
service = Service.fromName("spp-test-probe")
6869
),
6970
applyImmediately = true,
7071
id = breakpointId
@@ -110,8 +111,8 @@ class BreakpointReturnValueTest : ProbeIntegrationTest() {
110111
LiveBreakpoint(
111112
location = LiveSourceLocation(
112113
source = BreakpointReturnValueTest::class.java.name,
113-
line = 84,
114-
service = "spp-test-probe"
114+
line = 85,
115+
service = Service.fromName("spp-test-probe")
115116
),
116117
applyImmediately = true,
117118
id = breakpointId
@@ -157,8 +158,8 @@ class BreakpointReturnValueTest : ProbeIntegrationTest() {
157158
LiveBreakpoint(
158159
location = LiveSourceLocation(
159160
source = BreakpointReturnValueTest::class.java.name,
160-
line = 131,
161-
service = "spp-test-probe"
161+
line = 132,
162+
service = Service.fromName("spp-test-probe")
162163
),
163164
applyImmediately = true,
164165
id = breakpointId

boot/src/test/kotlin/integration/breakpoint/CollectionsTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import spp.protocol.instrument.event.LiveBreakpointHit
3030
import spp.protocol.instrument.event.LiveInstrumentEvent
3131
import spp.protocol.instrument.event.LiveInstrumentEventType
3232
import spp.protocol.instrument.location.LiveSourceLocation
33+
import spp.protocol.platform.general.Service
3334

3435
class CollectionsTest : ProbeIntegrationTest() {
3536

@@ -181,8 +182,8 @@ class CollectionsTest : ProbeIntegrationTest() {
181182
LiveBreakpoint(
182183
location = LiveSourceLocation(
183184
source = CollectionsTest::class.java.name,
184-
line = 52,
185-
service = "spp-test-probe"
185+
line = 53,
186+
service = Service.fromName("spp-test-probe")
186187
),
187188
applyImmediately = true,
188189
id = breakpointId

boot/src/test/kotlin/integration/breakpoint/InnerClassBreakpointTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import spp.protocol.instrument.event.LiveInstrumentEvent
2828
import spp.protocol.instrument.event.LiveInstrumentEventType
2929
import spp.protocol.instrument.location.LiveSourceLocation
3030
import spp.protocol.instrument.variable.LiveVariableScope
31+
import spp.protocol.platform.general.Service
3132

3233
@Suppress("UNUSED_VARIABLE")
3334
class InnerClassBreakpointTest : ProbeIntegrationTest() {
@@ -75,7 +76,7 @@ class InnerClassBreakpointTest : ProbeIntegrationTest() {
7576
location = LiveSourceLocation(
7677
InnerClass::class.java.name,
7778
getLineNumber("done"),
78-
"spp-test-probe"
79+
Service.fromName("spp-test-probe")
7980
),
8081
applyImmediately = true,
8182
id = breakpointId

boot/src/test/kotlin/integration/breakpoint/LambdaTest.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import spp.protocol.instrument.event.LiveInstrumentEventType
3131
import spp.protocol.instrument.location.LiveSourceLocation
3232
import spp.protocol.instrument.location.LocationScope
3333
import spp.protocol.instrument.throttle.InstrumentThrottle
34+
import spp.protocol.platform.general.Service
3435
import java.util.concurrent.atomic.AtomicInteger
3536

3637
@Execution(ExecutionMode.SAME_THREAD)
@@ -74,9 +75,9 @@ class LambdaTest : ProbeIntegrationTest() {
7475
LiveBreakpoint(
7576
location = LiveSourceLocation(
7677
source = LambdaTest::class.java.name,
77-
line = 45,
78+
line = 46,
7879
scope = LocationScope.LAMBDA,
79-
service = "spp-test-probe"
80+
service = Service.fromName("spp-test-probe")
8081
),
8182
applyImmediately = true,
8283
id = instrumentId
@@ -118,9 +119,9 @@ class LambdaTest : ProbeIntegrationTest() {
118119
LiveBreakpoint(
119120
location = LiveSourceLocation(
120121
source = LambdaTest::class.java.name,
121-
line = 95,
122+
line = 96,
122123
scope = LocationScope.LINE,
123-
service = "spp-test-probe"
124+
service = Service.fromName("spp-test-probe")
124125
),
125126
applyImmediately = true,
126127
id = instrumentId
@@ -162,9 +163,9 @@ class LambdaTest : ProbeIntegrationTest() {
162163
LiveBreakpoint(
163164
location = LiveSourceLocation(
164165
source = LambdaTest::class.java.name,
165-
line = 139,
166+
line = 140,
166167
scope = LocationScope.LAMBDA,
167-
service = "spp-test-probe"
168+
service = Service.fromName("spp-test-probe")
168169
),
169170
applyImmediately = true,
170171
id = instrumentId
@@ -209,9 +210,9 @@ class LambdaTest : ProbeIntegrationTest() {
209210
LiveBreakpoint(
210211
location = LiveSourceLocation(
211212
source = LambdaTest::class.java.name,
212-
line = 183,
213+
line = 184,
213214
scope = LocationScope.BOTH,
214-
service = "spp-test-probe"
215+
service = Service.fromName("spp-test-probe")
215216
),
216217
throttle = InstrumentThrottle.NONE,
217218
applyImmediately = true,

boot/src/test/kotlin/integration/breakpoint/LineNumberTest.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,23 @@ import spp.protocol.instrument.event.LiveBreakpointHit
2828
import spp.protocol.instrument.event.LiveInstrumentEvent
2929
import spp.protocol.instrument.event.LiveInstrumentEventType
3030
import spp.protocol.instrument.location.LiveSourceLocation
31+
import spp.protocol.platform.general.Service
3132

3233
class LineNumberTest : ProbeIntegrationTest() {
3334

3435
@Suppress("UNUSED_VARIABLE")
3536
private fun doTest() {
3637
val a = 1
3738
val b = "test"
39+
addLineLabel("done") { Throwable().stackTrace[0].lineNumber }
3840
}
3941

4042
@Test
4143
fun testLineNumber(): Unit = runBlocking {
44+
setupLineLabels {
45+
doTest()
46+
}
47+
4248
val breakpointId = testNameAsUniqueInstrumentId
4349
val testContext = VertxTestContext()
4450
getLiveInstrumentSubscription(breakpointId).handler {
@@ -49,8 +55,8 @@ class LineNumberTest : ProbeIntegrationTest() {
4955
val vars = item.stackTrace.first().variables
5056
assertEquals(3, vars.size)
5157

52-
assertEquals(36, vars.first { it.name == "a" }.lineNumber)
53-
assertEquals(37, vars.first { it.name == "b" }.lineNumber)
58+
assertEquals(37, vars.first { it.name == "a" }.lineNumber)
59+
assertEquals(38, vars.first { it.name == "b" }.lineNumber)
5460

5561
testContext.completeNow()
5662
}
@@ -62,8 +68,8 @@ class LineNumberTest : ProbeIntegrationTest() {
6268
LiveBreakpoint(
6369
location = LiveSourceLocation(
6470
source = LineNumberTest::class.java.name,
65-
line = 38,
66-
service = "spp-test-probe"
71+
line = getLineNumber("done"),
72+
service = Service.fromName("spp-test-probe")
6773
),
6874
applyImmediately = true,
6975
id = breakpointId

boot/src/test/kotlin/integration/breakpoint/MaxCollectionLengthControlTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import spp.protocol.instrument.event.LiveInstrumentEventType
3131
import spp.protocol.instrument.location.LiveSourceLocation
3232
import spp.protocol.instrument.variable.LiveVariableControl
3333
import spp.protocol.instrument.variable.LiveVariableControlBase
34+
import spp.protocol.platform.general.Service
3435

3536
class MaxCollectionLengthControlTest : ProbeIntegrationTest() {
3637

@@ -135,8 +136,8 @@ class MaxCollectionLengthControlTest : ProbeIntegrationTest() {
135136
),
136137
location = LiveSourceLocation(
137138
source = MaxCollectionLengthControlTest::class.java.name,
138-
line = 43,
139-
service = "spp-test-probe"
139+
line = 44,
140+
service = Service.fromName("spp-test-probe")
140141
),
141142
applyImmediately = true,
142143
id = instrumentId

boot/src/test/kotlin/integration/breakpoint/MaxObjectDepthControlTest.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import spp.protocol.instrument.event.LiveInstrumentEventType
3232
import spp.protocol.instrument.location.LiveSourceLocation
3333
import spp.protocol.instrument.variable.LiveVariableControl
3434
import spp.protocol.instrument.variable.LiveVariableControlBase
35+
import spp.protocol.platform.general.Service
3536

3637
class MaxObjectDepthControlTest : ProbeIntegrationTest() {
3738

@@ -77,8 +78,8 @@ class MaxObjectDepthControlTest : ProbeIntegrationTest() {
7778
),
7879
location = LiveSourceLocation(
7980
source = MaxObjectDepthControlTest::class.java.name,
80-
line = 42,
81-
service = "spp-test-probe"
81+
line = 43,
82+
service = Service.fromName("spp-test-probe")
8283
),
8384
applyImmediately = true,
8485
id = instrumentId
@@ -142,8 +143,8 @@ class MaxObjectDepthControlTest : ProbeIntegrationTest() {
142143
),
143144
location = LiveSourceLocation(
144145
source = MaxObjectDepthControlTest::class.java.name,
145-
line = 42,
146-
service = "spp-test-probe"
146+
line = 43,
147+
service = Service.fromName("spp-test-probe")
147148
),
148149
applyImmediately = true,
149150
id = instrumentId

boot/src/test/kotlin/integration/breakpoint/MaxObjectSizeControlTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import spp.protocol.instrument.event.LiveInstrumentEventType
3131
import spp.protocol.instrument.location.LiveSourceLocation
3232
import spp.protocol.instrument.variable.LiveVariableControl
3333
import spp.protocol.instrument.variable.LiveVariableControlBase
34+
import spp.protocol.platform.general.Service
3435

3536
class MaxObjectSizeControlTest : ProbeIntegrationTest() {
3637

@@ -104,8 +105,8 @@ class MaxObjectSizeControlTest : ProbeIntegrationTest() {
104105
),
105106
location = LiveSourceLocation(
106107
source = MaxObjectSizeControlTest::class.java.name,
107-
line = 41,
108-
service = "spp-test-probe"
108+
line = 42,
109+
service = Service.fromName("spp-test-probe")
109110
),
110111
applyImmediately = true,
111112
id = instrumentId

0 commit comments

Comments
 (0)