Search in sources :

Example 1 with Cli

use of io.confluent.ksql.cli.Cli 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"));
}
Also used : Cli(io.confluent.ksql.cli.Cli) KsqlRestClient(io.confluent.ksql.rest.client.KsqlRestClient) IntegrationTest(io.confluent.common.utils.IntegrationTest) Test(org.junit.Test)

Example 2 with Cli

use of io.confluent.ksql.cli.Cli 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));
}
Also used : Cli(io.confluent.ksql.cli.Cli) KsqlRestClient(io.confluent.ksql.rest.client.KsqlRestClient) IntegrationTest(io.confluent.common.utils.IntegrationTest) Test(org.junit.Test)

Example 3 with Cli

use of io.confluent.ksql.cli.Cli 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);
}
Also used : KsqlRestClient(io.confluent.ksql.rest.client.KsqlRestClient) KsqlRestApplication(io.confluent.ksql.rest.server.KsqlRestApplication) Cli(io.confluent.ksql.cli.Cli) KsqlRestConfig(io.confluent.ksql.rest.server.KsqlRestConfig) VersionCheckerAgent(io.confluent.ksql.version.metrics.VersionCheckerAgent) BeforeClass(org.junit.BeforeClass)

Example 4 with Cli

use of io.confluent.ksql.cli.Cli 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();
    }
}
Also used : JLineTerminal(io.confluent.ksql.cli.console.JLineTerminal) Options(io.confluent.ksql.cli.Options) KsqlRestClient(io.confluent.ksql.rest.client.KsqlRestClient) Cli(io.confluent.ksql.cli.Cli) Properties(java.util.Properties) KsqlVersionCheckerAgent(io.confluent.ksql.version.metrics.KsqlVersionCheckerAgent)

Aggregations

Cli (io.confluent.ksql.cli.Cli)4 KsqlRestClient (io.confluent.ksql.rest.client.KsqlRestClient)4 IntegrationTest (io.confluent.common.utils.IntegrationTest)2 Test (org.junit.Test)2 Options (io.confluent.ksql.cli.Options)1 JLineTerminal (io.confluent.ksql.cli.console.JLineTerminal)1 KsqlRestApplication (io.confluent.ksql.rest.server.KsqlRestApplication)1 KsqlRestConfig (io.confluent.ksql.rest.server.KsqlRestConfig)1 KsqlVersionCheckerAgent (io.confluent.ksql.version.metrics.KsqlVersionCheckerAgent)1 VersionCheckerAgent (io.confluent.ksql.version.metrics.VersionCheckerAgent)1 Properties (java.util.Properties)1 BeforeClass (org.junit.BeforeClass)1