java.lang.Object
io.ebean.test.LoggedSql
Provides access to the messages logged to
io.ebean.SQL.
This is here to allow easy access to the SQL that was executed during testing and if desired we can use that to perform asserts in tests.
// start capturing SQL log messages
LoggedSql.start();
List<Customer> customers =
Customer.find.where()
.name.ilike("rob%")
.findList();
assertNotNull(customers);
// perform an insert
new Product("ad", "asd").save()
// return the captured SQL log messages
// since LoggedSql.start()
List<String> sql = LoggedSql.stop();
assertThat(sql).hasSize(2);
assertThat(sql.get(0)).contains("from customer");
assertThat(sql.get(1)).contains("into product");
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncollect()Collect and return the messages/sql that was captured since the call to start() or collect().start()Start the capture of theio.ebean.SQLmessages.stop()Stop the capture of theio.ebean.SQLmessages and return the messages/sql that was captured since the call to start().
-
Constructor Details
-
LoggedSql
public LoggedSql()
-
-
Method Details
-
start
Start the capture of theio.ebean.SQLmessages. -
stop
Stop the capture of theio.ebean.SQLmessages and return the messages/sql that was captured since the call to start(). -
collect
Collect and return the messages/sql that was captured since the call to start() or collect().Unlike stop() collection of messages will continue.
-