Skip to content

Commit

Permalink
Add minimal support of Connection.*ClientInfo()
Browse files Browse the repository at this point in the history
At present, the driver doesn't support any properties and must retrieve
empty data instead of raising an error with an exception for
Statement.setClientInfo which will throw ClientInfoException for any
attempts to set a property.

Closes: #74
  • Loading branch information
nicktorwald committed Jun 12, 2019
1 parent 25b156d commit 828c312
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/tarantool/jdbc/SQLConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -479,13 +479,13 @@ private void throwUnknownClientProperties(Collection<Object> properties) throws
@Override
public String getClientInfo(String name) throws SQLException {
checkNotClosed();
throw new SQLFeatureNotSupportedException();
return null;
}

@Override
public Properties getClientInfo() throws SQLException {
checkNotClosed();
throw new SQLFeatureNotSupportedException();
return new Properties();
}

@Override
Expand Down
18 changes: 18 additions & 0 deletions src/test/java/org/tarantool/jdbc/JdbcConnectionIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;

import java.sql.ClientInfoStatus;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLClientInfoException;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.Statement;
import java.util.Map;

public class JdbcConnectionIT {

Expand Down Expand Up @@ -443,4 +446,19 @@ public void testGeneratedKeys() throws SQLException {
);
}

@Test
void testSetClientInfoProperties() {
String targetProperty = "ApplicationName";

SQLClientInfoException exception = assertThrows(
SQLClientInfoException.class,
() -> conn.setClientInfo(targetProperty, "TestApp")
);

Map<String, ClientInfoStatus> failedProperties = exception.getFailedProperties();
assertEquals(1, failedProperties.size());
assertEquals(ClientInfoStatus.REASON_UNKNOWN_PROPERTY, failedProperties.get(targetProperty));
}

}

8 changes: 8 additions & 0 deletions src/test/java/org/tarantool/jdbc/JdbcDatabaseMetaDataIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ public void tearDownTest() throws SQLException {
testHelper.executeSql(CLEAN_SQL);
}

@Test
public void testGetSupportedClientInfo() throws SQLException {
ResultSet rs = meta.getClientInfoProperties();
assertNotNull(rs);
assertFalse(rs.next());
rs.close();
}

@Test
public void testGetTableTypes() throws SQLException {
ResultSet rs = meta.getTableTypes();
Expand Down

0 comments on commit 828c312

Please sign in to comment.