/** * Verify that the type is set correctly and that the correct name is returned for the type. */ public void testSetRemoteTypeName_cluster() { RemoteCacheServerAttributes attributes = new RemoteCacheServerAttributes(); attributes.setRemoteTypeName( "CLUSTER" ); assertEquals( "Wrong type.", RemoteType.CLUSTER, attributes.getRemoteType() ); assertEquals( "Wrong name", "CLUSTER", attributes.getRemoteTypeName() ); } }
/** * @return String details */ @Override public String toString() { StringBuilder buf = new StringBuilder(super.toString()); buf.append( "\n servicePort = [" + this.getServicePort() + "]" ); buf.append( "\n allowClusterGet = [" + this.isAllowClusterGet() + "]" ); buf.append( "\n configFileName = [" + this.getConfigFileName() + "]" ); buf.append( "\n rmiSocketFactoryTimeoutMillis = [" + this.getRmiSocketFactoryTimeoutMillis() + "]" ); buf.append( "\n useRegistryKeepAlive = [" + this.isUseRegistryKeepAlive() + "]" ); buf.append( "\n registryKeepAliveDelayMillis = [" + this.getRegistryKeepAliveDelayMillis() + "]" ); buf.append( "\n eventQueueType = [" + this.getEventQueueType() + "]" ); buf.append( "\n eventQueuePoolName = [" + this.getEventQueuePoolName() + "]" ); return buf.toString(); } }
/** * Verify that we get a string, even if not attributes are set. */ public void testToString() { RemoteCacheServerAttributes attributes = new RemoteCacheServerAttributes(); assertNotNull( "Should have a string.", attributes.toString() ); }
rcsa.setConfigFileName( propFile ); rcsa.setRemotePort( port ); rcsa.setRemoteHost( host ); if ( log.isInfoEnabled() ) setServiceName( rcsa.getRemoteServiceName() ); RemoteUtils.configureGlobalCustomSocketFactory( rcsa.getRmiSocketFactoryTimeoutMillis() ); if (rcsa.isStartRegistry()) if ( rcsa.isUseRegistryKeepAlive() ) keepAliveDaemon.scheduleAtFixedRate(runner, 0, rcsa.getRegistryKeepAliveDelayMillis(), TimeUnit.MILLISECONDS);
rcsa.setRemoteLocation( host, port ); if ( log.isInfoEnabled() ) setServiceName( rcsa.getRemoteServiceName() ); RemoteUtils.configureGlobalCustomSocketFactory( rcsa.getRmiSocketFactoryTimeoutMillis() ); if ( rcsa.isUseRegistryKeepAlive() ) keepAliveDaemon.scheduleAtFixedRate(runner, 0, rcsa.getRegistryKeepAliveDelayMillis(), TimeUnit.MILLISECONDS);
/** * Configure. * <p> * jcs.remotecache.serverattributes.ATTRIBUTENAME=ATTRIBUTEVALUE * <p> * @param prop * @return RemoteCacheServerAttributesconfigureRemoteCacheServerAttributes */ protected static RemoteCacheServerAttributes configureRemoteCacheServerAttributes( Properties prop ) { RemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes(); // configure automatically PropertySetter.setProperties( rcsa, prop, CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX + "." ); configureManuallyIfValuesArePresent( prop, rcsa ); return rcsa; }
/** verify that we get the timeout value */ public void testConfigureRemoteCacheServerAttributes_timeoutPresent() { // SETUP int timeout = 123245; Properties props = new Properties(); props.put( IRemoteCacheConstants.SOCKET_TIMEOUT_MILLIS, String.valueOf( timeout ) ); // DO WORK RemoteCacheServerAttributes result = RemoteCacheServerFactory.configureRemoteCacheServerAttributes( props ); // VERIFY assertEquals( "Wrong timeout", timeout, result.getRmiSocketFactoryTimeoutMillis() ); }
/** verify that we get the startRegistry value */ public void testConfigureRemoteCacheServerAttributes_allowClusterGetPresent() { // SETUP boolean allowClusterGet = false; Properties props = new Properties(); props.put( IRemoteCacheConstants.CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX + ".allowClusterGet", String.valueOf( allowClusterGet ) ); // DO WORK RemoteCacheServerAttributes result = RemoteCacheServerFactory.configureRemoteCacheServerAttributes( props ); // VERIFY assertEquals( "Wrong allowClusterGet", allowClusterGet, result.isAllowClusterGet() ); }
/** verify that we get the timeout value */ public void testConfigureRemoteCacheServerAttributes_eventQueuePoolName() { // SETUP String eventQueuePoolName = "specialName"; Properties props = new Properties(); props.put( IRemoteCacheConstants.CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX + ".EventQueuePoolName", eventQueuePoolName ); // DO WORK RemoteCacheServerAttributes result = RemoteCacheServerFactory.configureRemoteCacheServerAttributes( props ); // VERIFY assertEquals( "Wrong eventQueuePoolName", eventQueuePoolName, result.getEventQueuePoolName() ); }
/** verify that we get the registryKeepAliveDelayMillis value */ public void testConfigureRemoteCacheServerAttributes_registryKeepAliveDelayMillisPresent() { // SETUP int registryKeepAliveDelayMillis = 123245; Properties props = new Properties(); props.put( IRemoteCacheConstants.CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX + ".registryKeepAliveDelayMillis", String.valueOf( registryKeepAliveDelayMillis ) ); // DO WORK RemoteCacheServerAttributes result = RemoteCacheServerFactory.configureRemoteCacheServerAttributes( props ); // VERIFY assertEquals( "Wrong registryKeepAliveDelayMillis", registryKeepAliveDelayMillis, result.getRegistryKeepAliveDelayMillis() ); }
/** verify that we get the useRegistryKeepAlive value */ public void testConfigureRemoteCacheServerAttributes_useRegistryKeepAlivePresent() { // SETUP boolean useRegistryKeepAlive = false; Properties props = new Properties(); props.put( IRemoteCacheConstants.CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX + ".useRegistryKeepAlive", String.valueOf( useRegistryKeepAlive ) ); // DO WORK RemoteCacheServerAttributes result = RemoteCacheServerFactory.configureRemoteCacheServerAttributes( props ); // VERIFY assertEquals( "Wrong useRegistryKeepAlive", useRegistryKeepAlive, result.isUseRegistryKeepAlive() ); }
/** * Configure. * <p> * jcs.remotecache.serverattributes.ATTRIBUTENAME=ATTRIBUTEVALUE * <p> * @param prop * @return RemoteCacheServerAttributesconfigureRemoteCacheServerAttributes */ protected static RemoteCacheServerAttributes configureRemoteCacheServerAttributes( Properties prop ) { RemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes(); // configure automatically PropertySetter.setProperties( rcsa, prop, CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX + "." ); configureManuallyIfValuesArePresent( prop, rcsa ); return rcsa; }
/** verify that we get the timeout value */ public void testConfigureRemoteCacheServerAttributes_timeoutPresent() { // SETUP int timeout = 123245; Properties props = new Properties(); props.put( IRemoteCacheConstants.SOCKET_TIMEOUT_MILLIS, String.valueOf( timeout ) ); // DO WORK RemoteCacheServerAttributes result = RemoteCacheServerFactory.configureRemoteCacheServerAttributes( props ); // VERIFY assertEquals( "Wrong timeout", timeout, result.getRmiSocketFactoryTimeoutMillis() ); }
/** * Verify that we get a string, even if not attributes are set. */ public void testToString() { RemoteCacheServerAttributes attributes = new RemoteCacheServerAttributes(); assertNotNull( "Should have a string.", attributes.toString() ); }
/** verify that we get the allowClusterGet value */ public void testConfigureRemoteCacheServerAttributes_allowClusterGetPresent() { // SETUP boolean allowClusterGet = false; Properties props = new Properties(); props.put( IRemoteCacheConstants.CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX + ".allowClusterGet", String.valueOf( allowClusterGet ) ); // DO WORK RemoteCacheServerAttributes result = RemoteCacheServerFactory.configureRemoteCacheServerAttributes( props ); // VERIFY assertEquals( "Wrong allowClusterGet", allowClusterGet, result.isAllowClusterGet() ); }
/** verify that we get the timeout value */ public void testConfigureRemoteCacheServerAttributes_eventQueuePoolName() { // SETUP String eventQueuePoolName = "specialName"; Properties props = new Properties(); props.put( IRemoteCacheConstants.CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX + ".EventQueuePoolName", eventQueuePoolName ); // DO WORK RemoteCacheServerAttributes result = RemoteCacheServerFactory.configureRemoteCacheServerAttributes( props ); // VERIFY assertEquals( "Wrong eventQueuePoolName", eventQueuePoolName, result.getEventQueuePoolName() ); }
/** verify that we get the registryKeepAliveDelayMillis value */ public void testConfigureRemoteCacheServerAttributes_registryKeepAliveDelayMillisPresent() { // SETUP int registryKeepAliveDelayMillis = 123245; Properties props = new Properties(); props.put( IRemoteCacheConstants.CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX + ".registryKeepAliveDelayMillis", String.valueOf( registryKeepAliveDelayMillis ) ); // DO WORK RemoteCacheServerAttributes result = RemoteCacheServerFactory.configureRemoteCacheServerAttributes( props ); // VERIFY assertEquals( "Wrong registryKeepAliveDelayMillis", registryKeepAliveDelayMillis, result.getRegistryKeepAliveDelayMillis() ); }
/** verify that we get the useRegistryKeepAlive value */ public void testConfigureRemoteCacheServerAttributes_useRegistryKeepAlivePresent() { // SETUP boolean useRegistryKeepAlive = false; Properties props = new Properties(); props.put( IRemoteCacheConstants.CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX + ".useRegistryKeepAlive", String.valueOf( useRegistryKeepAlive ) ); // DO WORK RemoteCacheServerAttributes result = RemoteCacheServerFactory.configureRemoteCacheServerAttributes( props ); // VERIFY assertEquals( "Wrong useRegistryKeepAlive", useRegistryKeepAlive, result.isUseRegistryKeepAlive() ); }
/** * @return String details */ @Override public String toString() { StringBuilder buf = new StringBuilder(super.toString()); buf.append( "\n servicePort = [" + this.getServicePort() + "]" ); buf.append( "\n allowClusterGet = [" + this.isAllowClusterGet() + "]" ); buf.append( "\n configFileName = [" + this.getConfigFileName() + "]" ); buf.append( "\n rmiSocketFactoryTimeoutMillis = [" + this.getRmiSocketFactoryTimeoutMillis() + "]" ); buf.append( "\n startRegistry = [" + this.isStartRegistry() + "]" ); buf.append( "\n useRegistryKeepAlive = [" + this.isUseRegistryKeepAlive() + "]" ); buf.append( "\n registryKeepAliveDelayMillis = [" + this.getRegistryKeepAliveDelayMillis() + "]" ); buf.append( "\n eventQueueType = [" + this.getEventQueueType() + "]" ); buf.append( "\n eventQueuePoolName = [" + this.getEventQueuePoolName() + "]" ); return buf.toString(); } }
/** * Verify that the type is set correctly and that the correct name is returned for the type. */ public void testSetRemoteTypeName_local() { RemoteCacheServerAttributes attributes = new RemoteCacheServerAttributes(); attributes.setRemoteTypeName( "LOCAL" ); assertEquals( "Wrong type.", RemoteType.LOCAL, attributes.getRemoteType() ); assertEquals( "Wrong name", "LOCAL", attributes.getRemoteTypeName() ); }