@Test
public void appendThroughConditionalClient() throws Exception {
String endpoint = "localhost";
int port = TestUtils.getAvailableListenPort();
String testString = "Hello world\n";
String scope = "scope";
String stream = "stream";
StreamSegmentStore store = this.serviceBuilder.createStreamSegmentService();
TableStore tableStore = serviceBuilder.createTableStoreService();
@Cleanup
PravegaConnectionListener server = new PravegaConnectionListener(false, port, store, tableStore);
server.startListening();
@Cleanup
ConnectionFactory clientCF = new ConnectionFactoryImpl(ClientConfig.builder().build());
Controller controller = new MockController(endpoint, port, clientCF);
controller.createScope(scope);
controller.createStream(scope, stream, StreamConfiguration.builder().build());
ConditionalOutputStreamFactoryImpl segmentClient = new ConditionalOutputStreamFactoryImpl(controller, clientCF);
Segment segment = Futures.getAndHandleExceptions(controller.getCurrentSegments(scope, stream), RuntimeException::new).getSegments().iterator().next();
@Cleanup
ConditionalOutputStream out = segmentClient.createConditionalOutputStream(segment, "", EventWriterConfig.builder().build());
assertTrue(out.write(ByteBuffer.wrap(testString.getBytes()), 0));
}