[jboss-cvs] JBossAS SVN: r109134 - in branches/JBPAPP_5_1_datagrid/testsuite/src: resources/test-configs/datagrid-0/deploy/datagrid.sar/META-INF and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Nov 4 14:35:43 EDT 2010


Author: mlinhard
Date: 2010-11-04 14:35:43 -0400 (Thu, 04 Nov 2010)
New Revision: 109134

Added:
   branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/MemcachedReplicationTestCase.java
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/MemcachedSession.java
   branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/RESTClientTestCase.java
   branches/JBPAPP_5_1_datagrid/testsuite/src/resources/test-configs/datagrid-0/deploy/datagrid.sar/META-INF/infinispan-configuration.xml
   branches/JBPAPP_5_1_datagrid/testsuite/src/resources/test-configs/datagrid-1/deploy/datagrid.sar/META-INF/infinispan-configuration.xml
Log:
added new memcached server tests, allowed statistics in default cache in datagrid-{0,1} configs

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-04 18:16:23 UTC (rev 109133)
+++ branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/MemcachedClientTestCase.java	2010-11-04 18:35:43 UTC (rev 109134)
@@ -25,6 +25,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.util.Map;
 
 import org.jboss.test.JBossClusteredTestCase;
 import org.jboss.test.cluster.datagrid.test.RESTClientTestCase.TestSerializable;
@@ -54,7 +55,7 @@
 		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, getServers()[0], 11211); // to run against infinispan 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);
 		mc.delete(KEY_C);
@@ -238,6 +239,19 @@
 		assertEquals("A", mc.get(KEY_A));
 	}
 	
+	public void testGetNotFound() throws Exception {
+		mc.writeln("get "+KEY_A);
+		mc.flush();
+		assertEquals("END", mc.readln());
+	}
+	
+	public void testCasNotFound() throws Exception {
+		mc.writeln("cas "+KEY_A+" 0 0 1 1");
+		mc.writeln("B");
+		mc.flush();
+		assertEquals("NOT_FOUND", mc.readln());
+	}
+	
 	public void testNoReply() throws Exception {
 		mc.writeln("set "+KEY_A+" 0 0 1 noreply");
 		mc.writeln("A");
@@ -271,7 +285,7 @@
 		assertEquals("A", mc.get(KEY_A));
 	}
 	
-	// FAILS: https://jira.jboss.org/browse/JBPAPP-5331
+	// https://jira.jboss.org/browse/JBPAPP-5331
 	public void testExpTimeAbsolutePast() throws Exception {
 		// set exp.time to min number treated as unix time
 		// 2592001 = 60*60*24*30 + 1
@@ -296,7 +310,7 @@
 		assertNull(mc.get(KEY_A));
 	}
 	
