Search in sources :

Example 96 with KeyValuePair

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());
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) Test(org.junit.Test)

Example 97 with KeyValuePair

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;
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) JdbcConnection(com.adaptris.core.jdbc.JdbcConnection) KeyValuePairSet(com.adaptris.util.KeyValuePairSet)

Example 98 with KeyValuePair

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);
        }
    }
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) Test(org.junit.Test)

Example 99 with KeyValuePair

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());
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) Test(org.junit.Test)

Example 100 with KeyValuePair

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));
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) BasicXmlSchemaValidator(com.adaptris.core.transform.schema.BasicXmlSchemaValidator) NotNullContentValidation(com.adaptris.transform.validate.NotNullContentValidation) DocumentBuilderFactoryBuilder(com.adaptris.core.util.DocumentBuilderFactoryBuilder) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) ValidationStage(com.adaptris.transform.validate.ValidationStage)

Aggregations

KeyValuePair (com.adaptris.util.KeyValuePair)143 Test (org.junit.Test)79 KeyValuePairSet (com.adaptris.util.KeyValuePairSet)55 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)26 KeyValuePairList (com.adaptris.util.KeyValuePairList)12 StandardJndiImplementation (com.adaptris.core.jms.jndi.StandardJndiImplementation)11 StandaloneProducer (com.adaptris.core.StandaloneProducer)10 Channel (com.adaptris.core.Channel)9 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)9 TimeInterval (com.adaptris.util.TimeInterval)9 ServiceException (com.adaptris.core.ServiceException)7 JmsConnection (com.adaptris.core.jms.JmsConnection)6 ArrayList (java.util.ArrayList)6 CoreException (com.adaptris.core.CoreException)5 StandardWorkflow (com.adaptris.core.StandardWorkflow)5 PasProducer (com.adaptris.core.jms.PasProducer)5 MetadataCollection (com.adaptris.core.MetadataCollection)4 MetadataElement (com.adaptris.core.MetadataElement)4 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)4 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)3