mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1183 - ENH: Add support for transaction profiling
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package io.ebeaninternal.server.transaction;
|
||||
|
||||
import io.ebean.config.ProfilingConfig;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class DefaultProfileHandlerTest {
|
||||
@Test
|
||||
public void createProfileStream() throws Exception {
|
||||
|
||||
DefaultProfileHandler handler = new DefaultProfileHandler(new ProfilingConfig());
|
||||
|
||||
assertNotNull(handler.createProfileStream(12));
|
||||
assertNull(handler.createProfileStream(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createProfileStream_when_specificIncludeIds() throws Exception {
|
||||
|
||||
ProfilingConfig config = new ProfilingConfig();
|
||||
config.setIncludeProfileIds(new int[]{100,101});
|
||||
|
||||
DefaultProfileHandler handler = new DefaultProfileHandler(config);
|
||||
|
||||
assertNotNull(handler.createProfileStream(100));
|
||||
assertNotNull(handler.createProfileStream(101));
|
||||
|
||||
assertNull(handler.createProfileStream(0));
|
||||
assertNull(handler.createProfileStream(12));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,12 +11,12 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Helper that can collect the SQL that is logged via SLF4J.
|
||||
* Helper that can collectTransactionProfile the SQL that is logged via SLF4J.
|
||||
* <p>
|
||||
* Used {@link #start()} and {@link #stop()} to collect the logged messages that contain the
|
||||
* Used {@link #start()} and {@link #stop()} to collectTransactionProfile the logged messages that contain the
|
||||
* executed SQL statements.
|
||||
* <p>
|
||||
* Internally this uses a Logback Appender to collect messages for org.avaje.ebean.SQL.
|
||||
* Internally this uses a Logback Appender to collectTransactionProfile messages for org.avaje.ebean.SQL.
|
||||
*/
|
||||
public class LoggedSqlCollector {
|
||||
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public class TestPersistenceContextScopeUsingOrders extends BaseTestCase {
|
||||
|
||||
assertTrue(!orders.isEmpty());
|
||||
|
||||
// collect the customer instances
|
||||
// collectTransactionProfile the customer instances
|
||||
List<Customer> customers = new ArrayList<>();
|
||||
Set<Integer> identities = new HashSet<>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user