Package org.jtester.core.context

Examples of org.jtester.core.context.TransactionManager


    Class testedClazz = TestedObject.currTestedClazz();
    ThreadLocal<TransactionManager> clazzLocal = localTransactionManager.get(testedClazz);
    if (clazzLocal == null) {
      return null;
    } else {
      TransactionManager transaction = clazzLocal.get();
      return transaction;
    }
  }
View Full Code Here


  /**
   * 设置当前线程的事务
   */
  public static void setLocalTransactionManager() {
    Class testedClazz = TestedObject.currTestedClazz();
    TransactionManager transaction = new TransactionManager();
    ThreadLocal<TransactionManager> clazzLocal = new ThreadLocal<TransactionManager>();
    {
      clazzLocal.set(transaction);
    }
    localTransactionManager.put(testedClazz, clazzLocal);
View Full Code Here

    if (clazzLocal == null) {
      return;
    }
    try {
      // 强行结束已经存在的事务, 如果有?
      TransactionManager transactionManager = clazzLocal.get();
      transactionManager.forceEnd();
    } catch (Throwable e) {
      e.printStackTrace();
      // do nothing
    }
    clazzLocal.remove();
View Full Code Here

    }

    @Override
    public void beforeMethodRunning(Object testObject, Method testMethod) {
      boolean isEnabledTransaction = TestedObject.isTransactionsEnabled();
      TransactionManager transaction = TestedObject.getLocalTransactionManager();
      if (isEnabledTransaction && transaction != null) {
        transaction.startTransaction();
      }
    }
View Full Code Here

    }

    @Override
    public void afterMethodRunned(Object testObject, Method testMethod, Throwable testThrowable) {
      boolean isEnabledTransaction = TestedObject.isTransactionsEnabled();
      TransactionManager transaction = TestedObject.getLocalTransactionManager();
      if (isEnabledTransaction && transaction != null) {
        transaction.endTransaction();
      }
    }
View Full Code Here

TOP

Related Classes of org.jtester.core.context.TransactionManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.