Search in sources :

Example 1 with PoolConfiguration

use of org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration in project wildfly by wildfly.

the class DatasourcePoolAttributesTestCase method testModifyNonReloadAttributes.

/**
     * Checks that attributes not requiring reload can be set.
     */
@Test
public void testModifyNonReloadAttributes() throws Exception {
    WrapperDataSource wrapperDataSource = JcaTestsUtil.extractWrapperDatasource((WildFlyDataSource) datasource);
    PoolConfiguration poolConfiguration = JcaTestsUtil.exctractPoolConfiguration(wrapperDataSource);
    // check initial values
    Assert.assertNotNull(poolConfiguration);
    Assert.assertEquals(0, poolConfiguration.getMinSize());
    Assert.assertEquals(20, poolConfiguration.getMaxSize());
    Assert.assertEquals(0, poolConfiguration.getInitialSize());
    Assert.assertEquals(30000, poolConfiguration.getBlockingTimeout());
    Assert.assertEquals(true, poolConfiguration.isFair());
    Assert.assertEquals(false, poolConfiguration.isStrictMin());
    // modify values
    writeAttribute(DS_ADDRESS, Constants.MIN_POOL_SIZE.getName(), "4");
    writeAttribute(DS_ADDRESS, Constants.MAX_POOL_SIZE.getName(), "10");
    writeAttribute(DS_ADDRESS, Constants.INITIAL_POOL_SIZE.getName(), "6");
    writeAttribute(DS_ADDRESS, Constants.BLOCKING_TIMEOUT_WAIT_MILLIS.getName(), "10000");
    writeAttribute(DS_ADDRESS, Constants.POOL_FAIR.getName(), "false");
    writeAttribute(DS_ADDRESS, Constants.POOL_USE_STRICT_MIN.getName(), "true");
    // check that server is not in reload-required state
    ModelNode serverState = readAttribute(new ModelNode(), "server-state");
    Assert.assertEquals("running", serverState.asString());
    // check that runtime was updated
    Assert.assertEquals(4, poolConfiguration.getMinSize());
    Assert.assertEquals(10, poolConfiguration.getMaxSize());
    Assert.assertEquals(6, poolConfiguration.getInitialSize());
    Assert.assertEquals(10000, poolConfiguration.getBlockingTimeout());
    Assert.assertEquals(false, poolConfiguration.isFair());
    Assert.assertEquals(true, poolConfiguration.isStrictMin());
}
Also used : PoolConfiguration(org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration) ModelNode(org.jboss.dmr.ModelNode) WrapperDataSource(org.jboss.jca.adapters.jdbc.WrapperDataSource) Test(org.junit.Test)

Example 2 with PoolConfiguration

use of org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration in project wildfly by wildfly.

the class ResourceAdapterPoolAttributesTestCase method testModifyPoolAttributes.

@Test
public void testModifyPoolAttributes() throws Exception {
    PoolConfiguration poolConfiguration = JcaTestsUtil.exctractPoolConfiguration(lcf);
    // check initial values
    Assert.assertNotNull(poolConfiguration);
    Assert.assertEquals(2, poolConfiguration.getMinSize());
    Assert.assertEquals(5, poolConfiguration.getMaxSize());
    Assert.assertEquals(2, poolConfiguration.getInitialSize());
    Assert.assertEquals(30000, poolConfiguration.getBlockingTimeout());
    Assert.assertEquals(true, poolConfiguration.isFair());
    Assert.assertEquals(false, poolConfiguration.isStrictMin());
    // modify values
    writeAttribute(CONNECTION_ADDRESS, Constants.MIN_POOL_SIZE.getName(), "4");
    writeAttribute(CONNECTION_ADDRESS, Constants.MAX_POOL_SIZE.getName(), "10");
    writeAttribute(CONNECTION_ADDRESS, Constants.INITIAL_POOL_SIZE.getName(), "6");
    writeAttribute(CONNECTION_ADDRESS, Constants.BLOCKING_TIMEOUT_WAIT_MILLIS.getName(), "10000");
    writeAttribute(CONNECTION_ADDRESS, Constants.POOL_FAIR.getName(), "false");
    writeAttribute(CONNECTION_ADDRESS, Constants.POOL_USE_STRICT_MIN.getName(), "true");
    // check that server is not in reload-required state
    ModelNode serverState = readAttribute(new ModelNode(), "server-state");
    Assert.assertEquals("running", serverState.asString());
    // check that runtime was updated
    Assert.assertEquals(4, poolConfiguration.getMinSize());
    Assert.assertEquals(10, poolConfiguration.getMaxSize());
    Assert.assertEquals(6, poolConfiguration.getInitialSize());
    Assert.assertEquals(10000, poolConfiguration.getBlockingTimeout());
    Assert.assertEquals(false, poolConfiguration.isFair());
    Assert.assertEquals(true, poolConfiguration.isStrictMin());
}
Also used : PoolConfiguration(org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 3 with PoolConfiguration

use of org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration in project wildfly by wildfly.

the class JcaTestsUtil method exctractPoolConfiguration.

public static PoolConfiguration exctractPoolConfiguration(Object connectionFactory) {
    ConnectionManager cm = extractConnectionManager(connectionFactory);
    // org.jboss.jca.core.connectionmanager.pool.strategy.OnePool
    Pool pool = cm.getPool();
    Class<?> clz = pool.getClass();
    // org.jboss.jca.core.connectionmanager.pool.AbstractPrefillPool
    clz = clz.getSuperclass();
    // org.jboss.jca.core.connectionmanager.pool.AbstractPool
    clz = clz.getSuperclass();
    try {
        Method getPoolConfiguration = clz.getDeclaredMethod("getPoolConfiguration");
        getPoolConfiguration.setAccessible(true);
        return (PoolConfiguration) getPoolConfiguration.invoke(pool);
    } catch (Throwable t) {
        fail(t.getMessage());
    }
    return null;
}
Also used : PoolConfiguration(org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration) ConnectionManager(org.jboss.jca.core.connectionmanager.ConnectionManager) Pool(org.jboss.jca.core.connectionmanager.pool.api.Pool) ManagedConnectionPool(org.jboss.jca.core.connectionmanager.pool.mcp.ManagedConnectionPool) Method(java.lang.reflect.Method)

Aggregations

PoolConfiguration (org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration)3 ModelNode (org.jboss.dmr.ModelNode)2 Test (org.junit.Test)2 Method (java.lang.reflect.Method)1 WrapperDataSource (org.jboss.jca.adapters.jdbc.WrapperDataSource)1 ConnectionManager (org.jboss.jca.core.connectionmanager.ConnectionManager)1 Pool (org.jboss.jca.core.connectionmanager.pool.api.Pool)1 ManagedConnectionPool (org.jboss.jca.core.connectionmanager.pool.mcp.ManagedConnectionPool)1