Search in sources :

Example 1 with SingleClassCompiler

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);
}
Also used : MuleArtifactLoaderDescriptor(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor) ArtifactPluginFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder) PolicyFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.PolicyFileBuilder) MulePolicyModelBuilder(org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder) URISyntaxException(java.net.URISyntaxException) SingleClassCompiler(org.mule.tck.util.CompilerUtils.SingleClassCompiler)

Example 2 with SingleClassCompiler

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");
}
Also used : ApplicationFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder) FileUtils.writeStringToFile(org.apache.commons.io.FileUtils.writeStringToFile) File(java.io.File) FileUtils.copyFile(org.apache.commons.io.FileUtils.copyFile) SingleClassCompiler(org.mule.tck.util.CompilerUtils.SingleClassCompiler) Issue(io.qameta.allure.Issue) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 3 with SingleClassCompiler

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);
}
Also used : JarFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder) ExtensionCompiler(org.mule.tck.util.CompilerUtils.ExtensionCompiler) JarCompiler(org.mule.tck.util.CompilerUtils.JarCompiler) SingleClassCompiler(org.mule.tck.util.CompilerUtils.SingleClassCompiler) BeforeClass(org.junit.BeforeClass)

Example 4 with SingleClassCompiler

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");
}
Also used : ArtifactPluginFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder) ApplicationFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder) FileUtils.writeStringToFile(org.apache.commons.io.FileUtils.writeStringToFile) File(java.io.File) FileUtils.copyFile(org.apache.commons.io.FileUtils.copyFile) SingleClassCompiler(org.mule.tck.util.CompilerUtils.SingleClassCompiler) Issue(io.qameta.allure.Issue) Description(io.qameta.allure.Description) Test(org.junit.Test)

Aggregations

SingleClassCompiler (org.mule.tck.util.CompilerUtils.SingleClassCompiler)4 Description (io.qameta.allure.Description)2 Issue (io.qameta.allure.Issue)2 File (java.io.File)2 FileUtils.copyFile (org.apache.commons.io.FileUtils.copyFile)2 FileUtils.writeStringToFile (org.apache.commons.io.FileUtils.writeStringToFile)2 Test (org.junit.Test)2 ApplicationFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder)2 ArtifactPluginFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder)2 URISyntaxException (java.net.URISyntaxException)1 BeforeClass (org.junit.BeforeClass)1 MuleArtifactLoaderDescriptor (org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor)1 MulePolicyModelBuilder (org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder)1 JarFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.JarFileBuilder)1 PolicyFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.PolicyFileBuilder)1 ExtensionCompiler (org.mule.tck.util.CompilerUtils.ExtensionCompiler)1 JarCompiler (org.mule.tck.util.CompilerUtils.JarCompiler)1