com.google.cloud.tools.managedcloudsdk.install.SdkInstallerException Java Examples
The following examples show how to use
com.google.cloud.tools.managedcloudsdk.install.SdkInstallerException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DownloadCloudSdkTaskTest.java From app-gradle-plugin with Apache License 2.0 | 6 votes |
@Test public void testDownloadCloudSdkAction_installMultipleComponents() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, CommandExecutionException, SdkInstallerException, IOException, CommandExitException { downloadCloudSdkTask.setManagedCloudSdk(managedCloudSdk); downloadCloudSdkTask.requiresComponent(SdkComponent.APP_ENGINE_JAVA); downloadCloudSdkTask.requiresComponent(SdkComponent.BETA); when(managedCloudSdk.isInstalled()).thenReturn(true); when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(false); when(managedCloudSdk.hasComponent(SdkComponent.BETA)).thenReturn(false); downloadCloudSdkTask.downloadCloudSdkAction(); verify(managedCloudSdk, never()).newInstaller(); verify(managedCloudSdk, times(2)).newComponentInstaller(); verify(componentInstaller).installComponent(eq(SdkComponent.APP_ENGINE_JAVA), any(), any()); verify(componentInstaller).installComponent(eq(SdkComponent.BETA), any(), any()); }
Example #2
Source File: DownloadCloudSdkTaskTest.java From app-gradle-plugin with Apache License 2.0 | 6 votes |
@Test public void testDownloadCloudSdkAction_installSomeOfMultipleComponents() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, CommandExecutionException, SdkInstallerException, IOException, CommandExitException { downloadCloudSdkTask.setManagedCloudSdk(managedCloudSdk); downloadCloudSdkTask.requiresComponent(SdkComponent.APP_ENGINE_JAVA); downloadCloudSdkTask.requiresComponent(SdkComponent.BETA); when(managedCloudSdk.isInstalled()).thenReturn(true); when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(false); when(managedCloudSdk.hasComponent(SdkComponent.BETA)).thenReturn(true); downloadCloudSdkTask.downloadCloudSdkAction(); verify(managedCloudSdk, never()).newInstaller(); verify(managedCloudSdk).newComponentInstaller(); verify(componentInstaller).installComponent(eq(SdkComponent.APP_ENGINE_JAVA), any(), any()); }
Example #3
Source File: CloudSdkInstallJobTest.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@Test public void testRun_notInstalled() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, IOException, SdkInstallerException, CommandExecutionException, CommandExitException { when(managedCloudSdk.isInstalled()).thenReturn(false); when(managedCloudSdk.hasComponent(any(SdkComponent.class))).thenReturn(false); CloudSdkInstallJob job = newCloudSdkInstallJob(); job.schedule(); job.join(); assertTrue(job.getResult().isOK()); verify(managedCloudSdk).newInstaller(); verify(managedCloudSdk).newComponentInstaller(); verify(sdkInstaller).install(any(ProgressListener.class), any(ConsoleListener.class)); verify(componentInstaller) .installComponent( any(SdkComponent.class), any(ProgressListener.class), any(ConsoleListener.class)); }
Example #4
Source File: CloudSdkInstallJobTest.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@Test public void testFailureSeverity() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, IOException, SdkInstallerException, CommandExecutionException, CommandExitException { when(managedCloudSdk.isInstalled()).thenReturn(false); when(managedCloudSdk.hasComponent(any(SdkComponent.class))).thenReturn(false); SdkInstallerException installerException = new SdkInstallerException("unsupported"); when(managedCloudSdk.newInstaller()).thenReturn(sdkInstaller); when(sdkInstaller.install(any(ProgressWrapper.class), any(ConsoleListener.class))) .thenThrow(installerException); CloudSdkInstallJob job = newCloudSdkInstallJob(); job.schedule(); job.join(); IStatus result = job.getResult(); assertEquals(IStatus.WARNING, result.getSeverity()); assertEquals("Failed to install the Google Cloud SDK.", result.getMessage()); assertEquals(installerException, result.getException()); }
Example #5
Source File: DownloadCloudSdkTask.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
/** Task entrypoint : Download/update Cloud SDK. */ @TaskAction public void downloadCloudSdkAction() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, CommandExecutionException, SdkInstallerException, CommandExitException, IOException { // managedCloudSdk is set by AppEngineCorePluginConfiguration if the cloud SDK home is empty if (managedCloudSdk == null) { throw new GradleException("Cloud SDK home path must not be configured to run this task."); } ProgressListener progressListener = new NoOpProgressListener(); ConsoleListener consoleListener = new DownloadCloudSdkTaskConsoleListener(getProject()); // Install sdk if not installed if (!managedCloudSdk.isInstalled()) { SdkInstaller installer = managedCloudSdk.newInstaller(); installer.install(progressListener, consoleListener); } // install components if (components != null) { for (SdkComponent component : components) { if (!managedCloudSdk.hasComponent(component)) { managedCloudSdk .newComponentInstaller() .installComponent(component, progressListener, consoleListener); } } } // If version is set to LATEST, update Cloud SDK if (!managedCloudSdk.isUpToDate()) { SdkUpdater updater = managedCloudSdk.newUpdater(); updater.update(progressListener, consoleListener); } }
Example #6
Source File: DownloadCloudSdkTaskTest.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
@Test public void testDownloadCloudSdkAction_badConfigure() throws CommandExecutionException, InterruptedException, SdkInstallerException, ManagedSdkVersionMismatchException, CommandExitException, ManagedSdkVerificationException, IOException { downloadCloudSdkTask.setManagedCloudSdk(null); try { downloadCloudSdkTask.downloadCloudSdkAction(); Assert.fail(); } catch (GradleException ex) { Assert.assertEquals( "Cloud SDK home path must not be configured to run this task.", ex.getMessage()); } }
Example #7
Source File: DownloadCloudSdkTaskTest.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
@Test public void testDownloadCloudSdkAction_install() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, CommandExecutionException, SdkInstallerException, IOException, CommandExitException { downloadCloudSdkTask.setManagedCloudSdk(managedCloudSdk); when(managedCloudSdk.isInstalled()).thenReturn(false); downloadCloudSdkTask.downloadCloudSdkAction(); verify(managedCloudSdk).newInstaller(); verify(managedCloudSdk, never()).newComponentInstaller(); }
Example #8
Source File: DownloadCloudSdkTaskTest.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
@Test public void testDownloadCloudSdkAction_installComponent() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, CommandExecutionException, SdkInstallerException, IOException, CommandExitException { downloadCloudSdkTask.setManagedCloudSdk(managedCloudSdk); downloadCloudSdkTask.requiresComponent(SdkComponent.APP_ENGINE_JAVA); when(managedCloudSdk.isInstalled()).thenReturn(true); when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(false); downloadCloudSdkTask.downloadCloudSdkAction(); verify(managedCloudSdk, never()).newInstaller(); verify(managedCloudSdk).newComponentInstaller(); verify(componentInstaller).installComponent(eq(SdkComponent.APP_ENGINE_JAVA), any(), any()); }
Example #9
Source File: DownloadCloudSdkTaskTest.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
@Test public void testDownloadCloudSdkAction_skipInstallComponent() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, CommandExecutionException, SdkInstallerException, IOException, CommandExitException { downloadCloudSdkTask.setManagedCloudSdk(managedCloudSdk); downloadCloudSdkTask.requiresComponent(SdkComponent.APP_ENGINE_JAVA); when(managedCloudSdk.isInstalled()).thenReturn(true); when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(true); downloadCloudSdkTask.downloadCloudSdkAction(); verify(managedCloudSdk, never()).newInstaller(); verify(managedCloudSdk, never()).newComponentInstaller(); }
Example #10
Source File: DownloadCloudSdkTaskTest.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
@Test public void testDownloadCloudSdkAction_update() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, CommandExecutionException, SdkInstallerException, IOException, CommandExitException { downloadCloudSdkTask.setManagedCloudSdk(managedCloudSdk); when(managedCloudSdk.isInstalled()).thenReturn(true); when(managedCloudSdk.isUpToDate()).thenReturn(false); downloadCloudSdkTask.downloadCloudSdkAction(); verify(managedCloudSdk, never()).newInstaller(); verify(managedCloudSdk, never()).newComponentInstaller(); verify(managedCloudSdk).newUpdater(); }
Example #11
Source File: ManagedCloudSdkTest.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
@Test public void testManagedCloudSdk_fixedVersion() throws BadCloudSdkVersionException, UnsupportedOsException, IOException, CommandExitException, InterruptedException, ManagedSdkVerificationException, ManagedSdkVersionMismatchException, CommandExecutionException, SdkInstallerException { ManagedCloudSdk testSdk = new ManagedCloudSdk(new Version(FIXED_VERSION), userHome, OsInfo.getSystemOsInfo()); Assert.assertFalse(testSdk.isInstalled()); Assert.assertFalse(testSdk.hasComponent(testComponent)); Assert.assertFalse(testSdk.isUpToDate()); testSdk.newInstaller().install(testProgressListener, testListener); Assert.assertTrue(testSdk.isInstalled()); Assert.assertFalse(testSdk.hasComponent(testComponent)); Assert.assertTrue(testSdk.isUpToDate()); testSdk .newComponentInstaller() .installComponent(testComponent, testProgressListener, testListener); Assert.assertTrue(testSdk.isInstalled()); Assert.assertTrue(testSdk.hasComponent(testComponent)); Assert.assertTrue(testSdk.isUpToDate()); // Make sure we can't update a versioned cloud SDK. try { testSdk.newUpdater(); Assert.fail("UnsupportedOperationException expected but not thrown"); } catch (UnsupportedOperationException ex) { Assert.assertEquals("Cannot update a fixed version SDK.", ex.getMessage()); } }
Example #12
Source File: ManagedCloudSdkTest.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
@Test public void testManagedCloudSdk_latest() throws UnsupportedOsException, ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, CommandExecutionException, CommandExitException, IOException, SdkInstallerException { ManagedCloudSdk testSdk = new ManagedCloudSdk(Version.LATEST, userHome, OsInfo.getSystemOsInfo()); Assert.assertFalse(testSdk.isInstalled()); Assert.assertFalse(testSdk.isUpToDate()); testSdk.newInstaller().install(testProgressListener, testListener); Assert.assertTrue(testSdk.isInstalled()); Assert.assertTrue(testSdk.isUpToDate()); // Forcibly downgrade the cloud SDK so we can test updating. downgradeCloudSdk(testSdk); Assert.assertTrue(testSdk.isInstalled()); Assert.assertFalse(testSdk.isUpToDate()); testSdk.newUpdater().update(testProgressListener, testListener); Assert.assertTrue(testSdk.isInstalled()); Assert.assertFalse(testSdk.hasComponent(testComponent)); Assert.assertTrue(testSdk.isUpToDate()); testSdk .newComponentInstaller() .installComponent(testComponent, testProgressListener, testListener); Assert.assertTrue(testSdk.isInstalled()); Assert.assertTrue(testSdk.hasComponent(testComponent)); Assert.assertTrue(testSdk.isUpToDate()); }
Example #13
Source File: CloudSdkDownloader.java From app-maven-plugin with Apache License 2.0 | 4 votes |
/** * Downloads/installs/updates the Cloud SDK. * * @return The cloud SDK installation directory */ public Path downloadIfNecessary( String version, Log log, List<SdkComponent> components, boolean offline) { ManagedCloudSdk managedCloudSdk = managedCloudSdkFactory.apply(version); if (offline) { // in offline mode, don't download anything return managedCloudSdk.getSdkHome(); } try { ProgressListener progressListener = new NoOpProgressListener(); ConsoleListener consoleListener = new CloudSdkDownloaderConsoleListener(log); if (!managedCloudSdk.isInstalled()) { managedCloudSdk.newInstaller().install(progressListener, consoleListener); } // install requested components if (components != null) { for (SdkComponent component : components) { if (!managedCloudSdk.hasComponent(component)) { managedCloudSdk .newComponentInstaller() .installComponent(component, progressListener, consoleListener); } } } if (!managedCloudSdk.isUpToDate()) { managedCloudSdk.newUpdater().update(progressListener, consoleListener); } return managedCloudSdk.getSdkHome(); } catch (IOException | SdkInstallerException | ManagedSdkVersionMismatchException | InterruptedException | CommandExecutionException | CommandExitException | ManagedSdkVerificationException ex) { throw new RuntimeException(ex); } }