MockCompositeCacheManager cacheMgr = new MockCompositeCacheManager(); CompositeCache<String, Integer> cache = cacheMgr.getCache( "test" );
/** * @param cacheName * @return Returns a CompositeCache */ @Override @SuppressWarnings("unchecked") public <K, V> CompositeCache<K, V> getCache( String cacheName ) { if ( cache == null ) { // System.out.println( "Creating mock cache" ); CompositeCache<K, V> newCache = new CompositeCache<K, V>( new CompositeCacheAttributes(), new ElementAttributes() ); this.setCache( newCache ); } return (CompositeCache<K, V>)cache; }
/** verify that we get the CacheEventLogger value */ public void testCreateRemoteHttpCacheService_WithLogger() { // SETUP MockCompositeCacheManager manager = new MockCompositeCacheManager(); String className = MockCacheEventLogger.class.getName(); Properties props = new Properties(); props.put( IRemoteHttpCacheConstants.HTTP_CACHE_SERVER_PREFIX + AuxiliaryCacheConfigurator.CACHE_EVENT_LOGGER_PREFIX, className ); boolean allowClusterGet = false; props.put( IRemoteHttpCacheConstants.HTTP_CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX + ".allowClusterGet", String .valueOf( allowClusterGet ) ); manager.setConfigurationProperties( props ); // DO WORK RemoteHttpCacheService<String, String> result = RemoteHttpCacheSeviceFactory .createRemoteHttpCacheService( manager ); // VERIFY assertNotNull( "Should have a service.", result ); }
/** Verify that we get a cache no wait. */ public void testGetCache_normal() { // SETUP ICompositeCacheManager cacheMgr = new MockCompositeCacheManager(); ICacheEventLogger cacheEventLogger = null; IElementSerializer elementSerializer = null; RemoteHttpCacheAttributes cattr = new RemoteHttpCacheAttributes(); RemoteHttpCacheFactory factory = new RemoteHttpCacheFactory(); // DO WORK AuxiliaryCache<String, String> result = factory.createCache(cattr, cacheMgr, cacheEventLogger, elementSerializer); // VEIFY assertNotNull( "Should have a cache.", result ); } }
/** Verify that we get a cache no wait. */ public void testGetCache_normal() { // SETUP ICompositeCacheManager cacheMgr = new MockCompositeCacheManager(); ICacheEventLogger cacheEventLogger = null; IElementSerializer elementSerializer = null; RemoteHttpCacheAttributes cattr = new RemoteHttpCacheAttributes(); RemoteHttpCacheManager manager = RemoteHttpCacheManager.getInstance( cacheMgr, cacheEventLogger, elementSerializer ); // DO WORK AuxiliaryCache<String, String> result = manager.getCache( cattr ); // VEIFY assertNotNull( "Should have a cache.", result ); } }
MockCompositeCacheManager cacheMgr = new MockCompositeCacheManager(); CompositeCache<String, Integer> cache = cacheMgr.getCache( "test" );
/** * Verify event log calls. * <p> * @throws Exception */ public void testGetMultiple_simple() throws Exception { // SETUP MockCompositeCacheManager manager = new MockCompositeCacheManager(); MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger(); RemoteHttpCacheServerAttributes rcsa = new RemoteHttpCacheServerAttributes(); RemoteHttpCacheService<String, String> server = new RemoteHttpCacheService<String, String>( manager, rcsa, cacheEventLogger ); // DO WORK server.getMultiple( "region", new HashSet<String>() ); // VERIFY assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls ); assertEquals( "End should have been called.", 1, cacheEventLogger.endICacheEventCalls ); }
MockCompositeCacheManager compositeCacheManager = new MockCompositeCacheManager(); compositeCacheManager.setConfigurationProperties( props );
/** * @param cacheName * @return Returns a CompositeCache */ @Override @SuppressWarnings("unchecked") public <K, V> CompositeCache<K, V> getCache( String cacheName ) { if ( cache == null ) { // System.out.println( "Creating mock cache" ); CompositeCache<K, V> newCache = new CompositeCache<K, V>( new CompositeCacheAttributes(), new ElementAttributes() ); this.setCache( newCache ); } return (CompositeCache<K, V>)cache; }
MockCompositeCacheManager cacheMgr = new MockCompositeCacheManager(); CompositeCache<GroupAttrName<String>, String> cache = cacheMgr.getCache( "test" );
/** * Verify event log calls. * <p> * @throws Exception */ public void testGetMultiple_simple() throws Exception { // SETUP MockCompositeCacheManager manager = new MockCompositeCacheManager(); MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger(); RemoteHttpCacheServerAttributes rcsa = new RemoteHttpCacheServerAttributes(); RemoteHttpCacheService<String, String> server = new RemoteHttpCacheService<String, String>( manager, rcsa, cacheEventLogger ); // DO WORK server.getMultiple( "region", new HashSet<String>() ); // VERIFY assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls ); assertEquals( "End should have been called.", 1, cacheEventLogger.endICacheEventCalls ); }
cattr.setTableName("JCSTESTTABLE_InitializePoolAccess"); MockCompositeCacheManager compositeCacheManager = new MockCompositeCacheManager(); compositeCacheManager.setConfigurationProperties( props ); JDBCDiskCacheFactory dcFactory = new JDBCDiskCacheFactory(); dcFactory.initialize();
MockCompositeCacheManager cacheMgr = new MockCompositeCacheManager(); CompositeCache<GroupAttrName<String>, String> cache = cacheMgr.getCache( "test" );
/** Verify that we get the default. */ public void testCreateRemoteHttpCacheClient_deafult() { // SETUP ICompositeCacheManager cacheMgr = new MockCompositeCacheManager(); ICacheEventLogger cacheEventLogger = null; IElementSerializer elementSerializer = null; RemoteHttpCacheAttributes cattr = new RemoteHttpCacheAttributes(); RemoteHttpCacheManager manager = RemoteHttpCacheManager.getInstance( cacheMgr, cacheEventLogger, elementSerializer ); // DO WORK IRemoteHttpCacheClient<String, String> result = manager.createRemoteHttpCacheClientForAttributes( cattr ); // VEIFY assertNotNull( "Should have a cache.", result ); assertTrue( "Wrong default.", result instanceof RemoteHttpCacheClient ); }
lattr.setTcpListenerPort( 1101 ); lattr.setTransmissionTypeName( "TCP" ); MockCompositeCacheManager cacheMgr = new MockCompositeCacheManager(); assertEquals( "Didn't get the correct number", cnt, cacheMgr.getCache().getUpdateCount() );
/** * Verify event log calls. * <p> * @throws Exception */ public void testGet_simple() throws Exception { // SETUP MockCompositeCacheManager manager = new MockCompositeCacheManager(); MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger(); RemoteHttpCacheServerAttributes rcsa = new RemoteHttpCacheServerAttributes(); RemoteHttpCacheService<String, String> server = new RemoteHttpCacheService<String, String>( manager, rcsa, cacheEventLogger ); // DO WORK server.get( "region", "key" ); // VERIFY assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls ); assertEquals( "End should have been called.", 1, cacheEventLogger.endICacheEventCalls ); }
lattr.setTcpListenerPort( 1101 ); lattr.setTransmissionTypeName( "TCP" ); MockCompositeCacheManager cacheMgr = new MockCompositeCacheManager(); assertEquals( "Didn't get the correct number", cnt, cacheMgr.getCache().getUpdateCount() );
/** * Verify event log calls. * <p> * @throws Exception */ public void testRemove_simple() throws Exception { // SETUP MockCompositeCacheManager manager = new MockCompositeCacheManager(); MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger(); RemoteHttpCacheServerAttributes rcsa = new RemoteHttpCacheServerAttributes(); RemoteHttpCacheService<String, String> server = new RemoteHttpCacheService<String, String>( manager, rcsa, cacheEventLogger ); // DO WORK server.remove( "region", "key" ); // VERIFY assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls ); assertEquals( "End should have been called.", 1, cacheEventLogger.endICacheEventCalls ); }
MockCompositeCacheManager cacheMgr = new MockCompositeCacheManager(); CompositeCache<String, String> cache = cacheMgr.getCache( "test" );
/** * Verify event log calls. * <p> * @throws Exception */ public void testGetMatching_simple() throws Exception { // SETUP MockCompositeCacheManager manager = new MockCompositeCacheManager(); MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger(); RemoteHttpCacheServerAttributes rcsa = new RemoteHttpCacheServerAttributes(); RemoteHttpCacheService<String, String> server = new RemoteHttpCacheService<String, String>( manager, rcsa, cacheEventLogger ); // DO WORK server.getMatching( "region", "pattern", 0 ); // VERIFY assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls ); assertEquals( "End should have been called.", 1, cacheEventLogger.endICacheEventCalls ); }