9
9
import static com .splunk .hecclient .JsonEventBatch .ENDPOINT ;
10
10
11
11
public class HecURIBuilderTest {
12
+ private static final String RAW_ENDPOINT = "/services/collector/raw?index=main&source=source" ;
12
13
private static final String BASE_URL = "https://localhost:8088" ;
13
14
private static final String TOKEN = "mytoken" ;
14
15
15
16
@ Test
16
17
public void testDefaultValues () {
17
- HecConfig hecConfig = new HecConfig (Collections .emptyList (), TOKEN );
18
- HecURIBuilder builder = new HecURIBuilder (BASE_URL , hecConfig );
18
+ {
19
+ HecConfig hecConfig = new HecConfig (Collections .emptyList (), TOKEN );
20
+ HecURIBuilder builder = new HecURIBuilder (BASE_URL , hecConfig );
21
+
22
+ URI uri = builder .getURI (ENDPOINT );
23
+
24
+ Assert .assertEquals ("https://localhost:8088/services/collector/event" , uri .toString ());
25
+ }
26
+ {
27
+ HecConfig hecConfig = new HecConfig (Collections .emptyList (), TOKEN );
28
+ HecURIBuilder builder = new HecURIBuilder (BASE_URL , hecConfig );
19
29
20
- URI uri = builder .getURI (ENDPOINT );
30
+ URI uri = builder .getURI (RAW_ENDPOINT );
21
31
22
- Assert .assertEquals ("https://localhost:8088/services/collector/event" , uri .toString ());
32
+ Assert .assertEquals ("https://localhost:8088/services/collector/raw?index=main&source=source" , uri .toString ());
33
+ }
23
34
}
24
35
25
36
@ Test
@@ -46,5 +57,27 @@ public void testAutoExtractTimestamp() {
46
57
HecURIBuilder .AUTO_EXTRACT_TIMESTAMP_PARAMETER + "=false" ,
47
58
uri .toString ());
48
59
}
60
+ {
61
+ HecConfig hecConfig = new HecConfig (Collections .emptyList (), TOKEN )
62
+ .setAutoExtractTimestamp (false );
63
+ HecURIBuilder builder = new HecURIBuilder (BASE_URL , hecConfig );
64
+
65
+ URI uri = builder .getURI (RAW_ENDPOINT );
66
+
67
+ Assert .assertEquals ("https://localhost:8088/services/collector/raw?index=main&source=source&" +
68
+ HecURIBuilder .AUTO_EXTRACT_TIMESTAMP_PARAMETER + "=false" ,
69
+ uri .toString ());
70
+ }
71
+ {
72
+ HecConfig hecConfig = new HecConfig (Collections .emptyList (), TOKEN )
73
+ .setAutoExtractTimestamp (true );
74
+ HecURIBuilder builder = new HecURIBuilder (BASE_URL , hecConfig );
75
+
76
+ URI uri = builder .getURI (RAW_ENDPOINT );
77
+
78
+ Assert .assertEquals ("https://localhost:8088/services/collector/raw?index=main&source=source&" +
79
+ HecURIBuilder .AUTO_EXTRACT_TIMESTAMP_PARAMETER + "=true" ,
80
+ uri .toString ());
81
+ }
49
82
}
50
83
}
0 commit comments