commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1799469 - in /commons/proper/jcs/trunk/commons-jcs-core/src: main/java/org/apache/commons/jcs/auxiliary/remote/ main/java/org/apache/commons/jcs/auxiliary/remote/server/ main/java/org/apache/commons/jcs/auxiliary/remote/server/behavior/ te...
Date Wed, 21 Jun 2017 15:14:57 GMT
Author: tv
Date: Wed Jun 21 15:14:56 2017
New Revision: 1799469

URL: http://svn.apache.org/viewvc?rev=1799469&view=rev
Log:
JCS-179: Fix different/duplicate loading methods of RemoteCacheServer configuration

Modified:
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtils.java
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServer.java
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java
    commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java
    commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerStartupUtil.java
    commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtils.java?rev=1799469&r1=1799468&r2=1799469&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtils.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtils.java
Wed Jun 21 15:14:56 2017
@@ -124,6 +124,15 @@ public class RemoteUtils
 
         if (null == is) // not found in class path
         {
+            // Try root of class path
+            if (propFile != null && !propFile.startsWith("/"))
+            {
+                is = RemoteUtils.class.getResourceAsStream("/" + propFile);
+            }
+        }
+        
+        if (null == is) // not found in class path
+        {
             if (new File(propFile).exists())
             {
                 // file found

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServer.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServer.java?rev=1799469&r1=1799468&r2=1799469&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServer.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServer.java
Wed Jun 21 15:14:56 2017
@@ -29,12 +29,14 @@ import java.rmi.server.Unreferenced;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.locks.ReentrantLock;
 
 import org.apache.commons.jcs.access.exception.CacheException;
+import org.apache.commons.jcs.auxiliary.remote.RemoteUtils;
 import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheListener;
 import org.apache.commons.jcs.auxiliary.remote.server.behavior.IRemoteCacheServer;
 import org.apache.commons.jcs.auxiliary.remote.server.behavior.IRemoteCacheServerAttributes;
@@ -71,6 +73,8 @@ public class RemoteCacheServer<K, V>
     extends UnicastRemoteObject
     implements IRemoteCacheServer<K, V>, Unreferenced
 {
+    public static final String DFEAULT_REMOTE_CONFIGURATION_FILE = "/remote.cache.ccf";
+
     /** For serialization. Don't change. */
     private static final long serialVersionUID = -8072345435941473116L;
 
@@ -121,11 +125,47 @@ public class RemoteCacheServer<K, V>
 
     /**
      * Constructor for the RemoteCacheServer object. This initializes the server with the
values
+     * from the properties object.
+     * <p>
+     * @param rcsa 
+     * @param config cache hub configuration
+     * @throws RemoteException
+     */
+    protected RemoteCacheServer( IRemoteCacheServerAttributes rcsa, Properties config )
+        throws RemoteException
+    {
+        super( rcsa.getServicePort() );
+        this.remoteCacheServerAttributes = rcsa;
+        init( config );
+    }
+
+    /**
+     * Constructor for the RemoteCacheServer object. This initializes the server with the
values
+     * from the properties object.
+     * <p>
+     * @param rcsa
+     * @param config cache hub configuration
+     * @param customRMISocketFactory
+     * @throws RemoteException
+     */
+    protected RemoteCacheServer( IRemoteCacheServerAttributes rcsa, Properties config, RMISocketFactory
customRMISocketFactory )
+        throws RemoteException
+    {
+        super( rcsa.getServicePort(), customRMISocketFactory, customRMISocketFactory );
+        this.remoteCacheServerAttributes = rcsa;
+        init( config );
+    }
+
+    /**
+     * Constructor for the RemoteCacheServer object. This initializes the server with the
values
      * from the config file.
      * <p>
      * @param rcsa
      * @throws RemoteException
+     * 
+     * @deprecated Use version with Properties object instead
      */
+    @Deprecated
     protected RemoteCacheServer( IRemoteCacheServerAttributes rcsa )
         throws RemoteException
     {
@@ -141,7 +181,10 @@ public class RemoteCacheServer<K, V>
      * @param rcsa
      * @param customRMISocketFactory
      * @throws RemoteException
+     * 
+     * @deprecated Use version with Properties object instead
      */
+    @Deprecated
     protected RemoteCacheServer( IRemoteCacheServerAttributes rcsa, RMISocketFactory customRMISocketFactory
)
         throws RemoteException
     {
@@ -155,8 +198,34 @@ public class RemoteCacheServer<K, V>
      * <p>
      * @param prop
      * @throws RemoteException if the configuration of the cache manager instance fails
+     * 
+     * @deprecated Use version with Properties parameter instead
      */
-    private void init( String prop ) throws RemoteException
+    @Deprecated
+    private void init( String propFile ) throws RemoteException
+    {
+        String propFileName = propFile == null ? DFEAULT_REMOTE_CONFIGURATION_FILE : propFile;
+        
+        Properties prop = null;
+        try
+        {
+            prop = RemoteUtils.loadProps(propFileName);
+        }
+        catch (IOException e)
+        {
+            throw new RemoteException(e.getMessage(), e);
+        }
+        
+        init(prop);
+    }
+    
+    /**
+     * Initialize the RMI Cache Server from a properties object.
+     * <p>
+     * @param prop the configuration properties
+     * @throws RemoteException if the configuration of the cache manager instance fails
+     */
+    private void init( Properties prop ) throws RemoteException
     {
         try
         {
@@ -181,23 +250,15 @@ public class RemoteCacheServer<K, V>
     /**
      * Subclass can override this method to create the specific cache manager.
      * <p>
-     * @param prop The name of the configuration file.
-     * @return The cache hub configured with this configuration file.
+     * @param prop the configuration object.
+     * @return The cache hub configured with this configuration.
      *
      * @throws CacheException if the configuration cannot be loaded
      */
-    private CompositeCacheManager createCacheManager( String prop ) throws CacheException
+    private CompositeCacheManager createCacheManager( Properties prop ) throws CacheException
     {
         CompositeCacheManager hub = CompositeCacheManager.getUnconfiguredInstance();
-
-        if ( prop == null )
-        {
-            hub.configure( "/remote.cache.ccf" );
-        }
-        else
-        {
-            hub.configure( prop );
-        }
+        hub.configure( prop );
         return hub;
     }
 

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java?rev=1799469&r1=1799468&r2=1799469&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
Wed Jun 21 15:14:56 2017
@@ -94,32 +94,48 @@ public class RemoteCacheServerFactory
      * <p>
      * A remote cache is either a local cache or a cluster cache.
      * <p>
-     * @param host
-     * @param port
-     * @param propFile
+     * @param host the host name 
+     * @param port the port number
+     * @param propFile the remote cache hub configuration file
      * @throws IOException
+     * 
+     * @deprecated Use startup(String, int, Properties) instead
      */
+    @Deprecated
     public static void startup( String host, int port, String propFile )
         throws IOException
     {
-        if ( remoteCacheServer != null )
+        if ( log.isInfoEnabled() )
         {
-            throw new IllegalArgumentException( "Server already started." );
+            log.info( "ConfigFileName = [" + propFile + "]" );
         }
+        Properties props = RemoteUtils.loadProps( propFile );
+        startup(host, port, props);
+    }
 
-        synchronized ( RemoteCacheServer.class )
+    /**
+     * Starts up the remote cache server on this JVM, and binds it to the registry on the
given host
+     * and port.
+     * <p>
+     * A remote cache is either a local cache or a cluster cache.
+     * <p>
+     * @param host the host name 
+     * @param port the port number
+     * @param props the remote cache hub configuration
+     * @param propFile the remote cache hub configuration file
+     * @throws IOException
+     * 
+     * @deprecated Use startup(String, int, Properties) instead
+     */
+    @Deprecated
+    public static void startup( String host, int port, Properties props, String propFile
)
+        throws IOException
+    {
+        if ( log.isWarnEnabled() )
         {
-            if ( remoteCacheServer != null )
-            {
-                return;
-            }
-            if ( log.isInfoEnabled() )
-            {
-                log.info( "ConfigFileName = [" + propFile + "]" );
-            }
-            Properties props = RemoteUtils.loadProps( propFile );
-            startup(host, port, props, propFile);
+            log.warn( "ConfigFileName = [" + propFile + "] ignored" );
         }
+        startup(host, port, props);
     }
 
     /**
@@ -133,7 +149,7 @@ public class RemoteCacheServerFactory
      * @param props
      * @throws IOException
      */
-    public static void startup( String host, int port, Properties props, String propFile
)
+    public static void startup( String host, int port, Properties props)
         throws IOException
     {
         if ( remoteCacheServer != null )
@@ -153,7 +169,6 @@ public class RemoteCacheServerFactory
             }
 
             RemoteCacheServerAttributes rcsa = configureRemoteCacheServerAttributes(props);
-            rcsa.setConfigFileName( propFile );
 
             // These should come from the file!
             rcsa.setRemoteLocation( host, port );
@@ -174,11 +189,11 @@ public class RemoteCacheServerFactory
             // CREATE SERVER
             if ( customRMISocketFactory != null )
             {
-                remoteCacheServer = new RemoteCacheServer<Serializable, Serializable>(
rcsa, customRMISocketFactory );
+                remoteCacheServer = new RemoteCacheServer<Serializable, Serializable>(
rcsa, props, customRMISocketFactory );
             }
             else
             {
-                remoteCacheServer = new RemoteCacheServer<Serializable, Serializable>(
rcsa );
+                remoteCacheServer = new RemoteCacheServer<Serializable, Serializable>(
rcsa, props );
             }
 
             remoteCacheServer.setCacheEventLogger( cacheEventLogger );
@@ -446,21 +461,9 @@ public class RemoteCacheServerFactory
         // shutdown
         if ( args.length > 0 && args[0].toLowerCase().indexOf( "-shutdown" ) !=
-1 )
         {
-            String remoteServiceName = prop.getProperty( REMOTE_CACHE_SERVICE_NAME, REMOTE_CACHE_SERVICE_VAL
).trim();
-            String registry = RemoteUtils.getNamingURL("", port, remoteServiceName);
-
-            if ( log.isDebugEnabled() )
-            {
-                log.debug( "looking up server " + registry );
-            }
-            Object obj = Naming.lookup( registry );
-            if ( log.isDebugEnabled() )
-            {
-                log.debug( "server found" );
-            }
-            ICacheServiceAdmin admin = (ICacheServiceAdmin) obj;
             try
             {
+                ICacheServiceAdmin admin = lookupCacheServiceAdmin(prop, port);
                 admin.shutdown();
             }
             catch ( Exception ex )
@@ -474,30 +477,21 @@ public class RemoteCacheServerFactory
         // STATS
         if ( args.length > 0 && args[0].toLowerCase().indexOf( "-stats" ) != -1
)
         {
-
             log.debug( "getting cache stats" );
 
             try
             {
-                String sz = prop.getProperty( REMOTE_CACHE_SERVICE_NAME, REMOTE_CACHE_SERVICE_VAL
).trim();
-                String registry = RemoteUtils.getNamingURL("", port, sz);
-                log.debug( "looking up server " + registry );
-                Object obj = Naming.lookup( registry );
-                log.debug( "server found" );
-
-                log.debug( "obj = " + obj );
-                ICacheServiceAdmin admin = (ICacheServiceAdmin) obj;
+                ICacheServiceAdmin admin = lookupCacheServiceAdmin(prop, port);
 
                 try
                 {
 //                    System.out.println( admin.getStats().toString() );
                     log.debug( admin.getStats() );
                 }
-                catch ( Exception es )
+                catch ( IOException es )
                 {
                     log.error( es );
                 }
-
             }
             catch ( Exception ex )
             {
@@ -516,11 +510,38 @@ public class RemoteCacheServerFactory
             RemoteUtils.createRegistry( port );
         }
         log.debug( "main> starting up RemoteCacheServer" );
-        RemoteCacheServerFactory.startup( host, port, args.length > 0 ? args[0] : null
);
+        startup( host, port, prop);
         log.debug( "main> done" );
     }
 
     /**
+     * Look up the remote cache service admin instance
+     *  
+     * @param config the configuration properties
+     * @param port the local port
+     * @return the admin object instance
+     * 
+     * @throws Exception if lookup fails 
+     */
+    private static ICacheServiceAdmin lookupCacheServiceAdmin(Properties config, int port)
throws Exception
+    {
+        String remoteServiceName = config.getProperty( REMOTE_CACHE_SERVICE_NAME, REMOTE_CACHE_SERVICE_VAL
).trim();
+        String registry = RemoteUtils.getNamingURL("", port, remoteServiceName);
+
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "looking up server " + registry );
+        }
+        Object obj = Naming.lookup( registry );
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "server found" );
+        }
+        
+        return (ICacheServiceAdmin) obj;
+    }
+    
+    /**
      * @param serviceName the serviceName to set
      */
     protected static void setServiceName( String serviceName )

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java?rev=1799469&r1=1799468&r2=1799469&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java
Wed Jun 21 15:14:56 2017
@@ -131,12 +131,10 @@ public class RemoteCacheStartupServlet
         {
             if (props == null)
             {
-                RemoteCacheServerFactory.startup(registryHost, registryPort, propsFileName);
-            }
-            else
-            {
-                RemoteCacheServerFactory.startup(registryHost, registryPort, props, propsFileName);
+                throw new ServletException("Could not load configuration from " + propsFileName);
             }
+
+            RemoteCacheServerFactory.startup(registryHost, registryPort, props);
             if (log.isInfoEnabled())
             {
                 log.info("Remote JCS Server started with properties from " + propsFileName);
@@ -144,7 +142,7 @@ public class RemoteCacheStartupServlet
         }
         catch (IOException e)
         {
-            log.error("Problem starting remote cache server.", e);
+            throw new ServletException("Problem starting remote cache server.", e);
         }
     }
 

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java?rev=1799469&r1=1799468&r2=1799469&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java
Wed Jun 21 15:14:56 2017
@@ -66,7 +66,7 @@ public interface IRemoteCacheServerAttri
     /**
      * Gets the ConfigFileName attribute of the IRemoteCacheAttributes object.
      * <p>
-     * @return The clusterServers value
+     * @return The configuration file name
      */
     String getConfigFileName();
 
@@ -74,7 +74,7 @@ public interface IRemoteCacheServerAttri
      * Sets the ConfigFileName attribute of the IRemoteCacheAttributes object.
      * <p>
      * @param s
-     *            The new clusterServers value
+     *            The new configuration file name
      */
     void setConfigFileName( String s );
 

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java?rev=1799469&r1=1799468&r2=1799469&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java
Wed Jun 21 15:14:56 2017
@@ -1,5 +1,7 @@
 package org.apache.commons.jcs.auxiliary.remote;
 
+import java.util.Properties;
+
 import org.apache.commons.jcs.JCS;
 import org.apache.commons.jcs.access.CacheAccess;
 import org.apache.commons.jcs.auxiliary.AuxiliaryCache;
@@ -52,8 +54,9 @@ public class TestRemoteCache
         {
             System.out.println( "main> creating registry on the localhost" );
             RemoteUtils.createRegistry( 1101 );
+            Properties config = RemoteUtils.loadProps("/TestRemoteServer.ccf");
 
-            RemoteCacheServerFactory.startup( "localhost", 1101, "/TestRemoteServer.ccf"
);
+            RemoteCacheServerFactory.startup( "localhost", 1101, config);
         }
         catch ( Exception e )
         {

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerStartupUtil.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerStartupUtil.java?rev=1799469&r1=1799468&r2=1799469&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerStartupUtil.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerStartupUtil.java
Wed Jun 21 15:14:56 2017
@@ -23,8 +23,8 @@ import java.io.IOException;
 import java.net.UnknownHostException;
 import java.util.Properties;
 
+import org.apache.commons.jcs.auxiliary.remote.RemoteUtils;
 import org.apache.commons.jcs.utils.net.HostNameUtil;
-import org.apache.commons.jcs.utils.props.PropertyLoader;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -53,7 +53,16 @@ public class RemoteCacheServerStartupUti
         // all three
         int registryPort = DEFAULT_REGISTRY_PORT;
 
-        Properties props = PropertyLoader.loadProperties( propsFileName );
+        Properties props = null;
+        try
+        {
+            props = RemoteUtils.loadProps(propsFileName);
+        }
+        catch (IOException e)
+        {
+            log.error( "Problem loading configuration from " + propsFileName, e);
+        }
+        
         if ( props != null )
         {
             String portS = props.getProperty( "registry.port", String.valueOf( DEFAULT_REGISTRY_PORT
) );
@@ -86,7 +95,7 @@ public class RemoteCacheServerStartupUti
 
             try
             {
-                RemoteCacheServerFactory.startup( registryHost, registryPort, "/" + propsFileName
);
+                RemoteCacheServerFactory.startup( registryHost, registryPort, props );
             }
             catch ( IOException e )
             {

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java?rev=1799469&r1=1799468&r2=1799469&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java
Wed Jun 21 15:14:56 2017
@@ -22,17 +22,19 @@ package org.apache.commons.jcs.auxiliary
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
-
-import junit.framework.TestCase;
+import java.util.Properties;
 
 import org.apache.commons.jcs.auxiliary.MockCacheEventLogger;
 import org.apache.commons.jcs.auxiliary.remote.MockRemoteCacheListener;
+import org.apache.commons.jcs.auxiliary.remote.RemoteUtils;
 import org.apache.commons.jcs.auxiliary.remote.server.behavior.IRemoteCacheServerAttributes;
 import org.apache.commons.jcs.auxiliary.remote.server.behavior.RemoteType;
 import org.apache.commons.jcs.engine.CacheElement;
 import org.apache.commons.jcs.engine.behavior.ICacheElement;
 import org.apache.commons.jcs.utils.timing.SleepUtil;
 
+import junit.framework.TestCase;
+
 /**
  * Since the server does not know that it is a server, it is easy to unit test. The factory
does all
  * the rmi work.
@@ -54,7 +56,8 @@ public class RemoteCacheServerUnitTest
 
         IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
         rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
-        this.server = new RemoteCacheServer<String, String>( rcsa );
+        Properties config = RemoteUtils.loadProps(rcsa.getConfigFileName());
+        this.server = new RemoteCacheServer<String, String>( rcsa, config );
     }
 
     @Override
@@ -223,8 +226,9 @@ public class RemoteCacheServerUnitTest
         IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
         rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
 
+        Properties config = RemoteUtils.loadProps(rcsa.getConfigFileName());
         MockRemoteCacheListener<String, Long> mockListener = new MockRemoteCacheListener<String,
Long>();
-        RemoteCacheServer<String, Long> server = new RemoteCacheServer<String, Long>(
rcsa );
+        RemoteCacheServer<String, Long> server = new RemoteCacheServer<String, Long>(
rcsa, config );
 
         String cacheName = "testSimpleRegisterListenerAndPut";
         server.addCacheListener( cacheName, mockListener );
@@ -268,7 +272,8 @@ public class RemoteCacheServerUnitTest
         IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
         rcsa.setLocalClusterConsistency( true );
         rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
-        RemoteCacheServer<String, Long> server = new RemoteCacheServer<String, Long>(
rcsa );
+        Properties config = RemoteUtils.loadProps(rcsa.getConfigFileName());
+        RemoteCacheServer<String, Long> server = new RemoteCacheServer<String, Long>(
rcsa, config );
 
         // this is to get the listener id for inserts.
         MockRemoteCacheListener<String, Long> clusterListener = new MockRemoteCacheListener<String,
Long>();



Mime
View raw message