Package javax.resource.cci

Examples of javax.resource.cci.ConnectionFactory


   * LocalTransaction when CciLocalTransactionManager is specified as
   * transaction manager.
   */
  public void testLocalTransactionCommit() throws ResourceException {
    MockControl connectionFactoryControl = MockControl.createControl(ConnectionFactory.class);
    final ConnectionFactory connectionFactory = (ConnectionFactory) connectionFactoryControl.getMock();
    MockControl connectionControl = MockControl.createControl(Connection.class);
    Connection connection = (Connection) connectionControl.getMock();
    MockControl interactionControl = MockControl.createControl(Interaction.class);
    Interaction interaction = (Interaction) interactionControl.getMock();
    MockControl localTransactionControl = MockControl.createControl(LocalTransaction.class);
    LocalTransaction localTransaction = (LocalTransaction) localTransactionControl.getMock();
    MockControl recordControl = MockControl.createControl(Record.class);
    final Record record = (Record) recordControl.getMock();

    MockControl interactionSpecControl = MockControl.createControl(InteractionSpec.class);
    final InteractionSpec interactionSpec = (InteractionSpec) interactionSpecControl.getMock();

    connectionFactory.getConnection();
    connectionFactoryControl.setReturnValue(connection, 1);

    connection.getLocalTransaction();
    connectionControl.setReturnValue(localTransaction, 1);

View Full Code Here


   * LocalTransaction when CciLocalTransactionManager is specified as
   * transaction manager and a non-checked exception is thrown.
   */
  public void testLocalTransactionRollback() throws ResourceException {
    MockControl connectionFactoryControl = MockControl.createControl(ConnectionFactory.class);
    final ConnectionFactory connectionFactory = (ConnectionFactory) connectionFactoryControl.getMock();
    MockControl connectionControl = MockControl.createControl(Connection.class);
    Connection connection = (Connection) connectionControl.getMock();
    MockControl interactionControl = MockControl.createControl(Interaction.class);
    Interaction interaction = (Interaction) interactionControl.getMock();
    MockControl localTransactionControl = MockControl.createControl(LocalTransaction.class);
    LocalTransaction localTransaction = (LocalTransaction) localTransactionControl.getMock();
    MockControl recordControl = MockControl.createControl(Record.class);
    final Record record = (Record) recordControl.getMock();

    MockControl interactionSpecControl = MockControl.createControl(InteractionSpec.class);
    final InteractionSpec interactionSpec = (InteractionSpec) interactionSpecControl.getMock();

    connectionFactory.getConnection();
    connectionFactoryControl.setReturnValue(connection);

    connection.getLocalTransaction();
    connectionControl.setReturnValue(localTransaction);

View Full Code Here

*/
public class EisOperationTests extends TestCase {

  public void testSimpleRecordOperation() throws ResourceException {
    MockControl connectionFactoryControl = MockControl.createControl(ConnectionFactory.class);
    ConnectionFactory connectionFactory = (ConnectionFactory) connectionFactoryControl.getMock();
    MockControl connectionControl = MockControl.createControl(Connection.class);
    Connection connection = (Connection) connectionControl.getMock();
    MockControl interactionControl = MockControl.createControl(Interaction.class);
    Interaction interaction = (Interaction) interactionControl.getMock();

    MockControl inputRecordControl = MockControl.createControl(Record.class);
    Record inputRecord = (Record) inputRecordControl.getMock();
    MockControl outputRecordControl = MockControl.createControl(Record.class);
    Record outputRecord = (Record) outputRecordControl.getMock();

    MockControl interactionSpecControl = MockControl.createControl(InteractionSpec.class);
    InteractionSpec interactionSpec = (InteractionSpec) interactionSpecControl.getMock();

    SimpleRecordOperation query = new SimpleRecordOperation(connectionFactory, interactionSpec);

    connectionFactory.getConnection();
    connectionFactoryControl.setReturnValue(connection);

    connection.createInteraction();
    connectionControl.setReturnValue(interaction);

View Full Code Here

    interactionControl.verify();
  }

  public void testSimpleRecordOperationWithExplicitOutputRecord() throws ResourceException {
    MockControl connectionFactoryControl = MockControl.createControl(ConnectionFactory.class);
    ConnectionFactory connectionFactory = (ConnectionFactory) connectionFactoryControl.getMock();
    MockControl connectionControl = MockControl.createControl(Connection.class);
    Connection connection = (Connection) connectionControl.getMock();
    MockControl interactionControl = MockControl.createControl(Interaction.class);
    Interaction interaction = (Interaction) interactionControl.getMock();

    MockControl inputRecordControl = MockControl.createControl(Record.class);
    Record inputRecord = (Record) inputRecordControl.getMock();
    MockControl outputRecordControl = MockControl.createControl(Record.class);
    Record outputRecord = (Record) outputRecordControl.getMock();

    MockControl interactionSpecControl = MockControl.createControl(InteractionSpec.class);
    InteractionSpec interactionSpec = (InteractionSpec) interactionSpecControl.getMock();

    SimpleRecordOperation operation = new SimpleRecordOperation(connectionFactory, interactionSpec);

    connectionFactory.getConnection();
    connectionFactoryControl.setReturnValue(connection, 1);

    connection.createInteraction();
    connectionControl.setReturnValue(interaction, 1);
View Full Code Here

    interactionControl.verify();
  }

  public void testSimpleRecordOperationWithInputOutputRecord() throws ResourceException {
    MockControl connectionFactoryControl = MockControl.createControl(ConnectionFactory.class);
    final ConnectionFactory connectionFactory = (ConnectionFactory) connectionFactoryControl.getMock();
    MockControl connectionControl = MockControl.createControl(Connection.class);
    Connection connection = (Connection) connectionControl.getMock();
    MockControl interactionControl = MockControl.createControl(Interaction.class);
    Interaction interaction = (Interaction) interactionControl.getMock();

    MockControl inputOutputRecordControl = MockControl.createControl(Record.class);
    Record inputOutputRecord = (Record) inputOutputRecordControl.getMock();

    MockControl interactionSpecControl = MockControl.createControl(InteractionSpec.class);
    InteractionSpec interactionSpec = (InteractionSpec) interactionSpecControl.getMock();

    SimpleRecordOperation query = new SimpleRecordOperation(connectionFactory, interactionSpec);

    connectionFactory.getConnection();
    connectionFactoryControl.setReturnValue(connection);

    connection.createInteraction();
    connectionControl.setReturnValue(interaction);
View Full Code Here

    interactionControl.verify();
  }

  public void testMappingRecordOperation() throws ResourceException {
    MockControl connectionFactoryControl = MockControl.createControl(ConnectionFactory.class);
    final ConnectionFactory connectionFactory = (ConnectionFactory) connectionFactoryControl.getMock();
    MockControl recordFactoryControl = MockControl.createStrictControl(RecordFactory.class);
    RecordFactory recordFactory = (RecordFactory) recordFactoryControl.getMock();
    MockControl connectionControl = MockControl.createControl(Connection.class);
    Connection connection = (Connection) connectionControl.getMock();
    MockControl interactionControl = MockControl.createControl(Interaction.class);
    Interaction interaction = (Interaction) interactionControl.getMock();

    MockControl inputRecordControl = MockControl.createControl(Record.class);
    Record inputRecord = (Record) inputRecordControl.getMock();
    MockControl outputRecordControl = MockControl.createControl(Record.class);
    Record outputRecord = (Record) outputRecordControl.getMock();

    MockControl interactionSpecControl = MockControl.createControl(InteractionSpec.class);
    InteractionSpec interactionSpec = (InteractionSpec) interactionSpecControl.getMock();

    MockControl callDetectorControl = MockControl.createControl(QueryCallDetector.class);
    QueryCallDetector callDetector = (QueryCallDetector) callDetectorControl.getMock();

    MappingRecordOperationImpl query = new MappingRecordOperationImpl(connectionFactory, interactionSpec);
    query.setCallDetector(callDetector);

    Object inObj = new Object();
    Object outObj = new Object();

    connectionFactory.getRecordFactory();
    connectionFactoryControl.setReturnValue(recordFactory, 1);

    callDetector.callCreateInputRecord(recordFactory, inObj);
    callDetectorControl.setReturnValue(inputRecord, 1);

    connectionFactory.getConnection();
    connectionFactoryControl.setReturnValue(connection, 1);

    connection.createInteraction();
    connectionControl.setReturnValue(interaction, 1);
View Full Code Here

    callDetectorControl.verify();
  }

  public void testMappingRecordOperationWithOutputRecordCreator() throws ResourceException {
    MockControl connectionFactoryControl = MockControl.createControl(ConnectionFactory.class);
    final ConnectionFactory connectionFactory = (ConnectionFactory) connectionFactoryControl.getMock();
    MockControl recordFactoryControl = MockControl.createStrictControl(RecordFactory.class);
    RecordFactory recordFactory = (RecordFactory) recordFactoryControl.getMock();
    MockControl connectionControl = MockControl.createControl(Connection.class);
    Connection connection = (Connection) connectionControl.getMock();
    MockControl interactionControl = MockControl.createControl(Interaction.class);
    Interaction interaction = (Interaction) interactionControl.getMock();

    MockControl inputRecordControl = MockControl.createControl(Record.class);
    Record inputRecord = (Record) inputRecordControl.getMock();
    MockControl outputRecordControl = MockControl.createControl(Record.class);
    Record outputRecord = (Record) outputRecordControl.getMock();
    MockControl outputCreatorControl = MockControl.createControl(RecordCreator.class);
    RecordCreator outputCreator = (RecordCreator) outputCreatorControl.getMock();

    MockControl interactionSpecControl = MockControl.createControl(InteractionSpec.class);
    InteractionSpec interactionSpec = (InteractionSpec) interactionSpecControl.getMock();

    MockControl callDetectorControl = MockControl.createControl(QueryCallDetector.class);
    QueryCallDetector callDetector = (QueryCallDetector) callDetectorControl.getMock();

    MappingRecordOperationImpl query = new MappingRecordOperationImpl(connectionFactory, interactionSpec);
    query.setOutputRecordCreator(outputCreator);
    query.setCallDetector(callDetector);

    Object inObj = new Object();
    Object outObj = new Object();

    connectionFactory.getRecordFactory();
    connectionFactoryControl.setReturnValue(recordFactory, 1);

    callDetector.callCreateInputRecord(recordFactory, inObj);
    callDetectorControl.setReturnValue(inputRecord, 1);

    connectionFactory.getConnection();
    connectionFactoryControl.setReturnValue(connection, 1);

    connection.createInteraction();
    connectionControl.setReturnValue(interaction, 1);

    connectionFactory.getRecordFactory();
    connectionFactoryControl.setReturnValue(recordFactory, 1);

    outputCreator.createRecord(recordFactory);
    outputCreatorControl.setReturnValue(outputRecord, 1);
View Full Code Here

        assertTrue(proxy instanceof ConnectionFactoryExtension);
        assertEquals("SomethingElse", ((ConnectionFactoryExtension)proxy).doSomethingElse());
    }

    public void testSerialization() throws Exception {
        ConnectionFactory proxy = (ConnectionFactory) kernel.invoke(managedConnectionFactoryName, "$getResource");
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(proxy);
        oos.flush();
        byte[] bytes = baos.toByteArray();
        oos.close();
        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes));
        Object proxy2 = ois.readObject();
        assertNotNull(proxy2);
        assertTrue(proxy instanceof ConnectionFactory);
        Connection connection = proxy.getConnection();
        assertNotNull(connection);
        kernel.stopGBean(managedConnectionFactoryName);
        ObjectInputStream ois2 = new ObjectInputStream(new ByteArrayInputStream(bytes));
        ConnectionFactory proxy3 = (ConnectionFactory) ois2.readObject();
        try {
            proxy3.getConnection();
            fail();
        } catch (IllegalStateException ise) {
        }
        kernel.startGBean(managedConnectionFactoryName);
        proxy3.getConnection();

    }
View Full Code Here

        assertTrue(proxy instanceof ConnectionFactoryExtension);
        assertEquals("SomethingElse", ((ConnectionFactoryExtension)proxy).doSomethingElse());
    }

    public void testSerialization() throws Exception {
        ConnectionFactory proxy = (ConnectionFactory) kernel.invoke(managedConnectionFactoryName, "$getResource");
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(proxy);
        oos.flush();
        byte[] bytes = baos.toByteArray();
        oos.close();
        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes));
        Object proxy2 = ois.readObject();
        assertNotNull(proxy2);
        assertTrue(proxy instanceof ConnectionFactory);
        Connection connection = proxy.getConnection();
        assertNotNull(connection);
        kernel.stopGBean(managedConnectionFactoryName);
        ObjectInputStream ois2 = new ObjectInputStream(new ByteArrayInputStream(bytes));
        ConnectionFactory proxy3 = (ConnectionFactory) ois2.readObject();
        try {
            proxy3.getConnection();
            fail();
        } catch (IllegalStateException ise) {
        }
        kernel.startGBean(managedConnectionFactoryName);
        proxy3.getConnection();

    }
View Full Code Here

        assertTrue(proxy instanceof ConnectionFactoryExtension);
        assertEquals("SomethingElse", ((ConnectionFactoryExtension)proxy).doSomethingElse());
    }

    public void XtestSerialization() throws Exception {
        ConnectionFactory proxy = (ConnectionFactory) kernel.invoke(connectionManagerName, "$getResource");
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(proxy);
        oos.flush();
        byte[] bytes = baos.toByteArray();
        oos.close();
        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes));
        Object proxy2 = ois.readObject();
        assertNotNull(proxy2);
        assertTrue(proxy instanceof ConnectionFactory);
        Connection connection = proxy.getConnection();
        assertNotNull(connection);
        kernel.stopGBean(managedConnectionFactoryName);
        ObjectInputStream ois2 = new ObjectInputStream(new ByteArrayInputStream(bytes));
        ConnectionFactory proxy3 = (ConnectionFactory) ois2.readObject();
        try {
            proxy3.getConnection();
            fail();
        } catch (IllegalStateException ise) {
        }
        kernel.startGBean(managedConnectionFactoryName);
        proxy3.getConnection();

    }
View Full Code Here

TOP

Related Classes of javax.resource.cci.ConnectionFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.