use of com.adaptris.core.jdbc.JdbcConnection in project interlok by adaptris.
the class ServiceFromDatabaseTest method testGetInputStream.
@Test
public void testGetInputStream() throws Exception {
DatabaseEntry entry = new DatabaseEntry("mySourcePartner", "myDestinationPartner");
createDatabase(Arrays.asList(entry));
JdbcConnection jdbcConn = configure(new JdbcConnection());
ServiceFromDatabase extractor = new ServiceFromDatabase().withQuery(SELECT_STMT).withConnection(jdbcConn);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata("source", "mySourcePartner");
msg.addMetadata("destination", "myDestinationPartner");
try {
LifecycleHelper.initAndStart(extractor);
try (InputStream in = extractor.getInputStream(msg)) {
assertNotNull(in);
assertEquals(ServiceList.class, DefaultMarshaller.getDefaultMarshaller().unmarshal(in).getClass());
}
} finally {
LifecycleHelper.stopAndClose(extractor);
}
}
use of com.adaptris.core.jdbc.JdbcConnection in project interlok by adaptris.
the class ServiceFromDatabaseTest method testLifecycle.
@Test
public void testLifecycle() throws Exception {
JdbcConnection jdbcConn = configure(new JdbcConnection());
ServiceFromDatabase extractor = new ServiceFromDatabase().withQuery(SELECT_STMT);
try {
LifecycleHelper.initAndStart(extractor);
fail();
} catch (Exception expected) {
} finally {
LifecycleHelper.stopAndClose(extractor);
}
extractor.setConnection(jdbcConn);
try {
LifecycleHelper.initAndStart(extractor);
} finally {
LifecycleHelper.stopAndClose(extractor);
}
}
use of com.adaptris.core.jdbc.JdbcConnection in project interlok by adaptris.
the class MetadataIdentitySequenceNumberServiceTest method retrieveObjectForSampleConfig.
@Override
protected MetadataIdentitySequenceNumberService retrieveObjectForSampleConfig() {
JdbcConnection connection = new JdbcConnection();
connection.setConnectUrl("jdbc:mysql://localhost:3306/mydatabase");
connection.setConnectionAttempts(2);
connection.setConnectionRetryInterval(new TimeInterval(3L, "SECONDS"));
MetadataIdentitySequenceNumberService service = new MetadataIdentitySequenceNumberService();
service.setMetadataKey("sequence_no");
service.setNumberFormat(DEFAULT_NUMBER_FORMAT);
service.setConnection(connection);
service.setIdentityMetadataKey(DEFAULT_IDENTITY_METADATA_KEY);
service.setOverflowBehaviour(AbstractJdbcSequenceNumberService.OverflowBehaviour.Continue);
return service;
}
use of com.adaptris.core.jdbc.JdbcConnection in project interlok by adaptris.
the class MetadataIdentitySequenceNumberServiceTest method configureForTests.
private MetadataIdentitySequenceNumberService configureForTests(MetadataIdentitySequenceNumberService service, boolean addConnection) {
if (addConnection) {
service.setConnection(new JdbcConnection(PROPERTIES.getProperty(JDBC_SEQUENCENUMBER_URL), PROPERTIES.getProperty(JDBC_SEQUENCENUMBER_DRIVER)));
}
service.setMetadataKey(DEFAULT_METADATA_KEY);
service.setNumberFormat(DEFAULT_NUMBER_FORMAT);
service.setIdentityMetadataKey(DEFAULT_IDENTITY_METADATA_KEY);
return service;
}
use of com.adaptris.core.jdbc.JdbcConnection in project interlok by adaptris.
the class JdbcServiceListTest method testSetConnection.
@Test
public void testSetConnection() {
JdbcConnection connection = new JdbcConnection();
JdbcServiceList list = new JdbcServiceList();
assertNull(list.getConnection());
list.setConnection(connection);
assertEquals(connection, list.connection());
assertEquals(connection, list.getConnection());
list.setConnection(null);
assertEquals(null, list.getConnection());
assertNull(list.connection());
}
Aggregations