@Test public void testMetaFunctionsLocal() throws Exception { final Connection connection = CalciteAssert.hr().connect(); assertThat(connection.isClosed(), is(false)); for (Meta.DatabaseProperty p : Meta.DatabaseProperty.values()) { switch (p) { case GET_NUMERIC_FUNCTIONS: assertThat(connection.getMetaData().getNumericFunctions(), not(equalTo(""))); break; case GET_SYSTEM_FUNCTIONS: assertThat(connection.getMetaData().getSystemFunctions(), CoreMatchers.notNullValue()); break; case GET_TIME_DATE_FUNCTIONS: assertThat(connection.getMetaData().getTimeDateFunctions(), not(equalTo(""))); break; case GET_S_Q_L_KEYWORDS: assertThat(connection.getMetaData().getSQLKeywords(), not(equalTo(""))); break; case GET_STRING_FUNCTIONS: assertThat(connection.getMetaData().getStringFunctions(), not(equalTo(""))); break; default: } } connection.close(); assertThat(connection.isClosed(), is(true)); }
@Test public void testDatabaseProperties() throws Exception { final Connection connection = ljs(); for (Meta.DatabaseProperty p : Meta.DatabaseProperty.values()) { switch (p) { case GET_NUMERIC_FUNCTIONS: assertThat( connection.getMetaData().getNumericFunctions(), equalTo( "ABS,ACOS,ASIN,ATAN,ATAN2,BITAND,BITOR,BITXOR," + "CEILING,COS,COT,DEGREES,EXP,FLOOR,LOG,LOG10,MOD," + "PI,POWER,RADIANS,RAND,ROUND,ROUNDMAGIC,SIGN,SIN," + "SQRT,TAN,TRUNCATE")); break; case GET_SYSTEM_FUNCTIONS: assertThat( connection.getMetaData().getSystemFunctions(), equalTo("DATABASE,IFNULL,USER")); break; case GET_TIME_DATE_FUNCTIONS: assertThat( connection.getMetaData().getTimeDateFunctions(), equalTo( "CURDATE,CURTIME,DATEDIFF,DAYNAME,DAYOFMONTH,DAYOFWEEK," + "DAYOFYEAR,HOUR,MINUTE,MONTH,MONTHNAME,NOW,QUARTER,SECOND," + "SECONDS_SINCE_MIDNIGHT,TIMESTAMPADD,TIMESTAMPDIFF," + "TO_CHAR,WEEK,YEAR")); break; case GET_S_Q_L_KEYWORDS: assertThat( connection.getMetaData().getSQLKeywords(), equalTo("")); // No SQL keywords return for HSQLDB break; case GET_STRING_FUNCTIONS: assertThat( connection.getMetaData().getStringFunctions(), equalTo( "ASCII,CHAR,CONCAT,DIFFERENCE,HEXTORAW,INSERT,LCASE," + "LEFT,LENGTH,LOCATE,LTRIM,RAWTOHEX,REPEAT,REPLACE," + "RIGHT,RTRIM,SOUNDEX,SPACE,SUBSTR,UCASE")); break; default: } } connection.close(); }