use of com.datastax.oss.protocol.internal.Compressor in project java-driver by datastax.
the class ChannelFactoryTestBase method setup.
@Before
public void setup() throws InterruptedException {
MockitoAnnotations.initMocks(this);
serverGroup = new DefaultEventLoopGroup(1);
clientGroup = new DefaultEventLoopGroup(1);
when(context.getConfig()).thenReturn(driverConfig);
when(driverConfig.getDefaultProfile()).thenReturn(defaultProfile);
when(defaultProfile.isDefined(DefaultDriverOption.AUTH_PROVIDER_CLASS)).thenReturn(false);
when(defaultProfile.getDuration(DefaultDriverOption.CONNECTION_INIT_QUERY_TIMEOUT)).thenReturn(Duration.ofMillis(TIMEOUT_MILLIS));
when(defaultProfile.getDuration(DefaultDriverOption.CONNECTION_SET_KEYSPACE_TIMEOUT)).thenReturn(Duration.ofMillis(TIMEOUT_MILLIS));
when(defaultProfile.getInt(DefaultDriverOption.CONNECTION_MAX_REQUESTS)).thenReturn(1);
when(defaultProfile.getDuration(DefaultDriverOption.HEARTBEAT_INTERVAL)).thenReturn(Duration.ofSeconds(30));
when(defaultProfile.getDuration(DefaultDriverOption.CONNECTION_CONNECT_TIMEOUT)).thenReturn(Duration.ofSeconds(5));
when(context.getProtocolVersionRegistry()).thenReturn(protocolVersionRegistry);
when(context.getNettyOptions()).thenReturn(nettyOptions);
when(nettyOptions.ioEventLoopGroup()).thenReturn(clientGroup);
when(nettyOptions.channelClass()).thenAnswer((Answer<Object>) i -> LocalChannel.class);
when(nettyOptions.allocator()).thenReturn(ByteBufAllocator.DEFAULT);
when(context.getFrameCodec()).thenReturn(FrameCodec.defaultClient(new ByteBufPrimitiveCodec(ByteBufAllocator.DEFAULT), Compressor.none()));
when(context.getSslHandlerFactory()).thenReturn(Optional.empty());
when(context.getEventBus()).thenReturn(eventBus);
when(context.getWriteCoalescer()).thenReturn(new PassThroughWriteCoalescer(null));
when(context.getCompressor()).thenReturn(compressor);
// Start local server
ServerBootstrap serverBootstrap = new ServerBootstrap().group(serverGroup).channel(LocalServerChannel.class).localAddress(SERVER_ADDRESS.resolve()).childHandler(new ServerInitializer());
ChannelFuture channelFuture = serverBootstrap.bind().sync();
serverAcceptChannel = (LocalServerChannel) channelFuture.sync().channel();
}
Aggregations