Search in sources :

Example 46 with KeyValuePairSet

use of com.adaptris.util.KeyValuePairSet 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 47 with KeyValuePairSet

use of com.adaptris.util.KeyValuePairSet 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)

Example 48 with KeyValuePairSet

use of com.adaptris.util.KeyValuePairSet in project interlok by adaptris.

the class PooledConnectionHelper method createAdvancedPooledConnection.

public static AdvancedJdbcPooledConnection createAdvancedPooledConnection(String driver, String url, int poolsize) {
    AdvancedJdbcPooledConnection conn = new AdvancedJdbcPooledConnection();
    conn.setConnectUrl(url);
    conn.setDriverImp(driver);
    KeyValuePairSet poolProps = new KeyValuePairSet();
    poolProps.add(new KeyValuePair(PooledConnectionProperties.maxPoolSize.name(), Integer.toString(poolsize)));
    poolProps.add(new KeyValuePair(PooledConnectionProperties.minPoolSize.name(), Integer.toString(poolsize)));
    poolProps.add(new KeyValuePair(PooledConnectionProperties.maxIdleTime.name(), Long.toString(DEFAULT_IDLE_TIME.toMilliseconds())));
    poolProps.add(new KeyValuePair(PooledConnectionProperties.idleConnectionTestPeriod.name(), Long.toString(DEFAULT_IDLE_CONNECTION_TEST.toMilliseconds())));
    poolProps.add(new KeyValuePair(PooledConnectionProperties.checkoutTimeout.name(), Long.toString(DEFAULT_ACQUIRE_WAIT.toMilliseconds())));
    conn.setConnectionAttempts(1);
    conn.setConnectionPoolProperties(poolProps);
    conn.setConnectionRetryInterval(DEFAULT_RETRY_WAIT);
    return conn;
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) KeyValuePairSet(com.adaptris.util.KeyValuePairSet)

Example 49 with KeyValuePairSet

use of com.adaptris.util.KeyValuePairSet in project interlok by adaptris.

the class PooledConnectionPropertiesTest method testApply.

@Test
public void testApply() throws Exception {
    String url = "jdbc:derby:memory:" + GUID.safeUUID() + ";create=true";
    String driver = "org.apache.derby.jdbc.EmbeddedDriver";
    KeyValuePairSet props = new KeyValuePairSet();
    for (PooledConnectionProperties p : PooledConnectionProperties.values()) {
        props.add(new KeyValuePair(p.name(), DUMMY_VALUES.get(p.propertyType()).value()));
    }
    props.add(new KeyValuePair("hello", "world"));
    ComboPooledDataSource ds = new ComboPooledDataSource();
    PooledConnectionProperties.apply(null, ds);
    PooledConnectionProperties.apply(props, ds);
    assertEquals(10, ds.getAcquireIncrement());
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource) KeyValuePair(com.adaptris.util.KeyValuePair) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) Test(org.junit.Test)

Example 50 with KeyValuePairSet

use of com.adaptris.util.KeyValuePairSet in project interlok by adaptris.

the class AdvancedJdbcPooledConnectionTest method configure.

@Override
protected AdvancedJdbcPooledConnection configure(AdvancedJdbcPooledConnection conn1) throws Exception {
    String url = initialiseDatabase();
    conn1.setConnectUrl(url);
    conn1.setDriverImp(DRIVER_IMP);
    conn1.setConnectionAttempts(1);
    conn1.setConnectionRetryInterval(new TimeInterval(10L, TimeUnit.MILLISECONDS.name()));
    KeyValuePairSet poolProps = new KeyValuePairSet();
    poolProps.add(new KeyValuePair(PooledConnectionProperties.acquireIncrement.name(), "5"));
    poolProps.add(new KeyValuePair(PooledConnectionProperties.minPoolSize.name(), "10"));
    poolProps.add(new KeyValuePair(PooledConnectionProperties.maxPoolSize.name(), "50"));
    conn1.setConnectionPoolProperties(poolProps);
    return conn1;
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) KeyValuePair(com.adaptris.util.KeyValuePair) KeyValuePairSet(com.adaptris.util.KeyValuePairSet)

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