cucumber.runtime.java.spring.hooks
Class SpringTransactionHooks

java.lang.Object
  extended by cucumber.runtime.java.spring.hooks.SpringTransactionHooks
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware

public class SpringTransactionHooks
extends Object
implements org.springframework.beans.factory.BeanFactoryAware

This class defines before and after hooks which provide automatic spring rollback capabilities. These hooks will apply to any element(s) within a .feature file tagged with @txn.

Clients wishing to leverage these hooks should include this class' package in the glue property of the Test class' Cucumber.Options annotation.

The BEFORE and AFTER hooks both rely on being able to obtain a PlatformTransactionManager by type, or by an optionally specified bean name, from the runtime BeanFactory.

NOTE: This class is NOT threadsafe! It relies on the fact that cucumber-jvm will instantiate an instance of any applicable hookdef class per scenario run.


Constructor Summary
SpringTransactionHooks()
           
 
Method Summary
 String getTxnManagerBeanName()
           
 void rollBackAfterHook()
           
 void rollBackBeforeHook()
           
 void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
           
 void setTxnManagerBeanName(String txnManagerBeanName)
          Setter to allow (optional) bean name to be specified for transaction manager bean - if null, attempt will be made to find a transaction manager by bean type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpringTransactionHooks

public SpringTransactionHooks()
Method Detail

setBeanFactory

public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
                    throws org.springframework.beans.BeansException
Specified by:
setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
Throws:
org.springframework.beans.BeansException

getTxnManagerBeanName

public String getTxnManagerBeanName()
Returns:
the (optional) bean name for the transaction manager to be obtained - if null, attempt will be made to find a transaction manager by bean type

setTxnManagerBeanName

public void setTxnManagerBeanName(String txnManagerBeanName)
Setter to allow (optional) bean name to be specified for transaction manager bean - if null, attempt will be made to find a transaction manager by bean type

Parameters:
txnManagerBeanName - bean name of transaction manager bean

rollBackBeforeHook

public void rollBackBeforeHook()

rollBackAfterHook

public void rollBackAfterHook()


Copyright © 2012. All Rights Reserved.