use of org.mule.tck.ZipUtils.ZipResource in project mule by mulesoft.
the class FileJarExplorerTestCase method readsPackagesFromJar.
@Test
public void readsPackagesFromJar() throws Exception {
final ZipResource fooClass = new ZipResource("EchoTest.clazz", "org/foo/Foo.class");
final ZipResource barClass = new ZipResource("EchoTest.clazz", "org/bar/Bar.class");
final ZipResource[] zipResources = { fooClass, barClass };
final File jarFile = File.createTempFile("test", ".jar");
jarFile.delete();
ZipUtils.compress(jarFile, zipResources);
final Set<String> packages = packageExplorer.explore(jarFile.toURI()).getPackages();
assertThat(packages.size(), equalTo(2));
assertThat(packages, hasItem("org.foo"));
assertThat(packages, hasItem("org.bar"));
}
use of org.mule.tck.ZipUtils.ZipResource in project mule by mulesoft.
the class ApplicationFileBuilder method doGetCustomResources.
@Override
protected List<ZipResource> doGetCustomResources() {
final List<ZipResource> customResources = new LinkedList<>();
Object redeploymentEnabled = deployProperties.get(PROPERTY_REDEPLOYMENT_ENABLED);
Object configResources = deployProperties.get(PROPERTY_CONFIG_RESOURCES);
File applicationDescriptor = createApplicationJsonDescriptorFile(redeploymentEnabled == null ? empty() : ofNullable(Boolean.valueOf((String) redeploymentEnabled)), Optional.ofNullable((String) configResources), ofNullable((String) properties.get(EXPORTED_PACKAGES)), ofNullable((String) properties.get(EXPORTED_RESOURCES)));
customResources.add(new ZipResource(applicationDescriptor.getAbsolutePath(), MULE_ARTIFACT_JSON_DESCRIPTOR_LOCATION));
return customResources;
}
use of org.mule.tck.ZipUtils.ZipResource in project mule by mulesoft.
the class ArtifactPluginFileBuilder method getCustomResources.
@Override
protected List<ZipResource> getCustomResources() {
final List<ZipResource> customResources = new LinkedList<>();
if (!properties.isEmpty()) {
final MulePluginModel.MulePluginModelBuilder builder = new MulePluginModel.MulePluginModelBuilder();
builder.setName(getArtifactId()).setMinMuleVersion("4.0.0").setRequiredProduct(MULE);
MuleArtifactLoaderDescriptorBuilder classLoaderModelDescriptorBuilder = new MuleArtifactLoaderDescriptorBuilder().setId(MULE_LOADER_ID);
if (properties.containsKey(EXPORTED_CLASS_PACKAGES_PROPERTY)) {
classLoaderModelDescriptorBuilder.addProperty(EXPORTED_PACKAGES, ((String) properties.get(EXPORTED_CLASS_PACKAGES_PROPERTY)).split(","));
}
if (properties.containsKey(PRIVILEGED_EXPORTED_CLASS_PACKAGES_PROPERTY)) {
classLoaderModelDescriptorBuilder.addProperty(PRIVILEGED_EXPORTED_PACKAGES, ((String) properties.get(PRIVILEGED_EXPORTED_CLASS_PACKAGES_PROPERTY)).split(","));
}
if (properties.containsKey(PRIVILEGED_ARTIFACTS_PROPERTY)) {
classLoaderModelDescriptorBuilder.addProperty(PRIVILEGED_ARTIFACTS_IDS, ((String) properties.get(PRIVILEGED_ARTIFACTS_PROPERTY)).split(","));
}
if (properties.containsKey(EXPORTED_RESOURCE_PROPERTY)) {
classLoaderModelDescriptorBuilder.addProperty(EXPORTED_RESOURCES, ((String) properties.get(EXPORTED_RESOURCE_PROPERTY)).split(","));
}
builder.withClassLoaderModelDescriptorLoader(classLoaderModelDescriptorBuilder.build());
builder.withBundleDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap()));
mulePluginModel = builder.build();
}
if (mulePluginModel != null) {
final File jsonDescriptorFile = new File(getTempFolder(), MULE_ARTIFACT_FOLDER + separator + MULE_ARTIFACT_JSON_DESCRIPTOR);
jsonDescriptorFile.deleteOnExit();
String jsonDescriber = new MulePluginModelJsonSerializer().serialize(mulePluginModel);
try {
writeStringToFile(jsonDescriptorFile, jsonDescriber);
} catch (IOException e) {
throw new IllegalStateException("There was an issue generating the JSON file for " + this.getId(), e);
}
customResources.add(new ZipResource(jsonDescriptorFile.getAbsolutePath(), MULE_ARTIFACT_PATH_INSIDE_JAR + "/" + MULE_ARTIFACT_JSON_DESCRIPTOR));
}
return customResources;
}
use of org.mule.tck.ZipUtils.ZipResource in project mule by mulesoft.
the class DomainFileBuilder method doGetCustomResources.
@Override
protected List<ZipResource> doGetCustomResources() {
final List<ZipResource> customResources = new LinkedList<>();
final ZipResource domainProperties = createPropertiesFile(this.deployProperties, DEFAULT_DEPLOY_PROPERTIES_RESOURCE, DEFAULT_DEPLOY_PROPERTIES_RESOURCE);
if (domainProperties != null) {
customResources.add(domainProperties);
}
Object redeploymentEnabled = deployProperties.get(PROPERTY_REDEPLOYMENT_ENABLED);
Object configResources = deployProperties.get(PROPERTY_CONFIG_RESOURCES);
File domainDescriptor = createDomainJsonDescriptorFile(redeploymentEnabled == null ? empty() : ofNullable(Boolean.valueOf((String) redeploymentEnabled)), Optional.ofNullable((String) configResources), empty());
customResources.add(new ZipResource(domainDescriptor.getAbsolutePath(), MULE_ARTIFACT_JSON_DESCRIPTOR_LOCATION));
return customResources;
}
use of org.mule.tck.ZipUtils.ZipResource in project mule by mulesoft.
the class PolicyFileBuilder method doGetCustomResources.
@Override
protected List<ZipResource> doGetCustomResources() {
final List<ZipResource> customResources = new LinkedList<>();
if (mulePolicyModel != null) {
final File jsonDescriptorFile = new File(getTempFolder(), META_INF + separator + MULE_ARTIFACT + separator + MULE_ARTIFACT_JSON_DESCRIPTOR);
jsonDescriptorFile.deleteOnExit();
String jsonDescriber = new MulePolicyModelJsonSerializer().serialize(mulePolicyModel);
try {
writeStringToFile(jsonDescriptorFile, jsonDescriber);
} catch (IOException e) {
throw new IllegalStateException("There was an issue generating the JSON file for " + this.getId(), e);
}
customResources.add(new ZipResource(jsonDescriptorFile.getAbsolutePath(), META_INF + "/" + MULE_ARTIFACT + "/" + MULE_ARTIFACT_JSON_DESCRIPTOR));
}
return customResources;
}
Aggregations