Fix some metadata tests

Original commit: elastic/x-pack-elasticsearch@391586d774
This commit is contained in:
Nik Everett 2017-06-27 18:25:15 -04:00
parent 620404c095
commit 2cd7f1bfe3
5 changed files with 20 additions and 6 deletions

View File

@ -50,6 +50,6 @@ public class MetaColumnRequest extends Request {
@Override
public String toString() {
return format(Locale.ROOT, "MetaColumn[index=%, table=%s, column=%s", type, column);
return "MetaColumn[index=" + index + ", type=" + type + " column=" + column + "]";
}
}

View File

@ -826,7 +826,7 @@ class JdbcDatabaseMetaData implements DatabaseMetaData, JdbcWrapper {
row[ 3] = col.name;
row[ 4] = col.type;
row[ 5] = JdbcUtils.nameOf(col.type);
row[ 6] = col.position;
row[ 6] = col.position; // NOCOMMIT this doesn't seem right
row[ 7] = null;
row[ 8] = null;
row[ 9] = 10;

View File

@ -57,7 +57,7 @@ class HttpClient {
}
BytesArray put(DataOutputConsumer os) throws SQLException {
return put("_jdbc/", os);
return put("_jdbc?error_trace=true", os); // NOCOMMIT Do something with the error trace. Useful for filing bugs and debugging.
}
BytesArray put(String path, DataOutputConsumer os) throws SQLException { // NOCOMMIT remove path?

View File

@ -11,8 +11,6 @@ import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Types;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.startsWith;
/**
@ -167,13 +165,30 @@ public class DatabaseMetaDataIT extends JdbcIntegrationTestCase {
assertEquals("test.doc", results.getString(i++));
assertEquals("name", results.getString(i++));
assertEquals(Types.VARCHAR, results.getInt(i++));
assertEquals("VARCHAR", results.getString(i++));
assertEquals(1, results.getInt(i++));
assertEquals(null, results.getString(i++));
assertEquals(null, results.getString(i++));
assertEquals(10, results.getInt(i++)); // NOCOMMIT 10 seems wrong to hard code for stuff like strings
// NOCOMMIT I think it'd be more correct to return DatabaseMetaData.columnNullable because all fields are nullable in es
assertEquals(DatabaseMetaData.columnNullableUnknown, results.getInt(i++));
assertEquals(null, results.getString(i++));
assertEquals(null, results.getString(i++));
assertEquals(null, results.getString(i++));
assertEquals(null, results.getString(i++));
assertEquals(null, results.getString(i++));
assertEquals(1, results.getInt(i++));
assertEquals("", results.getString(i++));
assertEquals(null, results.getString(i++));
assertEquals(null, results.getString(i++));
assertEquals(null, results.getString(i++));
assertEquals(null, results.getString(i++));
assertEquals("", results.getString(i++));
assertEquals("", results.getString(i++));
assertFalse(results.next());
});
// NOCOMMIT add some more columns and test that.
}
private static void assertColumn(String name, String type, ResultSetMetaData meta, int index) throws SQLException {

View File

@ -71,7 +71,6 @@ public class JreHttpUrlConnection implements Closeable {
if (err == null) {
response = "server did not return a response";
} else {
// NOCOMMIT figure out why this returns weird characters. Can reproduce with unauthorized.
response = new String(IOUtils.asBytes(err).bytes(), StandardCharsets.UTF_8);
}
throw new ClientException("Protocol/client error; server returned [" + con.getResponseMessage() + "]: " + response);