[jbosscache-commits] JBoss Cache SVN: r4459 - in core/trunk: src/main/resources and 1 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Thu Sep 13 12:37:52 EDT 2007


Author: manik.surtani at jboss.com
Date: 2007-09-13 12:37:52 -0400 (Thu, 13 Sep 2007)
New Revision: 4459

Added:
   core/trunk/src/main/resources/jboss-beans.xml
   core/trunk/src/test/java/org/jboss/cache/ConcurrentPutRemoveTest.java
Removed:
   core/trunk/.settings/
Log:
Removed IDE settings

Added: core/trunk/src/main/resources/jboss-beans.xml
===================================================================
--- core/trunk/src/main/resources/jboss-beans.xml	                        (rev 0)
+++ core/trunk/src/main/resources/jboss-beans.xml	2007-09-13 16:37:52 UTC (rev 4459)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:bean-deployer:2.0 bean-deployer_2_0.xsd"
+            xmlns="urn:jboss:bean-deployer:2.0">
+
+   <!-- Let's start with naming a few beans that we will always use regardless of configuration -->
+   <bean name="cache" class="org.jboss.cache.CacheImpl">
+      <!--<property name="notifier">-->
+         <!--<inject bean="notifier" />-->
+      <!--</property>-->
+   </bean>
+
+   <bean name="notifier" class="org.jboss.cache.notifications.Notifier">
+      <constructor>
+         <inject bean="cache" />
+      </constructor>
+   </bean>
+
+   <bean name="rpcManager" class="org.jboss.cache.RPCManagerImpl">
+      <property name="cache">
+         <inject bean="cache" />
+      </property>
+   </bean>
+
+
+
+</deployment>

Added: core/trunk/src/test/java/org/jboss/cache/ConcurrentPutRemoveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/ConcurrentPutRemoveTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/ConcurrentPutRemoveTest.java	2007-09-13 16:37:52 UTC (rev 4459)
@@ -0,0 +1,87 @@
+package org.jboss.cache;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.transaction.TransactionManager;
+
+import junit.framework.TestCase;
+
+import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
+
+public class ConcurrentPutRemoveTest extends TestCase {
+
+	private TransactionManager tm;
+
+	private Cache cache;
+
+	protected void setUp() throws Exception {
+		cache = DefaultCacheFactory.getInstance().createCache(false);
+		cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
+		cache.getConfiguration().setIsolationLevel(IsolationLevel.READ_COMMITTED);
+		cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+		cache.getConfiguration().setLockAcquisitionTimeout(10000);
+		cache.start();
+		tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
+	}
+
+	protected void tearDown() throws Exception {
+		super.tearDown();
+		cache.stop();
+		cache.destroy();
+	}
+
+	public void testLock() throws Exception {
+		List<SeparateThread> threads = new ArrayList<SeparateThread>();
+		for (int x = 0; x < 2; x++) {
+			SeparateThread t = new SeparateThread(x);
+			threads.add(t);
+			t.start();
+		}
+		for (SeparateThread separateThread : threads) {
+			separateThread.join();
+			if (separateThread.getException() != null) {
+				throw separateThread.getException();
+			}
+		}
+
+	}
+
+	private class SeparateThread extends Thread {
+		Exception e = null;
+
+		private int num = 0;
+
+		public SeparateThread(int num) {
+			this.num = num;
+		}
+
+		public Exception getException() {
+			return e;
+		}
+
+		public void run() {
+
+         Thread.currentThread().setName("Thread:" + num);
+			try {
+				for (int x = 0; x < 1000; x++) {
+					tm.begin();
+					System.out.println("R" + Thread.currentThread().getName());
+					//inside transaction
+					cache.removeNode(Fqn.fromString("/a"));
+					System.out.println("AR" + Thread.currentThread().getName());
+					tm.commit();
+					//outside transaction
+					System.out.println("P" + Thread.currentThread().getName());
+					cache.put(Fqn.fromString("/a/b/c/d"), "text"+x,"b");
+					System.out.println("AP" + Thread.currentThread().getName());
+				}
+			} catch (Exception e) {
+				this.e = e;
+			}
+		}
+	}
+
+}




More information about the jbosscache-commits mailing list