24
24
import com .influxdb .LogLevel ;
25
25
import com .influxdb .client .domain .Authorization ;
26
26
import com .influxdb .client .domain .OperationLogs ;
27
+ import com .influxdb .client .domain .WritePrecision ;
27
28
import com .influxdb .client .internal .AbstractInfluxDBClientTest ;
28
29
29
30
import okhttp3 .mockwebserver .MockResponse ;
@@ -183,8 +184,33 @@ void parseDateTime() {
183
184
184
185
@ Test
185
186
public void autoClosable () {
186
- try (InfluxDBClient client = InfluxDBClientFactory .create (mockServer .url ("/" ).url ().toString ())){
187
+ try (InfluxDBClient client = InfluxDBClientFactory .create (mockServer .url ("/" ).url ().toString ())) {
187
188
Assertions .assertThat (client ).isNotNull ();
188
189
}
189
190
}
191
+
192
+ @ Test
193
+ public void testTrailingSlashInUrl () throws InterruptedException {
194
+ mockServer .enqueue (new MockResponse ());
195
+ mockServer .enqueue (new MockResponse ());
196
+
197
+ String path = mockServer .url ("/" ).toString ();
198
+ InfluxDBClient influxDBClient = InfluxDBClientFactory
199
+ .create (path , "my-token" .toCharArray ());
200
+
201
+ influxDBClient .getWriteApiBlocking ().writeRecord ("my-bucket" , "my-org" , WritePrecision .NS , "record,tag=a value=1" );
202
+
203
+ RecordedRequest request = mockServer .takeRequest ();
204
+ Assertions .assertThat (request .getRequestUrl ().toString ()).isEqualTo (path + "api/v2/write?org=my-org&bucket=my-bucket&precision=ns" );
205
+ influxDBClient .close ();
206
+
207
+ influxDBClient = InfluxDBClientFactory
208
+ .create (path .substring (0 , path .length () - 1 ), "my-token" .toCharArray ());
209
+
210
+ influxDBClient .getWriteApiBlocking ().writeRecord ("my-bucket" , "my-org" , WritePrecision .NS , "record,tag=a value=1" );
211
+
212
+ request = mockServer .takeRequest ();
213
+ Assertions .assertThat (request .getRequestUrl ().toString ()).isEqualTo (path + "api/v2/write?org=my-org&bucket=my-bucket&precision=ns" );
214
+ influxDBClient .close ();
215
+ }
190
216
}
0 commit comments