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 class 
    This median implementation keeps all objects in memory.
    static class 
    This median implementation keeps all objects in memory.

    Nested classes/interfaces inherited from class org.h2.test.TestDb

    org.h2.test.TestDb.Child

    Nested 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(Object value)
    This method is called once for each row.
    static int
    addRow(Connection conn, int id, String name)
    This method is called via reflection from the database.
    static Integer[][]
    This method is called with reflection.
    static Blob
    blob(Blob value)
    This method is called via reflection from the database.
    This method is called via reflection from the database.
    static Clob
    clob(Clob value)
    This method is called via reflection from the database.
    static long
    This method is called via reflection from the database.
    static String[]
    dynamic(String[] args)
    This method is called via reflection from the database.
    static ResultSet
    This method is called via reflection from the database.
    static String[]
    This method is called via reflection from the database.
    static int
    This method is called via reflection from the database.
    This method returns the computed aggregate value.
    int
    getType(int[] inputTypes)
    This method must return the SQL type of the method, given the SQL type of the input data.
    static void
    main(String... a)
    Run just this test.
    static double
    This method is called via reflection from the database.
    static double
    mean(double... values)
    This method is called via reflection from the database.
    static double
    mean2(Connection conn, double... values)
    This method is called via reflection from the database.
    static BigDecimal
    This method is called via reflection from the database.
    static String
    printMean(String prefix, double... values)
    This method is called via reflection from the database.
    static ResultSet
    This method is called via reflection from the database.
    static String
    This method is called via reflection from the database.
    static int
    root(int value)
    This method is called via reflection from the database.
    static ResultSet
    select(Connection conn, String sql)
    This method is called via reflection from the database.
    static ResultSet
    This method is called via reflection from the database.
    static ResultSet
    This method is called via reflection from the database.
    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.
    This method is called via reflection from the database.
    void
    This method will be called by the test framework.
    static void
    This method is called via reflection from the database.
    static Value
    toChar(Value... args)
    This method is called via reflection from the database.
    static ResultSet
    varArgsFunctionTable(int... values)
    This method is called via reflection from the database.
    static UUID
    xorUUID(UUID a, 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
  • Constructor Details

    • TestFunctions

      public TestFunctions()
  • Method Details

    • main

      public static void main(String... a) throws Exception
      Run just this test.
      Parameters:
      a - ignored
      Throws:
      Exception
    • test

      public void test() throws Exception
      Description copied from class: org.h2.test.TestBase
      This method will be called by the test framework.
      Specified by:
      test in class org.h2.test.TestBase
      Throws:
      Exception - if an exception in the test occurs
    • simpleFunctionTable

      public static ResultSet simpleFunctionTable(Connection conn)
      This method is called via reflection from the database.
      Parameters:
      conn - the connection
      Returns:
      a result set
    • functionTableWithParameter

      public static ResultSet functionTableWithParameter(Connection conn, int p)
      This method is called via reflection from the database.
      Parameters:
      conn - the connection
      p - the parameter
      Returns:
      a result set
    • varArgsFunctionTable

      public static ResultSet varArgsFunctionTable(int... values) throws SQLException
      This method is called via reflection from the database.
      Parameters:
      values - the value array
      Returns:
      a result set
      Throws:
      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 SQLException
      This method is called via reflection from the database.
      Throws:
      SQLException
    • arrayParameters1

      public static Integer[][] arrayParameters1(String[][] x)
      This method is called with reflection.
      Parameters:
      x - argument
      Returns:
      result
    • blob2stream

      public static BufferedInputStream blob2stream(Blob value) throws SQLException
      This method is called via reflection from the database.
      Parameters:
      value - the blob
      Returns:
      the input stream
      Throws:
      SQLException
    • blob

      public static Blob blob(Blob value)
      This method is called via reflection from the database.
      Parameters:
      value - the blob
      Returns:
      the blob
    • clob

      public static Clob clob(Clob value)
      This method is called via reflection from the database.
      Parameters:
      value - the blob
      Returns:
      the blob
    • stream2stream

      public static BufferedInputStream stream2stream(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(Connection conn, int id, String name) throws SQLException
      This method is called via reflection from the database.
      Parameters:
      conn - the connection
      id - the test id
      name - the text
      Returns:
      the count
      Throws:
      SQLException
    • select

      public static ResultSet select(Connection conn, String sql) throws SQLException
      This method is called via reflection from the database.
      Parameters:
      conn - the connection
      sql - the SQL statement
      Returns:
      the result set
      Throws:
      SQLException
    • selectMaxId

      public static ResultSet selectMaxId(Connection conn) throws SQLException
      This method is called via reflection from the database.
      Parameters:
      conn - the connection
      Returns:
      the result set
      Throws:
      SQLException
    • getArray

      public static String[] getArray()
      This method is called via reflection from the database.
      Returns:
      the test array
    • resultSetWithNull

      public static ResultSet resultSetWithNull(Connection conn) throws SQLException
      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 rows
      ip - an int
      bp - a boolean
      fp - a float
      dp - a double
      lp - a long
      byParam - a byte
      sp - 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 BigDecimal noOp(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 String reverse(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(Connection conn, double... values)
      This method is called via reflection from the database.
      Parameters:
      conn - the connection
      values - the values
      Returns:
      the mean value
    • printMean

      public static String printMean(String prefix, double... values)
      This method is called via reflection from the database.
      Parameters:
      prefix - the print prefix
      values - the values
      Returns:
      the text
    • xorUUID

      public static UUID xorUUID(UUID a, UUID b)
      This method is called via reflection from the database.
      Parameters:
      a - the first UUID
      b - the second UUID
      Returns:
      a xor b
    • dynamic

      public static String[] dynamic(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(Object value)
      Description copied from interface: AggregateFunction
      This method is called once for each row. If the aggregate function is called with multiple parameters, those are passed as array.
      Specified by:
      add in interface AggregateFunction
      Parameters:
      value - the value(s) for this row
    • getResult

      public Object getResult()
      Description copied from interface: AggregateFunction
      This 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:
      getResult in interface AggregateFunction
      Returns:
      the aggregated value
    • getType

      public int getType(int[] inputTypes)
      Description copied from interface: AggregateFunction
      This 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:
      getType in interface AggregateFunction
      Parameters:
      inputTypes - the SQL type of the parameters, Types
      Returns:
      the SQL type of the result