-	// FAILS: https://jira.jboss.org/browse/JBPAPP-5332
+	// https://jira.jboss.org/browse/JBPAPP-5332
 	public void testKeyLonger250() throws Exception {
 		String key250 = "";
 		for (int i = 0; i <  250; i++) {
@@ -331,7 +345,7 @@
 		mc.flush();
 		assertEquals("1", mc.readln());
 	}
-	
+
 	public void testDecr() throws Exception {
 		mc.set(KEY_A, "1");
 		mc.writeln("decr "+KEY_A+" 1");
@@ -339,7 +353,19 @@
 		assertEquals("0", mc.readln());
 	}
 	
-	// FAILS: https://jira.jboss.org/browse/JBPAPP-5307
+	public void testIncrNotFound() throws Exception {
+		mc.writeln("incr "+KEY_A+" 1");
+		mc.flush();
+		assertEquals("NOT_FOUND", mc.readln());
+	}
+
+	public void testDecrNotFound() throws Exception {
+		mc.writeln("decr "+KEY_A+" 1");
+		mc.flush();
+		assertEquals("NOT_FOUND", mc.readln());
+	}
+	
+	// https://jira.jboss.org/browse/JBPAPP-5307
 	public void testIncr64BitMax() throws Exception {
 		mc.set(KEY_A, "18446744073709551614");
 		mc.writeln("incr "+KEY_A+" 1");
@@ -357,7 +383,7 @@
 		assertEquals("0", mc.readln());
 	}
 	
-	// FAILS: https://jira.jboss.org/browse/JBPAPP-5307
+	// https://jira.jboss.org/browse/JBPAPP-5307
 	public void testIncrBigIncrement() throws Exception {
 		mc.set(KEY_A, "0");
 		mc.writeln("incr "+KEY_A+" 18446744073709551615");
@@ -365,11 +391,160 @@
 		assertEquals("18446744073709551615", mc.readln());
 	}
 	
-	// FAILS: https://jira.jboss.org/browse/JBPAPP-5307
+	// https://jira.jboss.org/browse/JBPAPP-5307
 	public void testIncrBigDecrement() throws Exception {
 		mc.set(KEY_A, "18446744073709551615");
 		mc.writeln("decr "+KEY_A+" 18446744073709551615");
 		mc.flush();
 		assertEquals("0", mc.readln());
 	}
+	
+	public void testUnsupportedStats() throws Exception {
+		Map<String, String> stats = mc.getStats();
+		assertEquals(stats.get("pid"), "0");
+		assertEquals(stats.get("pointer_size"), "0");
+		assertEquals(stats.get("rusage_user"), "0");
+		assertEquals(stats.get("rusage_system"), "0");
+		assertEquals(stats.get("bytes"), "0");
+		assertEquals(stats.get("curr_connections"), "0");
+		assertEquals(stats.get("total_connections"), "0");
+		assertEquals(stats.get("connection_structures"), "0");
+		assertEquals(stats.get("auth_cmds"), "0");
+		assertEquals(stats.get("auth_errors"), "0");
+		assertEquals(stats.get("limit_maxbytes"), "0");
+		assertEquals(stats.get("conn_yields"), "0");
+		assertEquals(stats.get("bytes_read"), "0");
+		assertEquals(stats.get("bytes_written"), "0");
+		assertEquals(stats.get("threads"), "0");
+	}
+
+	public void testStatsTime() throws Exception {
+		Map<String, String> stats = mc.getStats();
+		int uptime = new Integer(stats.get("uptime"));
+		int time = new Integer(stats.get("time"));
+		Thread.sleep(1000);
+		stats = mc.getStats();
+		assertTrue(uptime < new Integer(stats.get("uptime")));
+		assertTrue(time < new Integer(stats.get("time")));
+	}
+	
+	public void testStatsGetSetItemCount() throws Exception {
+		Map<String, String> stats = mc.getStats();
+		int cmd_set = new Integer(stats.get("cmd_set"));
+		int cmd_get = new Integer(stats.get("cmd_get"));
+		int get_hits = new Integer(stats.get("get_hits"));
+		int get_misses = new Integer(stats.get("get_misses"));
+		int curr_items = new Integer(stats.get("curr_items"));
+		int total_items = new Integer(stats.get("total_items"));
+		mc.set(KEY_A, "A");
+		assertEquals("A", mc.get(KEY_A));
+		assertNull(mc.get(KEY_B));
+		stats = mc.getStats();
+		int cmd_set_new = new Integer(stats.get("cmd_set"));
+		int cmd_get_new = new Integer(stats.get("cmd_get"));
+		int get_hits_new = new Integer(stats.get("get_hits"));
+		int get_misses_new = new Integer(stats.get("get_misses"));
+		int curr_items_new = new Integer(stats.get("curr_items"));
+		int total_items_new = new Integer(stats.get("total_items"));
+		assertEquals(cmd_get + 2, cmd_get_new);
+		assertEquals(cmd_set + 1, cmd_set_new);
+		assertEquals(get_hits + 1, get_hits_new);
+		assertEquals(get_misses + 1, get_misses_new);
+		assertEquals(curr_items + 1, curr_items_new);
+		assertEquals(total_items + 1, total_items_new);
+	}
+	
+	public void testStatsDelete() throws Exception {
+		Map<String, String> stats = mc.getStats();
+		int delete_misses = new Integer(stats.get("delete_misses"));
+		int delete_hits = new Integer(stats.get("delete_hits"));
+		mc.set(KEY_A, "A");
+		assertEquals("DELETED", mc.delete(KEY_A));
+		assertEquals("NOT_FOUND", mc.delete(KEY_B));
+		stats = mc.getStats();
+		int delete_misses_new = new Integer(stats.get("delete_misses"));
+		int delete_hits_new = new Integer(stats.get("delete_hits"));
+		assertEquals(delete_misses + 1, delete_misses_new);
+		assertEquals(delete_hits + 1, delete_hits_new);
+	}
+	
+	public void testStatsIncrDecr() throws Exception {
+		Map<String, String> stats = mc.getStats();
+		int incr_misses = new Integer(stats.get("incr_misses"));
+		int incr_hits = new Integer(stats.get("incr_hits"));
+		int decr_misses = new Integer(stats.get("decr_misses"));
+		int decr_hits = new Integer(stats.get("decr_hits"));
+
+		mc.set(KEY_A, "0");
+		mc.writeln("incr "+KEY_A+" 1");
+		mc.flush();
+		assertEquals("1", mc.readln());
+		mc.writeln("decr "+KEY_A+" 1");
+		mc.flush();
+		assertEquals("0", mc.readln());
+		mc.writeln("incr "+KEY_B+" 1");
+		mc.flush();
+		assertEquals("NOT_FOUND", mc.readln());
+		mc.writeln("decr "+KEY_B+" 1");
+		mc.flush();
+		assertEquals("NOT_FOUND", mc.readln());
+
+		stats = mc.getStats();
+		int incr_misses_new = new Integer(stats.get("incr_misses"));
+		int incr_hits_new = new Integer(stats.get("incr_hits"));
+		int decr_misses_new = new Integer(stats.get("decr_misses"));
+		int decr_hits_new = new Integer(stats.get("decr_hits"));
+		assertEquals(incr_misses + 1, incr_misses_new);
+		assertEquals(incr_hits + 1, incr_hits_new);
+		assertEquals(decr_misses + 1, decr_misses_new);
+		assertEquals(decr_hits + 1, decr_hits_new);
+	}
+	
+	public void testStatsCas() throws Exception {
+		Map<String, String> stats = mc.getStats();
+		int cas_misses = new Integer(stats.get("cas_misses"));
+		int cas_hits = new Integer(stats.get("cas_hits"));
+		
+		// cas hit
+		mc.set(KEY_A, "A");
+		mc.writeln("gets "+KEY_A);
+		mc.flush();
+		String[] valueline = mc.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", mc.readln());
+		String casId = valueline[4];
+		assertEquals("END", mc.readln());
+		mc.writeln("cas "+KEY_A+" 0 0 1 " + casId);
+		mc.writeln("B");
+		mc.flush();
+		assertEquals("STORED", mc.readln());
+		assertEquals("B", mc.get(KEY_A));
+		
+		// cas miss
+		mc.writeln("cas "+KEY_B+" 0 0 1 1");
+		mc.writeln("B");
+		mc.flush();
+		assertEquals("NOT_FOUND", mc.readln());
+		
+		stats = mc.getStats();
+		int cas_misses_new = new Integer(stats.get("cas_misses"));
+		int cas_hits_new = new Integer(stats.get("cas_hits"));
+		assertEquals(cas_misses + 1, cas_misses_new);
+		assertEquals(cas_hits + 1, cas_hits_new);
+
+		int cas_badval = new Integer(stats.get("cas_badval"));
+		
+		// cas bad value
+		mc.writeln("cas "+KEY_A+" 0 0 1 1" + casId); // note appended 1 before casId
+		mc.writeln("C");
+		mc.flush();
+		assertEquals("EXISTS", mc.readln());
+		
+		stats = mc.getStats();
+		int cas_badval_new = new Integer(stats.get("cas_badval"));
+		assertEquals(cas_badval + 1, cas_badval_new);
+	}
 }
