[jboss-cvs] JBossAS SVN: r109549 - branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Nov 29 18:43:44 EST 2010


Author: rachmatowicz at jboss.com
Date: 2010-11-29 18:43:44 -0500 (Mon, 29 Nov 2010)
New Revision: 109549

Removed:
   branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/HotRodClientTestCase.java
Log:
Delete HotRodClientTestCase

Deleted: branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/HotRodClientTestCase.java
===================================================================
--- branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/HotRodClientTestCase.java	2010-11-29 23:09:53 UTC (rev 109548)
+++ branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/HotRodClientTestCase.java	2010-11-29 23:43:44 UTC (rev 109549)
@@ -1,937 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.cluster.datagrid.test;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Set;
-import java.util.Collection;
-import java.util.concurrent.Future;
-
-import org.infinispan.client.hotrod.*;
-import org.infinispan.Cache;
-import org.infinispan.config.Configuration;
-import org.infinispan.manager.EmbeddedCacheManager;
-import org.infinispan.marshall.Marshaller;
-import org.infinispan.marshall.jboss.JBossMarshaller;
-//import org.infinispan.server.core.CacheValue;
-import org.infinispan.util.ByteArrayKey;            
-import org.infinispan.util.logging.Log;
-import org.infinispan.util.logging.LogFactory;
-import org.infinispan.util.concurrent.NotifyingFuture;
-import org.infinispan.notifications.Listener;
-// import org.infinispan.notifications.cachemanagerlistener.event.Event;
-import org.infinispan.notifications.cachemanagerlistener.annotation.ViewChanged;
-import org.infinispan.notifications.cachelistener.event.Event;
-import org.infinispan.notifications.cachelistener.annotation.CacheEntryModified;
-import org.infinispan.notifications.cachelistener.annotation.CacheEntryCreated;
-import org.infinispan.notifications.cachelistener.annotation.CacheEntryRemoved;
-import org.infinispan.notifications.cachelistener.annotation.CacheEntryVisited;
-import org.infinispan.notifications.cachelistener.annotation.CacheEntryLoaded;
-import org.infinispan.notifications.cachelistener.annotation.CacheEntryEvicted;
-import org.infinispan.notifications.cachelistener.annotation.CacheEntryActivated;
-import org.infinispan.notifications.cachelistener.annotation.CacheEntryPassivated;
-
-import org.jboss.test.JBossClusteredTestCase;
-import org.jboss.test.JBossTestSetup;
-import org.jboss.test.JBossTestClusteredSetup;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Tests for the HotRod client..
- *
- * @author <a href="mailto:richard.achmatowicz at jboss.com">Richard Achmatowicz</a>
- * @version $Revision: $
- */
-public class HotRodClientTestCase
-		extends JBossClusteredTestCase
-{
-
-	private static final Log log = LogFactory.getLog(HotRodClientTestCase.class);
-	private static final String REPL_CACHE_NAME = "sampleReplicatedCache";
-	private static final String PERSIST_CACHE_NAME = "samplePersistentCache";
-
-	private RemoteCache remoteCache;
-	private RemoteCacheManager remoteCacheManager;
-
-	private String[] servers = null ;
-	private String hotRodServerList = null ;
-
-	public HotRodClientTestCase(String name) {
-		super(name) ;
-	}
-
-	/*
-	 * Per-test case setup
-	 */
-	public void setUp() throws Exception {
-		super.setUp();
-
-		remoteCacheManager = HotRodClientTestSetup.getRemoteCacheManager() ;
-		remoteCache = HotRodClientTestSetup.getRemoteCache() ;
-
-		remoteCache.clear();
-
-		// printCacheContents(remoteCache, "map of remoteCache elements") ;
-	}
-
-	/*
-	 * Per-test case tear down
-	 */
-	public void tearDown() throws Exception {
-		System.out.println("per test tearing down") ;
-
-		// clean up the server side copies - they persist as long is the servers are up                                                                                  
-		remoteCache.clear() ;
-
-		super.tearDown();
-	}
-
-	/*
-	 * The following operations should return an UnsupportedOperationException when invoked:
-	 * void compact()
-	 * AdvancedCache<K,V> getAdvancedCache()
-	 * Configuration getConfiguration()
-	 * void putForExternalRead(K key, V value)
-	 * boolean remove(Object k, Object v)
-	 * NotifyingFuture<Boolean> removeAsync(Object k, Object v)
-	 * boolean replace(K k, V oldValue, V newValue)
-	 * boolean replace(K k, V oldValue, V newValue, long lifespan, TimeUnit unit)
-	 * boolean replace(K k, V oldValue, V newValue, long lifespan, TimeUnit unit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
-	 * NotifyingFuture<Boolean> replaceAsync(K k, V oldValue, V newValue)
-	 * NotifyingFuture<Boolean> replaceAsync(K k, V oldValue, V newValue, long lifespan, TimeUnit unit)
-	 * NotifyingFuture<Boolean> replaceAsync(K k, V oldValue, V newValue, long lifespan, TimeUnit unit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
-	 * 
-	 * void evict()
-	 * void addListener(Object listener)
-	 * Set<Object> getListeners()
-	 * void removeListener(Object listener)
-	 */
-	public void testUnsupportedOperations() {
-		
-		try {
-			remoteCache.compact();
-			fail("call to compact() did not raise UnsupportedOperationException ") ;
-		}
-		catch(UnsupportedOperationException uoe) {
-			// Unsupported operation exception correctly thrown
-		}
-		try {
-			remoteCache.getAdvancedCache();
-			fail("call to getAdvancedCache() did not raise UnsupportedOperationException ") ;
-		}
-		catch(UnsupportedOperationException uoe) {
-			// Unsupported operation exception correctly thrown
-		}
-		try {
-			remoteCache.getConfiguration();
-			fail("call to getConfiguration() did not raise UnsupportedOperationException ") ;
-		}
-		catch(UnsupportedOperationException uoe) {
-			// Unsupported operation exception correctly thrown
-		}
-		try {
-			remoteCache.putForExternalRead("aKey", "aValue");
-			fail("call to getAdvancedCache() did not raise UnsupportedOperationException ") ;
-		}
-		catch(UnsupportedOperationException uoe) {
-			// Unsupported operation exception correctly thrown
-		}
-		try {
-			remoteCache.remove("aKey", "aValue");
-			fail("call to remove() did not raise UnsupportedOperationException ") ;
-		}
-		catch(UnsupportedOperationException uoe) {
-			// Unsupported operation exception correctly thrown
-		}
-		try {
-			remoteCache.removeAsync("aKey", "aValue");
-			fail("call to removeAsync() did not raise UnsupportedOperationException ") ;
-		}
-		catch(UnsupportedOperationException uoe) {
-			// Unsupported operation exception correctly thrown
-		}
-		try {
-			remoteCache.replace("aKey", "oldValue", "newValue");
-			fail("call to replace() did not raise UnsupportedOperationException ") ;
-		}
-		catch(UnsupportedOperationException uoe) {
-			// Unsupported operation exception correctly thrown
-		}
-		try {
-			remoteCache.replace("aKey", "oldValue", "newValue", -1, TimeUnit.SECONDS);
-			fail("call to replace() did not raise UnsupportedOperationException ") ;
-		}
-		catch(UnsupportedOperationException uoe) {
-			// Unsupported operation exception correctly thrown
-		}
-		try {
-			remoteCache.replace("aKey", "oldValue", "newValue", -1, TimeUnit.SECONDS, -1, TimeUnit.SECONDS);
-			fail("call to replace() did not raise UnsupportedOperationException ") ;
-		}
-		catch(UnsupportedOperationException uoe) {
-			// Unsupported operation exception correctly thrown
-		}
-		try {
-			remoteCache.replaceAsync("aKey", "oldValue", "newValue");
-			fail("call to replaceAsync() did not raise UnsupportedOperationException ") ;
-		}
-		catch(UnsupportedOperationException uoe) {
-			// Unsupported operation exception correctly thrown
-		}
-		try {
-			remoteCache.replaceAsync("aKey", "oldValue", "newValue", -1, TimeUnit.SECONDS);
-			fail("call to replaceAsync() did not raise UnsupportedOperationException ") ;
-		}
-		catch(UnsupportedOperationException uoe) {
-			// Unsupported operation exception correctly thrown
-		}
-		try {
-			remoteCache.replaceAsync("aKey", "oldValue", "newValue", -1, TimeUnit.SECONDS, -1, TimeUnit.SECONDS);
-			fail("call to replaceAsync() did not raise UnsupportedOperationException ") ;
-		}
-		catch(UnsupportedOperationException uoe) {
-			// Unsupported operation exception correctly thrown
-		}
-		try {
-			remoteCache.evict("aKey");
-			fail("call to evict() did not raise UnsupportedOperationException ") ;
-		}
-		catch(UnsupportedOperationException uoe) {
-			// Unsupported operation exception correctly thrown
-		}
-		try {
-			remoteCache.addListener(new SingleEventListener());
-			fail("call to addListener() did not raise UnsupportedOperationException ") ;
-		}
-		catch(UnsupportedOperationException uoe) {
-			// Unsupported operation exception correctly thrown
-		}
-		try {
-			remoteCache.removeListener(new SingleEventListener());
-			fail("call to removeListener() did not raise UnsupportedOperationException ") ;
-		}
-		catch(UnsupportedOperationException uoe) {
-			// Unsupported operation exception correctly thrown
-		}
-		try {
-			remoteCache.getListeners();
-			fail("call to getListeners() did not raise UnsupportedOperationException ") ;
-		}
-		catch(UnsupportedOperationException uoe) {
-			// Unsupported operation exception correctly thrown
-		}
-		try {
-			remoteCache.startBatch();
-			fail("call to startBatch() did not raise UnsupportedOperationException ") ;
-		}
-		catch(UnsupportedOperationException uoe) {
-			// Unsupported operation exception correctly thrown
-		}
-		try {
-			remoteCache.endBatch(true);
-			fail("call to endBatch() did not raise UnsupportedOperationException ") ;
-		}
-		catch(UnsupportedOperationException uoe) {
-			// Unsupported operation exception correctly thrown
-		}
-	}
-	
-	/*
-	 * Test the put operation
-	 * - put key/value, confirm presence of key, confirm presence of value
-	 * - test for default and named cache instances
-	 */
-	public void testPut() throws IOException {
-		
-		assert null == remoteCache.put("aKey", "aValue");
-		assert remoteCache.containsKey("aKey");
-		assert remoteCache.get("aKey").equals("aValue");
-	}	
-	
-	/*
-	 * Test the size operation
-	 */
-	public void testSize() throws IOException {
-		
-		assert remoteCache.size() == 0;
-		
-		assert null == remoteCache.put("aKey", "aValue");
-		assert remoteCache.containsKey("aKey");
-		assert remoteCache.size() == 1 ;
-
-		assert null == remoteCache.put("anotherKey", "anotherValue");
-		assert remoteCache.containsKey("anotherKey");
-		assert remoteCache.size() == 2 ;		
-		
-		assert null == remoteCache.remove("anotherKey");
-		assert !remoteCache.containsKey("anotherKey");
-		assert remoteCache.size() == 1 ;
-		
-		assert null == remoteCache.remove("aKey");
-		assert !remoteCache.containsKey("aKey");
-		assert remoteCache.size() == 0 ;
-	}	
-	
-	/*
-	 * Test the isEmpty operation
-	 */
-	public void testIsEmpty() throws IOException {
-		
-		assert remoteCache.isEmpty();
-		
-		assert null == remoteCache.put("aKey", "aValue");
-		assert remoteCache.containsKey("aKey");
-		assert !remoteCache.isEmpty();
-		
-		assert null == remoteCache.remove("aKey");
-		assert !remoteCache.containsKey("aKey");
-		assert remoteCache.isEmpty();		
-	}	
-	
-	
-	/*
-	 * Test the contains operations
-	 * - we start with empty cache
-	 */
-	public void testContains() {
-		assert !remoteCache.containsKey("aKey");
-		remoteCache.put("aKey", "aValue");
-		assert remoteCache.containsKey("aKey");
-		assert remoteCache.containsValue("aValue");
-		assert !remoteCache.containsValue("someOtherValue"); 
-	}
-	
-	/*
-	 * Test the withFlags operation
-	 * 
-	 * Flags available:
-	 * FORCE_RETURN_VALUE
-	 */
-	public void testWithFlags() throws IOException {
-		
-		assert null == remoteCache.put("aKey", "aValue");
-		assert remoteCache.containsKey("aKey");
-		assertEquals("aValue", remoteCache.get("aKey"));
-		
-		// should not return return old value
-		assert null == remoteCache.put("aKey", "anotherValue") ;
-		assertEquals("anotherValue", remoteCache.get("aKey"));
-		
-		// now should return old value
-		assertEquals("anotherValue", remoteCache.withFlags(Flag.FORCE_RETURN_VALUE).put("aKey","yetAnotherValue"));
-	}	
-	
-	/*
-	 * Test eviction of cache elements
-	 * - here, we assume there is no cache store available to persist the element if evicted
-	 */
-	public void XtestEviction() {
-		remoteCache.put("aKey", "aValue");
-		assert remoteCache.containsKey("aKey");
-		remoteCache.evict("aKey");
-		assert !remoteCache.containsKey("aKey");		
-	}
-	
-	/*
-	 * Test bulk put and get
-	 */
-	public void testBulkOperations() {
-		
-		Map<String,String> mapIn = new HashMap<String,String>() ;
-		Map<String,String> mapOut = new HashMap<String,String>() ;
-		mapOut.put("aKey", "aValue");
-		mapOut.put("bKey", "bValue");
-		mapOut.put("cKey", "cValue");
-		
-		remoteCache.putAll(mapOut);
-		mapIn = remoteCache.getBulk();
-		
-		assert mapIn.keySet().equals(mapOut.keySet());
-		assert mapIn.values().equals(mapOut.values());
-	}
-	
-	/*
-	 * Test bulk put and get with lifespan for eviction
-	 */
-	public void testBulkOperationsWithLifespan() {
-		
-		long lifespanInSecs = 3 ;
-		
-		Map<String,String> mapIn = new HashMap<String,String>() ;
-		Map<String,String> mapOut = new HashMap<String,String>() ;
-		mapOut.put("aKey", "aValue");
-		mapOut.put("bKey", "bValue");
-		mapOut.put("cKey", "cValue");
-		
-		remoteCache.putAll(mapOut, lifespanInSecs, TimeUnit.SECONDS);
-
-		// give the elements time to be evicted
-		sleepForSecs(lifespanInSecs) ;
-		
-		mapIn = remoteCache.getBulk();		
-		assert mapIn.size() == 0;
-	}
-
-	
-	/*
-	 * Test asynchronous bulk put and get
-	 */
-	public void testBulkOperationsAsync() {
-		
-		Map<String,String> mapIn = new HashMap<String,String>() ;
-		Map<String,String> mapOut = new HashMap<String,String>() ;
-		mapOut.put("aKey", "aValue");
-		mapOut.put("bKey", "bValue");
-		mapOut.put("cKey", "cValue");
-		
-		NotifyingFuture<Void> future = null ;
-		future = remoteCache.putAllAsync(mapOut);
-		
-		// wait for async operation to complelete
-		waitForNotifyingFutureToBeDone(future) ;		
-
-		mapIn = remoteCache.getBulk();
-		
-		assert mapIn.keySet().equals(mapOut.keySet());
-		assert mapIn.values().equals(mapOut.values());
-	}
-	
-	/*
-	 * Test bulk put and get with lifespan for eviction in async mode
-	 */
-	public void testBulkOperationsWithLifespanAsync() {
-		
-		long lifespanInSecs = 3 ;
-		
-		Map<String,String> mapIn = new HashMap<String,String>() ;
-		Map<String,String> mapOut = new HashMap<String,String>() ;
-		mapOut.put("aKey", "aValue");
-		mapOut.put("bKey", "bValue");
-		mapOut.put("cKey", "cValue");
-		
-		NotifyingFuture<Void> future = null ;
-		future = remoteCache.putAllAsync(mapOut, lifespanInSecs, TimeUnit.SECONDS);
-
-		waitForNotifyingFutureToBeDone(future) ;
-		
-		sleepForSecs(lifespanInSecs) ;
-				
-		mapIn = remoteCache.getBulk();
-		assert mapIn.size() == 0;
-	}
-	
-	
-	/*
-	 * Test operations on cache entry sets
-	 * - RemoteCache.entrySet()
-	 * - RemoteCache.keySet()
-	 * - RemoteCache.values()
-	 */
-	public void testEntrySets() {
-		
-		Map<String,String> mapOut = new HashMap<String,String>() ;
-		mapOut.put("aKey", "aValue");
-		mapOut.put("bKey", "bValue");
-		mapOut.put("cKey", "cValue");
-
-		Set<Map.Entry<String,String>> mapEntrySet = mapOut.entrySet() ; 
-		Set<String> mapKeySet = mapOut.keySet();
-		Collection<String> mapValues = mapOut.values() ;
-		
-		remoteCache.putAll(mapOut) ;
-		
-		assert mapEntrySet.equals(remoteCache.entrySet()) ;
-		assert mapKeySet.equals(remoteCache.keySet()) ;
-		assert mapValues.equals(remoteCache.values());		
-	}
-	
-	
-	/*
-	 * Test bulk put and get with lifespan for eviction in async mode
-	 */
-	public void XtestBatch() {
-
-		// check commit operation
-		remoteCache.startBatch() ;
-		remoteCache.put("aKey", "aValue") ;
-		remoteCache.endBatch(true) ;
-		
-		assertEquals(remoteCache.get("aKey"),"aValue") ;
-		
-		// check abort operation		
-		remoteCache.startBatch() ;
-		remoteCache.put("anotherKey", "anotherValue") ;
-		remoteCache.endBatch(false) ;
-		
-		assert null == remoteCache.get("aKey") ;
-		
-		// check no intermediate results committed 
-		
-//		remoteCache.startBatch() ;
-//		remoteCache.put("yetAnotherKey", "yetAnotherValue") ;
-//		assert null == remoteCache.get("yetAnotherKey") ;
-//		remoteCache.endBatch(true) ;
-//		
-//		assertEquals(remoteCache.get("yetAnotherKey"),"yetAnotherValue") ;
-		
-	}
-	
-	
-	/*
-	 * Test the versioned cache entries
-	 * - check that versions differ even if the key value pairs are the same
-	 * - check that versions differ when key value pairs are different
-	 */
-	public void testGetVersionedCacheEntry() {
-		
-		VersionedValue value = remoteCache.getVersioned("aKey");
-		assertNull(remoteCache.getVersioned("aKey"), "expected null but received: " + value);
-		
-		remoteCache.put("aKey", "aValue");
-		assert remoteCache.get("aKey").equals("aValue");
-		VersionedValue valueBinary = remoteCache.getVersioned("aKey");
-		assert valueBinary != null;
-		assertEquals(valueBinary.getValue(), "aValue");
-		log.info("Version is: " + valueBinary.getVersion());
-
-		//now put the same value
-		remoteCache.put("aKey", "aValue");
-		VersionedValue entry2 = remoteCache.getVersioned("aKey");
-		assertEquals(entry2.getValue(), "aValue");
-
-		assert entry2.getVersion() != valueBinary.getVersion();
-		assert !valueBinary.equals(entry2);
-
-		//now put a different value
-		remoteCache.put("aKey", "anotherValue");
-		VersionedValue entry3 = remoteCache.getVersioned("aKey");
-		assertEquals(entry3.getValue(), "anotherValue");
-		assert entry3.getVersion() != entry2.getVersion();
-		assert !entry3.equals(entry2);
-	}
-
-	/*
-	 * Test replace operation
-	 * - this replaces one value with another only if the key value pair exists
-	 * - returns the previous value, or null if no k/v pair
-	 */
-	public void testReplace() {
-		// this should return null, indicating no k/v pair in the map
-		assert null == remoteCache.replace("aKey", "anotherValue");
-		remoteCache.put("aKey", "aValue");
-		assert null == remoteCache.replace("aKey", "anotherValue");
-		assert remoteCache.get("aKey").equals("anotherValue");
-	}
-
-	/*
-	 * Tests replaceWithVersion operation
-	 * - replaces one value with another only if not modified since last time
-	 * version was read
-	 */
-	public void testReplaceWithVersion() {
-		assert null == remoteCache.replace("aKey", "aValue");
-
-		remoteCache.put("aKey", "aValue");
-		VersionedValue valueBinary = remoteCache.getVersioned("aKey");
-		// replacement should take place (and so return true)
-		assert remoteCache.replaceWithVersion("aKey", "aNewValue", valueBinary.getVersion());
-
-		// version should have changed; value should have changed
-		VersionedValue entry2 = remoteCache.getVersioned("aKey");
-		assert entry2.getVersion() != valueBinary.getVersion();
-		assertEquals(entry2.getValue(), "aNewValue");
-
-		// replacement should not take place because we have changed the value
-		assert !remoteCache.replaceWithVersion("aKey", "aNewValue", valueBinary.getVersion());
-	}
-
-	/*
-	 * Tests replaceWithVersion operation in async mode
-	 * - replaces one value with another only if not modified since last time
-	 * version was read
-	 */
-	public void testReplaceWithVersionAsync() throws Exception {
-		assert null == remoteCache.replace("aKey", "aValue");
-
-		remoteCache.put("aKey", "aValue");
-		VersionedValue valueBinary = remoteCache.getVersioned("aKey");
-		// replacement should take place (and so return true)
-		NotifyingFuture<Boolean> future = null ;
-		future = remoteCache.replaceWithVersionAsync("aKey", "aNewValue", valueBinary.getVersion());
-		assert future.get() ;
-		
-		// version should have changed; value should have changed
-		VersionedValue entry2 = remoteCache.getVersioned("aKey");
-		assert entry2.getVersion() != valueBinary.getVersion();
-		assertEquals(entry2.getValue(), "aNewValue");
-
-		// replacement should not take place because we have changed the value
-		future = remoteCache.replaceWithVersionAsync("aKey", "aNewValue", valueBinary.getVersion());
-		assert !future.get() ;
-	}
-	
-	/* to here */
-	
-	/*
-	 * Test the remove operation
-	 * - put key/value, verify put value, remove key, verify key removed
-	 */
-	public void testRemove() throws IOException {
-		assert null == remoteCache.put("aKey", "aValue");
-		assert remoteCache.get("aKey").equals("aValue");
-
-		assert null == remoteCache.remove("aKey");
-		assert !remoteCache.containsKey("aKey");
-	}
-
-	/*
-	 * Test removeWithVersion operation (which is basically removeIfUnmodified)
-	 */
-	public void testRemoveWithVersion() {
-		
-		assert !remoteCache.removeWithVersion("aKey", 12321212l);
-
-		remoteCache.put("aKey", "aValue");
-		VersionedValue valueBinary = remoteCache.getVersioned("aKey");
-		assert remoteCache.removeWithVersion("aKey", valueBinary.getVersion());
-
-		remoteCache.put("aKey", "aNewValue");
-
-		VersionedValue entry2 = remoteCache.getVersioned("aKey");
-		assert entry2.getVersion() != valueBinary.getVersion();
-		assertEquals(entry2.getValue(), "aNewValue");
-
-		assert  !remoteCache.removeWithVersion("aKey", valueBinary.getVersion());
-	}
-	
-	/*
-	 * Test removeWithVersion operation (which is basically removeIfUnmodified)
-	 * in async mode
-	 */
-	public void testRemoveWithVersionAsync() throws Exception {
-		NotifyingFuture<Boolean> future = null ;
-		
-		future = remoteCache.removeWithVersionAsync("aKey", 12321212l);
-		assert !future.get();
-
-		remoteCache.put("aKey", "aValue");
-		VersionedValue valueBinary = remoteCache.getVersioned("aKey");
-		future = remoteCache.removeWithVersionAsync("aKey", valueBinary.getVersion());
-		assert future.get();
-		
-		remoteCache.put("aKey", "aNewValue");
-
-		VersionedValue entry2 = remoteCache.getVersioned("aKey");
-		assert entry2.getVersion() != valueBinary.getVersion();
-		assertEquals(entry2.getValue(), "aNewValue");
-
-		future = remoteCache.removeWithVersionAsync("aKey", valueBinary.getVersion());
-		assert  !future.get();
-	}
-
-	
-	/*
-	 * Test putIfAbsent operatiion, which only puts if the key is not already associated
-	 * with a value
-	 */
-	public void testPutIfAbsent() {
-		
-		remoteCache.putIfAbsent("aKey", "aValue");
-		assert remoteCache.size() == 1;
-		assertEquals(remoteCache.get("aKey"),"aValue");		
-		
-		assert null == remoteCache.putIfAbsent("aKey", "anotherValue");
-		assertEquals(remoteCache.get("aKey"),"aValue");
-	}
-
-	/*
-	 * Tests the cache clear operation
-	 */
-	public void testClear() {
-		remoteCache.put("aKey", "aValue");
-		remoteCache.put("aKey2", "aValue");
-		remoteCache.clear();
-		assert !remoteCache.containsKey("aKey");
-		assert !remoteCache.containsKey("aKey2");
-	}
-	
-
-	/*
-	 * Tests getting a pointer to the originating RemoteCachemanager instance
-	 */
-	public void testGetRemoteCacheManager() {
-		
-		RemoteCacheManager manager = null ;
-		
-		manager = remoteCache.getRemoteCacheManager() ;
-		assert manager == this.remoteCacheManager : "getRemoteCachemanager() returned incorrect value" ;
-	}
-
-	public void testStats() {
-		
-		ServerStatistics remoteStats = remoteCache.stats();
-		assert null != remoteStats ;
-		System.out.println("named stats = " + remoteStats.getStatsMap()) ;
-	}
-	
-	
-	/*
-	 * Looks as thought CacheListeners are not supported with RemoteCache
-	 */
-	public void XtestCacheListener() {
-		
-		SingleEventListener listener = new SingleEventListener();
-		Set<Object> listeners = null ;
-		
-		remoteCache.addListener(listener);
-		listeners = remoteCache.getListeners() ;
-		assert listeners.size() == 1 ;
-		
-		remoteCache.put("aKey", "aValue");
-		org.infinispan.notifications.cachelistener.event.Event e = listener.getLastEvent() ;
-		assert null != e ;
-		assert (e.getType() == org.infinispan.notifications.cachelistener.event.Event.Type.CACHE_ENTRY_CREATED || 
-				e.getType() == org.infinispan.notifications.cachelistener.event.Event.Type.CACHE_ENTRY_MODIFIED) ;
-		
-		remoteCache.removeListener(listener);
-		listeners = remoteCache.getListeners() ;
-		assert listeners.size() == 0 ;		
-	}
-			
-	private void assertNull(Object obj, String msg) {
-		assert obj == null : msg ;
-	}
-
-	private void sleepForSecs(long numSecs) {
-		// give the elements time to be evicted
-		try {
-			Thread.sleep(numSecs * 1000) ;
-		}
-		catch(InterruptedException e) {
-		}
-	}
-	
-	
-	private void waitForNotifyingFutureToBeDone(NotifyingFuture future) {
-		// wait for operation to complete
-		while (!future.isDone()) {
-			// wait a bit
-			try {
-				Thread.sleep(1000) ;
-			}
-			catch(InterruptedException e) {
-			}
-		}		
-	}
-	
-//	private void waitForNotifyingFutureToBeDone(NotifyingFuture<Void> future) {
-//		// wait for operation to complete
-//		while (!future.isDone()) {
-//			// wait a bit
-//			try {
-//				Thread.sleep(1000) ;
-//			}
-//			catch(InterruptedException e) {
-//			}
-//		}		
-//	}	
-	
-	private void printCacheContents(RemoteCache c, String description) {
-        Map<String,String> cacheElements = c.getBulk();
-        System.out.println(description + " : " + cacheElements);
-	}
-	
-    public static Test suite() throws Exception {
-        return HotRodClientTestSetup.getCacheManagerSetup(HotRodClientTestCase.class,"repl") ;
-    }
-}
-
- at Listener
-class SingleEventListener {
-	
-	Event event = null ;
-	
-	public Event getLastEvent() {
-		return event ;
-	}
-	
-	@CacheEntryModified
-	@CacheEntryCreated
-	@CacheEntryLoaded
-	@CacheEntryVisited
-	public void logAccessEvent(Event event) {
-		this.event = event ;
-		System.out.println("Listener got access event: " + event) ;
-	}
-
-	@CacheEntryActivated
-	@CacheEntryPassivated
-	public void logPassiveActiveEvent(Event event) {
-		this.event = event ;
-		System.out.println("Listener got passivate/activate event: " + event) ;
-	}
-
-	@CacheEntryLoaded
-	@CacheEntryEvicted
-	public void logLoadedEvictedEvent(Event event) {
-		this.event = event ;
-		System.out.println("Listener got evict/load event: " + event) ;
-	}
-
-	@ViewChanged
-	public void logViewEvent(Event event) {
-		this.event = event ;
-		System.out.println("Listener got view event: " + event) ;
-	}
-}
-
-
-/*                                                                                                                                                                               
- * This class can be used to perform a one-time setup and teardown of the RemoteCache                                                                                            
- */
-class HotRodClientTestSetup extends JBossTestClusteredSetup {
-
-	private final String cacheConfig ;
-	private static RemoteCacheManager remoteCacheManager ;
-	private static RemoteCache remoteCache ;
-
-	public HotRodClientTestSetup(Test test, String cacheConfig) throws Exception
-	{
-		// workaround for a bug in JBossTestClusteredSetup                                                                                                                       
-		// the JBossTestClusteredSetup(Test) constructor needs to pass base test class                                                                                           
-		super(test, "");
-		this.cacheConfig = cacheConfig ;
-	}
-
-	public static RemoteCacheManager getRemoteCacheManager() {
-		return remoteCacheManager;
-	}
-
-	public static RemoteCache getRemoteCache() {
-		return remoteCache;
-	}
-
-	public static Test getCacheManagerSetup(final Test test, String cacheConfig)
-	throws Exception
-	{
-		return new HotRodClientTestSetup(test, cacheConfig);
-	}
-
-	public static Test getCacheManagerSetup(final Class<?> clazz, String cacheConfig)
-	throws Exception
-	{
-		TestSuite suite = new TestSuite() ;
-		suite.addTest(new TestSuite(clazz)) ;
-		return getCacheManagerSetup(suite, cacheConfig) ;
-	}
-
-	public void setUp() throws Exception {
-
-		// run this before any tests                                                                                                                                            
-		System.out.println("one-time setup of RemoteCacheManager") ;
-		remoteCacheManager = getRemoteCacheManagerInstance() ;
-		remoteCacheManager.start() ;
-
-		if (cacheConfig.equals("default")) {
-			remoteCache = remoteCacheManager.getCache() ;
-		}
-		else if (cacheConfig.equals("repl")) {
-			remoteCache = remoteCacheManager.getCache("sampleReplicatedCache") ;
-		}
-		else if (cacheConfig.equals("dist")) {
-			throw new IllegalArgumentException("dist cache configuration is not supported") ;
-		}
-		else {
-			throw new IllegalArgumentException("no cache config specified") ;
-		}
-		// delegate.setUp();                                                                                                                                                    
-		super.setUp();
-	}
-
-	public void tearDown() throws Exception {
-		try {
-			super.tearDown();
-		}
-		finally {
-			// run this after any tests                                                                                                                                         
-			System.out.println("one-time teardown of RemoteCachemanager") ;
-			remoteCacheManager.stop() ;
-		}
-	}
-
-	private Properties getRemoteCacheManagerProperties(String hotRodServerList) {
-		Properties props = new Properties();
-		// load balancing                                                                                                                                                      \
-
-		props.put("infinispan.client.hotrod.request_balancing_strategy",
-		"org.infinispan.client.hotrod.impl.transport.tcp.RoundRobinBalancingStrategy");
-		// list of HotRod servers available to connect to                                                                                                                      \
-
-		props.put("infinispan.client.hotrod.server_list", hotRodServerList);
-		props.put("infinispan.client.hotrod.force_return_values", "false");
-		// TCP stuff                                                                                                                                                           \
-
-		props.put("infinispan.client.hotrod.tcp_no_delay", "true");
-		props.put("infinispan.client.hotrod.ping_on_startup", "true");
-		props.put("infinispan.client.hotrod.transport_factory",
-		"org.infinispan.client.hotrod.impl.transport.tcp.TcpTransportFactory");
-		// marshalling                                                                                                                                                         \
-
-		props.put("infinispan.client.hotrod.marshaller", "org.infinispan.marshall.jboss.GenericJBossMarshaller");
-		// executors                                                                                                                                                           \
-
-		props.put("infinispan.client.hotrod.async_executor_factory",
-		"org.infinispan.client.hotrod.impl.async.DefaultAsyncExecutorFactory");
-		props.put("infinispan.client.hotrod.default_executor_factory.pool_size", "10");
-		props.put("infinispan.client.hotrod.default_executor_factory.queue_size", "100000");
-		// hashing                                                                                                                                                             \
-
-		props.put("infinispan.client.hotrod.hash_function_impl.1",
-		"org.infinispan.client.hotrod.impl.consistenthash.ConsistentHashV1");
-		props.put("infinispan.client.hotrod.key_size_estimate", "64");
-		props.put("infinispan.client.hotrod.value_size_estimate", "512");
-
-		return props ;
-	}
-
-	private RemoteCacheManager getRemoteCacheManagerInstance() {
-
-		String[] servers = new String[2];
-		servers[0] = System.getProperty("jbosstest.cluster.node0") ;
-		servers[1] = System.getProperty("jbosstest.cluster.node1") ;
-		String hotRodServerList = servers[0] + ":" + "11222" + ";" + servers[1] + ":" + "11222";
-
-		System.out.println("RemoteCacheManager: using server list:  " + hotRodServerList) ;
-
-		Properties props = getRemoteCacheManagerProperties(hotRodServerList) ;
-
-		return new RemoteCacheManager(props, false);
-	}
-}



More information about the jboss-cvs-commits mailing list