use of com.adaptris.util.KeyValuePairSet in project interlok by adaptris.
the class JndiExtraConfigPtpProducerTest method createJndiVendorImpExample.
static JmsConnection createJndiVendorImpExample(StandardJndiImplementation jndi, JmsConnection c) {
JndiPtpProducerTest.createJndiVendorImpExample(jndi, c);
SimpleFactoryConfiguration sfc = new SimpleFactoryConfiguration();
KeyValuePairSet jndiExtras = sfc.getProperties();
jndiExtras.add(new KeyValuePair("ConnectID", "MyConnectId"));
jndiExtras.add(new KeyValuePair("PingInterval", "10"));
jndi.setExtraFactoryConfiguration(sfc);
return c;
}
use of com.adaptris.util.KeyValuePairSet in project interlok by adaptris.
the class JdbcQueryServiceCase method buildExamples.
@Override
protected List<JdbcService> buildExamples() {
ArrayList<JdbcService> objects = new ArrayList<>();
JdbcDataQueryService service = new JdbcDataQueryService();
try {
JdbcConnection connection = new JdbcConnection("jdbc:mysql://localhost:3306/mydatabase", "com.mysql.jdbc.Driver");
KeyValuePairSet connectionProperties = new KeyValuePairSet();
connectionProperties.add(new KeyValuePair("useCompression", "true"));
connection.setConnectionProperties(connectionProperties);
connection.setConnectionAttempts(2);
connection.setConnectionRetryInterval(new TimeInterval(3L, "SECONDS"));
service.setConnection(connection);
service.setResultSetTranslator(configureForExample(createTranslatorForConfig()));
String additionalParams = "";
boolean first = true;
for (QueryClasses qc : QueryClasses.values()) {
service.addStatementParameter(qc.create());
if (first) {
additionalParams += qc.name() + "=?";
first = false;
} else {
additionalParams += " AND " + qc.name() + "=?";
}
}
service.setStatementCreator(new ConfiguredSQLStatement("SELECT StringColumn1, DateColumn2, IntegerColumn3, BlobColumn, ClobColumn FROM tablename WHERE " + additionalParams));
} catch (Exception e) {
throw new RuntimeException(e);
}
objects.add(service);
return objects;
}
use of com.adaptris.util.KeyValuePairSet in project interlok by adaptris.
the class JdbcDataCaptureServiceCase method testSetNamespaceContext.
@Test
public void testSetNamespaceContext() throws Exception {
JdbcIteratingDataCaptureServiceImpl service = newService();
assertNull(service.getNamespaceContext());
KeyValuePairSet kvps = new KeyValuePairSet();
kvps.add(new KeyValuePair("hello", "world"));
service.setNamespaceContext(kvps);
assertEquals(kvps, service.getNamespaceContext());
service.setNamespaceContext(null);
assertNull(service.getNamespaceContext());
}
use of com.adaptris.util.KeyValuePairSet in project interlok by adaptris.
the class JdbcMapInsertCase method configureForTests.
protected static <T extends JdbcMapInsert> T configureForTests(T t) {
JdbcMapInsert service = t;
JdbcConnection connection = new JdbcConnection();
connection.setConnectUrl(JDBC_URL);
connection.setDriverImp(JDBC_DRIVER);
service.setConnection(connection);
KeyValuePairSet mappings = new KeyValuePairSet();
mappings.add(new KeyValuePair("dob", JdbcMapInsert.BasicType.Date.name()));
service.withTable(TABLE_NAME).withMappings(mappings);
return t;
}
use of com.adaptris.util.KeyValuePairSet in project interlok by adaptris.
the class JdbcMapUpsertTest method testService_Update_AllColumns.
@Test
public void testService_Update_AllColumns() throws Exception {
createDatabase(CREATE_ALL_BASIC_TYPES);
populateDatabase(INSERT_STMT_ALL_TYPES);
UpsertProperties service = configureForTests(createService());
KeyValuePairSet mappings = new KeyValuePairSet();
mappings.add(new KeyValuePair("firstname", JdbcMapInsert.BasicType.String.name()));
mappings.add(new KeyValuePair("lastname", JdbcMapInsert.BasicType.String.name()));
mappings.add(new KeyValuePair("dob", JdbcMapInsert.BasicType.Date.name()));
mappings.add(new KeyValuePair("integerColumn", JdbcMapInsert.BasicType.Integer.name()));
mappings.add(new KeyValuePair("longColumn", JdbcMapInsert.BasicType.Long.name()));
mappings.add(new KeyValuePair("booleanColumn", JdbcMapInsert.BasicType.Boolean.name()));
mappings.add(new KeyValuePair("bigIntegerColumn", JdbcMapInsert.BasicType.BigInteger.name()));
mappings.add(new KeyValuePair("bigDecimalColumn", JdbcMapInsert.BasicType.BigDecimal.name()));
mappings.add(new KeyValuePair("floatColumn", JdbcMapInsert.BasicType.Float.name()));
mappings.add(new KeyValuePair("doubleColumn", JdbcMapInsert.BasicType.Double.name()));
mappings.add(new KeyValuePair("timestampColumn", JdbcMapInsert.BasicType.Timestamp.name()));
mappings.add(new KeyValuePair("timeColumn", JdbcMapInsert.BasicType.Time.name()));
service.setFieldMappings(mappings);
service.setIdField(ID_ELEMENT_VALUE);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(CONTENT_ALL_TYPES);
ExampleServiceCase.execute(service, msg);
doAssert(1);
checkDob(ALICE, DOB);
try (Connection c = createConnection();
Statement s = c.createStatement();
ResultSet rs = s.executeQuery(String.format(SELECT_STMT, TABLE_NAME, ALICE))) {
if (rs.next()) {
assertEquals(true, rs.getBoolean("booleanColumn"));
} else {
fail("No Match for firstname: " + ALICE);
}
}
}
Aggregations