}
catch (IllegalArgumentException e)
{
// OK
}
ValueParam paramConf = new ValueParam();
paramConf.setName(RPCServiceImpl.PARAM_JGROUPS_CONFIG);
params.addParameter(paramConf);
try
{
new RPCServiceImpl(container.getContext(), params, configManager);
fail("We expect a IllegalArgumentException since the jgroups config cannot be found");
}
catch (IllegalArgumentException e)
{
// OK
}
paramConf.setValue("fakePath");
try
{
new RPCServiceImpl(container.getContext(), params, configManager);
fail("We expect a IllegalArgumentException since the jgroups config cannot be found");
}
catch (IllegalArgumentException e)
{
// OK
}
paramConf.setValue("jar:/conf/portal/udp.xml");
RPCServiceImpl service = null;
try
{
service = new RPCServiceImpl(container.getContext(), params, configManager);
assertEquals(RPCServiceImpl.DEFAULT_TIMEOUT, service.getDefaultTimeout());
assertEquals(RPCServiceImpl.DEFAULT_RETRY_TIMEOUT, service.getRetryTimeout());
assertEquals(true, service.isAllowFailover());
assertEquals(RPCServiceImpl.CLUSTER_NAME + "-" + container.getContext().getName(), service.getClusterName());
}
finally
{
if (service != null)
{
service.stop();
}
}
ValueParam paramTimeout = new ValueParam();
paramTimeout.setName(RPCServiceImpl.PARAM_DEFAULT_TIMEOUT);
paramTimeout.setValue("fakeValue");
params.addParameter(paramTimeout);
try
{
new RPCServiceImpl(container.getContext(), params, configManager);
fail("We expect a NumberFormatException since the timeout is not properly set");
}
catch (NumberFormatException e)
{
// OK
}
paramTimeout.setValue("60");
try
{
service = new RPCServiceImpl(container.getContext(), params, configManager);
assertEquals(60, service.getDefaultTimeout());
assertEquals(RPCServiceImpl.DEFAULT_RETRY_TIMEOUT, service.getRetryTimeout());
assertEquals(true, service.isAllowFailover());
assertEquals(RPCServiceImpl.CLUSTER_NAME + "-" + container.getContext().getName(), service.getClusterName());
}
finally
{
if (service != null)
{
service.stop();
}
}
ValueParam paramRetryTimeout = new ValueParam();
paramRetryTimeout.setName(RPCServiceImpl.PARAM_RETRY_TIMEOUT);
paramRetryTimeout.setValue("fakeValue");
params.addParameter(paramRetryTimeout);
try
{
new RPCServiceImpl(container.getContext(), params, configManager);
fail("We expect a NumberFormatException since the retry timeout is not properly set");
}
catch (NumberFormatException e)
{
// OK
}
paramRetryTimeout.setValue("60");
try
{
service = new RPCServiceImpl(container.getContext(), params, configManager);
assertEquals(60, service.getDefaultTimeout());
assertEquals(60, service.getRetryTimeout());
assertEquals(true, service.isAllowFailover());
assertEquals(RPCServiceImpl.CLUSTER_NAME + "-" + container.getContext().getName(), service.getClusterName());
}
finally
{
if (service != null)
{
service.stop();
}
}
ValueParam paramAllowFailover = new ValueParam();
paramAllowFailover.setName(RPCServiceImpl.PARAM_ALLOW_FAILOVER);
paramAllowFailover.setValue("fakeValue");
params.addParameter(paramAllowFailover);
try
{
service = new RPCServiceImpl(container.getContext(), params, configManager);
assertEquals(60, service.getDefaultTimeout());
assertEquals(60, service.getRetryTimeout());
assertEquals(false, service.isAllowFailover());
assertEquals(RPCServiceImpl.CLUSTER_NAME + "-" + container.getContext().getName(), service.getClusterName());
}
finally
{
if (service != null)
{
service.stop();
}
}
paramAllowFailover.setValue("TRUE");
try
{
service = new RPCServiceImpl(container.getContext(), params, configManager);
assertEquals(60, service.getDefaultTimeout());
assertEquals(60, service.getRetryTimeout());
assertEquals(true, service.isAllowFailover());
assertEquals(RPCServiceImpl.CLUSTER_NAME + "-" + container.getContext().getName(), service.getClusterName());
}
finally
{
if (service != null)
{
service.stop();
}
}
ValueParam paramClusterName = new ValueParam();
paramClusterName.setName(RPCServiceImpl.PARAM_CLUSTER_NAME);
paramClusterName.setValue("MyName");
params.addParameter(paramClusterName);
try
{
service = new RPCServiceImpl(container.getContext(), params, configManager);
assertEquals(60, service.getDefaultTimeout());
assertEquals(paramClusterName.getValue() + "-" + container.getContext().getName(), service.getClusterName());
}
finally
{
if (service != null)
{