001 package com.mockrunner.mock.connector.cci;
002
003 import javax.resource.ResourceException;
004 import javax.resource.cci.Connection;
005 import javax.resource.cci.Interaction;
006 import javax.resource.cci.InteractionSpec;
007 import javax.resource.cci.Record;
008 import javax.resource.cci.ResourceWarning;
009
010 /**
011 * Mock implementation of <code>Interaction</code>.
012 * The <code>execute</code> calls are delegated to
013 * {@link com.mockrunner.connector.InteractionHandler}.
014 */
015 public class MockInteraction implements Interaction
016 {
017 private MockConnection mockConnection;
018 private boolean closed;
019
020 public MockInteraction(MockConnection mockConnection)
021 {
022 this.mockConnection = mockConnection;
023 closed = false;
024 }
025
026 public void clearWarnings() throws ResourceException
027 {
028
029 }
030
031 public void close() throws ResourceException
032 {
033 closed = true;
034 }
035
036 /**
037 * Calls {@link com.mockrunner.connector.InteractionHandler#execute(InteractionSpec, Record)}.
038 */
039 public Record execute(InteractionSpec is, Record record) throws ResourceException
040 {
041 return mockConnection.getInteractionHandler().execute(is, record);
042 }
043
044 /**
045 * Calls {@link com.mockrunner.connector.InteractionHandler#execute(InteractionSpec, Record, Record)}.
046 */
047 public boolean execute(InteractionSpec is, Record request, Record response) throws ResourceException
048 {
049 return mockConnection.getInteractionHandler().execute(is, request, response);
050 }
051
052 public Connection getConnection()
053 {
054 return mockConnection;
055 }
056
057 /**
058 * Returns if this <code>Interaction</code> is closed.
059 * @return <code>true</code> if this <code>Interaction</code> is closed,
060 * <code>false</code> otherwise
061 */
062 public boolean isClosed()
063 {
064 return closed;
065 }
066
067 /**
068 * Returns <code>null</code>, warnings not supported yet.
069 */
070 public ResourceWarning getWarnings() throws ResourceException
071 {
072 return null;
073 }
074 }