Search in sources :

Example 6 with FileHelper

use of com.thoughtworks.go.plugin.FileHelper in project gocd by gocd.

the class FelixGoPluginOSGiFrameworkIntegrationTest method setUp.

@BeforeEach
void setUp(@TempDir File rootDir) throws Exception {
    temporaryFolder = new FileHelper(rootDir);
    registry = new DefaultPluginRegistry();
    systemEnvironment = new SystemEnvironment();
    pluginOSGiFramework = new FelixGoPluginOSGiFramework(registry, systemEnvironment) {

        @Override
        protected HashMap<String, String> generateOSGiFrameworkConfig() {
            HashMap<String, String> config = super.generateOSGiFrameworkConfig();
            config.put(FelixConstants.RESOLVER_PARALLELISM, "1");
            return config;
        }
    };
    pluginOSGiFramework.start();
    try (ZipInputStream zippedOSGiBundleFile = new ZipInputStream(FileUtils.openInputStream(pathOfFileInDefaultFiles("descriptor-aware-test-plugin.osgi.jar")))) {
        descriptorBundleDir = explodeBundleIntoDirectory(zippedOSGiBundleFile, "descriptor-plugin-bundle-dir");
    }
    try (ZipInputStream zippedOSGiBundleFile = new ZipInputStream(FileUtils.openInputStream(pathOfFileInDefaultFiles("error-generating-descriptor-aware-test-plugin.osgi.jar")))) {
        errorGeneratingDescriptorBundleDir = explodeBundleIntoDirectory(zippedOSGiBundleFile, "error-generating-descriptor-plugin-bundle-dir");
    }
    try (ZipInputStream zippedOSGiBundleFile = new ZipInputStream(FileUtils.openInputStream(pathOfFileInDefaultFiles("exception-throwing-at-load-plugin.osgi.jar")))) {
        exceptionThrowingAtLoadDescriptorBundleDir = explodeBundleIntoDirectory(zippedOSGiBundleFile, "exception-throwing-at-load-plugin-bundle-dir");
    }
    try (ZipInputStream zippedOSGiBundleFile = new ZipInputStream(FileUtils.openInputStream(pathOfFileInDefaultFiles("valid-plugin-with-multiple-extensions.osgi.jar")))) {
        validMultipleExtensionPluginBundleDir = explodeBundleIntoDirectory(zippedOSGiBundleFile, "valid-plugin-with-multiple-extensions");
    }
    try (ZipInputStream zippedOSGiBundleFile = new ZipInputStream(FileUtils.openInputStream(pathOfFileInDefaultFiles("dumb.plugin.that.responds.with.classloader.name.osgi.jar")))) {
        pluginToTestClassloadPluginBundleDir = explodeBundleIntoDirectory(zippedOSGiBundleFile, "plugin-to-test-classloader");
    }
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ZipInputStream(java.util.zip.ZipInputStream) FileHelper(com.thoughtworks.go.plugin.FileHelper) DefaultPluginRegistry(com.thoughtworks.go.plugin.infra.plugininfo.DefaultPluginRegistry) HashMap(java.util.HashMap) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with FileHelper

use of com.thoughtworks.go.plugin.FileHelper in project gocd by gocd.

the class DefaultPluginJarChangeListenerTest method setUp.

@BeforeEach
void setUp(@TempDir File rootDir) {
    temporaryFolder = new FileHelper(rootDir);
    bundleDir = temporaryFolder.newFolder("bundleDir");
    pluginWorkDir = temporaryFolder.newFolder("pluginDir");
    registry = mock(DefaultPluginRegistry.class);
    osgiManifestGenerator = mock(GoPluginOSGiManifest.DefaultGoPluginOSGiManifestCreator.class);
    pluginLoader = mock(PluginLoader.class);
    goPluginBundleDescriptorBuilder = mock(GoPluginBundleDescriptorBuilder.class);
    systemEnvironment = mock(SystemEnvironment.class);
    when(systemEnvironment.get(PLUGIN_ACTIVATOR_JAR_PATH)).thenReturn("defaultFiles/go-plugin-activator.jar");
    when(systemEnvironment.get(PLUGIN_WORK_DIR)).thenReturn(bundleDir.getAbsolutePath());
    when(systemEnvironment.getOperatingSystemFamilyName()).thenReturn("Linux");
    listener = new DefaultPluginJarChangeListener(registry, osgiManifestGenerator, pluginLoader, goPluginBundleDescriptorBuilder, systemEnvironment);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) FileHelper(com.thoughtworks.go.plugin.FileHelper) PluginLoader(com.thoughtworks.go.plugin.infra.PluginLoader) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with FileHelper

use of com.thoughtworks.go.plugin.FileHelper in project gocd by gocd.

the class DefaultPluginManagerTest method setUp.

@BeforeEach
void setUp(@TempDir File rootDir) {
    FileHelper temporaryFolder = new FileHelper(rootDir);
    bundleDir = temporaryFolder.newFolder("bundleDir");
    File pluginExternalDir = temporaryFolder.newFolder("externalDir");
    when(systemEnvironment.get(PLUGIN_WORK_DIR)).thenReturn(bundleDir.getAbsolutePath());
    when(systemEnvironment.get(PLUGIN_EXTERNAL_PROVIDED_PATH)).thenReturn(pluginExternalDir.getAbsolutePath());
}
Also used : FileHelper(com.thoughtworks.go.plugin.FileHelper) File(java.io.File) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 9 with FileHelper

use of com.thoughtworks.go.plugin.FileHelper in project gocd by gocd.

the class GoPluginBundleDescriptorBuilderTest method setUp.

@BeforeEach
void setUp(@TempDir File rootDir) {
    final FileHelper temporaryFolder = new FileHelper(rootDir);
    pluginDirectory = temporaryFolder.newFolder("pluginDir");
    bundleDirectory = temporaryFolder.newFolder("bundleDir");
    goPluginBundleDescriptorBuilder = spy(new GoPluginBundleDescriptorBuilder());
}
Also used : FileHelper(com.thoughtworks.go.plugin.FileHelper) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

FileHelper (com.thoughtworks.go.plugin.FileHelper)9 BeforeEach (org.junit.jupiter.api.BeforeEach)7 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)3 File (java.io.File)3 PluginLoader (com.thoughtworks.go.plugin.infra.PluginLoader)1 PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)1 DefaultPluginRegistry (com.thoughtworks.go.plugin.infra.plugininfo.DefaultPluginRegistry)1 GoPluginBundleDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginBundleDescriptor)1 HashMap (java.util.HashMap)1 ZipFile (java.util.zip.ZipFile)1 ZipInputStream (java.util.zip.ZipInputStream)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1