[jboss-cvs] JBossAS SVN: r109444 - 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
Wed Nov 24 07:18:55 EST 2010


Author: mlinhard
Date: 2010-11-24 07:18:54 -0500 (Wed, 24 Nov 2010)
New Revision: 109444

Modified:
   branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/MemcachedClientTestCase.java
   branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/MemcachedReplicationTestCase.java
   branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/MemcachedSession.java
   branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/RESTClientTestCase.java
Log:
updated memcached and REST server module testsuites

Modified: branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/MemcachedClientTestCase.java
===================================================================
--- branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/MemcachedClientTestCase.java	2010-11-24 12:18:06 UTC (rev 109443)
+++ branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/MemcachedClientTestCase.java	2010-11-24 12:18:54 UTC (rev 109444)
@@ -54,7 +54,7 @@
 	protected void setUp() throws Exception {
 		super.setUp();
 		// to run original memcached server: memcached -p 11212
-//		mc = new MemcachedSession(ENCODING, "localhost", 11212); // to run against original memcached server
+		//mc = new MemcachedSession(ENCODING, "localhost", 11212); // to run against original memcached server
 		mc = new MemcachedSession(ENCODING, getServers()[0], Integer.getInteger("jboss.infinispan.memcached.server.port", 11211)); // to run against infinispan memcached server
 		mc.delete(KEY_A);
 		mc.delete(KEY_B);
@@ -218,6 +218,10 @@
 		mc.flush();
 		assertEquals("STORED", mc.readln());
 		assertEquals("B", mc.get(KEY_A));
+		mc.writeln("gets "+KEY_A);
+		mc.flush();
+		valueline = mc.readln().split(" ");
+		assertNotSame(casId, valueline[4]);
 	}
 	
 	public void testCasExists() throws Exception {
@@ -252,17 +256,6 @@
 		assertEquals("NOT_FOUND", mc.readln());
 	}
 	
-	public void testNoReply() throws Exception {
-		mc.writeln("set "+KEY_A+" 0 0 1 noreply");
-		mc.writeln("A");
-		mc.flush();
-		mc.writeln("get "+KEY_A);
-		mc.flush();
-		assertEquals("VALUE "+KEY_A+" 0 1", mc.readln());
-		assertEquals("A", mc.readln());
-		assertEquals("END", mc.readln());
-	}
-	
 	public void testExpTime() throws Exception {
 		mc.writeln("set "+KEY_A+" 0 2 1");
 		mc.writeln("A");
@@ -310,12 +303,18 @@
 		assertNull(mc.get(KEY_A));
 	}
 	
