org.springframework.jca.cci.core.RecordExtractor Java Examples

The following examples show how to use org.springframework.jca.cci.core.RecordExtractor. 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 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputExtractorFalse()
		throws ResourceException, SQLException {
	ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
	Connection connection = mock(Connection.class);
	Interaction interaction = mock(Interaction.class);
	RecordExtractor<Object> extractor = mock(RecordExtractor.class);

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

	InteractionSpec interactionSpec = mock(InteractionSpec.class);

	given(connectionFactory.getConnection()).willReturn(connection);
	given(connection.createInteraction()).willReturn(interaction);
	given(interaction.execute(interactionSpec, inputRecord)).willReturn(outputRecord);
	given(extractor.extractData(outputRecord)).willReturn(new Object());

	CciTemplate ct = new CciTemplate(connectionFactory);
	ct.execute(interactionSpec, inputRecord, extractor);

	verify(extractor).extractData(outputRecord);
	verify(interaction).close();
	verify(connection).close();
}
 
Example #2
Source File: CciTemplateTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputExtractorFalse()
		throws ResourceException, SQLException {
	ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
	Connection connection = mock(Connection.class);
	Interaction interaction = mock(Interaction.class);
	RecordExtractor<Object> extractor = mock(RecordExtractor.class);

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

	InteractionSpec interactionSpec = mock(InteractionSpec.class);

	given(connectionFactory.getConnection()).willReturn(connection);
	given(connection.createInteraction()).willReturn(interaction);
	given(interaction.execute(interactionSpec, inputRecord)).willReturn(outputRecord);
	given(extractor.extractData(outputRecord)).willReturn(new Object());

	CciTemplate ct = new CciTemplate(connectionFactory);
	ct.execute(interactionSpec, inputRecord, extractor);

	verify(extractor).extractData(outputRecord);
	verify(interaction).close();
	verify(connection).close();
}
 
Example #3
Source File: CciTemplateTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputExtractorFalse()
		throws ResourceException, SQLException {
	ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
	Connection connection = mock(Connection.class);
	Interaction interaction = mock(Interaction.class);
	RecordExtractor<Object> extractor = mock(RecordExtractor.class);

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

	InteractionSpec interactionSpec = mock(InteractionSpec.class);

	given(connectionFactory.getConnection()).willReturn(connection);
	given(connection.createInteraction()).willReturn(interaction);
	given(interaction.execute(interactionSpec, inputRecord)).willReturn(outputRecord);
	given(extractor.extractData(outputRecord)).willReturn(new Object());

	CciTemplate ct = new CciTemplate(connectionFactory);
	ct.execute(interactionSpec, inputRecord, extractor);

	verify(extractor).extractData(outputRecord);
	verify(interaction).close();
	verify(connection).close();
}
 
Example #4
Source File: CciTemplateTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputExtractorTrueWithCreator()
		throws ResourceException, SQLException {
	ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
	RecordFactory recordFactory = mock(RecordFactory.class);
	Connection connection = mock(Connection.class);
	Interaction interaction = mock(Interaction.class);
	RecordExtractor<Object> extractor = mock(RecordExtractor.class);
	RecordCreator creator = mock(RecordCreator.class);

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

	InteractionSpec interactionSpec = mock(InteractionSpec.class);

	given(connectionFactory.getConnection()).willReturn(connection);
	given(connection.createInteraction()).willReturn(interaction);
	given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
	given(creator.createRecord(recordFactory)).willReturn(outputRecord);
	given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
	given(extractor.extractData(outputRecord)).willReturn(new Object());

	CciTemplate ct = new CciTemplate(connectionFactory);
	ct.setOutputRecordCreator(creator);
	ct.execute(interactionSpec, inputRecord, extractor);

	verify(extractor).extractData(outputRecord);
	verify(interaction).close();
	verify(connection).close();
}
 
