use of org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder in project mule by mulesoft.
the class ApplicationDeploymentTestCase method deploysAppWithNotExportedPackage.
@Test
@Issue("MULE-13756")
@Description("Tests that code called form application's Processor can access internal resources/packages of the application")
public void deploysAppWithNotExportedPackage() throws Exception {
ApplicationFileBuilder nonExposingAppFileBuilder = new ApplicationFileBuilder("non-exposing-app").configuredWith(EXPORTED_PACKAGES, "org.bar1").configuredWith(EXPORTED_RESOURCES, "test-resource.txt").definedBy("app-with-loads-app-resource-plugin-config.xml").containingClass(loadsAppResourceCallbackClassFile, "org/foo/LoadsAppResourceCallback.class").containingClass(barUtils1ClassFile, "org/bar1/BarUtils.class").containingClass(barUtils2ClassFile, "org/bar2/BarUtils.class").containingResource("test-resource.txt", "test-resource.txt").containingResource("test-resource.txt", "test-resource-not-exported.txt");
addPackedAppFromBuilder(nonExposingAppFileBuilder);
startDeployment();
assertApplicationDeploymentSuccess(applicationDeploymentListener, nonExposingAppFileBuilder.getId());
executeApplicationFlow("main");
}
use of org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder in project mule by mulesoft.
the class ApplicationDeploymentTestCase method deploysExplodedAppsInOrderWhenAppArgumentIsUsed.
@Test
public void deploysExplodedAppsInOrderWhenAppArgumentIsUsed() throws Exception {
assumeThat(parallelDeployment, is(false));
ApplicationFileBuilder appFileBuilder1 = new ApplicationFileBuilder("1").definedBy("empty-config.xml");
addExplodedAppFromBuilder(appFileBuilder1);
ApplicationFileBuilder appFileBuilder2 = new ApplicationFileBuilder("2").definedBy("empty-config.xml");
addExplodedAppFromBuilder(appFileBuilder2);
ApplicationFileBuilder appFileBuilder3 = new ApplicationFileBuilder("3").definedBy("empty-config.xml");
addExplodedAppFromBuilder(appFileBuilder3);
Map<String, Object> startupOptions = new HashMap<>();
startupOptions.put("app", format("%s:%s:%s", appFileBuilder3.getId(), appFileBuilder1.getId(), appFileBuilder2.getId()));
StartupContext.get().setStartupOptions(startupOptions);
startDeployment();
assertApplicationDeploymentSuccess(applicationDeploymentListener, appFileBuilder3.getId());
assertApplicationDeploymentSuccess(applicationDeploymentListener, appFileBuilder1.getId());
assertApplicationDeploymentSuccess(applicationDeploymentListener, appFileBuilder2.getId());
assertAppsDir(NONE, new String[] { appFileBuilder1.getId(), appFileBuilder2.getId(), appFileBuilder3.getId() }, true);
// When apps are passed as -app app1:app2:app3 the startup order matters
List<Application> applications = deploymentService.getApplications();
assertNotNull(applications);
assertEquals(3, applications.size());
assertEquals(appFileBuilder3.getId(), applications.get(0).getArtifactName());
assertEquals(appFileBuilder1.getId(), applications.get(1).getArtifactName());
assertEquals(appFileBuilder2.getId(), applications.get(2).getArtifactName());
}
use of org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder in project mule by mulesoft.
the class ApplicationDeploymentTestCase method deploysAppWithNotExportedPackageAndPluginWithInterceptors.
@Test
@Issue("MULE-13756")
@Description("Tests that code called form plugin's ProcessorInterceptor cannot access internal resources/packages of the application")
public void deploysAppWithNotExportedPackageAndPluginWithInterceptors() throws Exception {
File loadsAppResourceInterceptorFactoryClassFile = new SingleClassCompiler().compile(getResourceFile("/org/foo/LoadsAppResourceInterceptorFactory.java"));
File loadsAppResourceInterceptorClassFile = new SingleClassCompiler().compile(getResourceFile("/org/foo/LoadsAppResourceInterceptor.java"));
ArtifactPluginFileBuilder loadsAppResourceInterceptorPlugin = new ArtifactPluginFileBuilder("loadsAppResourceInterceptorPlugin").configuredWith(EXPORTED_CLASS_PACKAGES_PROPERTY, "org.lalala").containingClass(loadsAppResourceInterceptorFactoryClassFile, "org/foo/LoadsAppResourceInterceptorFactory.class").containingClass(loadsAppResourceInterceptorClassFile, "org/foo/LoadsAppResourceInterceptor.class").containingResource("registry-bootstrap-loads-app-resource-pif.properties", "META-INF/org/mule/runtime/core/config/registry-bootstrap.properties");
ApplicationFileBuilder nonExposingAppFileBuilder = new ApplicationFileBuilder("non-exposing-app").configuredWith(EXPORTED_PACKAGES, "org.bar1").configuredWith(EXPORTED_RESOURCES, "test-resource.txt").definedBy("app-with-plugin-bootstrap.xml").containingClass(barUtils1ClassFile, "org/bar1/BarUtils.class").containingClass(barUtils2ClassFile, "org/bar2/BarUtils.class").containingResource("test-resource.txt", "test-resource.txt").containingResource("test-resource.txt", "test-resource-not-exported.txt").dependingOn(loadsAppResourceInterceptorPlugin);
addPackedAppFromBuilder(nonExposingAppFileBuilder);
startDeployment();
assertApplicationDeploymentSuccess(applicationDeploymentListener, nonExposingAppFileBuilder.getId());
executeApplicationFlow("main");
}
use of org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder in project mule by mulesoft.
the class ApplicationDeploymentTestCase method failsToDeployApplicationWithMissingPluginDependencyOnPlugin.
@Test
public void failsToDeployApplicationWithMissingPluginDependencyOnPlugin() throws Exception {
ArtifactPluginFileBuilder dependantPlugin = new ArtifactPluginFileBuilder("dependantPlugin").configuredWith(EXPORTED_CLASS_PACKAGES_PROPERTY, "org.foo.echo").containingClass(pluginEcho3TestClassFile, "org/foo/echo/Plugin3Echo.class");
final TestArtifactDescriptor artifactFileBuilder = new ApplicationFileBuilder("plugin-depending-on-plugin-app").definedBy("plugin-depending-on-plugin-app-config.xml").dependingOn(dependantPlugin);
addPackedAppFromBuilder(artifactFileBuilder);
startDeployment();
assertDeploymentSuccess(applicationDeploymentListener, artifactFileBuilder.getId());
try {
executeApplicationFlow("main");
fail("Expected to fail as there should be a missing class");
} catch (Exception e) {
assertThat(e.getCause().getCause(), instanceOf(MuleFatalException.class));
assertThat(e.getCause().getCause().getCause(), instanceOf(NoClassDefFoundError.class));
assertThat(e.getCause().getCause().getCause().getMessage(), containsString("org/foo/EchoTest"));
}
}
use of org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder in project mule by mulesoft.
the class ApplicationDeploymentTestCase method deploysAppWithExportedPackagePrecedenceOverPlugin.
@Test
public void deploysAppWithExportedPackagePrecedenceOverPlugin() throws Exception {
// Defines a plugin that contains org.bar package, which is also exported on the application
ArtifactPluginFileBuilder echoPluginWithoutLib1 = new ArtifactPluginFileBuilder("echoPlugin1").configuredWith(EXPORTED_CLASS_PACKAGES_PROPERTY, "org.foo").containingClass(pluginEcho1TestClassFile, "org/foo/Plugin1Echo.class").dependingOn(new JarFileBuilder("barUtils2_0", barUtils2_0JarFile));
ApplicationFileBuilder sharedLibPluginAppFileBuilder = new ApplicationFileBuilder("shared-plugin-lib-app").definedBy("app-with-echo1-plugin-config.xml").dependingOn(echoPluginWithoutLib1).dependingOnSharedLibrary(new JarFileBuilder("barUtils", barUtils1_0JarFile));
addPackedAppFromBuilder(sharedLibPluginAppFileBuilder);
startDeployment();
assertApplicationDeploymentSuccess(applicationDeploymentListener, sharedLibPluginAppFileBuilder.getId());
assertAppsDir(NONE, new String[] { sharedLibPluginAppFileBuilder.getId() }, true);
assertApplicationAnchorFileExists(sharedLibPluginAppFileBuilder.getId());
executeApplicationFlow("main");
}
Aggregations