org.springframework.jca.cci.connection.NotSupportedRecordFactory Java Examples

The following examples show how to use org.springframework.jca.cci.connection.NotSupportedRecordFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CciTemplateTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testTemplateExecuteWithCreatorAndRecordFactoryNotSupported()
		throws ResourceException {
	ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
	Connection connection = mock(Connection.class);
	Interaction interaction = mock(Interaction.class);

	Record inputRecord = mock(Record.class);
	final Record outputRecord = mock(Record.class);

	InteractionSpec interactionSpec = mock(InteractionSpec.class);

	given(connectionFactory.getConnection()).willReturn(connection);
	given(connectionFactory.getRecordFactory()).willThrow(new NotSupportedException("not supported"));
	given(connection.createInteraction()).willReturn(interaction);
	given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);

	CciTemplate ct = new CciTemplate(connectionFactory);
	ct.setOutputRecordCreator(new RecordCreator() {
		@Override
		public Record createRecord(RecordFactory recordFactory) {
			assertTrue(recordFactory instanceof NotSupportedRecordFactory);
			return outputRecord;
		}
	});
	ct.execute(interactionSpec, inputRecord);

	verify(interaction).execute(interactionSpec, inputRecord, outputRecord);
	verify(interaction).close();
	verify(connection).close();
}
 
Example #2
Source File: CciTemplateTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testTemplateExecuteWithCreatorAndRecordFactoryNotSupported()
		throws ResourceException {
	ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
	Connection connection = mock(Connection.class);
	Interaction interaction = mock(Interaction.class);

	Record inputRecord = mock(Record.class);
	final Record outputRecord = mock(Record.class);

	InteractionSpec interactionSpec = mock(InteractionSpec.class);

	given(connectionFactory.getConnection()).willReturn(connection);
	given(connectionFactory.getRecordFactory()).willThrow(new NotSupportedException("not supported"));
	given(connection.createInteraction()).willReturn(interaction);
	given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);

	CciTemplate ct = new CciTemplate(connectionFactory);
	ct.setOutputRecordCreator(new RecordCreator() {
		@Override
		public Record createRecord(RecordFactory recordFactory) {
			assertTrue(recordFactory instanceof NotSupportedRecordFactory);
			return outputRecord;
		}
	});
	ct.execute(interactionSpec, inputRecord);

	verify(interaction).execute(interactionSpec, inputRecord, outputRecord);
	verify(interaction).close();
	verify(connection).close();
}
 
Example #3
Source File: CciTemplateTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testTemplateExecuteWithCreatorAndRecordFactoryNotSupported()
		throws ResourceException {
	ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
	Connection connection = mock(Connection.class);
	Interaction interaction = mock(Interaction.class);

	Record inputRecord = mock(Record.class);
	final Record outputRecord = mock(Record.class);

	InteractionSpec interactionSpec = mock(InteractionSpec.class);

	given(connectionFactory.getConnection()).willReturn(connection);
	given(connectionFactory.getRecordFactory()).willThrow(new NotSupportedException("not supported"));
	given(connection.createInteraction()).willReturn(interaction);
	given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);

	CciTemplate ct = new CciTemplate(connectionFactory);
	ct.setOutputRecordCreator(new RecordCreator() {
		@Override
		public Record createRecord(RecordFactory recordFactory) {
			assertTrue(recordFactory instanceof NotSupportedRecordFactory);
			return outputRecord;
		}
	});
	ct.execute(interactionSpec, inputRecord);

	verify(interaction).execute(interactionSpec, inputRecord, outputRecord);
	verify(interaction).close();
	verify(connection).close();
}
 
Example #4
Source File: CciTemplate.java    From spring-analysis-note with MIT License 3 votes vote down vote up
/**
 * Return a RecordFactory for the given ConnectionFactory.
 * <p>Default implementation returns the connector's RecordFactory if
 * available, falling back to a NotSupportedRecordFactory placeholder.
 * This allows to invoke a RecordCreator callback with a non-null
 * RecordFactory reference in any case.
 * @param connectionFactory the CCI ConnectionFactory
 * @return the CCI RecordFactory for the ConnectionFactory
 * @throws ResourceException if thrown by CCI methods
 * @see org.springframework.jca.cci.connection.NotSupportedRecordFactory
 */
protected RecordFactory getRecordFactory(ConnectionFactory connectionFactory) throws ResourceException {
	try {
		return connectionFactory.getRecordFactory();
	}
	catch (NotSupportedException ex) {
		return new NotSupportedRecordFactory();
	}
}
 
Example #5
Source File: CciTemplate.java    From java-technology-stack with MIT License 3 votes vote down vote up
/**
 * Return a RecordFactory for the given ConnectionFactory.
 * <p>Default implementation returns the connector's RecordFactory if
 * available, falling back to a NotSupportedRecordFactory placeholder.
 * This allows to invoke a RecordCreator callback with a non-null
 * RecordFactory reference in any case.
 * @param connectionFactory the CCI ConnectionFactory
 * @return the CCI RecordFactory for the ConnectionFactory
 * @throws ResourceException if thrown by CCI methods
 * @see org.springframework.jca.cci.connection.NotSupportedRecordFactory
 */
protected RecordFactory getRecordFactory(ConnectionFactory connectionFactory) throws ResourceException {
	try {
		return connectionFactory.getRecordFactory();
	}
	catch (NotSupportedException ex) {
		return new NotSupportedRecordFactory();
	}
}
 
Example #6
Source File: CciTemplate.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Return a RecordFactory for the given ConnectionFactory.
 * <p>Default implementation returns the connector's RecordFactory if
 * available, falling back to a NotSupportedRecordFactory placeholder.
 * This allows to invoke a RecordCreator callback with a non-null
 * RecordFactory reference in any case.
 * @param connectionFactory the CCI ConnectionFactory
 * @return the CCI RecordFactory for the ConnectionFactory
 * @throws ResourceException if thrown by CCI methods
 * @see org.springframework.jca.cci.connection.NotSupportedRecordFactory
 */
protected RecordFactory getRecordFactory(ConnectionFactory connectionFactory) throws ResourceException {
	try {
		return connectionFactory.getRecordFactory();
	}
	catch (NotSupportedException ex) {
		return new NotSupportedRecordFactory();
	}
}
 
Example #7
Source File: CciTemplate.java    From spring4-understanding with Apache License 2.0 3 votes vote down vote up
/**
 * Return a RecordFactory for the given ConnectionFactory.
 * <p>Default implementation returns the connector's RecordFactory if
 * available, falling back to a NotSupportedRecordFactory placeholder.
 * This allows to invoke a RecordCreator callback with a non-null
 * RecordFactory reference in any case.
 * @param connectionFactory the CCI ConnectionFactory
 * @return the CCI RecordFactory for the ConnectionFactory
 * @throws ResourceException if thrown by CCI methods
 * @see org.springframework.jca.cci.connection.NotSupportedRecordFactory
 */
protected RecordFactory getRecordFactory(ConnectionFactory connectionFactory) throws ResourceException {
	try {
		return connectionFactory.getRecordFactory();
	}
	catch (NotSupportedException ex) {
		return new NotSupportedRecordFactory();
	}
}