Commits

Anonymous committed db4f3a3

Submitter: Andres March

Added test case for CACHE-127

Comments (0)

Files changed (1)

src/core/test/com/opensymphony/oscache/base/GroupConcurrencyProblemTestCase.java

+package com.opensymphony.oscache.base;
+
+import junit.framework.TestCase;
+
+import com.opensymphony.oscache.general.GeneralCacheAdministrator;
+
+public class GroupConcurrencyProblemTestCase extends TestCase {
+	private static GeneralCacheAdministrator cache = new GeneralCacheAdministrator();
+
+	public static void main( String[] args ) {
+		System.out.println( "START" );
+
+		// Create some clients and start them running.
+		for ( int i = 0; i < 100; i++ ) {
+			System.out.println( "Creating thread: " + i );
+
+			new Client( i, cache ).start();
+		}
+
+		System.out.println( "END" );
+	}
+}
+
+/* Inner class to hammer away at the cache. */
+class Client extends Thread {
+	private static final int MAX_ITERATIONS = 1000;
+
+	private int id;
+	private GeneralCacheAdministrator cache;
+
+	public Client(
+		int newId,
+		GeneralCacheAdministrator newCache
+	) {
+		super();
+		id = newId;
+		cache = newCache;
+	}
+
+	public void run() {
+		for ( int i = 0; i < MAX_ITERATIONS; i++ ) {
+
+			/* Put an entry from this Client into the shared group.
+			 */
+			cache.putInCache(
+				Integer.toString( id ),
+				"Some interesting data",
+				new String[] { "GLOBAL_GROUP" }
+			);
+
+			// Flush that group.
+			cache.flushGroup( "GLOBAL_GROUP" );
+		}
+	}
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.