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
Tests for user defined functions and aggregates.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis median implementation keeps all objects in memory.static classThis median implementation keeps all objects in memory.Nested classes/interfaces inherited from class org.h2.test.TestDb
org.h2.test.TestDb.ChildNested classes/interfaces inherited from class org.h2.test.TestBase
org.h2.test.TestBase.VoidCallable -
Field Summary
Fields inherited from class org.h2.test.TestBase
BASE_TEST_DIR, config, start, uniqueId -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThis method is called once for each row.static intaddRow(Connection conn, int id, String name) This method is called via reflection from the database.static Integer[][]arrayParameters1(String[][] x) This method is called with reflection.static BlobThis method is called via reflection from the database.static BufferedInputStreamblob2stream(Blob value) This method is called via reflection from the database.static ClobThis method is called via reflection from the database.static longThis method is called via reflection from the database.static String[]This method is called via reflection from the database.static ResultSetfunctionTableWithParameter(Connection conn, int p) This method is called via reflection from the database.static String[]getArray()This method is called via reflection from the database.static intgetCount()This method is called via reflection from the database.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 voidRun 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(Connection conn, double... values) This method is called via reflection from the database.static BigDecimalnoOp(BigDecimal dec) This method is called via reflection from the database.static StringThis method is called via reflection from the database.static ResultSetresultSetWithNull(Connection conn) This method is called via reflection from the database.static StringThis method is called via reflection from the database.static introot(int value) This method is called via reflection from the database.static ResultSetselect(Connection conn, String sql) This method is called via reflection from the database.static ResultSetselectMaxId(Connection conn) This method is called via reflection from the database.static ResultSetThis method is called via reflection from the database.static ResultSetsimpleResultSet(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 BufferedInputStreamstream2stream(InputStream value) This method is called via reflection from the database.voidtest()This method will be called by the test framework.static voidThis method is called via reflection from the database.static ValueThis method is called via reflection from the database.static ResultSetvarArgsFunctionTable(int... values) This method is called via reflection from the database.static UUIDThis method is called via reflection from the database.Methods inherited from class org.h2.test.TestDb
buildChild, deleteDb, deleteDb, getConnection, getConnection, getURLMethods 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, traceMemoryMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.h2.api.AggregateFunction
init
-
Constructor Details
-
TestFunctions
public TestFunctions()
-
-
Method Details
-
main
Run just this test.- Parameters:
a- ignored- Throws:
Exception
-
test
Description copied from class:org.h2.test.TestBaseThis method will be called by the test framework.- Specified by:
testin classorg.h2.test.TestBase- Throws:
Exception- if an exception in the test occurs
-
simpleFunctionTable
This method is called via reflection from the database.- Parameters:
conn- the connection- Returns:
- a result set
-
functionTableWithParameter
This method is called via reflection from the database.- Parameters:
conn- the connectionp- the parameter- Returns:
- a result set
-
varArgsFunctionTable
This method is called via reflection from the database.- Parameters:
values- the value array- Returns:
- a result set
- Throws:
SQLException
-
toChar
This method is called via reflection from the database.- Parameters:
args- the argument list- Returns:
- the value
-
testDefaultConn
This method is called via reflection from the database.- Throws:
SQLException
-
arrayParameters1
This method is called with reflection.- Parameters:
x- argument- Returns:
- result
-
blob2stream
This method is called via reflection from the database.- Parameters:
value- the blob- Returns:
- the input stream
- Throws:
SQLException
-
blob
This method is called via reflection from the database.- Parameters:
value- the blob- Returns:
- the blob
-
clob
This method is called via reflection from the database.- Parameters:
value- the blob- Returns:
- the blob
-
stream2stream
This method is called via reflection from the database.- Parameters:
value- the input stream- Returns:
- the buffered input stream
-
addRow
This method is called via reflection from the database.- Parameters:
conn- the connectionid- the test idname- the text- Returns:
- the count
- Throws:
SQLException
-
select
This method is called via reflection from the database.- Parameters:
conn- the connectionsql- the SQL statement- Returns:
- the result set
- Throws:
SQLException
-
selectMaxId
This method is called via reflection from the database.- Parameters:
conn- the connection- Returns:
- the result set
- Throws:
SQLException
-
getArray
This method is called via reflection from the database.- Returns:
- the test array
-
resultSetWithNull
This method is called via reflection from the database.- Parameters:
conn- the connection- Returns:
- the result set
- Throws:
SQLException
-
simpleResultSet
public static ResultSet simpleResultSet(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
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
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
This method is called via reflection from the database.- Parameters:
conn- the connectionvalues- the values- Returns:
- the mean value
-
printMean
This method is called via reflection from the database.- Parameters:
prefix- the print prefixvalues- the values- Returns:
- the text
-
xorUUID
This method is called via reflection from the database.- Parameters:
a- the first UUIDb- the second UUID- Returns:
- a xor b
-
dynamic
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
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
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
-