Search in sources :

Example 1 with ZipResource

use of org.mule.tck.ZipUtils.ZipResource in project mule by mulesoft.

the class FileUtilsTestCase method unzipsFileWithoutParentFolderEntry.

@Test
public void unzipsFileWithoutParentFolderEntry() throws Exception {
    final String resourceName = "dummy.xml";
    final String resourceAlias = "folder" + File.separator + resourceName;
    final File compressedFile = new File(toDir, "test.zip");
    compress(compressedFile, new ZipResource[] { new ZipResource(resourceName, resourceAlias) });
    unzip(compressedFile, toDir);
    assertThat(new File(new File(toDir, "folder"), resourceName).exists(), is(true));
}
Also used : ZipResource(org.mule.tck.ZipUtils.ZipResource) FileUtils.readFileToString(org.apache.commons.io.FileUtils.readFileToString) File(java.io.File) Test(org.junit.Test)

Example 2 with ZipResource

use of org.mule.tck.ZipUtils.ZipResource in project mule by mulesoft.

the class AbstractArtifactFileBuilder method createPropertiesFile.

protected ZipResource createPropertiesFile(Properties props, String propertiesFileName, String zipAlias) {
    ZipResource result = null;
    if (!props.isEmpty()) {
        final File applicationPropertiesFile = new File(getTempFolder(), propertiesFileName);
        applicationPropertiesFile.deleteOnExit();
        createPropertiesFile(applicationPropertiesFile, props);
        result = new ZipResource(applicationPropertiesFile.getAbsolutePath(), zipAlias);
    }
    return result;
}
Also used : ZipResource(org.mule.tck.ZipUtils.ZipResource) File(java.io.File)

Example 3 with ZipResource

use of org.mule.tck.ZipUtils.ZipResource in project mule by mulesoft.

the class ApplicationFileBuilder method usingResource.

/**
 * Adds a resource file to the artifact folder.
 *
 * @param resourceFile class file from a external file or test resource. Non empty.
 * @param targetFile name to use on the added resource. Non empty.
 * @return the same builder instance
 */
public ApplicationFileBuilder usingResource(String resourceFile, String targetFile) {
    checkImmutable();
    checkArgument(!isEmpty(resourceFile), "Resource file cannot be empty");
    resources.add(new ZipResource(resourceFile, targetFile));
    return getThis();
}
Also used : ZipResource(org.mule.tck.ZipUtils.ZipResource)

Example 4 with ZipResource

use of org.mule.tck.ZipUtils.ZipResource in project mule by mulesoft.

the class ApplicationFileBuilder method definedBy.

/**
 * Sets the configuration file used for the application.
 *
 * @param configFile application configuration from a external file or test resource. Non empty.
 * @return the same builder instance
 */
public ApplicationFileBuilder definedBy(String configFile) {
    checkImmutable();
    checkArgument(!StringUtils.isEmpty(configFile), "Config file cannot be empty");
    this.resources.add(new ZipResource(configFile, DEFAULT_CONFIGURATION_RESOURCE));
    return this;
}
Also used : ZipResource(org.mule.tck.ZipUtils.ZipResource)

Example 5 with ZipResource

use of org.mule.tck.ZipUtils.ZipResource in project mule by mulesoft.

the class ArtifactPluginFileBuilder method containingClass.

/**
 * Adds a class file to the artifact classes folder.
 *
 * @param classFile class file to include. Non null.
 * @param alias path where the file must be added inside the app file
 * @return the same builder instance
 */
@Override
public ArtifactPluginFileBuilder containingClass(File classFile, String alias) {
    checkImmutable();
    checkArgument(classFile != null, "Class file cannot be null");
    resources.add(new ZipResource(classFile.getAbsolutePath(), alias));
    return getThis();
}
Also used : ZipResource(org.mule.tck.ZipUtils.ZipResource)

Aggregations

ZipResource (org.mule.tck.ZipUtils.ZipResource)17 File (java.io.File)10 LinkedList (java.util.LinkedList)5 Test (org.junit.Test)4 FileUtils.readFileToString (org.apache.commons.io.FileUtils.readFileToString)3 FileUtils.writeStringToFile (org.apache.commons.io.FileUtils.writeStringToFile)3 IOException (java.io.IOException)2 MuleArtifactLoaderDescriptor (org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor)1 MuleArtifactLoaderDescriptorBuilder (org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder)1 MulePluginModel (org.mule.runtime.api.deployment.meta.MulePluginModel)1 MulePluginModelJsonSerializer (org.mule.runtime.api.deployment.persistence.MulePluginModelJsonSerializer)1 MulePolicyModelJsonSerializer (org.mule.runtime.api.deployment.persistence.MulePolicyModelJsonSerializer)1