Example #5
Source File: CciTemplateTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputGeneratorExtractorTrueWithCreator()
		throws ResourceException, SQLException {
	ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
	RecordFactory recordFactory = mock(RecordFactory.class);
	Connection connection = mock(Connection.class);
	Interaction interaction = mock(Interaction.class);
	RecordCreator generator = mock(RecordCreator.class);
	RecordExtractor<Object> extractor = mock(RecordExtractor.class);
	RecordCreator creator = mock(RecordCreator.class);

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

	Object obj = new Object();

	InteractionSpec interactionSpec = mock(InteractionSpec.class);

	given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
	given(connectionFactory.getConnection()).willReturn(connection);
	given(connection.createInteraction()).willReturn(interaction);
	given(creator.createRecord(recordFactory)).willReturn(outputRecord);
	given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
	given(generator.createRecord(recordFactory)).willReturn(inputRecord);
	given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
	given(extractor.extractData(outputRecord)).willReturn(obj);

	CciTemplate ct = new CciTemplate(connectionFactory);
	ct.setOutputRecordCreator(creator);
	assertEquals(obj, ct.execute(interactionSpec, generator, extractor));

	verify(interaction).close();
	verify(connection).close();
}
 
Example #6
Source File: CciTemplateTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputGeneratorExtractorFalse()
		throws ResourceException, SQLException {
	ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
	RecordFactory recordFactory = mock(RecordFactory.class);
	Connection connection = mock(Connection.class);
	Interaction interaction = mock(Interaction.class);
	RecordCreator generator = mock(RecordCreator.class);
	RecordExtractor<Object> extractor = mock(RecordExtractor.class);

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

	InteractionSpec interactionSpec = mock(InteractionSpec.class);

	given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
	given(connectionFactory.getConnection()).willReturn(connection);
	given(connection.createInteraction()).willReturn(interaction);
	given(generator.createRecord(recordFactory)).willReturn(inputRecord);
	given(interaction.execute(interactionSpec, inputRecord)).willReturn(outputRecord);
	given(extractor.extractData(outputRecord)).willReturn(new Object());

	CciTemplate ct = new CciTemplate(connectionFactory);
	ct.execute(interactionSpec, generator, extractor);

	verify(extractor).extractData(outputRecord);
	verify(interaction).close();
	verify(connection).close();
}
 
Example #7
Source File: CciTemplateTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputOutputResultsSetFalse()
		throws ResourceException, SQLException {
	ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
	RecordFactory recordFactory = mock(RecordFactory.class);
	Connection connection = mock(Connection.class);
	Interaction interaction = mock(Interaction.class);
	Record record = mock(Record.class);
	ResultSet resultset = mock(ResultSet.class);
	RecordCreator generator = mock(RecordCreator.class);
	RecordExtractor<Object> extractor = mock(RecordExtractor.class);

	InteractionSpec interactionSpec = mock(InteractionSpec.class);

	given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
	given(connectionFactory.getConnection()).willReturn(connection);
	given(connection.createInteraction()).willReturn(interaction);
	given(generator.createRecord(recordFactory)).willReturn(record);
	given(interaction.execute(interactionSpec, record)).willReturn(resultset);
	given(extractor.extractData(resultset)).willReturn(new Object());

	CciTemplate ct = new CciTemplate(connectionFactory);
	ct.execute(interactionSpec, generator, extractor);

	verify(extractor).extractData(resultset);
	verify(resultset).close();
	verify(interaction).close();
	verify(connection).close();
}
 
Example #8
Source File: CciTemplateTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputExtractorTrueWithCreator()
		throws ResourceException, SQLException {
	ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
	RecordFactory recordFactory = mock(RecordFactory.class);
	Connection connection = mock(Connection.class);
	Interaction interaction = mock(Interaction.class);
	RecordExtractor<Object> extractor = mock(RecordExtractor.class);
	RecordCreator creator = mock(RecordCreator.class);

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

	InteractionSpec interactionSpec = mock(InteractionSpec.class);

	given(connectionFactory.getConnection()).willReturn(connection);
	given(connection.createInteraction()).willReturn(interaction);
	given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
	given(creator.createRecord(recordFactory)).willReturn(outputRecord);
	given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
	given(extractor.extractData(outputRecord)).willReturn(new Object());

	CciTemplate ct = new CciTemplate(connectionFactory);
	ct.setOutputRecordCreator(creator);
	ct.execute(interactionSpec, inputRecord, extractor);

	verify(extractor).extractData(outputRecord);
	verify(interaction).close();
	verify(connection).close();
}
 
