-
Notifications
You must be signed in to change notification settings - Fork 333
Expand file tree
/
Copy pathDebuggerConfigBridgeTest.groovy
More file actions
117 lines (92 loc) · 3.25 KB
/
DebuggerConfigBridgeTest.groovy
File metadata and controls
117 lines (92 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package datadog.trace.api.debugger
import spock.lang.Specification
class DebuggerConfigBridgeTest extends Specification {
def cleanup() {
DebuggerConfigBridge.reset()
}
def "test bridge handles calls"() {
when:
def updater = new MockDebuggerConfigUpdater()
then:
!DebuggerConfigBridge.isDynamicInstrumentationEnabled()
!DebuggerConfigBridge.isExceptionReplayEnabled()
DebuggerConfigBridge.isCodeOriginEnabled()
!DebuggerConfigBridge.isDistributedDebuggerEnabled()
when:
DebuggerConfigBridge.setUpdater(updater)
DebuggerConfigBridge.updateConfig(new DebuggerConfigUpdate(null, true, null, null))
then:
updater.calls == 1
DebuggerConfigBridge.isExceptionReplayEnabled()
when:
DebuggerConfigBridge.updateConfig(new DebuggerConfigUpdate(true, null, null, null))
then:
updater.calls == 2
DebuggerConfigBridge.isExceptionReplayEnabled()
DebuggerConfigBridge.isDynamicInstrumentationEnabled()
when:
DebuggerConfigBridge.updateConfig(new DebuggerConfigUpdate(false, false, false, false))
then:
updater.calls == 3
!DebuggerConfigBridge.isDynamicInstrumentationEnabled()
!DebuggerConfigBridge.isExceptionReplayEnabled()
!DebuggerConfigBridge.isCodeOriginEnabled()
!DebuggerConfigBridge.isDistributedDebuggerEnabled()
}
def "test bridge ignores empty updates"() {
def updater = new MockDebuggerConfigUpdater()
DebuggerConfigBridge.setUpdater(updater)
when:
DebuggerConfigBridge.updateConfig(new DebuggerConfigUpdate())
then:
updater.calls == 0
}
def "test bridge handles deferred updates"() {
def updater = new MockDebuggerConfigUpdater()
when:
DebuggerConfigBridge.updateConfig(new DebuggerConfigUpdate(null, false, null, null))
DebuggerConfigBridge.updateConfig(new DebuggerConfigUpdate(true, true, true, true))
DebuggerConfigBridge.updateConfig(new DebuggerConfigUpdate(null, false, null, null))
then:
updater.calls == 0
when:
DebuggerConfigBridge.setUpdater(updater)
then:
updater.calls == 1
DebuggerConfigBridge.isDynamicInstrumentationEnabled()
!DebuggerConfigBridge.isExceptionReplayEnabled()
DebuggerConfigBridge.isCodeOriginEnabled()
DebuggerConfigBridge.isDistributedDebuggerEnabled()
}
private static class MockDebuggerConfigUpdater implements DebuggerConfigUpdater {
private int calls = 0
private boolean di
private boolean er
private boolean co
private boolean dd
@Override
void updateConfig(DebuggerConfigUpdate update) {
calls++
di = update.getDynamicInstrumentationEnabled() != null ? update.getDynamicInstrumentationEnabled() : di
er = update.getExceptionReplayEnabled() != null ? update.getExceptionReplayEnabled() : er
co = update.getCodeOriginEnabled() != null ? update.getCodeOriginEnabled() : co
dd = update.getDistributedDebuggerEnabled() != null ? update.getDistributedDebuggerEnabled() : dd
}
@Override
boolean isDynamicInstrumentationEnabled() {
return di
}
@Override
boolean isExceptionReplayEnabled() {
return er
}
@Override
boolean isCodeOriginEnabled() {
return co
}
@Override
boolean isDistributedDebuggerEnabled() {
return dd
}
}
}