use of org.mule.runtime.deployment.model.internal.domain.MuleSharedDomainClassLoader in project mule by mulesoft.
the class MuleApplicationClassLoaderTestCase method createAppClassLoader.
@Before
public void createAppClassLoader() throws Exception {
// Create directories structure
previousMuleHome = System.setProperty(MULE_HOME_DIRECTORY_PROPERTY, tempMuleHome.getRoot().getAbsolutePath());
final List<URL> urls = new LinkedList<>();
appFolder = getAppFolder(APP_NAME);
assertThat(appFolder.mkdirs(), is(true));
// Add isolated resources in classes dir
FileUtils.stringToFile(new File(appFolder, RESOURCE_IN_CLASSES_AND_JAR).getAbsolutePath(), "Some text");
FileUtils.stringToFile(new File(appFolder, RESOURCE_JUST_IN_CLASSES).getAbsolutePath(), "Some text");
urls.add(appFolder.toURI().toURL());
// Add jar file with resources in lib dir
File libDir = getAppLibFolder(APP_NAME);
assertThat(libDir.mkdirs(), is(true));
URL resourceSrcJarFile = currentThread().getContextClassLoader().getResource("test-jar-with-resources.jar");
assertNotNull(resourceSrcJarFile);
File srcJarFile = new File(resourceSrcJarFile.toURI());
jarFile = new File(libDir, "test-jar-with-resources.jar");
FileUtils.copyFile(srcJarFile, jarFile, false);
urls.add(jarFile.toURI().toURL());
// Add isolated resources in domain dir
domainDir = MuleFoldersUtil.getDomainFolder(DOMAIN_NAME);
assertThat(domainDir.mkdirs(), is(true));
FileUtils.stringToFile(new File(domainDir, RESOURCE_JUST_IN_DOMAIN).getAbsolutePath(), "Some text");
mockStatic(MuleArtifactClassLoader.class);
// Create app class loader
domainCL = new MuleSharedDomainClassLoader(new DomainDescriptor(DOMAIN_NAME), currentThread().getContextClassLoader(), mock(ClassLoaderLookupPolicy.class), emptyList(), emptyList());
final ApplicationDescriptor applicationDescriptor = new ApplicationDescriptor(APP_NAME);
ClassLoaderModel classLoaderModel = new ClassLoaderModel.ClassLoaderModelBuilder(applicationDescriptor.getClassLoaderModel()).containing(getAppFolder(APP_NAME).toURI().toURL()).build();
applicationDescriptor.setClassLoaderModel(classLoaderModel);
appCL = new MuleApplicationClassLoader(APP_NAME, applicationDescriptor, domainCL, null, urls, mock(ClassLoaderLookupPolicy.class), emptyList());
}
Aggregations