protected void checkLeaks() {
   int finalOpenSessions = CoreInstance.getInstance().getNumberOfSessions();
   int leakedOpenSessions = finalOpenSessions - initialOpenSessions;
   if (leakedOpenSessions != 0) {
     log.error(
         String.format(
             "There are %s open session(s) at tear down; it seems "
                 + "the test leaked %s session(s).",
             Integer.valueOf(finalOpenSessions), Integer.valueOf(leakedOpenSessions)));
     for (CoreInstance.RegistrationInfo info : CoreInstance.getInstance().getRegistrationInfos()) {
       log.warn("Leaking session", info);
     }
   }
   int finalSingleConnections = ConnectionHelper.countConnectionReferences();
   int leakedSingleConnections = finalSingleConnections - initialSingleConnections;
   if (leakedSingleConnections > 0) {
     log.error(
         String.format(
             "There are %s single datasource connection(s) open at tear down; "
                 + "the test leaked %s connection(s).",
             Integer.valueOf(finalSingleConnections), Integer.valueOf(leakedSingleConnections)));
   }
   ConnectionHelper.clearConnectionReferences();
 }
 protected static CoreSession getSessionFromDoc(DocumentModel doc) {
   return CoreInstance.getInstance().getSession(doc.getSessionId());
 }
 protected void initCheckLeaks() {
   initialOpenSessions = CoreInstance.getInstance().getNumberOfSessions();
   initialSingleConnections = ConnectionHelper.countConnectionReferences();
 }
 protected CoreSession getCoreSession() {
   String coreSessionId = treeRoot == null ? sessionId : treeRoot.getSessionId();
   return CoreInstance.getInstance().getSession(coreSessionId);
 }