Package org.h2.test.db
Class TestFunctions
- java.lang.Object
-
- org.h2.test.TestBase
-
- org.h2.test.TestDb
-
- org.h2.test.db.TestFunctions
-
- All Implemented Interfaces:
AggregateFunction
public class TestFunctions extends org.h2.test.TestDb implements AggregateFunction
Tests for user defined functions and aggregates.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTestFunctions.MedianStringThis median implementation keeps all objects in memory.static classTestFunctions.MedianStringTypeThis median implementation keeps all objects in memory.
-
Constructor Summary
Constructors Constructor Description TestFunctions()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.lang.Object value)This method is called once for each row.static intaddRow(java.sql.Connection conn, int id, java.lang.String name)This method is called via reflection from the database.static java.lang.Integer[][]arrayParameters1(java.lang.String[][] x)This method is called with reflection.static java.sql.Blobblob(java.sql.Blob value)This method is called via reflection from the database.static java.io.BufferedInputStreamblob2stream(java.sql.Blob value)This method is called via reflection from the database.static java.sql.Clobclob(java.sql.Clob value)This method is called via reflection from the database.static longcurrentTimestampOverride()This method is called via reflection from the database.static java.lang.String[]dynamic(java.lang.String[] args)This method is called via reflection from the database.static java.sql.ResultSetfunctionTableWithParameter(java.sql.Connection conn, int p)This method is called via reflection from the database.static java.lang.String[]getArray()This method is called via reflection from the database.static intgetCount()This method is called via reflection from the database.java.lang.ObjectgetResult()This method returns the computed aggregate value.intgetType(int[] inputTypes)This method must return the SQL type of the method, given the SQL type of the input data.static voidmain(java.lang.String... a)Run just this test.static doublemean()This method is called via reflection from the database.static doublemean(double... values)This method is called via reflection from the database.static doublemean2(java.sql.Connection conn, double... values)This method is called via reflection from the database.static java.math.BigDecimalnoOp(java.math.BigDecimal dec)This method is called via reflection from the database.static java.lang.StringprintMean(java.lang.String prefix, double... values)This method is called via reflection from the database.static java.sql.ResultSetresultSetWithNull(java.sql.Connection conn)This method is called via reflection from the database.static java.lang.Stringreverse(java.lang.String s)This method is called via reflection from the database.static introot(int value)This method is called via reflection from the database.static java.sql.ResultSetselect(java.sql.Connection conn, java.lang.String sql)This method is called via reflection from the database.static java.sql.ResultSetselectMaxId(java.sql.Connection conn)This method is called via reflection from the database.static java.sql.ResultSetsimpleFunctionTable(java.sql.Connection conn)This method is called via reflection from the database.static java.sql.ResultSetsimpleResultSet(java.lang.Integer rowCount, int ip, boolean bp, float fp, double dp, long lp, byte byParam, short sp)Test method to create a simple result set.static java.io.BufferedInputStreamstream2stream(java.io.InputStream value)This method is called via reflection from the database.voidtest()This method will be called by the test framework.static voidtestDefaultConn()This method is called via reflection from the database.static ValuetoChar(Value... args)This method is called via reflection from the database.static java.sql.ResultSetvarArgsFunctionTable(int... values)This method is called via reflection from the database.static java.util.UUIDxorUUID(java.util.UUID a, java.util.UUID b)This method is called via reflection from the database.-
Methods inherited from class org.h2.test.TestDb
buildChild, deleteDb, deleteDb, getConnection, getConnection, getURL
-
Methods inherited from class org.h2.test.TestBase
assertContains, assertEmpty, assertEqualDatabases, assertEqualReaders, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEqualStreams, assertFalse, assertFalse, assertKnownException, assertKnownException, assertNotContaining, assertNotNull, assertNotNull, assertNull, assertResult, assertResultRowCount, assertResultSetMeta, assertResultSetOrdered, assertResultSetOrdered, assertSame, assertSingleValue, assertSmaller, assertStartsWith, assertThrows, assertThrows, assertThrows, assertThrows, assertThrows, assertThrows, assertThrows, assertThrows, assertTrue, assertTrue, checkErrorCode, crash, createCaller, createFailingStream, eatMemory, execute, execute, fail, fail, freeMemory, getBaseDir, getClassPath, getFilePassword, getJVM, getMemoryUsed, getMemoryUsedBytes, getPassword, getPassword, getPowerOffCount, getSize, getTestDir, getTestName, getUser, init, init, isEnabled, logError, logErrorMessage, println, printTime, printTimeMemory, readString, runTest, setPowerOffCount, testFromMain, throwException, trace, trace, traceMemory
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.h2.api.AggregateFunction
init
-
-
-
-
Method Detail
-
main
public static void main(java.lang.String... a) throws java.lang.ExceptionRun just this test.- Parameters:
a- ignored- Throws:
java.lang.Exception
-
test
public void test() throws java.lang.ExceptionDescription copied from class:org.h2.test.TestBaseThis method will be called by the test framework.- Specified by:
testin classorg.h2.test.TestBase- Throws:
java.lang.Exception- if an exception in the test occurs
-
simpleFunctionTable
public static java.sql.ResultSet simpleFunctionTable(java.sql.Connection conn)
This method is called via reflection from the database.- Parameters:
conn- the connection- Returns:
- a result set
-
functionTableWithParameter
public static java.sql.ResultSet functionTableWithParameter(java.sql.Connection conn, int p)This method is called via reflection from the database.- Parameters:
conn- the connectionp- the parameter- Returns:
- a result set
-
varArgsFunctionTable
public static java.sql.ResultSet varArgsFunctionTable(int... values) throws java.sql.SQLExceptionThis method is called via reflection from the database.- Parameters:
values- the value array- Returns:
- a result set
- Throws:
java.sql.SQLException
-
toChar
public static Value toChar(Value... args)
This method is called via reflection from the database.- Parameters:
args- the argument list- Returns:
- the value
-
testDefaultConn
public static void testDefaultConn() throws java.sql.SQLExceptionThis method is called via reflection from the database.- Throws:
java.sql.SQLException
-
arrayParameters1
public static java.lang.Integer[][] arrayParameters1(java.lang.String[][] x)
This method is called with reflection.- Parameters:
x- argument- Returns:
- result
-
blob2stream
public static java.io.BufferedInputStream blob2stream(java.sql.Blob value) throws java.sql.SQLExceptionThis method is called via reflection from the database.- Parameters:
value- the blob- Returns:
- the input stream
- Throws:
java.sql.SQLException
-
blob
public static java.sql.Blob blob(java.sql.Blob value)
This method is called via reflection from the database.- Parameters:
value- the blob- Returns:
- the blob
-
clob
public static java.sql.Clob clob(java.sql.Clob value)
This method is called via reflection from the database.- Parameters:
value- the blob- Returns:
- the blob
-
stream2stream
public static java.io.BufferedInputStream stream2stream(java.io.InputStream value)
This method is called via reflection from the database.- Parameters:
value- the input stream- Returns:
- the buffered input stream
-
addRow
public static int addRow(java.sql.Connection conn, int id, java.lang.String name) throws java.sql.SQLExceptionThis method is called via reflection from the database.- Parameters:
conn- the connectionid- the test idname- the text- Returns:
- the count
- Throws:
java.sql.SQLException
-
select
public static java.sql.ResultSet select(java.sql.Connection conn, java.lang.String sql) throws java.sql.SQLExceptionThis method is called via reflection from the database.- Parameters:
conn- the connectionsql- the SQL statement- Returns:
- the result set
- Throws:
java.sql.SQLException
-
selectMaxId
public static java.sql.ResultSet selectMaxId(java.sql.Connection conn) throws java.sql.SQLExceptionThis method is called via reflection from the database.- Parameters:
conn- the connection- Returns:
- the result set
- Throws:
java.sql.SQLException
-
getArray
public static java.lang.String[] getArray()
This method is called via reflection from the database.- Returns:
- the test array
-
resultSetWithNull
public static java.sql.ResultSet resultSetWithNull(java.sql.Connection conn) throws java.sql.SQLExceptionThis method is called via reflection from the database.- Parameters:
conn- the connection- Returns:
- the result set
- Throws:
java.sql.SQLException
-
simpleResultSet
public static java.sql.ResultSet simpleResultSet(java.lang.Integer rowCount, int ip, boolean bp, float fp, double dp, long lp, byte byParam, short sp)Test method to create a simple result set.- Parameters:
rowCount- the number of rowsip- an intbp- a booleanfp- a floatdp- a doublelp- a longbyParam- a bytesp- a short- Returns:
- a result set
-
root
public static int root(int value)
This method is called via reflection from the database.- Parameters:
value- the value- Returns:
- the square root
-
mean
public static double mean()
This method is called via reflection from the database.- Returns:
- 1
-
noOp
public static java.math.BigDecimal noOp(java.math.BigDecimal dec)
This method is called via reflection from the database.- Parameters:
dec- the value- Returns:
- the value
-
getCount
public static int getCount()
This method is called via reflection from the database.- Returns:
- the count
-
reverse
public static java.lang.String reverse(java.lang.String s)
This method is called via reflection from the database.- Parameters:
s- the string- Returns:
- the string, reversed
-
mean
public static double mean(double... values)
This method is called via reflection from the database.- Parameters:
values- the values- Returns:
- the mean value
-
mean2
public static double mean2(java.sql.Connection conn, double... values)This method is called via reflection from the database.- Parameters:
conn- the connectionvalues- the values- Returns:
- the mean value
-
printMean
public static java.lang.String printMean(java.lang.String prefix, double... values)This method is called via reflection from the database.- Parameters:
prefix- the print prefixvalues- the values- Returns:
- the text
-
xorUUID
public static java.util.UUID xorUUID(java.util.UUID a, java.util.UUID b)This method is called via reflection from the database.- Parameters:
a- the first UUIDb- the second UUID- Returns:
- a xor b
-
dynamic
public static java.lang.String[] dynamic(java.lang.String[] args)
This method is called via reflection from the database.- Parameters:
args- the argument list- Returns:
- an array of one element
-
currentTimestampOverride
public static long currentTimestampOverride()
This method is called via reflection from the database.- Returns:
- a fixed number
-
add
public void add(java.lang.Object value)
Description copied from interface:AggregateFunctionThis method is called once for each row. If the aggregate function is called with multiple parameters, those are passed as array.- Specified by:
addin interfaceAggregateFunction- Parameters:
value- the value(s) for this row
-
getResult
public java.lang.Object getResult()
Description copied from interface:AggregateFunctionThis method returns the computed aggregate value. This method must preserve previously added values and must be able to reevaluate result if more values were added since its previous invocation.- Specified by:
getResultin interfaceAggregateFunction- Returns:
- the aggregated value
-
getType
public int getType(int[] inputTypes)
Description copied from interface:AggregateFunctionThis method must return the SQL type of the method, given the SQL type of the input data. The method should check here if the number of parameters passed is correct, and if not it should throw an exception.- Specified by:
getTypein interfaceAggregateFunction- Parameters:
inputTypes- the SQL type of the parameters,Types- Returns:
- the SQL type of the result
-
-