HHH-6015 - hibernate-infinispan test failures after migration to JUnit4

Fixed isolated classloader test making sure the two classloaders
required are created, one with the classes and the other without them.
This commit is contained in:
Galder Zamarreño 2011-03-15 14:08:36 +01:00
parent bcff8948fb
commit f3bab56382
1 changed files with 13 additions and 15 deletions

View File

@ -60,32 +60,30 @@ import org.hibernate.test.cache.infinispan.functional.cluster.DualNodeTestCase;
* @since 3.5
*/
public class IsolatedClassLoaderTest extends DualNodeTestCase {
private static final String CACHE_CONFIG = "classloader";
protected static final long SLEEP_TIME = 300L;
static int test = 0;
private Cache localQueryCache;
private CacheAccessListener localQueryListener;
private Cache remoteQueryCache;
private CacheAccessListener remoteQueryListener;
private static ClassLoader originalTCCL;
private static ClassLoader originalTCCL;
@BeforeClass
public static void prepareClassLoader() {
originalTCCL = Thread.currentThread().getContextClassLoader();
final String packageName = IsolatedClassLoaderTest.class.getPackage().getName();
final String[] isolatedClassNames = new String[] { packageName + "Account", packageName + "AccountHolder" };
final SelectedClassnameClassLoader visible = new SelectedClassnameClassLoader(
isolatedClassNames,
null,
null,
originalTCCL
);
Thread.currentThread().setContextClassLoader( visible );
final String packageName = IsolatedClassLoaderTest.class.getPackage().getName();
final String[] classes = new String[] { packageName + ".Account", packageName + ".AccountHolder" };
originalTCCL = Thread.currentThread().getContextClassLoader();
// Most likely, it will point to system classloader
ClassLoader parent = originalTCCL == null ? IsolatedClassLoaderTest.class.getClassLoader() : originalTCCL;
// First, create a classloader where classes won't be found
ClassLoader selectedTCCL = new SelectedClassnameClassLoader(null, null, classes, parent);
// Now, make the class visible to the test driver
SelectedClassnameClassLoader visible = new SelectedClassnameClassLoader(classes, null, null, selectedTCCL);
Thread.currentThread().setContextClassLoader(visible);
}
@AfterClass