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:
parent
bcff8948fb
commit
f3bab56382
|
@ -60,12 +60,8 @@ import org.hibernate.test.cache.infinispan.functional.cluster.DualNodeTestCase;
|
||||||
* @since 3.5
|
* @since 3.5
|
||||||
*/
|
*/
|
||||||
public class IsolatedClassLoaderTest extends DualNodeTestCase {
|
public class IsolatedClassLoaderTest extends DualNodeTestCase {
|
||||||
private static final String CACHE_CONFIG = "classloader";
|
|
||||||
|
|
||||||
protected static final long SLEEP_TIME = 300L;
|
protected static final long SLEEP_TIME = 300L;
|
||||||
|
|
||||||
static int test = 0;
|
|
||||||
|
|
||||||
private Cache localQueryCache;
|
private Cache localQueryCache;
|
||||||
private CacheAccessListener localQueryListener;
|
private CacheAccessListener localQueryListener;
|
||||||
|
|
||||||
|
@ -76,15 +72,17 @@ public class IsolatedClassLoaderTest extends DualNodeTestCase {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void prepareClassLoader() {
|
public static void prepareClassLoader() {
|
||||||
originalTCCL = Thread.currentThread().getContextClassLoader();
|
|
||||||
final String packageName = IsolatedClassLoaderTest.class.getPackage().getName();
|
final String packageName = IsolatedClassLoaderTest.class.getPackage().getName();
|
||||||
final String[] isolatedClassNames = new String[] { packageName + "Account", packageName + "AccountHolder" };
|
final String[] classes = new String[] { packageName + ".Account", packageName + ".AccountHolder" };
|
||||||
final SelectedClassnameClassLoader visible = new SelectedClassnameClassLoader(
|
originalTCCL = Thread.currentThread().getContextClassLoader();
|
||||||
isolatedClassNames,
|
// Most likely, it will point to system classloader
|
||||||
null,
|
ClassLoader parent = originalTCCL == null ? IsolatedClassLoaderTest.class.getClassLoader() : originalTCCL;
|
||||||
null,
|
|
||||||
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);
|
Thread.currentThread().setContextClassLoader(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue