/** * Initialize the classloader system * * @param clazz the original clazz * @param system the system * @param policy the policy * @param parentPackages the parentPackages * @return the clazz loaded from the new classloading system */ public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassLoaderPolicy policy, Set<String> parentPackages) { String[] parentPkgs = parentPackages.toArray(new String[parentPackages.size()]); return initializeClassLoader(clazz, system, policy, parentPkgs); }
/** * Initialize the classloader system * * @param clazz the original clazz * @param system the system * @param policy the policy * @param parentPackages the parentPackages * @return the clazz loaded from the new classloading system */ public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassLoaderPolicy policy, Set<String> parentPackages) { String[] parentPkgs = parentPackages.toArray(new String[parentPackages.size()]); return initializeClassLoader(clazz, system, policy, parentPkgs); }
/** * Initialize the classloader system * * @param clazz the original clazz * @param system the system * @param policy the policy * @return the clazz loaded from the new classloading system */ public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassLoaderPolicy policy) { return initializeClassLoader(clazz, system, policy, getParentPackages()); }
/** * Initialize the classloader system * * @param clazz the original clazz * @param parentFilter the parent filter * @param policy the policy * @return the clazz loaded from the new classloading system */ public Class<?> initializeClassLoader(Class<?> clazz, ClassFilter parentFilter, ClassLoaderPolicy policy) { ClassLoaderSystem system = new DefaultClassLoaderSystem(); return initializeClassLoader(clazz, system, parentFilter, policy); }
/** * Initialize the classloader system * * @param clazz the original clazz * @param system the system * @param policy the policy * @return the clazz loaded from the new classloading system */ public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassLoaderPolicy policy) { return initializeClassLoader(clazz, system, policy, getParentPackages()); }
/** * Initialize the classloader system * * @param clazz the original clazz * @param parentFilter the parent filter * @param policy the policy * @return the clazz loaded from the new classloading system */ public Class<?> initializeClassLoader(Class<?> clazz, ClassFilter parentFilter, ClassLoaderPolicy policy) { ClassLoaderSystem system = new DefaultClassLoaderSystem(); return initializeClassLoader(clazz, system, parentFilter, policy); }
/** * Initialize the classloader system * * @param clazz the original clazz * @param system the system * @param parentPolicy the parent policy * @param policy the policy * @return the clazz loaded from the new classloading system */ public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ParentPolicy parentPolicy, ClassLoaderPolicy policy) { ClassLoaderDomain domain = system.createAndRegisterDomain("TEST", parentPolicy); return initializeClassLoader(clazz, system, domain, policy); }
/** * Initialize the classloader system * * @param clazz the original clazz * @param system the system * @param parentPolicy the parent policy * @param policy the policy * @return the clazz loaded from the new classloading system */ public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ParentPolicy parentPolicy, ClassLoaderPolicy policy) { ClassLoaderDomain domain = system.createAndRegisterDomain("TEST", parentPolicy); return initializeClassLoader(clazz, system, domain, policy); }
/** * Initialize the classloader system * * @param clazz the original clazz * @param system the system * @param beforeFilter the before filter * @param afterFilter the after filter * @param policy the policy * @return the clazz loaded from the new classloading system */ public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassFilter beforeFilter, ClassFilter afterFilter, ClassLoaderPolicy policy) { ParentPolicy parentPolicy = new ParentPolicy(beforeFilter, afterFilter); return initializeClassLoader(clazz, system, parentPolicy, policy); }
/** * Initialize the classloader system * * @param clazz the original clazz * @param system the system * @param beforeFilter the before filter * @param afterFilter the after filter * @param policy the policy * @return the clazz loaded from the new classloading system */ public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassFilter beforeFilter, ClassFilter afterFilter, ClassLoaderPolicy policy) { ParentPolicy parentPolicy = new ParentPolicy(beforeFilter, afterFilter); return initializeClassLoader(clazz, system, parentPolicy, policy); }
/** * Initialize the classloader system * * @param clazz the original clazz * @param policy the policy * @return the clazz loaded from the new classloading system */ public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderPolicy policy) { ClassLoaderSystem system = new DefaultClassLoaderSystem(); return initializeClassLoader(clazz, system, policy, getParentPackages()); }
/** * Initialize the classloader system * * @param clazz the original clazz * @param importAll whether to import all * @param packages the reference classes for the packages * @return the clazz loaded from the new classloading system */ public Class<?> initializeClassLoader(Class<?> clazz, boolean importAll, Class<?>... packages) { MockClassLoaderPolicy policy = new MockClassLoaderPolicy(); Set<Class<?>> classes = new HashSet<Class<?>>(); classes.add(clazz); classes.addAll(Arrays.asList(packages)); policy.setImportAll(importAll); policy.setPathsAndPackageNames(classes.toArray(new Class[classes.size()])); return initializeClassLoader(clazz, policy); }
/** * Initialize the classloader system * * @param clazz the original clazz * @param parentFilter the parent filter * @param importAll whether to import all * @param packages the reference classes for the packages * @return the clazz loaded from the new classloading system */ public Class<?> initializeClassLoader(Class<?> clazz, ClassFilter parentFilter, boolean importAll, Class<?>... packages) { MockClassLoaderPolicy policy = new MockClassLoaderPolicy(); Set<Class<?>> classes = new HashSet<Class<?>>(); classes.add(clazz); classes.addAll(Arrays.asList(packages)); policy.setImportAll(importAll); policy.setPathsAndPackageNames(classes.toArray(new Class[classes.size()])); return initializeClassLoader(clazz, parentFilter, policy); }
/** * Initialize the classloader system * * @param clazz the original clazz * @param policy the policy * @return the clazz loaded from the new classloading system */ public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderPolicy policy) { ClassLoaderSystem system = new DefaultClassLoaderSystem(); return initializeClassLoader(clazz, system, policy, getParentPackages()); }
/** * Initialize the classloader system * * @param clazz the original clazz * @param importAll whether to import all * @param packages the reference classes for the packages * @return the clazz loaded from the new classloading system */ public Class<?> initializeClassLoader(Class<?> clazz, boolean importAll, Class<?>... packages) { MockClassLoaderPolicy policy = new MockClassLoaderPolicy(); Set<Class<?>> classes = new HashSet<Class<?>>(); classes.add(clazz); for (Class<?> c : packages) classes.add(c); policy.setImportAll(importAll); policy.setPathsAndPackageNames(classes.toArray(new Class[classes.size()])); return initializeClassLoader(clazz, policy); }
/** * Initialize the classloader system * * @param clazz the original clazz * @param system the system * @param policy the policy * @param parentPackages the parentPackages * @return the clazz loaded from the new classloading system */ public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassLoaderPolicy policy, String... parentPackages) { // The parent filter PackageClassFilter filter = new PackageClassFilter(parentPackages); filter.setIncludeJava(true); return initializeClassLoader(clazz, system, filter, ClassFilter.NOTHING, policy); }
/** * Initialize the classloader system * * @param clazz the original clazz * @param system the system * @param policy the policy * @param parentPackages the parentPackages * @return the clazz loaded from the new classloading system */ public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassLoaderPolicy policy, String... parentPackages) { // The parent filter PackageClassFilter filter = new PackageClassFilter(parentPackages); filter.setIncludeJava(true); return initializeClassLoader(clazz, system, filter, ClassFilterUtils.NOTHING, policy); }
/** * Create a test with test's package visible and the packages * of the classes listed * * It exports everything * * @param clazz the test class * @param importAll whether to import all * @param packages the classes in packages that should also be included * @return the test */ public static Test suite(Class<?> clazz, boolean importAll, Class<?>... packages) { helper = new IsolatedClassLoaderTestHelper(); Class<?> newClass = helper.initializeClassLoader(clazz, importAll, packages); // Create the test based on the isolated class return AbstractTestCaseWithSetup.suite(newClass); }
/** * Create a test with test's package visible and the packages * of the classes listed * * It exports everything * * @param clazz the test class * @param importAll whether to import all * @param packages the classes in packages that should also be included * @return the test */ public static Test suite(Class<?> clazz, boolean importAll, Class<?>... packages) { helper = new IsolatedClassLoaderTestHelper(); Class<?> newClass = helper.initializeClassLoader(clazz, importAll, packages); // Create the test based on the isolated class return AbstractTestCaseWithSetup.suite(newClass); }
/** * Initialize the classloader system * * @param clazz the original clazz * @param system the system * @param parentFilter the parent filter * @param policy the policy * @return the clazz loaded from the new classloading system */ public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassFilter parentFilter, ClassLoaderPolicy policy) { Set<String> parentPackages = getParentPackages(); String[] parentPkgs = parentPackages.toArray(new String[parentPackages.size()]); PackageClassFilter filter = new PackageClassFilter(parentPkgs); filter.setIncludeJava(true); CombiningClassFilter beforeFilter = CombiningClassFilter.create(filter, parentFilter); ParentPolicy parentPolicy = new ParentPolicy(beforeFilter, ClassFilter.NOTHING); return initializeClassLoader(clazz, system, parentPolicy, policy); }