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