diff --git a/sql-clients/build.gradle b/sql-clients/build.gradle index 33533b9ecda..6b965709119 100644 --- a/sql-clients/build.gradle +++ b/sql-clients/build.gradle @@ -27,22 +27,14 @@ subprojects { } dependencies { - testCompile("junit:junit:${versions.junit}") { - exclude group:'org.hamcrest', module:'hamcrest-core' - } - testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}" + testCompile "org.elasticsearch.test:framework:${version}" } - tasks.checkstyle.enabled = false // not worth it yet + tasks.checkstyleMain.enabled = false // not worth it yet tasks.checkstyleTest.enabled = false // not worth it yet forbiddenApisMain { // does not depend on core, so only jdk and http signatures should be checked signaturesURLs = [PrecommitTasks.getResource('/forbidden/jdk-signatures.txt')] } - - forbiddenApisTest { - // does not depend on core, so only jdk signatures should be checked - signaturesURLs = [PrecommitTasks.getResource('/forbidden/jdk-signatures.txt')] - } } diff --git a/sql-clients/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/Message.java b/sql-clients/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/Message.java index 88f5213d43f..d94d66e1883 100644 --- a/sql-clients/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/Message.java +++ b/sql-clients/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/Message.java @@ -3,24 +3,6 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -/* -w * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ package org.elasticsearch.xpack.sql.cli.net.protocol; import java.io.DataOutput; diff --git a/sql-clients/cli/build.gradle b/sql-clients/cli/build.gradle index f722d6ac9e3..c69291a6e60 100644 --- a/sql-clients/cli/build.gradle +++ b/sql-clients/cli/build.gradle @@ -34,3 +34,62 @@ run { // Needed so we can launch graphviz if it is installed project.compactProfile = 'full' + +forbiddenApisTest { + //we are using jdk-internal instead of jdk-non-portable to allow for com.sun.net.httpserver.* usage + bundledSignatures -= 'jdk-non-portable' + bundledSignatures += 'jdk-internal' +} + +thirdPartyAudit.excludes = [ + // included by jline but not used + // NOCOMMIT maybe we need some of these? + 'com.sun.jna.Library', + 'com.sun.jna.Native', + 'com.sun.jna.NativeLong', + 'com.sun.jna.Platform', + 'com.sun.jna.Pointer', + 'com.sun.jna.Structure$ByReference', + 'com.sun.jna.Structure$ByValue', + 'com.sun.jna.Structure', + 'com.sun.jna.Union', + 'com.sun.jna.ptr.IntByReference', + 'com.sun.jna.win32.StdCallLibrary', + 'com.sun.jna.win32.W32APIOptions', + 'org.apache.sshd.client.SshClient', + 'org.apache.sshd.client.auth.keyboard.UserInteraction', + 'org.apache.sshd.client.channel.ChannelShell', + 'org.apache.sshd.client.channel.ClientChannel', + 'org.apache.sshd.client.channel.ClientChannelEvent', + 'org.apache.sshd.client.future.AuthFuture', + 'org.apache.sshd.client.future.ConnectFuture', + 'org.apache.sshd.client.future.OpenFuture', + 'org.apache.sshd.client.session.ClientSession', + 'org.apache.sshd.common.Factory', + 'org.apache.sshd.common.channel.PtyMode', + 'org.apache.sshd.common.config.keys.FilePasswordProvider', + 'org.apache.sshd.common.util.io.NoCloseInputStream', + 'org.apache.sshd.common.util.io.NoCloseOutputStream', + 'org.apache.sshd.server.Command', + 'org.apache.sshd.server.Environment', + 'org.apache.sshd.server.ExitCallback', + 'org.apache.sshd.server.SessionAware', + 'org.apache.sshd.server.Signal', + 'org.apache.sshd.server.SshServer', + 'org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider', + 'org.apache.sshd.server.scp.ScpCommandFactory$Builder', + 'org.apache.sshd.server.session.ServerSession', + 'org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory$Builder', + 'org.fusesource.jansi.Ansi', + 'org.fusesource.jansi.WindowsAnsiOutputStream', + 'org.fusesource.jansi.internal.CLibrary$Termios', + 'org.fusesource.jansi.internal.CLibrary$WinSize', + 'org.fusesource.jansi.internal.CLibrary', + 'org.fusesource.jansi.internal.Kernel32$CONSOLE_SCREEN_BUFFER_INFO', + 'org.fusesource.jansi.internal.Kernel32$COORD', + 'org.fusesource.jansi.internal.Kernel32$INPUT_RECORD', + 'org.fusesource.jansi.internal.Kernel32$KEY_EVENT_RECORD', + 'org.fusesource.jansi.internal.Kernel32', + 'org.fusesource.jansi.internal.WindowsSupport', + 'org.mozilla.universalchardet.UniversalDetector' +] diff --git a/sql-clients/cli/src/test/java/org/elasticsearch/xpack/sql/cli/integration/net/protocol/ProtoTest.java b/sql-clients/cli/src/test/java/org/elasticsearch/xpack/sql/cli/integration/net/protocol/ProtoTests.java similarity index 89% rename from sql-clients/cli/src/test/java/org/elasticsearch/xpack/sql/cli/integration/net/protocol/ProtoTest.java rename to sql-clients/cli/src/test/java/org/elasticsearch/xpack/sql/cli/integration/net/protocol/ProtoTests.java index 3957cd8b500..551b41fb56a 100644 --- a/sql-clients/cli/src/test/java/org/elasticsearch/xpack/sql/cli/integration/net/protocol/ProtoTest.java +++ b/sql-clients/cli/src/test/java/org/elasticsearch/xpack/sql/cli/integration/net/protocol/ProtoTests.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.sql.cli.integration.net.protocol; import org.elasticsearch.client.Client; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.test.ESTestCase; import org.elasticsearch.transport.client.PreBuiltTransportClient; import org.elasticsearch.xpack.sql.cli.CliConfiguration; import org.elasticsearch.xpack.sql.cli.integration.server.CliHttpServer; @@ -15,7 +16,6 @@ import org.elasticsearch.xpack.sql.cli.net.protocol.CommandResponse; import org.elasticsearch.xpack.sql.cli.net.protocol.InfoResponse; import org.junit.AfterClass; import org.junit.BeforeClass; -import org.junit.Test; import java.util.Properties; @@ -24,23 +24,20 @@ import static org.hamcrest.Matchers.isEmptyOrNullString; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.startsWith; -import static org.junit.Assert.assertThat; - -public class ProtoTest { +public class ProtoTests extends ESTestCase { private static Client esClient; private static CliHttpServer server; private static HttpCliClient client; @BeforeClass - public static void setUp() throws Exception { + public static void setupServer() throws Exception { if (esClient == null) { esClient = new PreBuiltTransportClient(Settings.EMPTY); } if (server == null) { server = new CliHttpServer(esClient); server.start(0); - System.out.println("Server started at " + server.address().getPort()); } if (client == null) { @@ -50,7 +47,7 @@ public class ProtoTest { } @AfterClass - public static void tearDown() { + public static void shutdownServer() { if (server != null) { server.stop(); server = null; @@ -67,7 +64,6 @@ public class ProtoTest { } } - @Test public void testInfoAction() throws Exception { InfoResponse esInfo = client.serverInfo(); assertThat(esInfo, notNullValue()); @@ -79,9 +75,9 @@ public class ProtoTest { //assertThat(esInfo.minorVersion(), is(0)); } - @Test public void testBasicQuery() throws Exception { CommandResponse command = client.command("SHOW TABLES", null); - System.out.println(command.data); +// System.out.println(command.data); + // NOCOMMIT test this } } \ No newline at end of file diff --git a/sql-clients/jdbc/src/main/java/org/elasticsearch/xpack/sql/jdbc/jdbc/JdbcStatement.java b/sql-clients/jdbc/src/main/java/org/elasticsearch/xpack/sql/jdbc/jdbc/JdbcStatement.java index 49b606415a6..03b1e4a019d 100644 --- a/sql-clients/jdbc/src/main/java/org/elasticsearch/xpack/sql/jdbc/jdbc/JdbcStatement.java +++ b/sql-clients/jdbc/src/main/java/org/elasticsearch/xpack/sql/jdbc/jdbc/JdbcStatement.java @@ -34,7 +34,7 @@ class JdbcStatement implements Statement, JdbcWrapper { @Override public ResultSet executeQuery(String sql) throws SQLException { if (!execute(sql)) { - throw new SQLException(String.format("Invalid sql query %s", sql)); + throw new SQLException("Invalid sql query [" + sql + "]"); } return rs; }