### Question:
SybaseDatabase extends AbstractDatabase { @Override public int getDatabaseMinorVersion() throws DatabaseException { try { return getConnection().getDatabaseMinorVersion(); } catch (UnsupportedOperationException e) { LogFactory.getLogger() .warning("Your JDBC driver does not support getDatabaseMajorVersion(). Consider upgrading it."); return -1; } } SybaseDatabase(); String getProductName(); String getTypeName(); int getPriority(); @Override boolean supportsDDLInTransaction(); @Override Set<String> getSystemTablesAndViews(); boolean supportsInitiallyDeferrableColumns(); @Override boolean supportsSequences(); boolean isCorrectDatabaseImplementation(DatabaseConnection conn); String getDefaultDriver(String url); String getCurrentDateTimeFunction(); @Override String getDefaultCatalogName(); @Override String getConcatSql(String... values); boolean supportsTablespaces(); @Override boolean isSystemTable(String catalogName, String schemaName, String tableName); @Override boolean isSystemView(String catalogName, String schemaName, String viewName); String generateDefaultConstraintName(String tableName, String columnName); @Override String convertRequestedSchemaToCatalog(String requestedSchema); @Override String convertRequestedSchemaToSchema(String requestedSchema); @Override boolean supportsRestrictForeignKeys(); @Override String escapeDatabaseObject(String objectName); @Override String getViewDefinition(String schemaName, String viewName); @Override int getDatabaseMajorVersion(); @Override int getDatabaseMinorVersion(); @Override String escapeIndexName(String schemaName, String indexName); static final String PRODUCT_NAME; }### Answer:
@Test public void testGetDatabaseMinorVersionWhenImplemented() throws Exception { DatabaseConnection connection = createNiceMock(DatabaseConnection.class); expect(connection.getDatabaseMinorVersion()).andReturn(5); replay(connection); SybaseDatabase database = new SybaseDatabase(); database.setConnection(connection); assertEquals(5, database.getDatabaseMinorVersion()); }
@Test public void testGetDatabaseMinorVersionWhenNotImplemented() throws Exception { DatabaseConnection connection = createNiceMock(DatabaseConnection.class); expect(connection.getDatabaseMinorVersion()).andThrow(new UnsupportedOperationException()); replay(connection); SybaseDatabase database = new SybaseDatabase(); database.setConnection(connection); assertEquals(-1, database.getDatabaseMinorVersion()); }