All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mockrunner.mock.connector.cci.MockInteraction Maven / Gradle / Ivy

There is a newer version: 2.0.7
Show newest version
package com.mockrunner.mock.connector.cci;

import javax.resource.ResourceException;
import javax.resource.cci.Connection;
import javax.resource.cci.Interaction;
import javax.resource.cci.InteractionSpec;
import javax.resource.cci.Record;
import javax.resource.cci.ResourceWarning;

/**
 * Mock implementation of Interaction.
 * The execute calls are delegated to
 * {@link com.mockrunner.connector.InteractionHandler}.
 */
public class MockInteraction implements Interaction
{
    private MockConnection mockConnection;
    private boolean closed;

    public MockInteraction(MockConnection mockConnection)
    {
        this.mockConnection = mockConnection;
        closed = false;
    }

    public void clearWarnings() throws ResourceException
    {

    }

    public void close() throws ResourceException
    {
        closed = true;
    }

    /**
     * Calls {@link com.mockrunner.connector.InteractionHandler#execute(InteractionSpec, Record)}.
     */
    public Record execute(InteractionSpec is, Record record) throws ResourceException
    {
        return mockConnection.getInteractionHandler().execute(is, record);
    }

    /**
     * Calls {@link com.mockrunner.connector.InteractionHandler#execute(InteractionSpec, Record, Record)}.
     */
    public boolean execute(InteractionSpec is, Record request, Record response) throws ResourceException
    {
        return mockConnection.getInteractionHandler().execute(is, request, response);
    }

    public Connection getConnection()
    {
        return mockConnection;
    }

    /**
     * Returns if this Interaction is closed.
     * @return true if this Interaction is closed,
     *         false otherwise
     */
    public boolean isClosed()
    {
        return closed;
    }

    /**
     * Returns null, warnings not supported yet.
     */
    public ResourceWarning getWarnings() throws ResourceException
    {
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy