jdk/test/java/util/ResourceBundle/Bug4168625Test.java
changeset 9236 5db1131f95ba
parent 7668 d4a77089c587
child 14342 8435a30053c1
equal deleted inserted replaced
9235:ddd556c97e6c 9236:5db1131f95ba
   280         ConcurrentLoadingThread thread2 = new ConcurrentLoadingThread(loader, test, new Locale("en", "IE"));
   280         ConcurrentLoadingThread thread2 = new ConcurrentLoadingThread(loader, test, new Locale("en", "IE"));
   281 
   281 
   282         thread1.start();            //start thread 1
   282         thread1.start();            //start thread 1
   283         loader.waitForNotify(1);    //wait for thread1 to do getBundle & block in loader
   283         loader.waitForNotify(1);    //wait for thread1 to do getBundle & block in loader
   284         thread2.start();            //start second thread
   284         thread2.start();            //start second thread
   285         thread2.join(1000);         //wait until thread2 blocks somewhere in getBundle
   285         thread2.join();             //wait until thread2 terminates.
   286 
   286 
   287             //Thread1 should be blocked inside getBundle at the class loader
   287             //Thread1 should be blocked inside getBundle at the class loader
   288             //Thread2 should have completed its getBundle call and terminated
   288             //Thread2 should have completed its getBundle call and terminated
   289         if (!thread1.isAlive() || thread2.isAlive()) {
   289         if (!thread1.isAlive() || thread2.isAlive()) {
   290             errln("ResourceBundle.getBundle not allowing legal concurrent loads");
   290             errln("ResourceBundle.getBundle not allowing legal concurrent loads");
   291         }
   291         }
   292 
   292 
   293         thread1.ping();             //continue thread1
   293         thread1.ping();             //continue thread1
   294         thread1.join();
   294         thread1.join();
   295         thread2.join();
       
   296     }
   295     }
   297 
   296 
   298     /**
   297     /**
   299      * This test ensures that a resource loads correctly (with all its parents)
   298      * This test ensures that a resource loads correctly (with all its parents)
   300      * when memory is very low (ex. the cache gets purged during a load).
   299      * when memory is very low (ex. the cache gets purged during a load).
   316         causeResourceBundleCacheFlush();    //cause a cache flush
   315         causeResourceBundleCacheFlush();    //cause a cache flush
   317         thread1.ping();             //kick thread 1
   316         thread1.ping();             //kick thread 1
   318         loader.waitForNotify(3);    //wait for thread1 to do getBundle(en) & block in loader
   317         loader.waitForNotify(3);    //wait for thread1 to do getBundle(en) & block in loader
   319         causeResourceBundleCacheFlush();    //cause a cache flush
   318         causeResourceBundleCacheFlush();    //cause a cache flush
   320         thread1.ping();             //kick thread 1
   319         thread1.ping();             //kick thread 1
   321         thread1.ping();             //kick thread 1
   320         thread1.join();             //wait until thread1 terminates
   322         thread1.join(1000);         //wait until thread2 blocks somewhere in getBundle
       
   323 
   321 
   324         ResourceBundle bundle = (ResourceBundle)thread1.bundle;
   322         ResourceBundle bundle = (ResourceBundle)thread1.bundle;
   325         String s1 = bundle.getString("Bug4168625Resource3_en_US");
   323         String s1 = bundle.getString("Bug4168625Resource3_en_US");
   326         String s2 = bundle.getString("Bug4168625Resource3_en");
   324         String s2 = bundle.getString("Bug4168625Resource3_en");
   327         String s3 = bundle.getString("Bug4168625Resource3");
   325         String s3 = bundle.getString("Bug4168625Resource3");