com.ap.jdbcunit
Class SelectsMediaRecorder

java.lang.Object
  extended bycom.ap.jdbcunit.SelectsMediaRecorder
All Implemented Interfaces:
Recorder

public class SelectsMediaRecorder
extends java.lang.Object
implements Recorder

A recorder that records only SELECT sql statements, it fails if some other statement is executed (like insert, update or delete).

This recorder is a light recorder implementation targeted for "read-only" JDBC applications.

This recorder is a light recorder because it easily can decide it some statement was already recorded and pick up the previous result. It also doesn't need to have any strategy about track versioning, all the tracks are version 1.

Finally, the recorded application can change, provided the same statements are reused, and still the recorded data remain valid.

Author:
Jean Lazarou

Constructor Summary
SelectsMediaRecorder(Media media)
           
 
Method Summary
 void add(java.lang.String dbURL, java.lang.String sql, java.sql.ResultSet rs)
          Records the given result set obtained after executing the given SQL statement on the given database
 void clear()
          Clears everything...
 boolean existsTrack(java.lang.String dbURL, java.lang.String sql)
          Returns true
 java.sql.ResultSet get(java.sql.Statement stmt, java.lang.String dbURL, java.lang.String sql)
          Retrieves a previously recorded SQL statement
 void start()
          Start the recorder, doesn't mean "entering" in recording mode, rather it means "swicth on" the recorder
 void stop()
          Stop the recorder ("switch off")
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelectsMediaRecorder

public SelectsMediaRecorder(Media media)
Method Detail

start

public void start()
Description copied from interface: Recorder
Start the recorder, doesn't mean "entering" in recording mode, rather it means "swicth on" the recorder

Specified by:
start in interface Recorder

stop

public void stop()
Description copied from interface: Recorder
Stop the recorder ("switch off")

Specified by:
stop in interface Recorder

clear

public void clear()
Description copied from interface: Recorder
Clears everything...

Specified by:
clear in interface Recorder

existsTrack

public boolean existsTrack(java.lang.String dbURL,
                           java.lang.String sql)
Description copied from interface: Recorder
Returns true

Specified by:
existsTrack in interface Recorder
Parameters:
dbURL - the database url
sql - the SQL statement
Returns:
true if recorder contains the track (the result set)

add

public void add(java.lang.String dbURL,
                java.lang.String sql,
                java.sql.ResultSet rs)
Description copied from interface: Recorder
Records the given result set obtained after executing the given SQL statement on the given database

Specified by:
add in interface Recorder
Parameters:
dbURL - the database URL
sql - the executed SQL statement
rs - the result of the query

get

public java.sql.ResultSet get(java.sql.Statement stmt,
                              java.lang.String dbURL,
                              java.lang.String sql)
Description copied from interface: Recorder
Retrieves a previously recorded SQL statement

Specified by:
get in interface Recorder
Parameters:
stmt - the @link{java.sql.Statement}
dbURL - database URL
sql - SQL statement string
Returns:
the result set