Search in sources :

Example 6 with ClassLoaderModel

use of org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel in project mule by mulesoft.

the class DeployableArtifactDescriptorFactoryTestCase method classLoaderModelWithoutIncludeTestDependencies.

@Test
public void classLoaderModelWithoutIncludeTestDependencies() throws Exception {
    D desc = createArtifactDescriptor(getArtifactRootFolder() + "do-not-include-test-dependencies");
    ClassLoaderModel classLoaderModel = desc.getClassLoaderModel();
    assertThat(classLoaderModel.isIncludeTestDependencies(), is(false));
}
Also used : ClassLoaderModel(org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel) Test(org.junit.Test)

Example 7 with ClassLoaderModel

use of org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel in project mule by mulesoft.

the class DeployableArtifactDescriptorFactoryTestCase method classLoaderModelWithPluginDependencyWithAnotherPlugin.

@Test
public void classLoaderModelWithPluginDependencyWithAnotherPlugin() throws Exception {
    D desc = createArtifactDescriptor(getArtifactRootFolder() + "plugin-dependency-with-another-plugin");
    ClassLoaderModel classLoaderModel = desc.getClassLoaderModel();
    assertThat(classLoaderModel.getDependencies().size(), is(2));
    assertThat(classLoaderModel.getDependencies(), hasItems(dependantPluginDependencyMatcher(), emptyPluginDependencyMatcher()));
    assertThat(classLoaderModel.getUrls().length, is(1));
    classLoaderModel.getDependencies().stream().forEach(bundleDependency -> {
        assertThat(asList(classLoaderModel.getUrls()), not(hasItem(bundleDependency.getBundleUri())));
    });
}
Also used : ClassLoaderModel(org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel) Test(org.junit.Test)

Example 8 with ClassLoaderModel

use of org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel in project mule by mulesoft.

the class DeployableArtifactDescriptorFactoryTestCase method loadsDescriptorFromJson.

@Test
public void loadsDescriptorFromJson() throws Exception {
    String artifactPath = getArtifactRootFolder() + "no-dependencies";
    D desc = createArtifactDescriptor(artifactPath);
    assertThat(desc.getMinMuleVersion(), is(new MuleVersion("4.0.0")));
    assertThat(desc.getConfigResources(), hasSize(1));
    assertThat(desc.getConfigResources(), hasItem(getDefaultConfigurationResourceLocation()));
    ClassLoaderModel classLoaderModel = desc.getClassLoaderModel();
    assertThat(classLoaderModel.getDependencies().isEmpty(), is(true));
    assertThat(classLoaderModel.getUrls().length, is(1));
    assertThat(toFile(classLoaderModel.getUrls()[0]).getPath(), is(getArtifact(artifactPath).getAbsolutePath()));
    assertThat(classLoaderModel.getExportedPackages().isEmpty(), is(true));
    assertThat(classLoaderModel.getExportedResources().isEmpty(), is(true));
    assertThat(classLoaderModel.getDependencies().isEmpty(), is(true));
}
Also used : MuleVersion(org.mule.runtime.api.meta.MuleVersion) ClassLoaderModel(org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel) Test(org.junit.Test)

Example 9 with ClassLoaderModel

use of org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel in project mule by mulesoft.

the class FileSystemPolicyClassLoaderModelLoaderTestCase method createsClassLoaderModelFromFolder.

@Test
public void createsClassLoaderModelFromFolder() throws Exception {
    File policyFolder = temporaryFolder.newFolder();
    File libFolder = new File(policyFolder, LIB_DIR);
    assertThat(libFolder.mkdir(), is(true));
    File file1 = new File(libFolder, "test1.jar");
    stringToFile(file1.getAbsolutePath(), "foo");
    File file2 = new File(libFolder, "test2.jar");
    stringToFile(file2.getAbsolutePath(), "foo");
    ClassLoaderModel classLoaderModel = classLoaderModelLoader.load(policyFolder, null, POLICY);
    assertThat(classLoaderModel.getUrls().length, equalTo(3));
    assertThat(classLoaderModel.getUrls()[0], equalTo(policyFolder.toURI().toURL()));
    assertThat(asList(classLoaderModel.getUrls()), allOf(hasItem(file1.toURI().toURL()), hasItem(file2.toURI().toURL())));
    assertThat(classLoaderModel.getDependencies(), is(empty()));
    assertThat(classLoaderModel.getExportedPackages(), is(empty()));
    assertThat(classLoaderModel.getExportedResources(), is(empty()));
}
Also used : File(java.io.File) FileUtils.stringToFile(org.mule.runtime.core.api.util.FileUtils.stringToFile) ClassLoaderModel(org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel) Test(org.junit.Test)

Example 10 with ClassLoaderModel

use of org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel in project mule by mulesoft.

the class LibFolderClassLoaderModelLoaderTestCase method ignoresNonJarsFilesFromLibFolder.

@Test
public void ignoresNonJarsFilesFromLibFolder() throws Exception {
    File libFolder = serviceFolder.newFolder(LIB_FOLDER);
    File jarFile = new File(libFolder, "dummy.txt");
    jarFile.createNewFile();
    ClassLoaderModel classLoaderModel = classLoaderModelLoader.load(serviceFolder.getRoot(), emptyMap(), SERVICE);
    // Contains only the service root
    assertThat(classLoaderModel.getUrls(), hasItemInArray(serviceFolder.getRoot().toURL()));
}
Also used : File(java.io.File) ClassLoaderModel(org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel) Test(org.junit.Test)

Aggregations

ClassLoaderModel (org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel)21 Test (org.junit.Test)15 File (java.io.File)7 BundleDependency (org.mule.runtime.module.artifact.api.descriptor.BundleDependency)5 URL (java.net.URL)3 Paths (java.nio.file.Paths)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Map (java.util.Map)3 Set (java.util.Set)3 LocalRepositorySupplierFactory (org.mule.maven.client.api.LocalRepositorySupplierFactory)3 MavenClient (org.mule.maven.client.api.MavenClient)3 Files.createTempDir (com.google.common.io.Files.createTempDir)2 Boolean.getBoolean (java.lang.Boolean.getBoolean)2 Boolean.valueOf (java.lang.Boolean.valueOf)2 String.format (java.lang.String.format)2 MalformedURLException (java.net.MalformedURLException)2 Optional (java.util.Optional)2 Optional.of (java.util.Optional.of)2