-	// https://jira.jboss.org/browse/JBPAPP-5332
-	public void testKeyLonger250() throws Exception {
+	private String key250() {
 		String key250 = "";
 		for (int i = 0; i <  250; i++) {
 			key250 += "a";
 		}
+		return key250;
+	}
+	
+	// https://jira.jboss.org/browse/JBPAPP-5332
+	public void testKeyLonger250() throws Exception {
+		String key250 = key250();
+		mc.delete(key250);
 		String key251 = key250 + "a";
 		// byte length is the same, because we're using "UTF-8 safe" char 'a'
 		assertEquals(key250.length(), key250.getBytes(ENCODING).length);
@@ -323,11 +322,95 @@
 		mc.set(key250, "A");
 		assertEquals("A", mc.get(key250));
 		mc.writeln("set "+key251+" 0 0 1");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+	}
+	
+	public void testKeyLonger250Get() throws Exception {
+		mc.writeln("get " + key250() + "a");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+	}	
+	
+	public void testKeyLonger250Gets() throws Exception {
+		mc.writeln("gets " + key250() + "a");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+	}	
+	
+	public void testKeyLonger250Multiget() throws Exception {
+		String key250 = key250();
+		String key251 = key250 + "a";
+		// byte length is the same, because we're using "UTF-8 safe" char 'a'
+		assertEquals(key250.length(), key250.getBytes(ENCODING).length);
+		assertEquals(key251.length(), key251.getBytes(ENCODING).length);
+		mc.set(key250, "A");
+		assertEquals("A", mc.get(key250));
+		mc.writeln("get " + key250 + " " + key251);
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+		assertEquals("DELETED", mc.delete(key250));
+	}
+	
+	public void testKeyLonger250Add() throws Exception {
+		String key250 = key250();
+		mc.delete(key250);
+		String key251 = key250 + "a";
+		// byte length is the same, because we're using "UTF-8 safe" char 'a'
+		assertEquals(key250.length(), key250.getBytes(ENCODING).length);
+		assertEquals(key251.length(), key251.getBytes(ENCODING).length);
+		mc.writeln("add " + key250 + " 0 0 1");
 		mc.writeln("A");
 		mc.flush();
+		assertEquals("STORED", mc.readln());
+		assertEquals("A", mc.get(key250));
+		mc.writeln("add "+key251+" 0 0 1");
+		mc.flush();
 		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
 	}
 	
+	public void testKeyLonger250Replace() throws Exception {
+		mc.writeln("replace "+key250()+"a 0 0 1");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+	}
+	
+	public void testKeyLonger250Append() throws Exception {
+		mc.writeln("append "+key250()+"a 0 0 1");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+	}
+	
+	public void testKeyLonger250Prepend() throws Exception {
+		mc.writeln("prepend "+key250()+"a 0 0 1");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+	}
+
+	public void testKeyLonger250Cas() throws Exception {
+		mc.writeln("prepend "+key250()+"a 0 0 1 1");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+	}
+
+	public void testKeyLonger250Incr() throws Exception {
+		mc.writeln("incr "+key250()+"a 1");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+	}
+
+	public void testKeyLonger250Decr() throws Exception {
+		mc.writeln("decr "+key250()+"a 1");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+	}
+	
+	public void testKeyLonger250Delete() throws Exception {
+		mc.writeln("delete "+key250()+"a");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+	}
+	
 	public void testDelete() throws Exception {
 		mc.set(KEY_A, "A");
 		assertEquals("A", mc.get(KEY_A));
@@ -547,4 +630,434 @@
 		int cas_badval_new = new Integer(stats.get("cas_badval"));
 		assertEquals(cas_badval + 1, cas_badval_new);
 	}
+	
+	// https://jira.jboss.org/browse/JBPAPP-5413
+	public void testBogusCommand() throws Exception {
+		mc.writeln("boguscommand");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("ERROR"));
+	}
+	
+	public void testBogusCommandArgs() throws Exception {
+		mc.writeln("boguscommand arg1 arg2 arg3");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("ERROR"));
+	}
+	
+	public void testBogusCommandPipeline() throws Exception {
+		mc.writeln("boguscommand");
+		mc.writeln("delete " + KEY_A);
+		mc.flush();
+		assertTrue(mc.readln().startsWith("ERROR"));
+		assertEquals("NOT_FOUND", mc.readln());
+	}
+	
+	public void testCasParsing1() throws Exception {
+		mc.writeln("cas bad blah 0 0 0");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+	}
+	
+	public void testCasParsing2() throws Exception {
+		mc.writeln("cas bad 0 blah 0 0");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+	}
+	
+	public void testCasParsing3() throws Exception {
+		mc.writeln("cas bad 0 0 blah 0");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+	}
+	
+	public void testCasParsing4() throws Exception {
+		mc.writeln("cas bad 0 0 0 blah");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+	}
+	
+//	public void testCasParsing5() throws Exception {
+//		mc.writeln("cas bad 0 0 0 0 0");
+//		mc.flush();
+//		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+//	}
+	
+	// missing cas unique value
+	public void testCasParsing6() throws Exception {
+		mc.writeln("cas bad 0 0 6");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+	}
+	
+	public void testCasUniqueIs64Bit() throws Exception {
+		mc.writeln("cas a 0 0 1 18446744073709551615");
+		mc.writeln("a");
+		mc.flush();
+		assertEquals("NOT_FOUND", mc.readln());
+		mc.writeln("cas a 0 0 1 -1");
+		mc.writeln("a");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+	}
+	
+	// https://jira.jboss.org/browse/JBPAPP-5446
+	public void testSetFlagsRange() throws Exception {
+		mc.writeln("set a 0 0 1");
+		mc.writeln("a");
+		mc.flush();
+		assertEquals("STORED", mc.readln());
+		mc.writeln("set a 4294967295 0 1");
+		mc.writeln("a");
+		mc.flush();
+		assertEquals("STORED", mc.readln());
+		mc.writeln("set a -1 0 1");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+		mc.writeln("set a 4294967296 0 1");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+	}
+	
+	// https://jira.jboss.org/browse/JBPAPP-5445
+	public void testVerbosity() throws Exception {
+		mc.writeln("verbosity 0");
+		mc.flush();
+		assertEquals("OK", mc.readln());
+	}
+	
+	// https://jira.jboss.org/browse/JBPAPP-5444
+	public void testQuit() throws Exception {
+		mc.writeln("quit");
+		mc.flush();
+		assertEquals("", mc.readln());
+	}
+	
+	public void testFlushAll() throws Exception {
+		mc.set(KEY_A, "valA");
+		mc.set(KEY_B, "valB");
+		mc.set(KEY_C, "valC");
+		assertEquals("valA", mc.get(KEY_A));
+		assertEquals("valB", mc.get(KEY_B));
+		assertEquals("valC", mc.get(KEY_C));
+		mc.writeln("flush_all");
+		mc.flush();
+		assertEquals("OK", mc.readln());
+		assertNull(mc.get(KEY_A));
+		assertNull(mc.get(KEY_B));
+		assertNull(mc.get(KEY_C));
+	}
+	
+
+	public void testFlushAllDelayed() throws Exception {
+		mc.set(KEY_A, "valA");
+		mc.set(KEY_B, "valB");
+		mc.set(KEY_C, "valC");
+		assertEquals("valA", mc.get(KEY_A));
+		assertEquals("valB", mc.get(KEY_B));
+		assertEquals("valC", mc.get(KEY_C));
+		mc.writeln("flush_all 2");
+		mc.flush();
+		assertEquals("OK", mc.readln());
+		assertEquals("valA", mc.get(KEY_A));
+		assertEquals("valB", mc.get(KEY_B));
+		assertEquals("valC", mc.get(KEY_C));
+		Thread.sleep(2000);
+		assertNull(mc.get(KEY_A));
+		assertNull(mc.get(KEY_B));
+		assertNull(mc.get(KEY_C));
+	}
+	
+	public void testFlushAllDelayedUnixTime() throws Exception {
+		mc.set(KEY_A, "valA");
+		mc.set(KEY_B, "valB");
+		mc.set(KEY_C, "valC");
+		assertEquals("valA", mc.get(KEY_A));
+		assertEquals("valB", mc.get(KEY_B));
+		assertEquals("valC", mc.get(KEY_C));
+		long t = mc.getServerTime();
+		mc.writeln("flush_all " + (t + 2));
+		mc.flush();
+		assertEquals("OK", mc.readln());
+		assertEquals("valA", mc.get(KEY_A));
+		assertEquals("valB", mc.get(KEY_B));
+		assertEquals("valC", mc.get(KEY_C));
+		Thread.sleep(2100);
+		assertNull(mc.get(KEY_A));
+		assertNull(mc.get(KEY_B));
+		assertNull(mc.get(KEY_C));
+	}
+	
+	public void testPipeliningSet() throws Exception {
+		mc.writeln("set " + KEY_A + " 0 0 1");
+		mc.writeln("a");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("STORED", mc.readln());
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testPipeliningAdd() throws Exception {
+		mc.writeln("add " + KEY_A + " 0 0 1");
+		mc.writeln("a");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("STORED", mc.readln());
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testPipeliningReplace() throws Exception {
+		mc.set(KEY_A, "b");
+		mc.writeln("replace " + KEY_A + " 0 0 1");
+		mc.writeln("a");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("STORED", mc.readln());
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testPipeliningAppend() throws Exception {
+		mc.set(KEY_A, "a");
+		mc.writeln("append " + KEY_A + " 0 0 1");
+		mc.writeln("a");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("STORED", mc.readln());
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testPipeliningPrepend() throws Exception {
+		mc.set(KEY_A, "a");
+		mc.writeln("prepend " + KEY_A + " 0 0 1");
+		mc.writeln("a");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("STORED", mc.readln());
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testPipeliningCas() throws Exception {
+		mc.writeln("cas " + KEY_A + " 0 0 1 0");
+		mc.writeln("a");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("NOT_FOUND", mc.readln());
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testPipeliningGet() throws Exception {
+		mc.writeln("get " + KEY_A);
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("END", mc.readln());
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testPipeliningGetMulti() throws Exception {
+		mc.writeln("get " + KEY_A + " " + KEY_C);
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("END", mc.readln());
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testPipeliningGets() throws Exception {
+		mc.writeln("gets " + KEY_A);
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("END", mc.readln());
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testPipeliningGetsMulti() throws Exception {
+		mc.writeln("gets " + KEY_A + " " + KEY_C);
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("END", mc.readln());
+		assertEquals("END", mc.readln());
+	}
+	
+	// https://jira.jboss.org/browse/JBPAPP-5422
+	public void testPipeliningDelete() throws Exception {
+		mc.writeln("delete " + KEY_A);
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("NOT_FOUND", mc.readln());
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testPipeliningIncr() throws Exception {
+		mc.set(KEY_A, "1");
+		mc.writeln("incr " + KEY_A + " 1");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("2", mc.readln());
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testPipeliningDecr() throws Exception {
+		mc.set(KEY_A, "2");
+		mc.writeln("decr " + KEY_A + " 1");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("1", mc.readln());
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testPipeliningStats() throws Exception {
+		mc.writeln("stats");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		String line = null;
+		do {
+			line = mc.readln();
+		} while (!line.equals("END"));
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testPipeliningVersion() throws Exception {
+		mc.writeln("version");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertNotNull(mc.readln());
+		assertEquals("END", mc.readln());
+	}
+	
+	// https://jira.jboss.org/browse/JBPAPP-5445
+	public void testPipeliningVerbosity() throws Exception {
+		mc.writeln("verbosity 0");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("OK", mc.readln());
+		assertEquals("END", mc.readln());
+	}
+	
+	// https://jira.jboss.org/browse/JBPAPP-5449
+	public void testPipeliningFlushAll() throws Exception {
+		mc.writeln("flush_all");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("OK", mc.readln());
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testPipeliningFlushAllDelayed() throws Exception {
+		mc.writeln("flush_all 1");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("OK", mc.readln());
+		assertEquals("END", mc.readln());
+	}
+	
+	// https://jira.jboss.org/browse/JBPAPP-5440
+	public void testStatsArgs() throws Exception {
+		mc.writeln("stats args");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("SERVER_ERROR"));
+	}
+	
+	// https://jira.jboss.org/browse/JBPAPP-5425
+	public void testNegativeItemSize() throws Exception {
+		mc.writeln("set a 0 0 -1");
+		mc.flush();
+		assertTrue(mc.readln().startsWith("CLIENT_ERROR"));
+	}
+	
+
+	public void testNoReplySet() throws Exception {
+		mc.writeln("set " + KEY_A + " 0 0 1 noreply");
+		mc.writeln("a");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testNoReplyAdd() throws Exception {
+		mc.writeln("add " + KEY_A + " 0 0 1 noreply");
+		mc.writeln("a");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testNoReplyReplace() throws Exception {
+		mc.set(KEY_A, "b");
+		mc.writeln("replace " + KEY_A + " 0 0 1 noreply");
+		mc.writeln("a");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testNoReplyAppend() throws Exception {
+		mc.set(KEY_A, "a");
+		mc.writeln("append " + KEY_A + " 0 0 1 noreply");
+		mc.writeln("a");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testNoReplyPrepend() throws Exception {
+		mc.set(KEY_A, "a");
+		mc.writeln("prepend " + KEY_A + " 0 0 1 noreply");
+		mc.writeln("a");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testNoReplyCas() throws Exception {
+		mc.writeln("cas " + KEY_A + " 0 0 1 0 noreply");
+		mc.writeln("a");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testNoReplyDelete() throws Exception {
+		mc.writeln("delete " + KEY_A + " noreply");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testNoReplyIncr() throws Exception {
+		mc.set(KEY_A, "1");
+		mc.writeln("incr " + KEY_A + " 1 noreply");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testNoReplyDecr() throws Exception {
+		mc.set(KEY_A, "2");
+		mc.writeln("decr " + KEY_A + " 1 noreply");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("END", mc.readln());
+	}
+		
+	// https://jira.jboss.org/browse/JBPAPP-5445
+	public void testNoReplyVerbosity() throws Exception {
+		mc.writeln("verbosity 0 noreply");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("END", mc.readln());
+	}
+	
+	// https://jira.jboss.org/browse/JBPAPP-5439
+	public void testNoReplyFlushAll() throws Exception {
+		mc.writeln("flush_all noreply");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testNoReplyFlushAllDelayed() throws Exception {
+		mc.writeln("flush_all 1 noreply");
+		mc.writeln("get " + KEY_B);
+		mc.flush();
+		assertEquals("END", mc.readln());
+	}
+	
 }
\ No newline at end of file

Modified: branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/MemcachedReplicationTestCase.java
===================================================================
--- branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/MemcachedReplicationTestCase.java	2010-11-24 12:18:06 UTC (rev 109443)
+++ branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/MemcachedReplicationTestCase.java	2010-11-24 12:18:54 UTC (rev 109444)
@@ -138,16 +138,7 @@
 	
 	public void testReplicatedCas() throws Exception {
 		mc1.set(KEY_A, "A");
-		mc2.writeln("gets "+KEY_A);
-		mc2.flush();
-		String[] valueline = mc2.readln().split(" ");
-		assertEquals("VALUE", valueline[0]);
-		assertEquals(KEY_A, valueline[1]);
-		assertEquals("0", valueline[2]); // flags
-		assertEquals("1", valueline[3]); // number of bytes in str "A"
-		assertEquals("A", mc2.readln());
-		String casId = valueline[4];
-		assertEquals("END", mc2.readln());
+		String casId = mc2.getCasId(KEY_A);
 		mc2.writeln("cas "+KEY_A+" 0 0 1 " + casId);
 		mc2.writeln("B");
 		mc2.flush();
@@ -157,16 +148,7 @@
 	
 	public void testReplicatedCasExists() throws Exception {
 		mc1.set(KEY_A, "A");
-		mc1.writeln("gets "+KEY_A);
-		mc1.flush();
-		String[] valueline = mc1.readln().split(" ");
-		assertEquals("VALUE", valueline[0]);
-		assertEquals(KEY_A, valueline[1]);
-		assertEquals("0", valueline[2]); // flags
-		assertEquals("1", valueline[3]); // number of bytes in str "A"
-		assertEquals("A", mc1.readln());
-		String casId = valueline[4];
-		assertEquals("END", mc1.readln());
+		String casId = mc2.getCasId(KEY_A);
 		mc2.writeln("cas "+KEY_A+" 0 0 1 1" + casId); // note appended 1 before casId
 		mc2.writeln("B");
 		mc2.flush();
@@ -174,6 +156,22 @@
 		assertEquals("A", mc1.get(KEY_A));
 	}
 	
+	public void testReplicatedCasExists2() throws Exception {
+		mc1.set(KEY_A, "A");
+		String casId1 = mc1.getCasId(KEY_A);
+		String casId2 = mc2.getCasId(KEY_A);
+		assertEquals(casId1, casId2);
+		mc2.writeln("cas "+KEY_A+" 0 0 2 " + casId1);
+		mc2.writeln("B2");
+		mc1.writeln("cas "+KEY_A+" 0 0 2 " + casId1);
+		mc1.writeln("B1");
+		mc2.flush();
+		mc1.flush();
+		assertEquals("STORED", mc2.readln());
+		assertEquals("EXISTS", mc1.readln());
+		assertNotSame(mc1.getCasId(KEY_A), mc2.getCasId(KEY_A));
+	}
+	
 	public void testReplicatedDelete() throws Exception {
 		mc1.set(KEY_A, "A");
 		assertEquals("A", mc2.get(KEY_A));

Modified: branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/MemcachedSession.java
===================================================================
--- branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/MemcachedSession.java	2010-11-24 12:18:06 UTC (rev 109443)
+++ branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/MemcachedSession.java	2010-11-24 12:18:54 UTC (rev 109444)
@@ -208,4 +208,16 @@
 		assertEquals("END", statline);
 		return time;
 	}
+	
+	public String getCasId(String aKey) throws IOException {
+		writeln("gets "+aKey);
+		flush();
+		String[] valueline = readln().split(" ");
+		assertEquals("VALUE", valueline[0]);
+		assertEquals(aKey, valueline[1]);
+		in.read(new Integer(valueline[3]));
+		assertEquals("", readln());
+		assertEquals("END", readln());
+		return valueline[4];
+	}
 }
\ No newline at end of file

Modified: branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/RESTClientTestCase.java
===================================================================
--- branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/RESTClientTestCase.java	2010-11-24 12:18:06 UTC (rev 109443)
+++ branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/RESTClientTestCase.java	2010-11-24 12:18:54 UTC (rev 109444)
@@ -34,6 +34,7 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpStatus;
 import org.apache.commons.httpclient.methods.DeleteMethod;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.commons.httpclient.methods.HeadMethod;
@@ -50,14 +51,15 @@
  * @version $Revision$
  */
 public class RESTClientTestCase extends JBossClusteredTestCase {
-
+	private static final String KEY_A = "a";
+	private static final String KEY_B = "b";
+	private static final String KEY_C = "c";
+	
 	public RESTClientTestCase(String name) {
 		super(name);
 	}
 	private String[] httpUrls;
 	private HttpClient client;
-	private String infinispanRestPrefix;
-	private String fullPath;
 	private static final String DATE_PATTERN_RFC1123 = "EEE, dd MMM yyyy HH:mm:ss zzz";
 
 	public static class TestSerializable implements Serializable {
@@ -72,96 +74,35 @@
 			return content;
 		}
 	}
-
+	
 	@Override
 	protected void setUp() throws Exception {
 		super.setUp();
 		httpUrls = getHttpURLs();
 		client = new HttpClient();
-		infinispanRestPrefix = httpUrls[0] + "/infinispan-server-rest/rest"; 
-		fullPath = infinispanRestPrefix + "/___defaultcache";
 		
-		delete(fullPath + "/testBasicOperation");
-		delete(fullPath + "/testBasicClusteredOperation");
-		delete(fullPath + "/testGet");
-		delete(fullPath + "/testHead");
-		delete(fullPath + "/testPostDuplicate");
-		delete(fullPath + "/testPutDataWithTimeToLive");
-		delete(fullPath + "/testPutDataWithMaxIdleTime");
-		delete(fullPath + "/testPutDataTTLMaxIdleCombo1");
-		delete(fullPath + "/testPutDataTTLMaxIdleCombo2");
-		delete(fullPath + "/testPutDataWithTimeToLiveAsync");
-		delete(fullPath + "/testPutDataWithMaxIdleTimeAsync");
-		delete(fullPath + "/testPutDataTTLMaxIdleCombo1Async");
-		delete(fullPath + "/testPutDataTTLMaxIdleCombo2Async");
-		delete(fullPath + "/testRemoveEntry");
-		delete(fullPath + "/testWipeCacheBucket");
-		delete(fullPath + "/testWipeCacheBucket2");
-		delete(fullPath + "/testAsyncAddRemove");
-		delete(fullPath + "/testPutUnknownClass");
-		delete(fullPath + "/testETagChanges");
-		delete(fullPath + "/testIfModifiedSince");
-		delete(fullPath + "/testIfUnmodifiedSince");
-		delete(fullPath + "/testIfNoneMatch");
-		delete(fullPath + "/testIfMatch");
-		delete(infinispanRestPrefix + "/sampleReplicatedCache/testGetNamedCache");
+		delete(fullPathKey(KEY_A));
+		delete(fullPathKey(KEY_B));
+		delete(fullPathKey(KEY_C));
+		delete(fullPathKey("sampleReplicatedCache", KEY_A));
 		
-		head(fullPath + "/testBasicOperation", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testBasicClusteredOperation", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testGet", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testHead", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testPostDuplicate", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testPutDataWithTimeToLive", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testPutDataWithMaxIdleTime", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testPutDataTTLMaxIdleCombo1", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testPutDataTTLMaxIdleCombo2", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testPutDataWithTimeToLiveAsync", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testPutDataWithMaxIdleTimeAsync", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testPutDataTTLMaxIdleCombo1Async", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testPutDataTTLMaxIdleCombo2Async", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testRemoveEntry", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testWipeCacheBucket", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testWipeCacheBucket2", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testAsyncAddRemove", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testPutUnknownClass", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testETagChanges", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testIfModifiedSince", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testIfUnmodifiedSince", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testIfNoneMatch", HttpServletResponse.SC_NOT_FOUND);
-		head(infinispanRestPrefix + "/sampleReplicatedCache/testGetNamedCache", HttpServletResponse.SC_NOT_FOUND);
+		head(fullPathKey(KEY_A), HttpServletResponse.SC_NOT_FOUND);
+		head(fullPathKey(KEY_B), HttpServletResponse.SC_NOT_FOUND);
+		head(fullPathKey(KEY_C), HttpServletResponse.SC_NOT_FOUND);
+		head(fullPathKey("sampleReplicatedCache", KEY_A), HttpServletResponse.SC_NOT_FOUND);
 	}
 	
 	@Override
 	protected void tearDown() throws Exception {
 		super.tearDown();
-		delete(fullPath + "/testBasicOperation");
-		delete(fullPath + "/testBasicClusteredOperation");
-		delete(fullPath + "/testGet");
-		delete(fullPath + "/testHead");
-		delete(fullPath + "/testPostDuplicate");
-		delete(fullPath + "/testPutDataWithTimeToLive");
-		delete(fullPath + "/testPutDataWithMaxIdleTime");
-		delete(fullPath + "/testPutDataTTLMaxIdleCombo1");
-		delete(fullPath + "/testPutDataTTLMaxIdleCombo2");
-		delete(fullPath + "/testPutDataWithTimeToLiveAsync");
-		delete(fullPath + "/testPutDataWithMaxIdleTimeAsync");
-		delete(fullPath + "/testPutDataTTLMaxIdleCombo1Async");
-		delete(fullPath + "/testPutDataTTLMaxIdleCombo2Async");
-		delete(fullPath + "/testRemoveEntry");
-		delete(fullPath + "/testWipeCacheBucket");
-		delete(fullPath + "/testWipeCacheBucket2");
-		delete(fullPath + "/testAsyncAddRemove");
-		delete(fullPath + "/testPutUnknownClass");
-		delete(fullPath + "/testETagChanges");
-		delete(fullPath + "/testIfModifiedSince");
-		delete(fullPath + "/testIfUnmodifiedSince");
-		delete(fullPath + "/testIfNoneMatch");
-		delete(fullPath + "/testIfMatch");
-		delete(infinispanRestPrefix + "/sampleReplicatedCache/testGetNamedCache");
+		delete(fullPathKey(KEY_A));
+		delete(fullPathKey(KEY_B));
+		delete(fullPathKey(KEY_C));
+		delete(fullPathKey("sampleReplicatedCache", KEY_A));
 	}
 
 	public void testBasicOperation() throws Exception {
-		String fullPathKey = fullPath + "/testBasicOperation";
+		String fullPathKey = fullPathKey(KEY_A);
 		String initialXML = "<hey>ho</hey>";
 		PutMethod insert = put(fullPathKey, initialXML, "application/octet-stream");
 		assertEquals("", insert.getResponseBodyAsString().trim());
@@ -180,7 +121,7 @@
 		client.executeMethod(get);
 		assertEquals(initialXML, get.getResponseBodyAsString());
 
-		DeleteMethod removeAll = new DeleteMethod(fullPath);
+		DeleteMethod removeAll = new DeleteMethod(fullPathKey(null));
 		client.executeMethod(removeAll);
 
 		client.executeMethod(get);
@@ -204,11 +145,11 @@
 	}
 
 	public void testEmptyGet() throws Exception {
-		get(fullPath + "/nodata", HttpServletResponse.SC_NOT_FOUND);
+		get(fullPathKey("nodata"), HttpServletResponse.SC_NOT_FOUND);
 	}
 
 	public void testGet() throws Exception {
-		String fullPathKey = fullPath + "/testGet";
+		String fullPathKey = fullPathKey(KEY_A);
 		post(fullPathKey, "data", "application/text");
 		GetMethod get = get(fullPathKey);
 		assertNotNull(get.getResponseHeader("ETag").getValue());
@@ -218,7 +159,7 @@
 	}
 	
 	public void testGetNamedCache() throws Exception {
-		String fullPathKey = infinispanRestPrefix + "/sampleReplicatedCache/testGetNamedCache";
+		String fullPathKey = fullPathKey("sampleReplicatedCache", KEY_A);
 		post(fullPathKey, "data", "application/text");
 		GetMethod get = get(fullPathKey);
 		assertNotNull(get.getResponseHeader("ETag").getValue());
@@ -228,7 +169,7 @@
 	}
 
 	public void testHead() throws Exception {
-		String fullPathKey = fullPath + "/testHead";
+		String fullPathKey = fullPathKey(KEY_A);
 		post(fullPathKey, "data", "application/text");
 		HeadMethod head = head(fullPathKey);
 		assertNotNull(head.getResponseHeader("ETag").getValue());
@@ -238,7 +179,7 @@
 	}
 
 	public void testPostDuplicate() throws Exception {
-		String fullPathKey = fullPath + "/testPostDuplicate";
+		String fullPathKey = fullPathKey(KEY_A);
 		
 		post(fullPathKey, "data", "application/text");
 		// second post, returns 409
@@ -248,7 +189,7 @@
 	}
 
 	public void testPutDataWithTimeToLive() throws Exception {
-		String fullPathKey = fullPath + "/testPutDataWithTimeToLive";
+		String fullPathKey = fullPathKey(KEY_A);
 		
 		post(fullPathKey, "data", "application/text", HttpServletResponse.SC_OK, 
 			// headers
@@ -264,7 +205,7 @@
 	
 	// https://jira.jboss.org/browse/JBPAPP-5289
 	public void testPutDataWithMaxIdleTime() throws Exception {
-		String fullPathKey = fullPath + "/testPutDataWithMaxIdleTime";
+		String fullPathKey = fullPathKey(KEY_A);
 		
 		post(fullPathKey, "data", "application/text", HttpServletResponse.SC_OK, 
 			// headers
@@ -287,7 +228,7 @@
 	}
 	
 	public void testPutDataTTLMaxIdleCombo1() throws Exception {
-		String fullPathKey = fullPath + "/testPutDataTTLMaxIdleCombo1";
+		String fullPathKey = fullPathKey(KEY_A);
 		
 		post(fullPathKey, "data", "application/text", HttpServletResponse.SC_OK, 
 			// headers
@@ -311,7 +252,7 @@
 	}
 	
 	public void testPutDataTTLMaxIdleCombo2() throws Exception {
-		String fullPathKey = fullPath + "/testPutDataTTLMaxIdleCombo2";
+		String fullPathKey = fullPathKey(KEY_A);
 		
 		post(fullPathKey, "data", "application/text", HttpServletResponse.SC_OK, 
 			// headers
@@ -327,7 +268,7 @@
 	}
 	
 	public void testPutDataWithTimeToLiveAsync() throws Exception {
-		String fullPathKey = fullPath + "/testPutDataWithTimeToLiveAsync";
+		String fullPathKey = fullPathKey(KEY_A);
 		
 		post(fullPathKey, "data", "application/text", HttpServletResponse.SC_OK, 
 			// headers
@@ -344,7 +285,7 @@
 	
 	// https://jira.jboss.org/browse/JBPAPP-5289
 	public void testPutDataWithMaxIdleTimeAsync() throws Exception {
-		String fullPathKey = fullPath + "/testPutDataWithMaxIdleTimeAsync";
+		String fullPathKey = fullPathKey(KEY_A); 
 		
 		post(fullPathKey, "data", "application/text", HttpServletResponse.SC_OK, 
 			// headers
@@ -368,7 +309,7 @@
 	}
 	
 	public void testPutDataTTLMaxIdleCombo1Async() throws Exception {
-		String fullPathKey = fullPath + "/testPutDataTTLMaxIdleCombo1Async";
+		String fullPathKey = fullPathKey(KEY_A); 
 		
 		post(fullPathKey, "data", "application/text", HttpServletResponse.SC_OK, 
 			// headers
@@ -393,7 +334,7 @@
 	}
 	
 	public void testPutDataTTLMaxIdleCombo2Async() throws Exception {
-		String fullPathKey = fullPath + "/testPutDataTTLMaxIdleCombo2Async";
+		String fullPathKey = fullPathKey(KEY_A); 
 		
 		post(fullPathKey, "data", "application/text", HttpServletResponse.SC_OK, 
 			// headers
@@ -410,7 +351,7 @@
 	}
 
 	public void testRemoveEntry() throws Exception {
-		String fullPathKey = fullPath + "/testRemoveEntry";
+		String fullPathKey = fullPathKey(KEY_A); 
 		post(fullPathKey, "data", "application/text");
 		head(fullPathKey);
 		client.executeMethod(new DeleteMethod(fullPathKey));
@@ -418,18 +359,17 @@
 	}
 
 	public void testWipeCacheBucket() throws Exception {
-		String fullPathKey = fullPath + "/testWipeCacheBucket";
-		post(fullPathKey, "data", "application/text");
-		post(fullPathKey + "2", "data", "application/text");
-		head(fullPathKey);
-		head(fullPathKey + "2");
-		client.executeMethod(new DeleteMethod(fullPath));
-		head(fullPathKey, HttpServletResponse.SC_NOT_FOUND);
-		head(fullPathKey + "2", HttpServletResponse.SC_NOT_FOUND);
+		post(fullPathKey(KEY_A), "data", "application/text");
+		post(fullPathKey(KEY_B), "data", "application/text");
+		head(fullPathKey(KEY_A));
+		head(fullPathKey(KEY_B));
+		client.executeMethod(new DeleteMethod(fullPathKey(null)));
+		head(fullPathKey(KEY_A), HttpServletResponse.SC_NOT_FOUND);
+		head(fullPathKey(KEY_B), HttpServletResponse.SC_NOT_FOUND);
 	}
 
 	public void testAsyncAddRemove() throws Exception {
-		String fullPathKey = fullPath + "/testAsyncAddRemove";
+		String fullPathKey = fullPathKey(KEY_A);
 		post(fullPathKey, "data", "application/text", HttpServletResponse.SC_OK, 
 				// headers
 				"performAsync", "true" );
@@ -446,7 +386,7 @@
 	
 	// https://jira.jboss.org/browse/JBPAPP-5256
 	public void testPutUnknownClass() throws Exception {
-		String fullPathKey = fullPath + "/testPutUnknownClass";
+		String fullPathKey = fullPathKey(KEY_A); 
 
 		ByteArrayOutputStream bout = new ByteArrayOutputStream();
 		ObjectOutputStream oo = new ObjectOutputStream(bout);
@@ -463,7 +403,7 @@
 	}
 	
 	public void testETagChanges() throws Exception {
-		String fullPathKey = fullPath + "/testETagChanges";
+		String fullPathKey = fullPathKey(KEY_A); 
 		put(fullPathKey, "data", "application/text");
 		String eTagFirst = get(fullPathKey).getResponseHeader("ETag").getValue();
 		// second get should get the same ETag
@@ -475,7 +415,7 @@
 	}
 	
 	public void testIfModifiedSince() throws Exception {
-		String fullPathKey = fullPath + "/testIfModifiedSince";
+		String fullPathKey = fullPathKey(KEY_A); 
 		put(fullPathKey, "data", "application/text");
 		String dateLast = get(fullPathKey).getResponseHeader("Last-Modified").getValue();
 		String dateMinus = addDay(dateLast, -1);
@@ -487,11 +427,11 @@
 		);
 		assertNotNull(get.getResponseBodyAsString());
 		
-		get = get(fullPathKey, HttpServletResponse.SC_OK, 
+		get = get(fullPathKey, HttpServletResponse.SC_NOT_MODIFIED, 
 			// exact same date as stored one
 			"If-Modified-Since", dateLast
 		);
-		assertNotNull(get.getResponseBodyAsString());
+		assertNull(get.getResponseBodyAsString());
 		
 		get = get(fullPathKey, HttpServletResponse.SC_NOT_MODIFIED, 
 			// resource hasn't been modified since
@@ -502,7 +442,7 @@
 
 	
 	public void testIfUnmodifiedSince() throws Exception {
-		String fullPathKey = fullPath + "/testIfUnmodifiedSince";
+		String fullPathKey = fullPathKey(KEY_A); 
 		put(fullPathKey, "data", "application/text");
 		
 		String dateLast = get(fullPathKey).getResponseHeader("Last-Modified").getValue();
@@ -520,7 +460,7 @@
 	}
 
 	public void testIfNoneMatch() throws Exception {
-		String fullPathKey = fullPath + "/testIfNoneMatch";
+		String fullPathKey = fullPathKey(KEY_A); 
 		put(fullPathKey, "data", "application/text");
 		String eTag = get(fullPathKey).getResponseHeader("ETag").getValue();
 		
@@ -534,7 +474,7 @@
 	}
 	
 	public void testIfMatch() throws Exception {
-		String fullPathKey = fullPath + "/testIfMatch";
+		String fullPathKey = fullPathKey(KEY_A); 
 		put(fullPathKey, "data", "application/text");
 		GetMethod get = get(fullPathKey);
 		
@@ -559,24 +499,53 @@
 	
 	// https://jira.jboss.org/browse/JBPAPP-5266
 	public void testNonExistentCache() throws Exception {
-		head(infinispanRestPrefix + "/nonexistentcache/nodata", HttpServletResponse.SC_NOT_FOUND);
-		get(infinispanRestPrefix + "/nonexistentcache/nodata", HttpServletResponse.SC_NOT_FOUND);
+		head(fullPathKey("nonexistentcache", "nodata"), HttpServletResponse.SC_NOT_FOUND);
+		get(fullPathKey("nonexistentcache", "nodata"), HttpServletResponse.SC_NOT_FOUND);
 	}
 	
-	public void testBasicClusteredOperation() throws Exception {
+	public void testReplicationPut() throws Exception {
 		assertEquals(2, httpUrls.length);
-		String fullPathKey1 = fullPath + "/testBasicClusteredOperation";
-		String fullPathKey2 = httpUrls[1] + "/infinispan-server-rest/rest/___defaultcache/testBasicClusteredOperation";
-		System.out.println("PUT "+fullPathKey1);
-		put(fullPathKey1, "data", "text/plain");
-		// wait for replication
-		Thread.sleep(1000);
-		System.out.println("GET "+fullPathKey2);
-		assertEquals("data", get(fullPathKey2).getResponseBodyAsString());
+		put(fullPathKey(0, KEY_A), "data", "text/plain");
+		assertEquals("data", get(fullPathKey(1, KEY_A)).getResponseBodyAsString());
 	}
 	
-	// TODO: more clustered test cases
+	public void testReplicationPost() throws Exception {
+		assertEquals(2, httpUrls.length);
+		post(fullPathKey(0, KEY_A), "data", "text/plain");
+		assertEquals("data", get(fullPathKey(1, KEY_A)).getResponseBodyAsString());
+	}
 	
+	public void testReplicationDelete() throws Exception {
+		assertEquals(2, httpUrls.length);
+		post(fullPathKey(0, KEY_A), "data", "text/plain");
+		assertEquals("data", get(fullPathKey(1, KEY_A)).getResponseBodyAsString());
+		delete(fullPathKey(0, KEY_A));
+		head(fullPathKey(1, KEY_A), HttpStatus.SC_NOT_FOUND);
+	}
+	
+	public void testReplicationWipeCache() throws Exception {
+		assertEquals(2, httpUrls.length);
+		post(fullPathKey(0, KEY_A), "data", "text/plain");
+		post(fullPathKey(0, KEY_B), "data", "text/plain");
+		head(fullPathKey(0, KEY_A));
+		head(fullPathKey(0, KEY_B));
+		delete(fullPathKey(0, null));
+		head(fullPathKey(1, KEY_A), HttpStatus.SC_NOT_FOUND);
+		head(fullPathKey(1, KEY_B), HttpStatus.SC_NOT_FOUND);
+	}
+	
+	public void testReplicationTTL() throws Exception {
+		post(fullPathKey(0, KEY_A), "data", "application/text", HttpServletResponse.SC_OK, 
+			// headers
+			"Content-Type", "application/text",	
+			"timeToLiveSeconds", "2"	
+		);
+		head(fullPathKey(1, KEY_A));
+		Thread.sleep(2100);
+		// should be evicted
+		head(fullPathKey(1, KEY_A), HttpServletResponse.SC_NOT_FOUND);
+	}
+	
 	//----------------------------------------- helper methods -----------------------------------------
 	
 	private String addDay(String aDate, int days) throws Exception {
@@ -680,4 +649,29 @@
 		client.executeMethod(delete);
 		return delete;
 	}
+
+	/** returns full uri for given server number cache name and key
+	 *  if key is null the key part is ommited
+	 */
+	private String fullPathKey(int server, String cache, String key) {
+		StringBuffer sb = new StringBuffer(httpUrls[server]).append("/infinispan-server-rest/rest/").append(cache);
+		if (key == null) {
+			return sb.toString();
+		} else {
+			return sb.append("/").append(key).toString();
+		}
+	}
+
+	private String fullPathKey(int server, String key) {
+		return fullPathKey(server, "___defaultcache", key);
+	}
+
+	private String fullPathKey(String key) {
+		return fullPathKey(0, key);
+	}
+	
+	private String fullPathKey(String cache, String key) {
+		return fullPathKey(0, cache, key);
+	}
+
 }



More information about the jboss-cvs-commits mailing list