use of io.confluent.ksql.rest.client.KsqlRestClient in project ksql by confluentinc.
the class CliTest method shouldPrintErrorIfCantConnectToRestServer.
@Test
public void shouldPrintErrorIfCantConnectToRestServer() {
new Cli(1L, 1L, new KsqlRestClient("xxxx", Collections.emptyMap()), terminal);
assertThat(terminal.getOutputString(), containsString("Remote server address may not be valid"));
}
use of io.confluent.ksql.rest.client.KsqlRestClient in project ksql by confluentinc.
the class CliTest method shouldRegisterRemoteCommand.
@Test
public void shouldRegisterRemoteCommand() {
new Cli(1L, 1L, new KsqlRestClient("xxxx", Collections.emptyMap()), terminal);
assertThat(terminal.getCliSpecificCommands().get("server"), instanceOf(Cli.RemoteServerSpecificCommand.class));
}
use of io.confluent.ksql.rest.client.KsqlRestClient in project ksql by confluentinc.
the class CliTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
KsqlRestClient restClient = new KsqlRestClient(LOCAL_REST_SERVER_ADDR);
// TODO: Fix Properties Setup in Local().getCli()
// Local local = new Local().getCli();
// LocalCli localCli = local.getCli(restClient, terminal);
// TODO: add remote cli test cases
terminal = new TestTerminal(CLI_OUTPUT_FORMAT, restClient);
KsqlRestConfig restServerConfig = new KsqlRestConfig(defaultServerProperties());
commandTopicName = restServerConfig.getCommandTopic(KsqlConfig.KSQL_SERVICE_ID_DEFAULT);
orderDataProvider = new OrderDataProvider();
CLUSTER.createTopic(orderDataProvider.topicName());
KsqlRestApplication restServer = KsqlRestApplication.buildApplication(restServerConfig, false, EasyMock.mock(VersionCheckerAgent.class));
restServer.start();
localCli = new Cli(STREAMED_QUERY_ROW_LIMIT, STREAMED_QUERY_TIMEOUT_MS, restClient, terminal);
TestRunner.setup(localCli, terminal);
topicProducer = new TopicProducer(CLUSTER);
topicConsumer = new TopicConsumer(CLUSTER);
testListOrShowCommands();
produceInputStream(orderDataProvider);
}
use of io.confluent.ksql.rest.client.KsqlRestClient in project ksql by confluentinc.
the class Ksql method main.
public static void main(String[] args) throws IOException {
final Options options = args.length == 0 ? Options.parse("http://localhost:8088") : Options.parse(args);
if (options == null) {
System.exit(-1);
}
final Properties properties = loadProperties(options.getConfigFile());
final KsqlRestClient restClient = new KsqlRestClient(options.getServer(), properties);
options.getUserNameAndPassword().ifPresent(creds -> restClient.setupAuthenticationCredentials(creds.left, creds.right));
final KsqlVersionCheckerAgent versionChecker = new KsqlVersionCheckerAgent();
versionChecker.start(KsqlModuleType.REMOTE_CLI, properties);
try (final Cli cli = new Cli(options.getStreamedQueryRowLimit(), options.getStreamedQueryTimeoutMs(), restClient, new JLineTerminal(options.getOutputFormat(), restClient))) {
cli.runInteractively();
}
}
use of io.confluent.ksql.rest.client.KsqlRestClient in project ksql by confluentinc.
the class RemoteCliSpecificCommandTest method shouldPrintErrorOnErrorResponseFromRestClient.
@Test
public void shouldPrintErrorOnErrorResponseFromRestClient() {
final Cli.RemoteServerSpecificCommand command = new Cli.RemoteServerSpecificCommand(new KsqlRestClient("xxxx", Collections.emptyMap()) {
@Override
public RestResponse<ServerInfo> getServerInfo() {
return RestResponse.erroneous(new ErrorMessage("it is broken", Collections.emptyList()));
}
}, new PrintWriter(out));
command.execute("http://localhost:8088");
assertThat(out.toString(), containsString("it is broken"));
}
Aggregations