\ No newline at end of file

Added: 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	                        (rev 0)
+++ branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/MemcachedReplicationTestCase.java	2010-11-04 18:35:43 UTC (rev 109134)
@@ -0,0 +1,197 @@
+/*
+ * 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 org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * Tests for the Memcached client. Clustering test cases.
+ * 
+ * @author <a href="mailto:mlinhard at redhat.com">Michal Linhard</a>
+ * @version $Revision: $
+ */
+public class MemcachedReplicationTestCase extends JBossClusteredTestCase {
+	private static final String ENCODING = "UTF-8";
+	// keys used during tests
+	// they are deleted in the setUp and tearDown methods
+	private static final String KEY_A = "a";
+	private static final String KEY_B = "b";
+	private static final String KEY_C = "c";
+	
+	private MemcachedSession mc1;
+	private MemcachedSession mc2;
+	
+	public MemcachedReplicationTestCase(String name) {
+		super(name);
+	}
+	
+	@Override
+	protected void setUp() throws Exception {
+		super.setUp();
+		int memcachedPort = Integer.getInteger("jboss.infinispan.memcached.server.port", 11211);
+		mc1 = new MemcachedSession(ENCODING, getServers()[0], memcachedPort); // to run against infinispan memcached server
+		mc2 = new MemcachedSession(ENCODING, getServers()[1], memcachedPort); // to run against infinispan memcached server
+		mc1.delete(KEY_A);
+		mc1.delete(KEY_B);
+		mc1.delete(KEY_C);
+		mc2.delete(KEY_A);
+		mc2.delete(KEY_B);
+		mc2.delete(KEY_C);
+		assertNull(mc1.get(KEY_A));
+		assertNull(mc1.get(KEY_B));
+		assertNull(mc1.get(KEY_C));
+		assertNull(mc2.get(KEY_A));
+		assertNull(mc2.get(KEY_B));
+		assertNull(mc2.get(KEY_C));
+	}
+
+	@Override
+	protected void tearDown() throws Exception {
+		super.tearDown();
+		mc1.delete(KEY_A);
+		mc1.delete(KEY_B);
+		mc1.delete(KEY_C);
+		mc2.delete(KEY_A);
+		mc2.delete(KEY_B);
+		mc2.delete(KEY_C);
+		mc1.close();
+		mc2.close();
+	}
+
+	public void testReplicatedSet() throws Exception {
+		mc1.set(KEY_A, "A");
+		assertEquals("A", mc2.get(KEY_A));
+	}
+	
+	public void testReplicatedGetMultipleKeys() throws Exception {
+		mc1.set(KEY_A, "A");
+		mc1.set(KEY_B, "B");
+		mc1.set(KEY_C, "C");
+		mc2.writeln("get "+KEY_A+" "+KEY_B+" "+KEY_C);
+		mc2.flush();
+		assertEquals("VALUE "+KEY_A+" 0 1", mc2.readln());
+		assertEquals("A", mc2.readln());
+		assertEquals("VALUE "+KEY_B+" 0 1", mc2.readln());
+		assertEquals("B", mc2.readln());
+		assertEquals("VALUE "+KEY_C+" 0 1", mc2.readln());
+		assertEquals("C", mc2.readln());
+		assertEquals("END", mc2.readln());
+	}
+	
+	public void testReplicatedAdd() throws Exception {
+		String data = "testAdd";
+		mc1.writeln("add "+KEY_A+" 0 0 " + data.getBytes(ENCODING).length);
+		mc1.writeln(data);
+		mc1.flush();
+		assertEquals("STORED", mc1.readln());
+		assertEquals(data, mc2.get(KEY_A));
+	}
+	
+	public void testReplicatedReplace() throws Exception {
+		mc1.set(KEY_A, "data1");
+		assertEquals("data1", mc2.get(KEY_A));
+		mc1.writeln("replace "+KEY_A+" 0 0 " + "data2".getBytes(ENCODING).length);
+		mc1.writeln("data2");
+		mc1.flush();
+		assertEquals("STORED", mc1.readln());
+		assertEquals("data2", mc2.get(KEY_A));
+	}
+	
+	public void testReplicatedAppend() throws Exception {
+		mc1.set(KEY_A, "Hello");
+		assertEquals("Hello", mc2.get(KEY_A));
+		mc2.writeln("append "+KEY_A+" 0 0 " + ", World!".getBytes(ENCODING).length);
+		mc2.writeln(", World!");
+		mc2.flush();
+		assertEquals("STORED", mc2.readln());
+		assertEquals("Hello, World!", mc1.get(KEY_A));
+	}
+	
+	public void testReplicatedPrepend() throws Exception {
+		mc1.set(KEY_A, "World!");
+		assertEquals("World!", mc1.get(KEY_A));
+		mc2.writeln("prepend "+KEY_A+" 0 0 " + "Hello, ".getBytes(ENCODING).length);
+		mc2.writeln("Hello, ");
+		mc2.flush();
+		assertEquals("STORED", mc2.readln());
+		assertEquals("Hello, World!", mc1.get(KEY_A));
+	}
+	
+	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());
+		mc2.writeln("cas "+KEY_A+" 0 0 1 " + casId);
+		mc2.writeln("B");
+		mc2.flush();
+		assertEquals("STORED", mc2.readln());
+		assertEquals("B", mc1.get(KEY_A));
+	}
+	
+	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());
+		mc2.writeln("cas "+KEY_A+" 0 0 1 1" + casId); // note appended 1 before casId
+		mc2.writeln("B");
+		mc2.flush();
+		assertEquals("EXISTS", mc2.readln());
+		assertEquals("A", mc1.get(KEY_A));
+	}
+	
+	public void testReplicatedDelete() throws Exception {
+		mc1.set(KEY_A, "A");
+		assertEquals("A", mc2.get(KEY_A));
+		assertEquals("DELETED", mc1.delete(KEY_A));
+		assertNull(mc2.get(KEY_A));
+	}
+	
+	public void testReplicatedIncrement() throws Exception {
+		mc1.set(KEY_A, "0");
+		mc2.writeln("incr "+KEY_A+" 1");
+		mc2.flush();
+		assertEquals("1", mc2.readln());
+	}
+	
+	public void testReplicatedDecrement() throws Exception {
+		mc1.set(KEY_A, "1");
+		mc2.writeln("decr "+KEY_A+" 1");
+		mc2.flush();
+		assertEquals("0", mc2.readln());
+	}
+}
\ No newline at end of file

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-04 18:16:23 UTC (rev 109133)
+++ branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/MemcachedSession.java	2010-11-04 18:35:43 UTC (rev 109134)
@@ -21,12 +21,16 @@
  */
 package org.jboss.test.cluster.datagrid.test;
 