Example #9
Source File: CciTemplateTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputGeneratorExtractorTrueWithCreator()
		throws ResourceException, SQLException {
	ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
	RecordFactory recordFactory = mock(RecordFactory.class);
	Connection connection = mock(Connection.class);
	Interaction interaction = mock(Interaction.class);
	RecordCreator generator = mock(RecordCreator.class);
	RecordExtractor<Object> extractor = mock(RecordExtractor.class);
	RecordCreator creator = mock(RecordCreator.class);

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

	Object obj = new Object();

	InteractionSpec interactionSpec = mock(InteractionSpec.class);

	given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
	given(connectionFactory.getConnection()).willReturn(connection);
	given(connection.createInteraction()).willReturn(interaction);
	given(creator.createRecord(recordFactory)).willReturn(outputRecord);
	given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
	given(generator.createRecord(recordFactory)).willReturn(inputRecord);
	given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
	given(extractor.extractData(outputRecord)).willReturn(obj);

	CciTemplate ct = new CciTemplate(connectionFactory);
	ct.setOutputRecordCreator(creator);
	assertEquals(obj, ct.execute(interactionSpec, generator, extractor));

	verify(interaction).close();
	verify(connection).close();
}
 
Example #10
Source File: CciTemplateTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputGeneratorExtractorFalse()
		throws ResourceException, SQLException {
	ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
	RecordFactory recordFactory = mock(RecordFactory.class);
	Connection connection = mock(Connection.class);
	Interaction interaction = mock(Interaction.class);
	RecordCreator generator = mock(RecordCreator.class);
	RecordExtractor<Object> extractor = mock(RecordExtractor.class);

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

	InteractionSpec interactionSpec = mock(InteractionSpec.class);

	given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
	given(connectionFactory.getConnection()).willReturn(connection);
	given(connection.createInteraction()).willReturn(interaction);
	given(generator.createRecord(recordFactory)).willReturn(inputRecord);
	given(interaction.execute(interactionSpec, inputRecord)).willReturn(outputRecord);
	given(extractor.extractData(outputRecord)).willReturn(new Object());

	CciTemplate ct = new CciTemplate(connectionFactory);
	ct.execute(interactionSpec, generator, extractor);

	verify(extractor).extractData(outputRecord);
	verify(interaction).close();
	verify(connection).close();
}
 
Example #11
Source File: CciTemplateTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputOutputResultsSetFalse()
		throws ResourceException, SQLException {
	ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
	RecordFactory recordFactory = mock(RecordFactory.class);
	Connection connection = mock(Connection.class);
	Interaction interaction = mock(Interaction.class);
	Record record = mock(Record.class);
	ResultSet resultset = mock(ResultSet.class);
	RecordCreator generator = mock(RecordCreator.class);
	RecordExtractor<Object> extractor = mock(RecordExtractor.class);

	InteractionSpec interactionSpec = mock(InteractionSpec.class);

	given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
	given(connectionFactory.getConnection()).willReturn(connection);
	given(connection.createInteraction()).willReturn(interaction);
	given(generator.createRecord(recordFactory)).willReturn(record);
	given(interaction.execute(interactionSpec, record)).willReturn(resultset);
	given(extractor.extractData(resultset)).willReturn(new Object());

	CciTemplate ct = new CciTemplate(connectionFactory);
	ct.execute(interactionSpec, generator, extractor);

	verify(extractor).extractData(resultset);
	verify(resultset).close();
	verify(interaction).close();
	verify(connection).close();
}
 
