/** * Create a classloader * * @param policy the policy * @return the classloader * @throws Exception for any error */ public ClassLoader createClassLoader(MockClassLoaderPolicy policy) throws Exception { ClassLoaderDomain domain = getDomain(); return createClassLoader(domain, policy); }
/** * Create the default delegate loader * * @return the loaders */ public List<? extends DelegateLoader> createDefaultDelegates() { return createDelegates(getPolicy()); }
/** * Create a scoped classloader domain using the test domain as parent * using the parent last policy * * @param name the name * @return the domain */ public ClassLoaderDomain createScopedClassLoaderDomainParentLast(String name) { return createScopedClassLoaderDomain(name, ParentPolicy.AFTER_BUT_JAVA_BEFORE, getDomain()); }
/** * 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 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); }
/** * Get the classloader system, this will be configured with * a domain called TEST that includes the test case's classloader * * @return the classloader */ public static ClassLoaderSystem getClassLoaderSystem() { return helper.getSystem(); }
/** * Create a classloader * * @param domainName the domainName * @param policy the policy * @return the classloader * @throws Exception for any error */ public ClassLoader createClassLoader(String domainName, MockClassLoaderPolicy policy) throws Exception { ClassLoaderSystem system = getSystem(); ClassLoaderDomain domain = system.getDomain(domainName); return createClassLoader(domain, 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 classloader * * It exports everything * * @param name the name * @param importAll whether to import all * @param packages the packages * @return the classloader * @throws Exception for any error */ protected static ClassLoader createClassLoader(String name, boolean importAll, String... packages) throws Exception { return helper.createClassLoader(name, importAll, packages); }
/** * Unregister a classloader * * @param classLoader the classloader * @throws Exception for any error */ protected static void unregisterClassLoader(ClassLoader classLoader) throws Exception { helper.unregisterClassLoader(classLoader); } }
/** * 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 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); }
/** * Get the classloader system, this will be configured with * a domain called TEST that includes the test case's classloader * * @return the classloader */ public static ClassLoaderSystem getClassLoaderSystem() { return helper.getSystem(); }
/** * Create a classloader * * @param domainName the domainName * @param policy the policy * @return the classloader * @throws Exception for any error */ public ClassLoader createClassLoader(String domainName, MockClassLoaderPolicy policy) throws Exception { ClassLoaderSystem system = getSystem(); ClassLoaderDomain domain = system.getDomain(domainName); return createClassLoader(domain, 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 classloader * * It exports everything * * @param name the name * @param importAll whether to import all * @param packages the packages * @return the classloader * @throws Exception for any error */ protected static ClassLoader createClassLoader(String name, boolean importAll, String... packages) throws Exception { return helper.createClassLoader(name, importAll, packages); }
/** * Unregister a classloader * * @param classLoader the classloader * @throws Exception for any error */ protected static void unregisterClassLoader(ClassLoader classLoader) throws Exception { helper.unregisterClassLoader(classLoader); } }
/** * 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()); }
/** * Create a scoped classloader domain using the test domain as parent * * @param name the name * @param parentPolicy the parent policy * @return the domain */ public ClassLoaderDomain createScopedClassLoaderDomain(String name, ParentPolicy parentPolicy) { return createScopedClassLoaderDomain(name, parentPolicy, getDomain()); }
/** * 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); }