Buggy code:
public class TestPreparedQueryCache extends TestCase { private static String RESOURCE = "META-INF//persistence.xml" ; private static String UNIT_NAME = "PreparedQuery" ; protected static final int SAMPLE_SIZE = 100 ; public static final boolean USE_CACHE = true ; private static Object [ ] NO_PARAMS = null ; public static final boolean IS_NAMED_QUERY = true ; private static boolean FAIL_IF_PERF_DEGRADE = false ; private static Company IBM ; public static final String [ ] COMPANY_NAMES = new String [ ] { "IBM" , "BEA" , "acme.org" } ; public static final int [ ] START_YEARS = new int [ ] { 1900 , 2000 , 2010 } ; public static final String [ ] DEPARTMENT_NAMES = new String [ ] { "Marketing" , "Sales" , "Engineering" } ; public static final String [ ] EMPLOYEE_NAMES = new String [ ] { "Tom" , "Dick" , "Harray" } ; public static final String [ ] CITY_NAMES = new String [ ] { "Tulsa" , "Durban" , "Harlem" } ; public static final String EXCLUDED_QUERY_1 = "select<seq2seq4repair_space>count(p)<seq2seq4repair_space>from<seq2seq4repair_space>Company<seq2seq4repair_space>p" ; public static final String EXCLUDED_QUERY_2 = "select<seq2seq4repair_space>count(p)<seq2seq4repair_space>from<seq2seq4repair_space>Department<seq2seq4repair_space>p" ; public static final String INCLUDED_QUERY = "select<seq2seq4repair_space>p<seq2seq4repair_space>from<seq2seq4repair_space>Address<seq2seq4repair_space>p" ; public static final long [ ] BOOK_IDS = new long [ ] { 1000 , 2000 , 3000 } ; public static final String [ ] BOOK_NAMES = new String [ ] { "Argumentative<seq2seq4repair_space>Indian" , "Tin<seq2seq4repair_space>Drum" , "Blink" } ; public static final long [ ] CD_IDS = new long [ ] { 1001 , 2001 , 3001 } ; public static final String [ ] CD_LABELS = new String [ ] { "Beatles" , "Sinatra" , "Don't<seq2seq4repair_space>Rock<seq2seq4repair_space>My<seq2seq4repair_space>Boat" } ; protected static OpenJPAEntityManagerFactorySPI emf ; protected static TestPreparedQueryCache . SQLAuditor auditor ; private OpenJPAEntityManagerSPI em ; public void setUp ( ) { if ( ( TestPreparedQueryCache . emf ) == null ) { Properties config = new Properties ( ) ; config . put ( "openjpa.jdbc.SynchronizeMappings" , "buildSchema(ForeignKeys=true,SchemaAction='drop,add')" ) ; config . put ( "openjpa.jdbc.JDBCListeners" , new JDBCListener [ ] { TestPreparedQueryCache . auditor = new TestPreparedQueryCache . SQLAuditor ( ) } ) ; <START_BUG> config . put ( "openjpa.jdbc.QuerySQLCache" , "true" ) ; <END_BUG> config . put ( "openjpa.RuntimeUnenhancedClasses" , "unsupported" ) ; config . put ( "openjpa.DynamicEnhancementAgent" , "false" ) ; TestPreparedQueryCache . emf = ( ( OpenJPAEntityManagerFactorySPI ) ( OpenJPAPersistence . createEntityManagerFactory ( TestPreparedQueryCache . UNIT_NAME , TestPreparedQueryCache . RESOURCE , config ) ) ) ; em = TestPreparedQueryCache . emf . createEntityManager ( ) ; createTestData ( ) ; } else { em = TestPreparedQueryCache . emf . createEntityManager ( ) ; getPreparedQueryCache ( ) . clear ( ) ; } } void createTestData ( ) { } public void tearDown ( ) throws Exception { } public void testPreparedQueryCacheIsActiveByDefault ( ) { } public void testPreparedQueryCacheIsPerUnitSingleton ( ) { } public void testPreparedQueryIdentifierIsOriginalJPQLQuery ( ) { } public void testOriginalJPQLQueryStringIsSetOnPreparedQuery ( ) { } public void testOrderByElementsAbsentInProjection ( ) { } public void testExclusionPattern ( ) { } void assertLanguage ( OpenJPAQuery < ? > q , String lang ) { } void assertCached ( String id ) { } void assertNotCached ( String id ) { } public void testPreparedQueryIsCachedOnExecution ( ) { } public void testPreparedQueryIsCachedAcrossExecution ( ) { } public void testInvalidatePreparedQueryWithHint ( ) { } public void testIgnorePreparedQueryWithHint ( ) { } public void testQueryStatistics ( ) { } public void testResetQueryStatistics ( ) { } public void testQueryWithNoParameter ( ) { } public void testQueryWithLiteral ( ) { } public void testQueryWithParameter ( ) { } public void testQueryWithJoinsAndParameters ( ) { } public void testNamedQueryWithNoParameter ( ) { } public void testNamedQueryWithLiteral ( ) { } public void testNamedQueryWithPositionalParameter ( ) { } public void testNamedQueryWithNamedParameter ( ) { } public void testPersistenceCapableParameter ( ) { } public void testProjectionResult ( ) { } public void testCollectionValuedParameters ( ) { } public void testQueryProjectionNotCandidateClass ( ) { } public void testQueryMultipleProjectionClass ( ) { } public void testQueryWithOrderByClause ( ) { } public void testQueryCount ( ) { } public void testProjectRepeatsTerm ( ) { } public void testProjectEmbedded ( ) { } public void testNeedsTypeConversion ( ) { } String literal ( String s ) { } public void testPositional ( ) { } public void testNamed ( ) { } public void testWrongParameterValueTypeThrowException ( ) { } public void testNullParameterValueForPrimitiveTypeThrowsException ( ) { } public void testQueryWithLazyRelationIsCached ( ) { } public void testQueryWithEagerRelationIsNotCached ( ) { } @ AllowFailure ( message = "We<seq2seq4repair_space>have<seq2seq4repair_space>problems<seq2seq4repair_space>with<seq2seq4repair_space>reparametrization<seq2seq4repair_space>of<seq2seq4repair_space>subquery<seq2seq4repair_space>+<seq2seq4repair_space>constant<seq2seq4repair_space>literals" ) public void xtestQueryWithUserDefinedAndInternalParamtersInSubquery ( ) { } public void testPreparedQueryIgnoredWhenLockModeIsSet ( ) { } public void testEnumParameter ( ) { } public void testMultithreadedAccess ( ) { } public void testParameterOnExternalizedFieldIsExcluded ( ) { } public void testNoParameterOnExternalizedFieldIsIncluded ( ) { } public void testRepeatedParameterInSubqueryInDifferentOrder ( ) { } public void testRepeatedParameterInSubqueryInSameOrder ( ) { } public void testPartiallyRepeatedParameterInSubquery ( ) { } public void testPartiallyRepeatedParameterInMainquery ( ) { } public void testRangeIsExcluded ( ) { } public List < Company > getAllCompaniesPaged ( int start , int max ) { } PreparedQueryCache getPreparedQueryCache ( ) { } void compare ( String jpql , boolean isNamed ) { } void compare ( String jpql , boolean isNamed , int expectedCount ) { } void compare ( String jpql , boolean isNamed , Object ... params ) { } void compare ( String query , boolean isNamed , int expectedCount , Object ... params ) { } void compareSQLs ( List < String > a , List < String > b ) { } long run ( String jpql , boolean isNamedQuery , Object [ ] params , int expectedCount , boolean useCache , int N ) { } void parameterize ( Query q , Object [ ] params ) { } void iterate ( List < ? > list ) { } String getJPQLString ( String name , boolean isNamedQuery ) { }

Fix:
config . put ( "openjpa.jdbc.QuerySQLCache" , "true(EnableStatistics=true)" ) ;