Example #12
Source File: CciTemplateTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputExtractorTrueWithCreator()
		throws ResourceException, SQLException {
	ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
	RecordFactory recordFactory = mock(RecordFactory.class);
	Connection connection = mock(Connection.class);
	Interaction interaction = mock(Interaction.class);
	RecordExtractor<Object> extractor = mock(RecordExtractor.class);
	RecordCreator creator = mock(RecordCreator.class);

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

	InteractionSpec interactionSpec = mock(InteractionSpec.class);

	given(connectionFactory.getConnection()).willReturn(connection);
	given(connection.createInteraction()).willReturn(interaction);
	given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
	given(creator.createRecord(recordFactory)).willReturn(outputRecord);
	given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
	given(extractor.extractData(outputRecord)).willReturn(new Object());

	CciTemplate ct = new CciTemplate(connectionFactory);
	ct.setOutputRecordCreator(creator);
	ct.execute(interactionSpec, inputRecord, extractor);

	verify(extractor).extractData(outputRecord);
	verify(interaction).close();
	verify(connection).close();
}
 
Example #13
Source File: CciTemplateTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputGeneratorExtractorTrueWithCreator()
		throws ResourceException, SQLException {
	ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
	RecordFactory recordFactory = mock(RecordFactory.class);
	Connection connection = mock(Connection.class);
	Interaction interaction = mock(Interaction.class);
	RecordCreator generator = mock(RecordCreator.class);
	RecordExtractor<Object> extractor = mock(RecordExtractor.class);
	RecordCreator creator = mock(RecordCreator.class);

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

	Object obj = new Object();

	InteractionSpec interactionSpec = mock(InteractionSpec.class);

	given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
	given(connectionFactory.getConnection()).willReturn(connection);
	given(connection.createInteraction()).willReturn(interaction);
	given(creator.createRecord(recordFactory)).willReturn(outputRecord);
	given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
	given(generator.createRecord(recordFactory)).willReturn(inputRecord);
	given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
	given(extractor.extractData(outputRecord)).willReturn(obj);

	CciTemplate ct = new CciTemplate(connectionFactory);
	ct.setOutputRecordCreator(creator);
	assertEquals(obj, ct.execute(interactionSpec, generator, extractor));

	verify(interaction).close();
	verify(connection).close();
}
 
Example #14
Source File: CciTemplateTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputGeneratorExtractorFalse()
		throws ResourceException, SQLException {
	ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
	RecordFactory recordFactory = mock(RecordFactory.class);
	Connection connection = mock(Connection.class);
	Interaction interaction = mock(Interaction.class);
	RecordCreator generator = mock(RecordCreator.class);
	RecordExtractor<Object> extractor = mock(RecordExtractor.class);

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

	InteractionSpec interactionSpec = mock(InteractionSpec.class);

	given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
	given(connectionFactory.getConnection()).willReturn(connection);
	given(connection.createInteraction()).willReturn(interaction);
	given(generator.createRecord(recordFactory)).willReturn(inputRecord);
	given(interaction.execute(interactionSpec, inputRecord)).willReturn(outputRecord);
	given(extractor.extractData(outputRecord)).willReturn(new Object());

	CciTemplate ct = new CciTemplate(connectionFactory);
	ct.execute(interactionSpec, generator, extractor);

	verify(extractor).extractData(outputRecord);
	verify(interaction).close();
	verify(connection).close();
}
 
Example #15
Source File: CciTemplateTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputOutputResultsSetFalse()
		throws ResourceException, SQLException {
	ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
	RecordFactory recordFactory = mock(RecordFactory.class);
	Connection connection = mock(Connection.class);
	Interaction interaction = mock(Interaction.class);
	Record record = mock(Record.class);
	ResultSet resultset = mock(ResultSet.class);
	RecordCreator generator = mock(RecordCreator.class);
	RecordExtractor<Object> extractor = mock(RecordExtractor.class);

	InteractionSpec interactionSpec = mock(InteractionSpec.class);

	given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
	given(connectionFactory.getConnection()).willReturn(connection);
	given(connection.createInteraction()).willReturn(interaction);
	given(generator.createRecord(recordFactory)).willReturn(record);
	given(interaction.execute(interactionSpec, record)).willReturn(resultset);
	given(extractor.extractData(resultset)).willReturn(new Object());

	CciTemplate ct = new CciTemplate(connectionFactory);
	ct.execute(interactionSpec, generator, extractor);

	verify(extractor).extractData(resultset);
	verify(resultset).close();
	verify(interaction).close();
	verify(connection).close();
}