use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class PluginsZipTest method fileAccessErrorShouldContainPathToTheFolderInWhichTheErrorOccurred.
@Test
public void fileAccessErrorShouldContainPathToTheFolderInWhichTheErrorOccurred() throws Exception {
SystemEnvironment systemEnvironmentFail = mock(SystemEnvironment.class);
when(systemEnvironmentFail.get(SystemEnvironment.PLUGIN_FRAMEWORK_ENABLED)).thenReturn(true);
when(systemEnvironmentFail.get(PLUGIN_GO_PROVIDED_PATH)).thenReturn("/dummy");
when(systemEnvironmentFail.get(PLUGIN_EXTERNAL_PROVIDED_PATH)).thenReturn(externalPluginsDir.getAbsolutePath());
when(systemEnvironmentFail.get(ALL_PLUGINS_ZIP_PATH)).thenReturn("");
FileUtils.writeStringToFile(new File(externalPluginsDir, "external1.jar"), "External1");
expectedException.expect(FileAccessRightsCheckException.class);
expectedException.expectMessage("dummy");
PluginsZip pluginsZipFail = new PluginsZip(systemEnvironmentFail, new ZipUtil());
pluginsZipFail.create();
}
use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class GoPluginOSGiManifestTest method createPluginBundle.
private File createPluginBundle(String bundleName) throws IOException, URISyntaxException {
File destinationPluginBundleLocation = new File(TMP_DIR, bundleName);
destinationPluginBundleLocation.mkdirs();
URL resource = getClass().getClassLoader().getResource("defaultFiles/descriptor-aware-test-plugin.jar");
new ZipUtil().unzip(new File(resource.toURI()), destinationPluginBundleLocation);
return destinationPluginBundleLocation;
}
use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class CommandRepositoryInitializerTest method setUp.
@Before
public void setUp() {
serverHealthService = mock(ServerHealthService.class);
systemEnvironment = mock(SystemEnvironment.class);
zipUtil = mock(ZipUtil.class);
zipInputStream = mock(ZipInputStream.class);
when(systemEnvironment.get(SystemEnvironment.VERSION_FILE_IN_DEFAULT_COMMAND_REPOSITORY)).thenReturn("version.txt");
CommandRepositoryInitializer initializer = new CommandRepositoryInitializer(systemEnvironment, zipUtil, serverHealthService);
spy = spy(initializer);
tempFiles = new TempFiles();
}
use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class PluginsInitializerTest method setUp.
@Before
public void setUp() throws Exception {
systemEnvironment = mock(SystemEnvironment.class);
serverVersion = mock(ServerVersion.class);
goPluginsDir = FileSystemUtils.createDirectory("go-plugins");
when(systemEnvironment.get(SystemEnvironment.PLUGIN_GO_PROVIDED_PATH)).thenReturn(goPluginsDir.getAbsolutePath());
when(systemEnvironment.get(SystemEnvironment.PLUGIN_FRAMEWORK_ENABLED)).thenReturn(true);
pluginManager = mock(PluginManager.class);
pluginsInitializer = spy(new PluginsInitializer(pluginManager, systemEnvironment, serverVersion, new ZipUtil()));
doReturn(new ZipInputStream(new FileInputStream(new File("test/data/dummy-plugins.zip")))).when(pluginsInitializer).getPluginsZipStream();
}
use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class PluginsInitializerTest method shouldUnzipPluginsAndRegisterZipUpdaterBeforeStartingPluginsFramework.
@Test
public void shouldUnzipPluginsAndRegisterZipUpdaterBeforeStartingPluginsFramework() throws IOException {
ZipUtil zipUtil = mock(ZipUtil.class);
pluginsInitializer = spy(new PluginsInitializer(pluginManager, systemEnvironment, serverVersion, zipUtil));
doReturn(new ZipInputStream(new FileInputStream(new File("test/data/dummy-plugins.zip")))).when(pluginsInitializer).getPluginsZipStream();
pluginsInitializer.initialize();
InOrder inOrder = inOrder(zipUtil, pluginManager);
inOrder.verify(zipUtil).unzip(Matchers.<ZipInputStream>any(), Matchers.<File>any());
inOrder.verify(pluginManager, times(1)).startInfrastructure(true);
inOrder.verify(pluginManager, times(1)).registerPluginsFolderChangeListener();
}
Aggregations