@@ -37,7 +37,7 @@ static void setUp() {
37
37
SERVICE_URL , "jservice:jmx:rmi:///jndi/rmi://localhost:9010/jmxrmi" );
38
38
validProperties .setProperty (CUSTOM_JMX_SCRAPING_CONFIG , "" );
39
39
validProperties .setProperty (TARGET_SYSTEM , "tomcat, activemq" );
40
- validProperties .setProperty (METRICS_EXPORTER_TYPE , "otel " );
40
+ validProperties .setProperty (METRICS_EXPORTER_TYPE , "otlp " );
41
41
validProperties .setProperty (INTERVAL_MILLISECONDS , "1410" );
42
42
validProperties .setProperty (REGISTRY_SSL , "true" );
43
43
validProperties .setProperty (OTLP_ENDPOINT , "http://localhost:4317" );
@@ -77,13 +77,29 @@ void shouldCreateMinimalValidConfiguration() throws ConfigurationException {
77
77
assertThat (config .getTargetSystems ()).isEmpty ();
78
78
assertThat (config .getIntervalMilliseconds ()).isEqualTo (10000 );
79
79
assertThat (config .getMetricsExporterType ()).isEqualTo ("logging" );
80
- assertThat (config .getOtlpExporterEndpoint ()).isNull ();
80
+ assertThat (config .getOtlpExporterEndpoint ()).isBlank ();
81
81
assertThat (config .getUsername ()).isNull ();
82
82
assertThat (config .getPassword ()).isNull ();
83
83
assertThat (config .getRemoteProfile ()).isNull ();
84
84
assertThat (config .getRealm ()).isNull ();
85
85
}
86
86
87
+ @ Test
88
+ void shouldCreateConfig_defaultOtlEndpoint () throws ConfigurationException {
89
+ // Given
90
+ Properties properties = new Properties ();
91
+ properties .setProperty (SERVICE_URL , "jservice:jmx:rmi:///jndi/rmi://localhost:9010/jmxrmi" );
92
+ properties .setProperty (CUSTOM_JMX_SCRAPING_CONFIG , "/file.properties" );
93
+ properties .setProperty (METRICS_EXPORTER_TYPE , "otlp" );
94
+
95
+ // When
96
+ JmxScraperConfig config = fromProperties (properties , new Properties ());
97
+
98
+ // Then
99
+ assertThat (config .getMetricsExporterType ()).isEqualTo ("otlp" );
100
+ assertThat (config .getOtlpExporterEndpoint ()).isEqualTo ("http://localhost:4318" );
101
+ }
102
+
87
103
@ Test
88
104
@ ClearSystemProperty (key = "javax.net.ssl.keyStore" )
89
105
@ ClearSystemProperty (key = "javax.net.ssl.keyStorePassword" )
@@ -116,7 +132,7 @@ void shouldUseValuesFromProperties() throws ConfigurationException {
116
132
assertThat (config .getCustomJmxScrapingConfigPath ()).isEqualTo ("" );
117
133
assertThat (config .getTargetSystems ()).containsOnly ("tomcat" , "activemq" );
118
134
assertThat (config .getIntervalMilliseconds ()).isEqualTo (1410 );
119
- assertThat (config .getMetricsExporterType ()).isEqualTo ("otel " );
135
+ assertThat (config .getMetricsExporterType ()).isEqualTo ("otlp " );
120
136
assertThat (config .getOtlpExporterEndpoint ()).isEqualTo ("http://localhost:4317" );
121
137
assertThat (config .getUsername ()).isEqualTo ("some-user" );
122
138
assertThat (config .getPassword ()).isEqualTo ("some-password" );
@@ -196,10 +212,10 @@ void shouldFailValidation_invalidTargetSystem() {
196
212
}
197
213
198
214
@ Test
199
- void shouldFailValidation_missingOtlpEndpoint () {
215
+ void shouldFailValidation_blankOtlpEndpointProvided () {
200
216
// Given
201
217
Properties properties = (Properties ) validProperties .clone ();
202
- properties .remove (OTLP_ENDPOINT );
218
+ properties .setProperty (OTLP_ENDPOINT , "" );
203
219
properties .setProperty (METRICS_EXPORTER_TYPE , "otlp" );
204
220
205
221
// When and Then
0 commit comments