use of com.adaptris.util.KeyValuePair 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.KeyValuePair 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.KeyValuePair 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);
}
}
}
use of com.adaptris.util.KeyValuePair in project interlok by adaptris.
the class XmlRuleValidatorTest method testSetNamespaceContext.
@Test
public void testSetNamespaceContext() {
XmlRuleValidator obj = new XmlRuleValidator();
assertNull(obj.getNamespaceContext());
KeyValuePairSet kvps = new KeyValuePairSet();
kvps.add(new KeyValuePair("hello", "world"));
obj.setNamespaceContext(kvps);
assertEquals(kvps, obj.getNamespaceContext());
obj.setNamespaceContext(null);
assertNull(obj.getNamespaceContext());
}
use of com.adaptris.util.KeyValuePair in project interlok by adaptris.
the class XmlValidationServiceTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
ValidationStage vs = new ValidationStage();
vs.setIterationXpath("/document/names");
vs.setElementXpath("fullName");
vs.addRule(new NotNullContentValidation());
KeyValuePair disableExternalEntities = new KeyValuePair("http://xml.org/sax/features/external-general-entities", "false");
KeyValuePair disableDoctypeDecl = new KeyValuePair("http://apache.org/xml/features/disallow-doctype-decl", "true");
return new XmlValidationService(new XmlBasicValidator(new DocumentBuilderFactoryBuilder().withNamespaceAware(true).withFeatures(new KeyValuePairSet(Arrays.asList(disableExternalEntities, disableDoctypeDecl)))), new BasicXmlSchemaValidator().withSchema("http://host/schema.xsd or %message{metadatKey}"), new XmlRuleValidator(vs));
}
Aggregations