Class TestListener

java.lang.Object
org.h2.test.TestBase
org.h2.test.TestDb
org.h2.test.db.TestListener
All Implemented Interfaces:
EventListener, DatabaseEventListener

public class TestListener extends org.h2.test.TestDb implements DatabaseEventListener
Tests the DatabaseEventListener.
  • Nested Class Summary

    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
    This method is called before the database is closed normally.
    void
    This method is called if an exception occurred.
    void
    init(String url)
    This method is called just after creating the object.
    boolean
     
    static void
    main(String... a)
    Run just this test.
    void
    This method is called after the database has been opened.
    void
    setProgress(int state, String name, long current, long max)
    This method is called for long running events, such as recovering, scanning a file or building an index.
    void
    This method will be called by the test framework.

    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, 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
  • Constructor Details

    • TestListener

      public TestListener()
  • Method Details

    • main

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

      public boolean isEnabled()
      Overrides:
      isEnabled in class org.h2.test.TestBase
      Returns:
      whether this test is enabled in the current configuration
    • test

      public void test() throws SQLException
      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:
      SQLException
    • exceptionThrown

      public void exceptionThrown(SQLException e, String sql)
      Description copied from interface: DatabaseEventListener
      This method is called if an exception occurred.
      Specified by:
      exceptionThrown in interface DatabaseEventListener
      Parameters:
      e - the exception
      sql - the SQL statement
    • setProgress

      public void setProgress(int state, String name, long current, long max)
      Description copied from interface: DatabaseEventListener
      This method is called for long running events, such as recovering, scanning a file or building an index.

      More states might be added in future versions, therefore implementations should silently ignore states that they don't understand.

      Specified by:
      setProgress in interface DatabaseEventListener
      Parameters:
      state - the state
      name - the object name
      current - the current position
      max - the highest possible value or 0 if unknown
    • closingDatabase

      public void closingDatabase()
      Description copied from interface: DatabaseEventListener
      This method is called before the database is closed normally. It is safe to connect to the database and execute statements at this point, however the connection must be closed before the method returns.
      Specified by:
      closingDatabase in interface DatabaseEventListener
    • init

      public void init(String url)
      Description copied from interface: DatabaseEventListener
      This method is called just after creating the object. This is done when opening the database if the listener is specified in the database URL, but may be later if the listener is set at runtime with the SET SQL statement.
      Specified by:
      init in interface DatabaseEventListener
      Parameters:
      url - - the database URL
    • opened

      public void opened()
      Description copied from interface: DatabaseEventListener
      This method is called after the database has been opened. It is safe to connect to the database and execute statements at this point.
      Specified by:
      opened in interface DatabaseEventListener