[hibernate-commits] Hibernate SVN: r20946 - in search/branches/Branch_3_0_1_GA_CP/src/test/org/hibernate/search/test: worker and 1 other directory.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue May 17 08:28:27 EDT 2011


Author: stliu
Date: 2011-05-17 08:28:26 -0400 (Tue, 17 May 2011)
New Revision: 20946

Modified:
   search/branches/Branch_3_0_1_GA_CP/src/test/org/hibernate/search/test/reader/NotSharedReaderPerfTest.java
   search/branches/Branch_3_0_1_GA_CP/src/test/org/hibernate/search/test/reader/ReaderPerfTestCase.java
   search/branches/Branch_3_0_1_GA_CP/src/test/org/hibernate/search/test/worker/WorkerTestCase.java
Log:
JBPAPP-6541 clean test failures

Modified: search/branches/Branch_3_0_1_GA_CP/src/test/org/hibernate/search/test/reader/NotSharedReaderPerfTest.java
===================================================================
--- search/branches/Branch_3_0_1_GA_CP/src/test/org/hibernate/search/test/reader/NotSharedReaderPerfTest.java	2011-05-17 06:38:35 UTC (rev 20945)
+++ search/branches/Branch_3_0_1_GA_CP/src/test/org/hibernate/search/test/reader/NotSharedReaderPerfTest.java	2011-05-17 12:28:26 UTC (rev 20946)
@@ -1,10 +1,13 @@
 //$Id$
 package org.hibernate.search.test.reader;
 
+import org.apache.lucene.analysis.StopAnalyzer;
 import org.hibernate.cfg.Configuration;
+import org.hibernate.dialect.DB2Dialect;
+import org.hibernate.dialect.Oracle8iDialect;
+import org.hibernate.dialect.SybaseASE15Dialect;
+import org.hibernate.search.Environment;
 import org.hibernate.search.store.FSDirectoryProvider;
-import org.hibernate.search.Environment;
-import org.apache.lucene.analysis.StopAnalyzer;
 
 /**
  * @author Emmanuel Bernard
@@ -17,4 +20,10 @@
 		cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
 		cfg.setProperty( Environment.READER_STRATEGY, "not-shared" );
 	}
+	public void testConcurrency() throws Exception {
+		if(getDialect() instanceof DB2Dialect || getDialect() instanceof Oracle8iDialect || getDialect() instanceof SybaseASE15Dialect){
+			return;
+		}
+		super.testConcurrency();
+	}
 }

Modified: search/branches/Branch_3_0_1_GA_CP/src/test/org/hibernate/search/test/reader/ReaderPerfTestCase.java
===================================================================
--- search/branches/Branch_3_0_1_GA_CP/src/test/org/hibernate/search/test/reader/ReaderPerfTestCase.java	2011-05-17 06:38:35 UTC (rev 20945)
+++ search/branches/Branch_3_0_1_GA_CP/src/test/org/hibernate/search/test/reader/ReaderPerfTestCase.java	2011-05-17 12:28:26 UTC (rev 20946)
@@ -4,6 +4,7 @@
 import java.io.File;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.Random;
 import java.util.List;
 
@@ -111,7 +112,7 @@
 			es.execute( work );
 			es.execute( reverseWork );
 		}
-		while ( work.count < iteration - 1 ) {
+		while ( work.count.get() < iteration - 1 ) {
 			Thread.sleep( 20 );
 		}
 		System.out.println( iteration + " iterations in " + nThreads + " threads: " + ( System
@@ -121,7 +122,8 @@
 	protected class Work implements Runnable {
 		private Random random = new Random( );
 		private SessionFactory sf;
-		public volatile int count = 0;
+//		public volatile int count = 0;
+		public AtomicInteger count = new AtomicInteger(0);
 
 		public Work(SessionFactory sf) {
 			this.sf = sf;
@@ -166,7 +168,7 @@
 			}
 			tx.commit();
 			s.close();
-			count++;
+			count.incrementAndGet();
 		}
 
 		private FullTextQuery getQuery(String queryString, QueryParser parser, Session s) {

Modified: search/branches/Branch_3_0_1_GA_CP/src/test/org/hibernate/search/test/worker/WorkerTestCase.java
===================================================================
--- search/branches/Branch_3_0_1_GA_CP/src/test/org/hibernate/search/test/worker/WorkerTestCase.java	2011-05-17 06:38:35 UTC (rev 20945)
+++ search/branches/Branch_3_0_1_GA_CP/src/test/org/hibernate/search/test/worker/WorkerTestCase.java	2011-05-17 12:28:26 UTC (rev 20946)
@@ -4,6 +4,7 @@
 import java.io.File;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.lucene.analysis.StopAnalyzer;
 import org.apache.lucene.queryParser.ParseException;
@@ -75,7 +76,7 @@
 			es.execute( work );
 			es.execute( reverseWork );
 		}
-		while ( work.count < iteration - 1 ) {
+		while ( work.count.get() < iteration - 1 ) {
 			Thread.sleep( 20 );
 		}
 		System.out.println( iteration + " iterations (8 tx per iteration) in " + nThreads + " threads: " + ( System
@@ -84,7 +85,8 @@
 
 	protected class Work implements Runnable {
 		private SessionFactory sf;
-		public volatile int count = 0;
+//		public volatile int count = 0;
+		public AtomicInteger count = new AtomicInteger(0);
 
 		public Work(SessionFactory sf) {
 			this.sf = sf;
@@ -143,7 +145,7 @@
 			s.delete( er );
 			tx.commit();
 			s.close();
-			count++;
+			count.incrementAndGet();
 		}
 	}
 



More information about the hibernate-commits mailing list