+import static junit.framework.Assert.assertEquals;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.net.Socket;
 import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * A Really simple Memcached client/helper.
@@ -142,12 +146,12 @@
 		}
 		if (valueStr.startsWith("VALUE")) {
 			String[] value = valueStr.split(" ");
-			MemcachedClientTestCase.assertEquals(key, value[1]);
+			assertEquals(key, value[1]);
 			int size = new Integer(value[3]);
 			byte[] ret = in.read(size);
-			MemcachedClientTestCase.assertEquals('\r', in.read());
-			MemcachedClientTestCase.assertEquals('\n', in.read());
-			MemcachedClientTestCase.assertEquals("END", readln());
+			assertEquals('\r', in.read());
+			assertEquals('\n', in.read());
+			assertEquals("END", readln());
 			return ret;
 		} else {
 			return null;
@@ -158,7 +162,7 @@
 		writeln("set " + key + " 0 0 " + value.getBytes(encoding).length);
 		writeln(value);
 		flush();
-		MemcachedClientTestCase.assertEquals("STORED", readln());
+		assertEquals("STORED", readln());
 	}
 	
 	/**
@@ -171,6 +175,20 @@
 		return readln();
 	}
 	
+	public Map<String, String> getStats() throws IOException {
+		writeln("stats");
+		flush();
+		String statline = readln();
+		Map<String, String> stats = new HashMap<String, String>();
+		while (statline.startsWith("STAT")) {
+			String[] stat = statline.split(" ");
+			stats.put(stat[1], stat[2]);
+			statline = readln();
+		}
+		assertEquals("END", statline);
+		return stats;
+	}
+	
 	/**
 	 * returns server time retrieved via stats command
 	 * -1 if time stat is not returned. 
@@ -187,7 +205,7 @@
 			}
 			statline = readln();
 		}
-		MemcachedClientTestCase.assertEquals("END", statline);
+		assertEquals("END", statline);
 		return time;
 	}
 }
\ 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-04 18:16:23 UTC (rev 109133)
+++ branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/RESTClientTestCase.java	2010-11-04 18:35:43 UTC (rev 109134)
@@ -80,11 +80,7 @@
 		client = new HttpClient();
 		infinispanRestPrefix = httpUrls[0] + "/infinispan-server-rest/rest"; 
 		fullPath = infinispanRestPrefix + "/___defaultcache";
-	}
-	
-	@Override
-	protected void tearDown() throws Exception {
-		super.tearDown();
+		
 		delete(fullPath + "/testBasicOperation");
 		delete(fullPath + "/testBasicClusteredOperation");
 		delete(fullPath + "/testGet");
@@ -108,9 +104,8 @@
 		delete(fullPath + "/testIfUnmodifiedSince");
 		delete(fullPath + "/testIfNoneMatch");
 		delete(fullPath + "/testIfMatch");
-	}
-
-	public void testCacheIsCleanForTesting() throws Exception {
+		delete(infinispanRestPrefix + "/sampleReplicatedCache/testGetNamedCache");
+		
 		head(fullPath + "/testBasicOperation", HttpServletResponse.SC_NOT_FOUND);
 		head(fullPath + "/testBasicClusteredOperation", HttpServletResponse.SC_NOT_FOUND);
 		head(fullPath + "/testGet", HttpServletResponse.SC_NOT_FOUND);
@@ -133,9 +128,38 @@
 		head(fullPath + "/testIfModifiedSince", HttpServletResponse.SC_NOT_FOUND);
 		head(fullPath + "/testIfUnmodifiedSince", HttpServletResponse.SC_NOT_FOUND);
 		head(fullPath + "/testIfNoneMatch", HttpServletResponse.SC_NOT_FOUND);
-		head(fullPath + "/testIfMatch", HttpServletResponse.SC_NOT_FOUND);
+		head(infinispanRestPrefix + "/sampleReplicatedCache/testGetNamedCache", 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");
+	}
+
 	public void testBasicOperation() throws Exception {
 		String fullPathKey = fullPath + "/testBasicOperation";
 		String initialXML = "<hey>ho</hey>";
@@ -178,16 +202,6 @@
 		TestSerializable ts = (TestSerializable) oin.readObject();
 		assertEquals("CONTENT", ts.getContent());
 	}
-	
-	public void testBasicClusteredOperation() throws Exception {
-		assertEquals(2, httpUrls.length);
-		String fullPathKey1 = fullPath + "/testBasicClusteredOperation";
-		String fullPathKey2 = httpUrls[1] + "/infinispan-server-rest/rest/___defaultcache/testBasicClusteredOperation";
-		put(fullPathKey1, "data", "text/plain");
-		// wait for replication
-		Thread.sleep(1000);
-		assertEquals("data", get(fullPathKey2).getResponseBodyAsString());
-	}
 
 	public void testEmptyGet() throws Exception {
 		get(fullPath + "/nodata", HttpServletResponse.SC_NOT_FOUND);
@@ -202,6 +216,16 @@
 		assertEquals("application/text", get.getResponseHeader("Content-Type").getValue());
 		assertEquals("data", get.getResponseBodyAsString());
 	}
+	
+	public void testGetNamedCache() throws Exception {
+		String fullPathKey = infinispanRestPrefix + "/sampleReplicatedCache/testGetNamedCache";
+		post(fullPathKey, "data", "application/text");
+		GetMethod get = get(fullPathKey);
+		assertNotNull(get.getResponseHeader("ETag").getValue());
+		assertNotNull(get.getResponseHeader("Last-Modified").getValue());
+		assertEquals("application/text", get.getResponseHeader("Content-Type").getValue());
+		assertEquals("data", get.getResponseBodyAsString());
+	}
 
 	public void testHead() throws Exception {
 		String fullPathKey = fullPath + "/testHead";
@@ -430,7 +454,7 @@
 		oo.flush();
 		byte[] byteData = bout.toByteArray();
 		put(fullPathKey, byteData, "application/x-java-serialized-object");
-		byte[] bytesBack = get(fullPathKey).getResponseBody();
+		byte[] bytesBack = get(fullPathKey, HttpServletResponse.SC_OK, "Accept", "application/x-java-serialized-object").getResponseBody();
 		assertEquals(byteData.length, bytesBack.length);
 		ObjectInputStream oin = new ObjectInputStream(new ByteArrayInputStream(
 				bytesBack));
@@ -539,6 +563,20 @@
 		get(infinispanRestPrefix + "/nonexistentcache/nodata", HttpServletResponse.SC_NOT_FOUND);
 	}
 	
+	public void testBasicClusteredOperation() 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());
+	}
+	
+	// TODO: more clustered test cases
+	
 	//----------------------------------------- helper methods -----------------------------------------
 	
 	private String addDay(String aDate, int days) throws Exception {

Modified: branches/JBPAPP_5_1_datagrid/testsuite/src/resources/test-configs/datagrid-0/deploy/datagrid.sar/META-INF/infinispan-configuration.xml
===================================================================
--- branches/JBPAPP_5_1_datagrid/testsuite/src/resources/test-configs/datagrid-0/deploy/datagrid.sar/META-INF/infinispan-configuration.xml	2010-11-04 18:16:23 UTC (rev 109133)
+++ branches/JBPAPP_5_1_datagrid/testsuite/src/resources/test-configs/datagrid-0/deploy/datagrid.sar/META-INF/infinispan-configuration.xml	2010-11-04 18:35:43 UTC (rev 109134)
@@ -12,7 +12,7 @@
       <!--
       Expose global, cache manager level, statistics
       -->
-      <globalJmxStatistics enabled="false" jmxDomain="infinispan"/>
+      <globalJmxStatistics enabled="true" jmxDomain="infinispan"/>
 
       <transport clusterName="${jboss.infinispan.partition.name:DatagridPartition}-Infinispan">
          <properties>
@@ -85,7 +85,7 @@
       <!--
       Expose cache level statistics
       -->
-      <jmxStatistics enabled="false"/>
+      <jmxStatistics enabled="true"/>
 
       <!--
       This element specifies that the cache is clustered.

Modified: branches/JBPAPP_5_1_datagrid/testsuite/src/resources/test-configs/datagrid-1/deploy/datagrid.sar/META-INF/infinispan-configuration.xml
===================================================================
--- branches/JBPAPP_5_1_datagrid/testsuite/src/resources/test-configs/datagrid-1/deploy/datagrid.sar/META-INF/infinispan-configuration.xml	2010-11-04 18:16:23 UTC (rev 109133)
+++ branches/JBPAPP_5_1_datagrid/testsuite/src/resources/test-configs/datagrid-1/deploy/datagrid.sar/META-INF/infinispan-configuration.xml	2010-11-04 18:35:43 UTC (rev 109134)
@@ -12,7 +12,7 @@
       <!--
       Expose global, cache manager level, statistics
       -->
-      <globalJmxStatistics enabled="false" jmxDomain="infinispan"/>
+      <globalJmxStatistics enabled="true" jmxDomain="infinispan"/>
 
       <transport clusterName="${jboss.infinispan.partition.name:DatagridPartition}-Infinispan">
          <properties>
@@ -85,7 +85,7 @@
       <!--
       Expose cache level statistics
       -->
-      <jmxStatistics enabled="false"/>
+      <jmxStatistics enabled="true"/>
 
       <!--
       This element specifies that the cache is clustered.



More information about the jboss-cvs-commits mailing list