Skip to content

Commit dc29704

Browse files
feat: improve test
1 parent 147498b commit dc29704

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

src/test/java/com/influxdb/v3/client/query/QueryOptionsTest.java

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
import java.nio.charset.StandardCharsets;
2626
import java.util.ArrayList;
2727
import java.util.List;
28-
import java.util.concurrent.TimeUnit;
2928
import java.util.stream.Stream;
3029
import javax.annotation.Nonnull;
3130

31+
import io.grpc.ManagedChannel;
32+
import io.grpc.ManagedChannelBuilder;
3233
import org.apache.arrow.flight.CallOption;
3334
import org.apache.arrow.flight.CallOptions;
3435
import org.apache.arrow.flight.CallStatus;
@@ -37,6 +38,7 @@
3738
import org.apache.arrow.flight.Location;
3839
import org.apache.arrow.flight.NoOpFlightProducer;
3940
import org.apache.arrow.flight.Ticket;
41+
import org.apache.arrow.flight.impl.FlightServiceGrpc;
4042
import org.apache.arrow.memory.BufferAllocator;
4143
import org.apache.arrow.memory.RootAllocator;
4244
import org.apache.arrow.vector.VarCharVector;
@@ -176,28 +178,25 @@ void setInboundMessageSizeLarge() throws Exception {
176178

177179
@Test
178180
void grpcCallOption() {
179-
GrpcCallOption.Builder builder = new GrpcCallOption.Builder();
180-
builder.withMaxInboundMessageSize(1024);
181-
builder.withMaxOutboundMessageSize(1024);
182-
builder.withCompressorName("my-compressor");
183-
builder.withDeadlineAfter(2, TimeUnit.HOURS);
184-
builder.withExecutor(Runnable::run);
185-
builder.withWaitForReady();
186-
187-
GrpcCallOption callOption = builder.build();
188-
Assertions.assertThat(callOption.getMaxInboundMessageSize()).isEqualTo(1024);
189-
Assertions.assertThat(callOption.getMaxOutboundMessageSize()).isEqualTo(1024);
190-
Assertions.assertThat(callOption.getCompressorName()).isEqualTo("my-compressor");
191-
Assertions.assertThat(callOption.getDeadlineAfter()).isNotNull();
192-
Assertions.assertThat(callOption.getExecutor()).isNotNull();
193-
Assertions.assertThat(callOption.getWaitForReady()).isTrue();
194-
195-
CallOption[] callBackArray = callOption.getCallOptionCallback();
196-
Assertions.assertThat(callBackArray).isNotNull();
197-
Assertions.assertThat(callBackArray.length).isEqualTo(6);
198-
for (CallOption option : callBackArray) {
199-
Assertions.assertThat(option).isInstanceOf(CallOptions.GrpcCallOption.class);
181+
GrpcCallOption grpcCallOption = new GrpcCallOption.Builder()
182+
.withMaxInboundMessageSize(1024)
183+
.withMaxOutboundMessageSize(1024)
184+
.withCompressorName("my-compressor")
185+
.withWaitForReady()
186+
.build();
187+
ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 3333)
188+
.usePlaintext()
189+
.build();
190+
FlightServiceGrpc.FlightServiceStub stub = FlightServiceGrpc.newStub(channel);
191+
for (CallOption option : grpcCallOption.getCallOptionCallback()) {
192+
stub = ((CallOptions.GrpcCallOption) option).wrapStub(stub);
200193
}
194+
195+
io.grpc.CallOptions stubCallOptions = stub.getCallOptions();
196+
Assertions.assertThat(stubCallOptions.getMaxInboundMessageSize()).isEqualTo(grpcCallOption.getMaxInboundMessageSize());
197+
Assertions.assertThat(stubCallOptions.getMaxOutboundMessageSize()).isEqualTo(grpcCallOption.getMaxOutboundMessageSize());
198+
Assertions.assertThat(stubCallOptions.getCompressor()).isEqualTo(grpcCallOption.getCompressorName());
199+
Assertions.assertThat(stubCallOptions.isWaitForReady()).isEqualTo(grpcCallOption.getWaitForReady());
201200
}
202201

203202
private FlightServer simpleFlightServer(@Nonnull final URI uri,

0 commit comments

Comments
 (0)