You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by ms...@apache.org on 2007/08/02 19:57:58 UTC
svn commit: r562202 - in /ode/branches/bart/bpel-test/src:
main/java/org/apache/ode/test/
test/resources/bpel/2.0/TestImplicitFaultHandler/
Author: mszefler
Date: Thu Aug 2 10:57:57 2007
New Revision: 562202
URL: http://svn.apache.org/viewvc?view=rev&rev=562202
Log:
BART tweaks.
Added:
ode/branches/bart/bpel-test/src/main/java/org/apache/ode/test/MockTransactionManager.java (with props)
ode/branches/bart/bpel-test/src/test/resources/bpel/2.0/TestImplicitFaultHandler/test.properties (with props)
Modified:
ode/branches/bart/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java
ode/branches/bart/bpel-test/src/main/java/org/apache/ode/test/MessageExchangeContextImpl.java
Modified: ode/branches/bart/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java
URL: http://svn.apache.org/viewvc/ode/branches/bart/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java?view=diff&rev=562202&r1=562201&r2=562202
==============================================================================
--- ode/branches/bart/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java (original)
+++ ode/branches/bart/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java Thu Aug 2 10:57:57 2007
@@ -132,6 +132,7 @@
_server.setScheduler(scheduler);
_server.setBindingContext(new BindingContextImpl());
_server.setMessageExchangeContext(mexContext);
+ _server.setTransactionManager(_txm);
scheduler.setJobProcessor(_server);
store = new ProcessStoreImpl(null, "jpa", true);
store.registerListener(new ProcessStoreListener() {
@@ -366,6 +367,7 @@
private void failure(Object where, String message, Exception ex) {
Failure f = new Failure(where, message, ex);
_failures.add(f);
+ ex.printStackTrace();
fail(f.toString());
}
Modified: ode/branches/bart/bpel-test/src/main/java/org/apache/ode/test/MessageExchangeContextImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/bart/bpel-test/src/main/java/org/apache/ode/test/MessageExchangeContextImpl.java?view=diff&rev=562202&r1=562201&r2=562202
==============================================================================
--- ode/branches/bart/bpel-test/src/main/java/org/apache/ode/test/MessageExchangeContextImpl.java (original)
+++ ode/branches/bart/bpel-test/src/main/java/org/apache/ode/test/MessageExchangeContextImpl.java Thu Aug 2 10:57:57 2007
@@ -90,7 +90,7 @@
}
- public void onAsyncReply(MyRoleMessageExchange myRoleMex)
+ public void onMyRoleMessageExchangeStateChanged(MyRoleMessageExchange myRoleMex)
throws BpelEngineException {
Added: ode/branches/bart/bpel-test/src/main/java/org/apache/ode/test/MockTransactionManager.java
URL: http://svn.apache.org/viewvc/ode/branches/bart/bpel-test/src/main/java/org/apache/ode/test/MockTransactionManager.java?view=auto&rev=562202
==============================================================================
--- ode/branches/bart/bpel-test/src/main/java/org/apache/ode/test/MockTransactionManager.java (added)
+++ ode/branches/bart/bpel-test/src/main/java/org/apache/ode/test/MockTransactionManager.java Thu Aug 2 10:57:57 2007
@@ -0,0 +1,211 @@
+package org.apache.ode.test;
+
+import java.util.ArrayList;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAResource;
+
+/**
+ * A minimal transaction manager that can be used for testing.
+ *
+ * @author Maciej Szefler <mszefler at gmail dot com>
+ *
+ */
+public class MockTransactionManager implements TransactionManager {
+ ThreadLocal<TX> _transaction = new ThreadLocal<TX>();
+
+ public void begin() throws NotSupportedException, SystemException {
+ if (_transaction.get() != null)
+ throw new NotSupportedException("Transaction active (nested tx not supported): " + _transaction.get());
+
+ _transaction.set(new TX());
+ }
+
+ public void commit() throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException, RollbackException,
+ SecurityException, SystemException {
+ if (_transaction.get() == null)
+ throw new IllegalStateException("Transaction not active. ");
+
+ _transaction.get().commit();
+ }
+
+ public int getStatus() throws SystemException {
+ if (_transaction.get() == null)
+ return Status.STATUS_NO_TRANSACTION;
+
+ return _transaction.get().getStatus();
+
+ }
+
+ public Transaction getTransaction() throws SystemException {
+ return _transaction.get();
+ }
+
+ public void resume(Transaction tx) throws IllegalStateException, InvalidTransactionException, SystemException {
+ if (_transaction.get() != null)
+ throw new IllegalStateException("Transaction is active in current thread: " + _transaction.get());
+ try {
+ _transaction.set((TX) tx);
+ } catch (ClassCastException cce) {
+ throw new InvalidTransactionException();
+ }
+
+ }
+
+ public void rollback() throws IllegalStateException, SecurityException, SystemException {
+ if (_transaction.get() == null)
+ throw new IllegalStateException("Transaction not active. ");
+
+ _transaction.get().rollback();
+ }
+
+ public void setRollbackOnly() throws IllegalStateException, SystemException {
+ if (_transaction.get() == null)
+ throw new IllegalStateException("Transaction not active. ");
+
+ _transaction.get().setRollbackOnly();
+
+ }
+
+ public void setTransactionTimeout(int arg0) throws SystemException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Transaction suspend() throws SystemException {
+ try {
+ return _transaction.get();
+ } finally {
+ _transaction.set(null);
+ }
+ }
+
+
+ protected void doBegin(TX tx) {}
+ protected void doCommit(TX tx) {}
+ protected void doRollback(TX tx){}
+
+ public class TX implements Transaction {
+
+ final ArrayList<XAResource> _resources = new ArrayList<XAResource>();
+
+ final ArrayList<Synchronization> _synchros = new ArrayList<Synchronization> ();
+
+ private int _status;
+
+ public void commit() throws HeuristicMixedException, HeuristicRollbackException, RollbackException, SecurityException,
+ SystemException {
+ switch (_status) {
+ case Status.STATUS_COMMITTED:
+ return;
+ case Status.STATUS_MARKED_ROLLBACK:
+ rollback();
+ throw new RollbackException("Transaction was marked for rollback!");
+ case Status.STATUS_ACTIVE:
+ fireBefore();
+ if (_status == Status.STATUS_MARKED_ROLLBACK) {
+ rollback();
+ throw new RollbackException("Transaction was marked for rollback in beforeCompletion handler.");
+ }
+ _status = Status.STATUS_COMMITTING;
+ try {
+ doCommit(this);
+ _status = Status.STATUS_COMMITTED;
+ } catch (Exception ex) {
+ _status = Status.STATUS_ROLLEDBACK;
+ throw new RollbackException("Transaction was rolled back due to commit failure." );
+ } finally {
+ fireAfter();
+ }
+ break;
+ default:
+ throw new IllegalStateException("Unexpected transaction state.");
+ }
+ }
+
+ public boolean delistResource(XAResource arg0, int arg1) throws IllegalStateException, SystemException {
+ // TODO: perhaps we should do something with the resources?
+ _resources.remove(arg0);
+ return true;
+ }
+
+ public boolean enlistResource(XAResource r) throws IllegalStateException, RollbackException, SystemException {
+ return _resources.add(r);
+ }
+
+ public int getStatus() throws SystemException {
+ return _status;
+ }
+
+ public void registerSynchronization(Synchronization synch) throws IllegalStateException, RollbackException, SystemException {
+ _synchros.add(synch);
+ }
+
+ public void rollback() throws IllegalStateException, SystemException {
+ // TODO Auto-generated method stub
+ switch (_status) {
+ case Status.STATUS_ROLLEDBACK:
+ return;
+ case Status.STATUS_MARKED_ROLLBACK:
+ case Status.STATUS_ACTIVE:
+ _status = Status.STATUS_ROLLING_BACK;
+ try {
+ doRollback(this);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ } finally {
+ _status = Status.STATUS_ROLLEDBACK;
+ fireAfter();
+ }
+ break;
+ default:
+ throw new IllegalStateException("Unexpected transaction state.");
+ }
+ }
+
+ public void setRollbackOnly() throws IllegalStateException, SystemException {
+ switch (_status) {
+ case Status.STATUS_ACTIVE:
+ case Status.STATUS_MARKED_ROLLBACK:
+ _status = Status.STATUS_MARKED_ROLLBACK;
+ break;
+ case Status.STATUS_ROLLEDBACK:
+ case Status.STATUS_ROLLING_BACK:
+ break;
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ private void fireBefore() {
+ for (Synchronization s : _synchros)
+ try {
+ s.beforeCompletion();
+ } catch (Throwable t) {
+ ; // ignore errors.
+ }
+
+ }
+
+ private void fireAfter() {
+ for (Synchronization s : _synchros)
+ try {
+ s.afterCompletion(_status);
+ } catch (Throwable t) {
+ ; // ignore errors.
+ }
+
+ }
+
+ }
+
+}
Propchange: ode/branches/bart/bpel-test/src/main/java/org/apache/ode/test/MockTransactionManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: ode/branches/bart/bpel-test/src/test/resources/bpel/2.0/TestImplicitFaultHandler/test.properties
URL: http://svn.apache.org/viewvc/ode/branches/bart/bpel-test/src/test/resources/bpel/2.0/TestImplicitFaultHandler/test.properties?view=auto&rev=562202
==============================================================================
--- ode/branches/bart/bpel-test/src/test/resources/bpel/2.0/TestImplicitFaultHandler/test.properties (added)
+++ ode/branches/bart/bpel-test/src/test/resources/bpel/2.0/TestImplicitFaultHandler/test.properties Thu Aug 2 10:57:57 2007
@@ -0,0 +1,22 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+namespace=http://ode/bpel/unit-test/testImplicitFaultHandler.wsdl
+service=testImplicitFaultHandlerService
+operation=request
+request1=<message><requestID>Start TestImplicitFaultHandler</requestID><requestText>Event TestImplicitFaultHandler</requestText><faultIndicator1>yes</faultIndicator1><faultIndicator2>no</faultIndicator2></message>
+response1=.*Event TestFaultWithVariable1 -> caught FaultMessage1 -> Event TestFaultWithVariable1 -> process complete.*
Propchange: ode/branches/bart/bpel-test/src/test/resources/bpel/2.0/TestImplicitFaultHandler/test.properties
------------------------------------------------------------------------------
svn:eol-style = native