Search in sources :

Example 41 with KeyValuePairSet

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

Example 42 with KeyValuePairSet

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;
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) TimeInterval(com.adaptris.util.TimeInterval) ArrayList(java.util.ArrayList) JdbcConnection(com.adaptris.core.jdbc.JdbcConnection) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) ServiceException(com.adaptris.core.ServiceException) SQLException(java.sql.SQLException) CoreException(com.adaptris.core.CoreException) JdbcService(com.adaptris.core.jdbc.JdbcService)

Example 43 with KeyValuePairSet

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

Example 44 with KeyValuePairSet

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

Example 45 with KeyValuePairSet

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);
        }
    }
}
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)

Aggregations

KeyValuePairSet (com.adaptris.util.KeyValuePairSet)62 KeyValuePair (com.adaptris.util.KeyValuePair)54 Test (org.junit.Test)30 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)5 StandardJndiImplementation (com.adaptris.core.jms.jndi.StandardJndiImplementation)5 TimeInterval (com.adaptris.util.TimeInterval)4 SimpleFactoryConfiguration (com.adaptris.core.jms.jndi.SimpleFactoryConfiguration)3 Connection (java.sql.Connection)3 ArrayList (java.util.ArrayList)3 CoreException (com.adaptris.core.CoreException)2 ServiceException (com.adaptris.core.ServiceException)2 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)2 StandaloneProducer (com.adaptris.core.StandaloneProducer)2 Execution (com.adaptris.core.common.Execution)2 MetadataDataInputParameter (com.adaptris.core.common.MetadataDataInputParameter)2 StringPayloadDataInputParameter (com.adaptris.core.common.StringPayloadDataInputParameter)2 JdbcConnection (com.adaptris.core.jdbc.JdbcConnection)2 JunitBootstrapProperties (com.adaptris.core.stubs.JunitBootstrapProperties)2 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)2 ComboPooledDataSource (com.mchange.v2.c3p0.ComboPooledDataSource)2