use of org.mule.tck.util.CompilerUtils.SingleClassCompiler in project mule by mulesoft.
the class AbstractDeploymentTestCase method createPolicyIncludingDependantPluginFileBuilder.
private PolicyFileBuilder createPolicyIncludingDependantPluginFileBuilder() {
MulePolicyModelBuilder mulePolicyModelBuilder = new MulePolicyModelBuilder().setMinMuleVersion(MIN_MULE_VERSION).setName(BAZ_POLICY_NAME).setRequiredProduct(Product.MULE).withBundleDescriptorLoader(createBundleDescriptorLoader(BAZ_POLICY_NAME, MULE_POLICY_CLASSIFIER, PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID)).withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap()));
ArtifactPluginFileBuilder dependantPlugin;
try {
dependantPlugin = new ArtifactPluginFileBuilder("dependantPlugin").configuredWith(EXPORTED_CLASS_PACKAGES_PROPERTY, "org.foo.echo").containingClass(new SingleClassCompiler().compile(getResourceFile("/org/foo/echo/Plugin3Echo.java")), "org/foo/echo/Plugin3Echo.class").dependingOn(helloExtensionV1Plugin);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
return new PolicyFileBuilder(BAZ_POLICY_NAME).describedBy(mulePolicyModelBuilder.build()).dependingOn(dependantPlugin);
}
use of org.mule.tck.util.CompilerUtils.SingleClassCompiler in project mule by mulesoft.
the class ApplicationDeploymentTestCase method deploysAppWithInterceptorsAndNotExportedPackage.
@Test
@Issue("MULE-13756")
@Description("Tests that code called form application's ProcessorInterceptor can access internal resources/packages of the application")
public void deploysAppWithInterceptorsAndNotExportedPackage() throws Exception {
File loadsOwnResourceInterceptorFactoryClassFile = new SingleClassCompiler().compile(getResourceFile("/org/foo/LoadsOwnResourceInterceptorFactory.java"));
File loadsOwnResourceInterceptorClassFile = new SingleClassCompiler().compile(getResourceFile("/org/foo/LoadsOwnResourceInterceptor.java"));
ApplicationFileBuilder nonExposingAppFileBuilder = new ApplicationFileBuilder("non-exposing-app").configuredWith(EXPORTED_PACKAGES, "org.bar1").configuredWith(EXPORTED_RESOURCES, "test-resource.txt").definedBy("app-with-interceptor.xml").containingClass(loadsOwnResourceInterceptorFactoryClassFile, "org/foo/LoadsOwnResourceInterceptorFactory.class").containingClass(loadsOwnResourceInterceptorClassFile, "org/foo/LoadsOwnResourceInterceptor.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.tck.util.CompilerUtils.SingleClassCompiler in project mule by mulesoft.
the class AbstractDeploymentTestCase method beforeClass.
@BeforeClass
public static void beforeClass() throws URISyntaxException, IllegalAccessException {
barUtils1ClassFile = new SingleClassCompiler().compile(getResourceFile("/org/bar1/BarUtils.java"));
barUtils1_0JarFile = new JarFileBuilder("barUtils1", new JarCompiler().compiling(getResourceFile("/org/bar1/BarUtils.java")).compile("bar-1.0.jar")).getArtifactFile();
barUtils2ClassFile = new SingleClassCompiler().compile(getResourceFile("/org/bar2/BarUtils.java"));
barUtils2_0JarFile = new JarCompiler().compiling(getResourceFile("/org/bar2/BarUtils.java")).compile("bar-2.0.jar");
echoTestJarFile = new JarCompiler().compiling(getResourceFile("/org/foo/EchoTest.java")).compile("echo.jar");
defaulServiceEchoJarFile = new JarCompiler().compiling(getResourceFile("/org/mule/echo/DefaultEchoService.java"), getResourceFile("/org/mule/echo/EchoServiceProvider.java")).compile("mule-module-service-echo-default-4.0-SNAPSHOT.jar");
defaultFooServiceJarFile = new JarCompiler().compiling(getResourceFile("/org/mule/service/foo/DefaultFooService.java"), getResourceFile("/org/mule/service/foo/FooServiceProvider.java")).dependingOn(defaulServiceEchoJarFile.getAbsoluteFile()).compile("mule-module-service-foo-default-4.0-SNAPSHOT.jar");
helloExtensionV1JarFile = new ExtensionCompiler().compiling(getResourceFile("/org/foo/hello/HelloExtension.java"), getResourceFile("/org/foo/hello/HelloOperation.java")).including(getResourceFile("/org/foo/hello/registry-bootstrap.properties"), "META-INF/org/mule/runtime/core/config/registry-bootstrap.properties").compile("mule-module-hello-1.0.0.jar", "1.0.0");
helloExtensionV2JarFile = new ExtensionCompiler().compiling(getResourceFile("/org/foo/hello/HelloExtension.java"), getResourceFile("/org/foo/hello/HelloOperation.java")).compile("mule-module-hello-2.0.0.jar", "2.0.0");
echoTestClassFile = new SingleClassCompiler().compile(getResourceFile("/org/foo/EchoTest.java"));
loadsAppResourceCallbackClassFile = new SingleClassCompiler().compile(getResourceFile("/org/foo/LoadsAppResourceCallback.java"));
pluginEcho1TestClassFile = new SingleClassCompiler().dependingOn(barUtils1_0JarFile).compile(getResourceFile("/org/foo/Plugin1Echo.java"));
internalIsRunningTests = (Boolean) readDeclaredStaticField(ModuleDelegatingEntityResolver.class, "internalIsRunningTests", true);
writeDeclaredStaticField(ModuleDelegatingEntityResolver.class, "internalIsRunningTests", true, true);
}
use of org.mule.tck.util.CompilerUtils.SingleClassCompiler 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");
}
Aggregations