public final class Sniffer extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Sniffer.Executable
Executable interface is similar to
Runnable but it allows throwing Exception
from it's Sniffer.Executable.execute() method |
Modifier and Type | Method and Description |
---|---|
static <V> SpyWithValue<V> |
call(Callable<V> callable)
Execute the
Callable.call() method, record the SQL queries
and return the SpyWithValue object with stats |
static void |
enterJdbcMethod() |
static Spy |
execute(Sniffer.Executable executable)
Execute the
Sniffer.Executable.execute() method, record the SQL queries
and return the Spy object with stats |
static int |
executedStatements()
Deprecated.
|
static StatementMetaData |
executeStatement(String sql,
long elapsedTime,
String stackTrace) |
static StatementMetaData |
executeStatement(String sql,
long elapsedTime,
String stackTrace,
int rowsUpdated) |
static void |
exitJdbcMethod(Method method,
long elapsedTime) |
static Spy |
expect(int allowedStatements)
Deprecated.
|
static Spy |
expect(int allowedStatements,
Query query)
Deprecated.
|
static Spy |
expect(int allowedStatements,
Query query,
Threads threadMatcher)
Deprecated.
|
static Spy |
expect(int allowedStatements,
Threads threadMatcher)
Deprecated.
|
static Spy |
expect(int allowedStatements,
Threads threadMatcher,
Query query)
Deprecated.
|
static Spy |
expect(List<Expectation> expectationList) |
static Spy |
expect(Spy.Expectation expectation) |
static Spy |
expectAtLeast(int allowedStatements)
Deprecated.
|
static Spy |
expectAtLeast(int allowedStatements,
Query query)
Deprecated.
|
static Spy |
expectAtLeast(int allowedStatements,
Query query,
Threads threadMatcher)
Deprecated.
|
static Spy |
expectAtLeast(int allowedStatements,
Threads threadMatcher)
Deprecated.
|
static Spy |
expectAtLeast(int allowedStatements,
Threads threadMatcher,
Query query)
Deprecated.
|
static Spy |
expectAtMost(int allowedStatements)
Deprecated.
|
static Spy |
expectAtMost(int allowedStatements,
Query query)
Deprecated.
|
static Spy |
expectAtMost(int allowedStatements,
Query query,
Threads threadMatcher)
Deprecated.
|
static Spy |
expectAtMost(int allowedStatements,
Threads threadMatcher)
Deprecated.
|
static Spy |
expectAtMost(int allowedStatements,
Threads threadMatcher,
Query query)
Deprecated.
|
static Spy |
expectAtMostOnce()
Deprecated.
|
static Spy |
expectAtMostOnce(Query query)
Deprecated.
|
static Spy |
expectAtMostOnce(Query query,
Threads threadMatcher)
Deprecated.
|
static Spy |
expectAtMostOnce(Threads threadMatcher)
Deprecated.
|
static Spy |
expectAtMostOnce(Threads threadMatcher,
Query query)
Deprecated.
|
static Spy |
expectBetween(int minAllowedStatements,
int maxAllowedStatements)
Deprecated.
|
static Spy |
expectBetween(int minAllowedStatements,
int maxAllowedStatements,
Query query)
Deprecated.
|
static Spy |
expectBetween(int minAllowedStatements,
int maxAllowedStatements,
Query query,
Threads threadMatcher)
Deprecated.
|
static Spy |
expectBetween(int minAllowedStatements,
int maxAllowedStatements,
Threads threadMatcher)
Deprecated.
|
static Spy |
expectBetween(int minAllowedStatements,
int maxAllowedStatements,
Threads threadMatcher,
Query query)
Deprecated.
|
static Spy |
expectNever()
Deprecated.
|
static Spy |
expectNever(Query query)
Deprecated.
|
static Spy |
expectNever(Query query,
Threads threadMatcher)
Deprecated.
|
static Spy |
expectNever(Threads threadMatcher)
Deprecated.
|
static Spy |
expectNever(Threads threadMatcher,
Query query)
Deprecated.
|
static void |
initialize() |
static void |
logSocket(String stackTrace,
int connectionId,
InetSocketAddress address,
long elapsedTime,
int bytesDown,
int bytesUp) |
static void |
readDatabaseRow(Method method,
long elapsedTime,
StatementMetaData statementMetaData) |
protected static List<WeakReference<Spy>> |
registeredSpies() |
protected static WeakReference<Spy> |
registerSpy(Spy spy) |
protected static void |
removeSpyReference(WeakReference<Spy> spyReference) |
static Spy |
run(Runnable runnable)
Execute the
Runnable.run() method, record the SQL queries
and return the Spy object with stats |
static <T extends Spy<T>> |
spy() |
static <T extends Spy<T>> |
spyCurrentThread() |
public static void initialize()
protected static WeakReference<Spy> registerSpy(Spy spy)
protected static void removeSpyReference(WeakReference<Spy> spyReference)
protected static List<WeakReference<Spy>> registeredSpies()
public static void logSocket(String stackTrace, int connectionId, InetSocketAddress address, long elapsedTime, int bytesDown, int bytesUp)
public static void enterJdbcMethod()
public static void exitJdbcMethod(Method method, long elapsedTime)
public static void readDatabaseRow(Method method, long elapsedTime, StatementMetaData statementMetaData)
public static StatementMetaData executeStatement(String sql, long elapsedTime, String stackTrace)
public static StatementMetaData executeStatement(String sql, long elapsedTime, String stackTrace, int rowsUpdated)
public static <T extends Spy<T>> Spy<? extends Spy<T>> spy()
Spy
instancepublic static <T extends Spy<T>> Spy<? extends Spy<T>> spyCurrentThread()
Spy
instancepublic static Spy expect(Spy.Expectation expectation)
public static Spy expect(List<Expectation> expectationList)
expectationList
- a list of Expectation
annotationsSpy
instance with given expectationsspy()
public static Spy execute(Sniffer.Executable executable)
Sniffer.Executable.execute()
method, record the SQL queries
and return the Spy
object with statsexecutable
- code to testRuntimeException
- if underlying code under test throws an Exceptionpublic static Spy run(Runnable runnable)
Runnable.run()
method, record the SQL queries
and return the Spy
object with statsrunnable
- code to testpublic static <V> SpyWithValue<V> call(Callable<V> callable) throws Exception
Callable.call()
method, record the SQL queries
and return the SpyWithValue
object with statsV
- type of return valuecallable
- code to testException
- if underlying code under test throws an Exception@Deprecated public static int executedStatements()
@Deprecated public static Spy expectNever()
Spy
instance with an expectation initializedspy()
,
Spy.expectNever()
@Deprecated public static Spy expectNever(Threads threadMatcher)
Spy
instance with an expectation initializedspy()
,
Spy.expectNever(Threads)
@Deprecated public static Spy expectNever(Query query)
Spy
instance with an expectation initializedspy()
,
Spy.expectNever(Query)
@Deprecated public static Spy expectNever(Threads threadMatcher, Query query)
Spy
instance with an expectation initializedspy()
,
Spy.expectNever(Threads, Query)
@Deprecated public static Spy expectNever(Query query, Threads threadMatcher)
Spy
instance with an expectation initializedspy()
,
Spy.expectNever(Threads, Query)
@Deprecated public static Spy expectAtMostOnce()
Spy
instance with an expectation initializedspy()
,
Spy.expectAtMostOnce()
@Deprecated public static Spy expectAtMostOnce(Threads threadMatcher)
Spy
instance with an expectation initializedspy()
,
Spy.expectAtMostOnce(Threads)
@Deprecated public static Spy expectAtMostOnce(Query query)
Spy
instance with an expectation initializedspy()
,
Spy.expectAtMostOnce(Query)
@Deprecated public static Spy expectAtMostOnce(Threads threadMatcher, Query query)
Spy
instance with an expectation initializedspy()
,
Spy.expectAtMostOnce(Threads, Query)
@Deprecated public static Spy expectAtMostOnce(Query query, Threads threadMatcher)
Spy
instance with an expectation initializedspy()
,
Spy.expectAtMostOnce(Threads, Query)
@Deprecated public static Spy expectAtMost(int allowedStatements)
Spy
instance with an expectation initializedspy()
,
Spy.expectAtMost(int)
@Deprecated public static Spy expectAtMost(int allowedStatements, Threads threadMatcher)
Spy
instance with an expectation initializedspy()
,
Spy.expectAtMost(int, Threads)
@Deprecated public static Spy expectAtMost(int allowedStatements, Query query)
Spy
instance with an expectation initializedspy()
,
Spy.expectAtMost(int, Query)
@Deprecated public static Spy expectAtMost(int allowedStatements, Threads threadMatcher, Query query)
Spy
instance with an expectation initializedspy()
,
Spy.expectAtMost(int, Threads, Query)
@Deprecated public static Spy expectAtMost(int allowedStatements, Query query, Threads threadMatcher)
Spy
instance with an expectation initializedspy()
,
Spy.expectAtMost(int, Threads, Query)
@Deprecated public static Spy expect(int allowedStatements)
Spy
instance with an expectation initializedspy()
,
Spy.expect(int)
@Deprecated public static Spy expect(int allowedStatements, Threads threadMatcher)
Spy
instance with an expectation initializedspy()
,
Spy.expect(int, Threads)
@Deprecated public static Spy expect(int allowedStatements, Query query)
Spy
instance with an expectation initializedspy()
,
Spy.expect(int, Query)
@Deprecated public static Spy expect(int allowedStatements, Threads threadMatcher, Query query)
Spy
instance with an expectation initializedspy()
,
Spy.expect(int, Threads, Query)
@Deprecated public static Spy expect(int allowedStatements, Query query, Threads threadMatcher)
Spy
instance with an expectation initializedspy()
,
Spy.expect(int, Threads, Query)
@Deprecated public static Spy expectAtLeast(int allowedStatements)
Spy
instance with an expectation initializedspy()
,
Spy.expectAtLeast(int)
@Deprecated public static Spy expectAtLeast(int allowedStatements, Threads threadMatcher)
Spy
instance with an expectation initializedspy()
,
Spy.expectAtLeast(int, Threads)
@Deprecated public static Spy expectAtLeast(int allowedStatements, Query query)
Spy
instance with an expectation initializedspy()
,
Spy.expectAtLeast(int, Query)
@Deprecated public static Spy expectAtLeast(int allowedStatements, Threads threadMatcher, Query query)
Spy
instance with an expectation initializedspy()
,
Spy.expectAtLeast(int, Threads, Query)
@Deprecated public static Spy expectAtLeast(int allowedStatements, Query query, Threads threadMatcher)
Spy
instance with an expectation initializedspy()
,
Spy.expectAtLeast(int, Threads, Query)
@Deprecated public static Spy expectBetween(int minAllowedStatements, int maxAllowedStatements)
Spy
instance with an expectation initializedspy()
,
Spy.expectBetween(int, int)
@Deprecated public static Spy expectBetween(int minAllowedStatements, int maxAllowedStatements, Threads threadMatcher)
Spy
instance with an expectation initializedspy()
,
Spy.expectBetween(int, int, Threads)
@Deprecated public static Spy expectBetween(int minAllowedStatements, int maxAllowedStatements, Query query)
Spy
instance with an expectation initializedspy()
,
Spy.expectBetween(int, int, Query)
@Deprecated public static Spy expectBetween(int minAllowedStatements, int maxAllowedStatements, Threads threadMatcher, Query query)
Spy
instance with an expectation initializedspy()
,
Spy.expectBetween(int, int, Threads, Query)
@Deprecated public static Spy expectBetween(int minAllowedStatements, int maxAllowedStatements, Query query, Threads threadMatcher)
Spy
instance with an expectation initializedspy()
,
Spy.expectBetween(int, int, Threads, Query)
Copyright © 2016. All rights reserved.