Package javax.resource.cci

Examples of javax.resource.cci.ConnectionFactory


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

    public void XtestSerialization() 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


*/
public class CciTemplateTests extends TestCase {

  public void testCreateIndexedRecord() throws ResourceException {
    MockControl connectionFactoryControl = MockControl.createStrictControl(ConnectionFactory.class);
    ConnectionFactory connectionFactory = (ConnectionFactory) connectionFactoryControl.getMock();
    MockControl recordFactoryControl = MockControl.createStrictControl(RecordFactory.class);
    RecordFactory recordFactory = (RecordFactory) recordFactoryControl.getMock();
    MockControl indexedRecordControl = MockControl.createStrictControl(IndexedRecord.class);
    IndexedRecord indexedRecord = (IndexedRecord) indexedRecordControl.getMock();

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

    recordFactory.createIndexedRecord("name");
    recordFactoryControl.setReturnValue(indexedRecord, 1);

View Full Code Here

    recordFactoryControl.verify();
  }

  public void testCreateMappedRecord() throws ResourceException {
    MockControl connectionFactoryControl = MockControl.createStrictControl(ConnectionFactory.class);
    ConnectionFactory connectionFactory = (ConnectionFactory) connectionFactoryControl.getMock();
    MockControl recordFactoryControl = MockControl.createStrictControl(RecordFactory.class);
    RecordFactory recordFactory = (RecordFactory) recordFactoryControl.getMock();
    MockControl mappedRecordControl = MockControl.createStrictControl(MappedRecord.class);
    MappedRecord mappedRecord = (MappedRecord) mappedRecordControl.getMock();

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

    recordFactory.createMappedRecord("name");
    recordFactoryControl.setReturnValue(mappedRecord, 1);
View Full Code Here

    recordFactoryControl.verify();
  }

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

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

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

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

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

    interactionControl.verify();
  }

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

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

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

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

    connectionFactory.getRecordFactory();
    connectionFactoryControl.setThrowable(new NotSupportedException("not supported"), 1);

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

    interactionControl.verify();
  }

  public void testTemplateExecuteInputTrueWithCreator() throws ResourceException {
    MockControl connectionFactoryControl = MockControl.createStrictControl(ConnectionFactory.class);
    ConnectionFactory connectionFactory = (ConnectionFactory) connectionFactoryControl.getMock();
    MockControl recordFactoryControl = MockControl.createStrictControl(RecordFactory.class);
    RecordFactory recordFactory = (RecordFactory) recordFactoryControl.getMock();
    MockControl connectionControl = MockControl.createStrictControl(Connection.class);
    Connection connection = (Connection) connectionControl.getMock();
    MockControl interactionControl = MockControl.createStrictControl(Interaction.class);
    Interaction interaction = (Interaction) interactionControl.getMock();
    MockControl creatorControl = MockControl.createStrictControl(RecordCreator.class);
    RecordCreator creator = (RecordCreator) creatorControl.getMock();

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

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

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

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

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

    creatorControl.verify();
  }

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

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

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

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

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

    interactionControl.verify();
  }

  public void testTemplateExecuteInputExtractorTrueWithCreator() throws ResourceException, SQLException {
    MockControl connectionFactoryControl = MockControl.createStrictControl(ConnectionFactory.class);
    ConnectionFactory connectionFactory = (ConnectionFactory) connectionFactoryControl.getMock();
    MockControl recordFactoryControl = MockControl.createStrictControl(RecordFactory.class);
    RecordFactory recordFactory = (RecordFactory) recordFactoryControl.getMock();
    MockControl connectionControl = MockControl.createStrictControl(Connection.class);
    Connection connection = (Connection) connectionControl.getMock();
    MockControl interactionControl = MockControl.createStrictControl(Interaction.class);
    Interaction interaction = (Interaction) interactionControl.getMock();
    MockControl extractorControl = MockControl.createStrictControl(RecordExtractor.class);
    RecordExtractor extractor = (RecordExtractor) extractorControl.getMock();
    MockControl creatorControl = MockControl.createStrictControl(RecordCreator.class);
    RecordCreator creator = (RecordCreator) creatorControl.getMock();

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

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

    Object obj = new Object();

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

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

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

    creator.createRecord(recordFactory);
    creatorControl.setReturnValue(outputRecord);
View Full Code Here

    creatorControl.verify();
  }

  public void testTemplateExecuteInputExtractorFalse() throws ResourceException, SQLException {
    MockControl connectionFactoryControl = MockControl.createStrictControl(ConnectionFactory.class);
    ConnectionFactory connectionFactory = (ConnectionFactory) connectionFactoryControl.getMock();
    MockControl connectionControl = MockControl.createStrictControl(Connection.class);
    Connection connection = (Connection) connectionControl.getMock();
    MockControl interactionControl = MockControl.createStrictControl(Interaction.class);
    Interaction interaction = (Interaction) interactionControl.getMock();
    MockControl extractorControl = MockControl.createStrictControl(RecordExtractor.class);
    RecordExtractor extractor = (RecordExtractor) extractorControl.getMock();

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

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

    Object obj = new Object();

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

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

    extractorControl.verify();
  }

  public void testTemplateExecuteInputGeneratorTrueWithCreator() throws ResourceException {
    MockControl connectionFactoryControl = MockControl.createStrictControl(ConnectionFactory.class);
    ConnectionFactory connectionFactory = (ConnectionFactory) connectionFactoryControl.getMock();
    MockControl recordFactoryControl = MockControl.createStrictControl(RecordFactory.class);
    RecordFactory recordFactory = (RecordFactory) recordFactoryControl.getMock();
    MockControl connectionControl = MockControl.createStrictControl(Connection.class);
    Connection connection = (Connection) connectionControl.getMock();
    MockControl interactionControl = MockControl.createStrictControl(Interaction.class);
    Interaction interaction = (Interaction) interactionControl.getMock();
    MockControl generatorControl = MockControl.createStrictControl(RecordCreator.class);
    RecordCreator generator = (RecordCreator) generatorControl.getMock();
    MockControl creatorControl = MockControl.createStrictControl(RecordCreator.class);
    RecordCreator creator = (RecordCreator) creatorControl.getMock();

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

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

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

    generator.createRecord(recordFactory);
    generatorControl.setReturnValue(inputRecord);

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

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

    creator.createRecord(recordFactory);
    creatorControl.setReturnValue(outputRecord);

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

    interaction.execute(interactionSpec, inputRecord, outputRecord);
    interactionControl.setReturnValue(true, 1);
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.