[jboss-cvs] JBossAS SVN: r108944 - in branches/JBPAPP_5_1_datagrid: testsuite/src/main/org/jboss/test/cluster/datagrid/test and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 27 14:08:01 EDT 2010
Author: rachmatowicz at jboss.com
Date: 2010-10-27 14:08:00 -0400 (Wed, 27 Oct 2010)
New Revision: 108944
Modified:
branches/JBPAPP_5_1_datagrid/testsuite/build.xml
branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/HotRodClientTestCase.java
branches/JBPAPP_5_1_datagrid/thirdparty/pom.xml
Log:
Add in jars for HotRod client, update classpaths and add test case.
Modified: branches/JBPAPP_5_1_datagrid/testsuite/build.xml
===================================================================
--- branches/JBPAPP_5_1_datagrid/testsuite/build.xml 2010-10-27 18:07:12 UTC (rev 108943)
+++ branches/JBPAPP_5_1_datagrid/testsuite/build.xml 2010-10-27 18:08:00 UTC (rev 108944)
@@ -213,6 +213,11 @@
<!-- jbossts crash recovery tests need server manager -->
<path refid="jboss.server.manager.classpath"/>
<path refid="jboss.jbossts.classpath"/>
+
+ <!-- datagrid tests -->
+ <path refid="org.infinispan.classpath"/>
+ <path refid="org.infinispan.client.hotrod.classpath"/>
+ <path refid="commons.pool.classpath"/>
</path>
@@ -450,6 +455,13 @@
<pathelement path="${jboss.dist.common.lib}/jbossts-common.jar" />
<pathelement path="${jboss.dist}/docs/examples/transactions/jbossts-tools.sar" />
<pathelement path="${jboss.dist}/docs/examples/transactions/jbossxts.sar" />
+
+ <!-- datagrid tests -->
+ <path refid="org.infinispan.classpath"/>
+ <path refid="org.infinispan.client.hotrod.classpath"/>
+ <path refid="commons.pool.classpath"/>
+ <path refid="org.jboss.marshalling.classpath"/>
+
</path>
<!-- ======= -->
Modified: 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-10-27 18:07:12 UTC (rev 108943)
+++ branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/HotRodClientTestCase.java 2010-10-27 18:08:00 UTC (rev 108944)
@@ -21,9 +21,26 @@
*/
package org.jboss.test.cluster.datagrid.test;
+import java.io.IOException;
+import java.util.Arrays;
import java.util.Properties;
+
+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.jboss.test.JBossClusteredTestCase;
+
import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
/**
* Tests for the HotRod client..
@@ -32,28 +49,197 @@
* @version $Revision: $
*/
public class HotRodClientTestCase
- extends JBossClusteredTestCase
+ extends JBossClusteredTestCase
{
-
- public HotRodClientTestCase(String name)
- {
- super(name);
- }
- /*
- * Do we need a deployment for HotRod test cases?
- *
- public static Test suite()
- throws Exception
- {
- return JBossClusteredTestCase.getDeploySetup(HAInvokerUnitTestCase.class, "ha-invoker.sar");
- }
- */
+ private static final Log log = LogFactory.getLog(HotRodClientTestCase.class);
+ private static final String CACHE_NAME = "replSync";
- public void testHotRodClient()
- throws Exception
- {
- getLog().debug("testHotRodClient");
- }
+ RemoteCache defaultRemote;
+ RemoteCache remoteCache;
+ private RemoteCacheManager remoteCacheManager;
+ String[] servers = null ;
+ String hotRodServerList = null ;
+
+ public HotRodClientTestCase(String name) {
+ super(name) ;
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ System.out.println("setting up ...") ;
+ servers = getServers() ;
+ hotRodServerList = servers[0] + ":" + "11216" ;
+ System.out.println("datagrid host0 = " + servers[0]) ;
+ System.out.println("datagrid host1 = " + servers[1]) ;
+ System.out.println("HotRodServer list = " + hotRodServerList ) ;
+
+ createCacheManager() ;
+ }
+
+ public void tearDown() throws Exception {
+ System.out.println("tearing down...") ;
+ super.tearDown();
+ }
+
+
+ protected void createCacheManager() throws Exception {
+ // get the Remote Cache Manager proxy from the server
+ remoteCacheManager = getRemoteCacheManager();
+ // get the default cache
+ defaultRemote = remoteCacheManager.getCache();
+ // get a named cache
+ //remoteCache = remoteCacheManager.getCache(CACHE_NAME);
+ }
+
+ // this should be in a one time setup
+ protected RemoteCacheManager getRemoteCacheManager() {
+ Properties config = new Properties();
+ config.put("infinispan.client.hotrod.server_list", hotRodServerList);
+ return new RemoteCacheManager(config);
+ }
+
+ /*
+ *******************************
+ * basic tests of the HotRod API
+ *******************************
+ */
+
+ public void testPut() throws IOException {
+ //assert null == remoteCache.put("aKey", "aValue");
+ assert null == defaultRemote.put("otherKey", "otherValue");
+ //assert remoteCache.containsKey("aKey");
+ assert defaultRemote.containsKey("otherKey");
+ //assert remoteCache.get("aKey").equals("aValue");
+ assert defaultRemote.get("otherKey").equals("otherValue");
+ }
+
+ 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");
+ }
+
+ public void testContains() {
+ assert !remoteCache.containsKey("aKey");
+ remoteCache.put("aKey", "aValue");
+ assert remoteCache.containsKey("aKey");
+ }
+
+ 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);
+ }
+
+ public void testReplace() {
+ assert null == remoteCache.replace("aKey", "anotherValue");
+ remoteCache.put("aKey", "aValue");
+ assert null == remoteCache.replace("aKey", "anotherValue");
+ assert remoteCache.get("aKey").equals("anotherValue");
+ }
+
+ public void testReplaceIfUnmodified() {
+ assert null == remoteCache.replace("aKey", "aValue");
+
+
+ remoteCache.put("aKey", "aValue");
+ VersionedValue valueBinary = remoteCache.getVersioned("aKey");
+ assert remoteCache.replaceWithVersion("aKey", "aNewValue", valueBinary.getVersion());
+
+ VersionedValue entry2 = remoteCache.getVersioned("aKey");
+ assert entry2.getVersion() != valueBinary.getVersion();
+ assertEquals(entry2.getValue(), "aNewValue");
+
+ assert !remoteCache.replaceWithVersion("aKey", "aNewValue", valueBinary.getVersion());
+ }
+
+ public void testRemoveIfUnmodified() {
+ 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());
+ }
+
+ public void testPutIfAbsent() {
+ remoteCache.put("aKey", "aValue");
+ assert null == remoteCache.putIfAbsent("aKey", "anotherValue");
+ assertEquals(remoteCache.get("aKey"),"aValue");
+
+ assertEquals(remoteCache.get("aKey"),"aValue");
+ assert remoteCache.containsKey("aKey");
+
+ assert true : remoteCache.replace("aKey", "anotherValue");
+ }
+
+ public void testClear() {
+ remoteCache.put("aKey", "aValue");
+ remoteCache.put("aKey2", "aValue");
+ remoteCache.clear();
+ assert !remoteCache.containsKey("aKey");
+ assert !remoteCache.containsKey("aKey2");
+ }
+
+ /*
+ private void assertCacheContains(Cache cache, String key, String value) throws IOException {
+ Marshaller marshaller = new JBossMarshaller();
+ byte[] keyBytes = marshaller.objectToByteBuffer(key, 64);
+ byte[] valueBytes = marshaller.objectToByteBuffer(value, 64);
+ ByteArrayKey cacheKey = new ByteArrayKey(keyBytes);
+ CacheValue cacheValue = (CacheValue) cache.get(cacheKey);
+ if (value == null) {
+ assert cacheValue == null : "Expected null value but received: " + cacheValue;
+ } else {
+ assert Arrays.equals(valueBytes, (byte[])cacheValue.data());
+ }
+ }
+ */
+
+ private void assertNull(Object obj, String msg) {
+ assert obj == null : msg ;
+ }
+
+ public static Test suite() {
+ TestSuite suite= new TestSuite();
+ suite.addTest(new HotRodClientTestCase("testPut"));
+ return suite;
+ }
+
+ public static void main(String args[]) {
+ junit.textui.TestRunner.run(suite());
+ }
}
\ No newline at end of file
Modified: branches/JBPAPP_5_1_datagrid/thirdparty/pom.xml
===================================================================
--- branches/JBPAPP_5_1_datagrid/thirdparty/pom.xml 2010-10-27 18:07:12 UTC (rev 108943)
+++ branches/JBPAPP_5_1_datagrid/thirdparty/pom.xml 2010-10-27 18:08:00 UTC (rev 108944)
@@ -1046,6 +1046,15 @@
<componentId>sun-jaf</componentId>
</mapping>
</dependency>
+ <dependency>
+ <groupId>org.infinispan</groupId>
+ <artifactId>infinispan-client-hotrod</artifactId>
+ <version>4.1.0.FINAL</version>
+ <mapping>
+ <componentId>org.infinispan.client.hotrod</componentId>
+ </mapping>
+ </dependency>
+
<!-- End mapped dependecies -->
</mappedDependencies>
@@ -1946,6 +1955,11 @@
<type>war</type>
</dependency>
<dependency>
+ <groupId>org.infinispan</groupId>
+ <artifactId>infinispan-client-hotrod</artifactId>
+ <version>4.1.0.FINAL</version>
+ </dependency>
+ <dependency>
<groupId>joesnmp</groupId>
<artifactId>joesnmp</artifactId>
</dependency>
More information about the jboss-cvs-commits
mailing list