Author: jonesde
Date: Tue Sep 11 00:15:30 2007 New Revision: 574493 URL: http://svn.apache.org/viewvc?rev=574493&view=rev Log: Added service to test case that is currently not working where a service with a transaction with rollback only set can't call a service in its own transaction Modified: ofbiz/trunk/framework/service/servicedef/services_test_se.xml ofbiz/trunk/framework/service/src/org/ofbiz/service/test/ServiceEngineTestServices.java ofbiz/trunk/framework/service/testdef/servicetests.xml Modified: ofbiz/trunk/framework/service/servicedef/services_test_se.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/servicedef/services_test_se.xml?rev=574493&r1=574492&r2=574493&view=diff ============================================================================== --- ofbiz/trunk/framework/service/servicedef/services_test_se.xml (original) +++ ofbiz/trunk/framework/service/servicedef/services_test_se.xml Tue Sep 11 00:15:30 2007 @@ -48,12 +48,21 @@ location="org.ofbiz.service.test.ServiceEngineTestServices" invoke="testServiceLockWaitTimeoutRetryWaiter"> </service> - <!-- lock wait timeout retry testing services - a scenario that I can't figure out yet how to recover automatically --> + <!-- lock wait timeout retry testing services - a scenario that we can't do automatically with the single service because the parent owns the tx we have to have end before it will succeed --> <service name="testServiceLockWaitTimeoutRetryCantRecover" engine="java" auth="false" transaction-timeout="2" location="org.ofbiz.service.test.ServiceEngineTestServices" invoke="testServiceLockWaitTimeoutRetryCantRecover"> <implements service="testServiceInterface"/> </service> <service name="testServiceLockWaitTimeoutRetryCantRecoverWaiter" engine="java" auth="false" transaction-timeout="4" location="org.ofbiz.service.test.ServiceEngineTestServices" invoke="testServiceLockWaitTimeoutRetryCantRecoverWaiter"> + </service> + + <!-- make sure that if rollback only is set on the tx of the parent service you can still run a child service in a separate tx --> + <service name="testServiceOwnTxSubServiceAfterSetRollbackOnlyInParent" engine="java" auth="false" + location="org.ofbiz.service.test.ServiceEngineTestServices" invoke="testServiceOwnTxSubServiceAfterSetRollbackOnlyInParent"> + <implements service="testServiceInterface"/> + </service> + <service name="testServiceOwnTxSubServiceAfterSetRollbackOnlyInParentSubService" engine="java" auth="false" require-new-transaction="true" + location="org.ofbiz.service.test.ServiceEngineTestServices" invoke="testServiceOwnTxSubServiceAfterSetRollbackOnlyInParentSubService"> </service> </services> Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/test/ServiceEngineTestServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/test/ServiceEngineTestServices.java?rev=574493&r1=574492&r2=574493&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/test/ServiceEngineTestServices.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/test/ServiceEngineTestServices.java Tue Sep 11 00:15:30 2007 @@ -28,6 +28,7 @@ import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.transaction.TransactionUtil; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericResultWaiter; import org.ofbiz.service.GenericServiceException; @@ -224,6 +225,10 @@ * * TODO: there's got to be some way to do this, but how?!? :( * + * NOTE: maybe this will work: create a list that the service engine maintains of services it will run after the + * current service run is complete, and AFTER it has committed or rolled back its transaction; if a service finds + * it has a lock wait timeout, add itself to the list for its parent service (somehow...) and off we go! + * * @param dctx * @param context * @return @@ -276,4 +281,26 @@ return ServiceUtil.returnSuccess(); } + + public static Map testServiceOwnTxSubServiceAfterSetRollbackOnlyInParent(DispatchContext dctx, Map context) { + LocalDispatcher dispatcher = dctx.getDispatcher(); + try { + TransactionUtil.setRollbackOnly("Intentionally setting rollback only for testing purposes", null); + + Map resultMap = dispatcher.runSync("testServiceOwnTxSubServiceAfterSetRollbackOnlyInParentSubService", null, 60, true); + if (ServiceUtil.isError(resultMap)) { + return ServiceUtil.returnError("Error running sub-service in testServiceOwnTxSubServiceAfterSetRollbackOnlyInParent", null, null, resultMap); + } + } catch (Exception e) { + String errMsg = "Error running sub-service with own tx: " + e.toString(); + Debug.logError(e, errMsg, module); + return ServiceUtil.returnError(errMsg); + } + + return ServiceUtil.returnSuccess(); + } + public static Map testServiceOwnTxSubServiceAfterSetRollbackOnlyInParentSubService(DispatchContext dctx, Map context) { + // this service doesn't actually have to do anything, the problem was in just pausing and resuming the transaciton with setRollbackOnly + return ServiceUtil.returnSuccess(); + } } Modified: ofbiz/trunk/framework/service/testdef/servicetests.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/testdef/servicetests.xml?rev=574493&r1=574492&r2=574493&view=diff ============================================================================== --- ofbiz/trunk/framework/service/testdef/servicetests.xml (original) +++ ofbiz/trunk/framework/service/testdef/servicetests.xml Tue Sep 11 00:15:30 2007 @@ -45,4 +45,8 @@ <test-case case-name="service-lock-wait-timeout-retry-assert-data"> <entity-xml action="assert" entity-xml-url="component://service/testdef/data/ServiceLockTimeoutRetryCantRecoverAssertData.xml"/> </test-case> + + <test-case case-name="service-own-tx-sub-service-after-set-rollback-only-in-parent"> + <service-test service-name="testServiceOwnTxSubServiceAfterSetRollbackOnlyInParent"/> + </test-case> </test-suite> |
Free forum by Nabble | Edit this page |