use of org.mule.runtime.module.artifact.api.descriptor.InvalidDescriptorLoaderException in project mule by mulesoft.
the class DeployableMavenClassLoaderModelLoaderTestCase method testPatchedDependency.
private void testPatchedDependency(String application, int totalExpectedDependencies, String patchedArtifactId, String patchedArtifactVersion) throws InvalidDescriptorLoaderException {
DeployableMavenClassLoaderModelLoader deployableMavenClassLoaderModelLoader = new DeployableMavenClassLoaderModelLoader(mockMavenClient, mockLocalRepository);
URL patchedAppUrl = getClass().getClassLoader().getResource(Paths.get(APPS_FOLDER, application).toString());
ClassLoaderModel classLoaderModel = deployableMavenClassLoaderModelLoader.load(FileUtils.toFile(patchedAppUrl), emptyMap(), APP);
Set<BundleDependency> dependencies = classLoaderModel.getDependencies();
assertThat(dependencies, hasSize(totalExpectedDependencies));
List<BundleDependency> connectorsFound = dependencies.stream().filter(bundleDependency -> bundleDependency.getDescriptor().getArtifactId().equals(patchedArtifactId)).collect(Collectors.toList());
assertThat(connectorsFound, hasSize(1));
assertThat(connectorsFound.get(0).getDescriptor().getVersion(), is(patchedArtifactVersion));
}
use of org.mule.runtime.module.artifact.api.descriptor.InvalidDescriptorLoaderException in project mule by mulesoft.
the class FileSystemPolicyClassLoaderModelLoader method loadUrls.
private void loadUrls(ClassLoaderModel.ClassLoaderModelBuilder classLoaderModelBuilder, File artifactFolder) throws InvalidDescriptorLoaderException {
try {
classLoaderModelBuilder.containing(artifactFolder.toURI().toURL());
final File libDir = new File(artifactFolder, LIB_DIR);
if (libDir.exists()) {
final File[] jars = libDir.listFiles((FilenameFilter) new SuffixFileFilter(JAR_FILE));
for (int i = 0; i < jars.length; i++) {
classLoaderModelBuilder.containing(jars[i].toURI().toURL());
}
}
} catch (MalformedURLException e) {
throw new InvalidDescriptorLoaderException("Failed to create plugin descriptor " + artifactFolder);
}
}
use of org.mule.runtime.module.artifact.api.descriptor.InvalidDescriptorLoaderException in project mule by mulesoft.
the class PropertiesBundleDescriptorLoader method load.
/**
* Loads a bundle descriptor from the provided properties
*
* @param artifactFolder {@link File} where the current artifact to work with. Non null
* @param attributes attributes defined in the loader.
* @param artifactType the type of the artifact of the descriptor to be loaded.
* @return a locator of the coordinates of the current artifact
* @throws ArtifactDescriptorCreateException if any bundle descriptor required property is missing on the given attributes.
*/
@Override
public BundleDescriptor load(File artifactFolder, Map<String, Object> attributes, ArtifactType artifactType) throws InvalidDescriptorLoaderException {
String version = (String) attributes.get(VERSION);
String groupId = (String) attributes.get(GROUP_ID);
String artifactId = (String) attributes.get(ARTIFACT_ID);
String classifier = (String) attributes.get(CLASSIFIER);
String type = (String) attributes.get(TYPE);
try {
return new BundleDescriptor.Builder().setVersion(version).setGroupId(groupId).setArtifactId(artifactId).setClassifier(classifier).setType(type).build();
} catch (IllegalArgumentException e) {
throw new InvalidDescriptorLoaderException("Bundle descriptor attributes are not complete", e);
}
}
Aggregations