From 5f53f07b5ac42d0389f837ea0495a9814bd9917f Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Mon, 16 Dec 2024 17:23:08 -0800 Subject: [PATCH] Organize imports --- .../java/hudson/plugins/ec2/CloudHelper.java | 4 +- .../java/hudson/plugins/ec2/EC2Cloud.java | 43 ++++++++++++++----- .../java/hudson/plugins/ec2/EC2Computer.java | 6 ++- .../plugins/ec2/EC2HostAddressProvider.java | 6 +-- .../hudson/plugins/ec2/EC2OndemandSlave.java | 2 +- .../hudson/plugins/ec2/EC2PrivateKey.java | 4 +- .../hudson/plugins/ec2/EC2SlaveMonitor.java | 5 +-- src/main/java/hudson/plugins/ec2/EC2Step.java | 12 +++++- .../hudson/plugins/ec2/SlaveTemplate.java | 40 ++++++++--------- .../hudson/plugins/ec2/SpotConfiguration.java | 5 +-- .../plugins/ec2/ssh/EC2MacLauncher.java | 23 ++++++++-- .../plugins/ec2/ssh/EC2UnixLauncher.java | 11 ++++- .../plugins/ec2/util/EC2AgentFactory.java | 3 +- .../plugins/ec2/util/EC2AgentFactoryImpl.java | 3 +- .../plugins/ec2/win/EC2WindowsLauncher.java | 7 ++- .../win/winrm/NegotiateNTLMSchemaFactory.java | 6 ++- .../plugins/ec2/AmazonEC2CloudTest.java | 3 +- .../plugins/ec2/AmazonEC2CloudUnitTest.java | 5 +-- .../plugins/ec2/ConfigurationAsCodeTest.java | 22 +++++----- .../plugins/ec2/EC2AbstractSlaveTest.java | 20 ++++----- .../plugins/ec2/EC2CloudMigrationTest.java | 4 +- .../java/hudson/plugins/ec2/EC2CloudTest.java | 4 +- .../ec2/EC2HostAddressProviderTest.java | 21 +++++---- .../plugins/ec2/SlaveTemplateUnitTest.java | 9 +++- .../ec2/util/AmazonEC2FactoryMockImpl.java | 34 ++++++++++++++- .../ec2/util/EC2AgentFactoryMockImpl.java | 9 +++- .../plugins/ec2/win/WinConnectionTest.java | 2 +- 27 files changed, 208 insertions(+), 105 deletions(-) diff --git a/src/main/java/hudson/plugins/ec2/CloudHelper.java b/src/main/java/hudson/plugins/ec2/CloudHelper.java index 158078051..86e631616 100644 --- a/src/main/java/hudson/plugins/ec2/CloudHelper.java +++ b/src/main/java/hudson/plugins/ec2/CloudHelper.java @@ -1,7 +1,5 @@ package hudson.plugins.ec2; -import static hudson.plugins.ec2.EC2Cloud.EC2_REQUEST_EXPIRED_ERROR_CODE; - import com.amazonaws.AmazonClientException; import com.amazonaws.AmazonServiceException; import com.amazonaws.services.ec2.AmazonEC2; @@ -32,7 +30,7 @@ static Instance getInstanceWithRetry(String instanceId, EC2Cloud cloud) return getInstance(instanceId, cloud); } catch (AmazonServiceException e) { if (e.getErrorCode().equals("InvalidInstanceID.NotFound") - || EC2_REQUEST_EXPIRED_ERROR_CODE.equals(e.getErrorCode())) { + || EC2Cloud.EC2_REQUEST_EXPIRED_ERROR_CODE.equals(e.getErrorCode())) { // retry in 5 seconds. Thread.sleep(5000); continue; diff --git a/src/main/java/hudson/plugins/ec2/EC2Cloud.java b/src/main/java/hudson/plugins/ec2/EC2Cloud.java index 44cd7057d..28302e62a 100644 --- a/src/main/java/hudson/plugins/ec2/EC2Cloud.java +++ b/src/main/java/hudson/plugins/ec2/EC2Cloud.java @@ -18,9 +18,6 @@ */ package hudson.plugins.ec2; -import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST; -import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR; - import com.amazonaws.AmazonClientException; import com.amazonaws.AmazonServiceException; import com.amazonaws.ClientConfiguration; @@ -31,7 +28,19 @@ import com.amazonaws.auth.InstanceProfileCredentialsProvider; import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider; import com.amazonaws.services.ec2.AmazonEC2; -import com.amazonaws.services.ec2.model.*; +import com.amazonaws.services.ec2.model.DescribeInstancesRequest; +import com.amazonaws.services.ec2.model.DescribeInstancesResult; +import com.amazonaws.services.ec2.model.DescribeSpotInstanceRequestsRequest; +import com.amazonaws.services.ec2.model.DescribeSpotInstanceRequestsResult; +import com.amazonaws.services.ec2.model.Filter; +import com.amazonaws.services.ec2.model.Instance; +import com.amazonaws.services.ec2.model.InstanceStateName; +import com.amazonaws.services.ec2.model.InstanceType; +import com.amazonaws.services.ec2.model.KeyPair; +import com.amazonaws.services.ec2.model.KeyPairInfo; +import com.amazonaws.services.ec2.model.Reservation; +import com.amazonaws.services.ec2.model.SpotInstanceRequest; +import com.amazonaws.services.ec2.model.Tag; import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3ClientBuilder; import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest; @@ -81,7 +90,17 @@ import java.net.MalformedURLException; import java.net.Proxy; import java.net.URL; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.UUID; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; @@ -90,6 +109,7 @@ import java.util.logging.Logger; import java.util.logging.SimpleFormatter; import javax.servlet.ServletException; +import javax.servlet.http.HttpServletResponse; import jenkins.model.Jenkins; import jenkins.model.JenkinsLocationConfiguration; import org.apache.commons.lang.StringUtils; @@ -505,25 +525,26 @@ public void doAttach(StaplerRequest req, StaplerResponse rsp, @QueryParameter St public HttpResponse doProvision(@QueryParameter String template) throws ServletException, IOException { checkPermission(PROVISION); if (template == null) { - throw HttpResponses.error(SC_BAD_REQUEST, "The 'template' query parameter is missing"); + throw HttpResponses.error(HttpServletResponse.SC_BAD_REQUEST, "The 'template' query parameter is missing"); } SlaveTemplate t = getTemplate(template); if (t == null) { - throw HttpResponses.error(SC_BAD_REQUEST, "No such template: " + template); + throw HttpResponses.error(HttpServletResponse.SC_BAD_REQUEST, "No such template: " + template); } final Jenkins jenkinsInstance = Jenkins.get(); if (jenkinsInstance.isQuietingDown()) { - throw HttpResponses.error(SC_BAD_REQUEST, "Jenkins instance is quieting down"); + throw HttpResponses.error(HttpServletResponse.SC_BAD_REQUEST, "Jenkins instance is quieting down"); } if (jenkinsInstance.isTerminating()) { - throw HttpResponses.error(SC_BAD_REQUEST, "Jenkins instance is terminating"); + throw HttpResponses.error(HttpServletResponse.SC_BAD_REQUEST, "Jenkins instance is terminating"); } try { List nodes = getNewOrExistingAvailableSlave(t, 1, true); if (nodes == null || nodes.isEmpty()) { throw HttpResponses.error( - SC_BAD_REQUEST, "Cloud or AMI instance cap would be exceeded for: " + template); + HttpServletResponse.SC_BAD_REQUEST, + "Cloud or AMI instance cap would be exceeded for: " + template); } // Reconnect a stopped instance, the ADD is invoking the connect only for the node creation @@ -536,7 +557,7 @@ public HttpResponse doProvision(@QueryParameter String template) throws ServletE return HttpResponses.redirectViaContextPath( "/computer/" + nodes.get(0).getNodeName()); } catch (AmazonClientException e) { - throw HttpResponses.error(SC_INTERNAL_SERVER_ERROR, e); + throw HttpResponses.error(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e); } } diff --git a/src/main/java/hudson/plugins/ec2/EC2Computer.java b/src/main/java/hudson/plugins/ec2/EC2Computer.java index 03e7b2494..44aa9dc19 100644 --- a/src/main/java/hudson/plugins/ec2/EC2Computer.java +++ b/src/main/java/hudson/plugins/ec2/EC2Computer.java @@ -25,7 +25,11 @@ import com.amazonaws.AmazonClientException; import com.amazonaws.services.ec2.AmazonEC2; -import com.amazonaws.services.ec2.model.*; +import com.amazonaws.services.ec2.model.DescribeInstanceTypesRequest; +import com.amazonaws.services.ec2.model.DescribeInstanceTypesResult; +import com.amazonaws.services.ec2.model.GetConsoleOutputRequest; +import com.amazonaws.services.ec2.model.GetConsoleOutputResult; +import com.amazonaws.services.ec2.model.Instance; import edu.umd.cs.findbugs.annotations.CheckForNull; import hudson.Util; import hudson.model.Node; diff --git a/src/main/java/hudson/plugins/ec2/EC2HostAddressProvider.java b/src/main/java/hudson/plugins/ec2/EC2HostAddressProvider.java index d36c04283..009ee0db9 100644 --- a/src/main/java/hudson/plugins/ec2/EC2HostAddressProvider.java +++ b/src/main/java/hudson/plugins/ec2/EC2HostAddressProvider.java @@ -1,7 +1,5 @@ package hudson.plugins.ec2; -import static hudson.plugins.ec2.ConnectionStrategy.*; - import com.amazonaws.services.ec2.model.Instance; import java.util.Optional; import org.apache.commons.lang.StringUtils; @@ -38,9 +36,9 @@ public static String mac(Instance instance, ConnectionStrategy strategy) { } public static String windows(Instance instance, ConnectionStrategy strategy) { - if (strategy.equals(PRIVATE_DNS) || strategy.equals(PRIVATE_IP)) { + if (strategy.equals(ConnectionStrategy.PRIVATE_DNS) || strategy.equals(ConnectionStrategy.PRIVATE_IP)) { return getPrivateIpAddress(instance); - } else if (strategy.equals(PUBLIC_DNS) || strategy.equals(PUBLIC_IP)) { + } else if (strategy.equals(ConnectionStrategy.PUBLIC_DNS) || strategy.equals(ConnectionStrategy.PUBLIC_IP)) { return getPublicIpAddress(instance); } else { throw new IllegalArgumentException("Could not windows host address for strategy = " + strategy); diff --git a/src/main/java/hudson/plugins/ec2/EC2OndemandSlave.java b/src/main/java/hudson/plugins/ec2/EC2OndemandSlave.java index fe759f14a..c56c427d5 100644 --- a/src/main/java/hudson/plugins/ec2/EC2OndemandSlave.java +++ b/src/main/java/hudson/plugins/ec2/EC2OndemandSlave.java @@ -2,7 +2,7 @@ import com.amazonaws.AmazonClientException; import com.amazonaws.services.ec2.AmazonEC2; -import com.amazonaws.services.ec2.model.*; +import com.amazonaws.services.ec2.model.TerminateInstancesRequest; import hudson.Extension; import hudson.model.Computer; import hudson.model.Descriptor.FormException; diff --git a/src/main/java/hudson/plugins/ec2/EC2PrivateKey.java b/src/main/java/hudson/plugins/ec2/EC2PrivateKey.java index 30f708bb9..b77a8fc06 100644 --- a/src/main/java/hudson/plugins/ec2/EC2PrivateKey.java +++ b/src/main/java/hudson/plugins/ec2/EC2PrivateKey.java @@ -23,8 +23,6 @@ */ package hudson.plugins.ec2; -import static hudson.plugins.ec2.EC2Cloud.SSH_PRIVATE_KEY_FILEPATH; - import com.amazonaws.AmazonClientException; import com.amazonaws.services.ec2.AmazonEC2; import com.amazonaws.services.ec2.model.KeyPairInfo; @@ -155,7 +153,7 @@ public String decryptWindowsPassword(String encodedPassword) throws AmazonClient /* visible for testing */ @CheckForNull public static EC2PrivateKey fetchFromDisk() { - return fetchFromDisk(System.getProperty(SSH_PRIVATE_KEY_FILEPATH, "")); + return fetchFromDisk(System.getProperty(EC2Cloud.SSH_PRIVATE_KEY_FILEPATH, "")); } @CheckForNull diff --git a/src/main/java/hudson/plugins/ec2/EC2SlaveMonitor.java b/src/main/java/hudson/plugins/ec2/EC2SlaveMonitor.java index 5209c89b6..192d3b64c 100644 --- a/src/main/java/hudson/plugins/ec2/EC2SlaveMonitor.java +++ b/src/main/java/hudson/plugins/ec2/EC2SlaveMonitor.java @@ -1,7 +1,5 @@ package hudson.plugins.ec2; -import static hudson.plugins.ec2.EC2Cloud.EC2_REQUEST_EXPIRED_ERROR_CODE; - import com.amazonaws.AmazonClientException; import com.amazonaws.services.ec2.model.AmazonEC2Exception; import hudson.Extension; @@ -52,7 +50,8 @@ private void removeDeadNodes() { } } catch (AmazonClientException e) { if (e instanceof AmazonEC2Exception - && EC2_REQUEST_EXPIRED_ERROR_CODE.equals(((AmazonEC2Exception) e).getErrorCode())) { + && EC2Cloud.EC2_REQUEST_EXPIRED_ERROR_CODE.equals( + ((AmazonEC2Exception) e).getErrorCode())) { LOGGER.info("EC2 request expired, skipping consideration of " + ec2Slave.getInstanceId() + " due to unknown state."); } else { diff --git a/src/main/java/hudson/plugins/ec2/EC2Step.java b/src/main/java/hudson/plugins/ec2/EC2Step.java index 9407462cf..57135242c 100644 --- a/src/main/java/hudson/plugins/ec2/EC2Step.java +++ b/src/main/java/hudson/plugins/ec2/EC2Step.java @@ -29,9 +29,17 @@ import hudson.model.TaskListener; import hudson.slaves.Cloud; import hudson.util.ListBoxModel; -import java.util.*; +import java.util.Collections; +import java.util.EnumSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; import jenkins.model.Jenkins; -import org.jenkinsci.plugins.workflow.steps.*; +import org.jenkinsci.plugins.workflow.steps.Step; +import org.jenkinsci.plugins.workflow.steps.StepContext; +import org.jenkinsci.plugins.workflow.steps.StepDescriptor; +import org.jenkinsci.plugins.workflow.steps.StepExecution; +import org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.QueryParameter; import org.kohsuke.stapler.verb.POST; diff --git a/src/main/java/hudson/plugins/ec2/SlaveTemplate.java b/src/main/java/hudson/plugins/ec2/SlaveTemplate.java index eb878be26..859d2065d 100644 --- a/src/main/java/hudson/plugins/ec2/SlaveTemplate.java +++ b/src/main/java/hudson/plugins/ec2/SlaveTemplate.java @@ -18,12 +18,6 @@ */ package hudson.plugins.ec2; -import static hudson.plugins.ec2.EC2AbstractSlave.DEFAULT_JAVA_PATH; -import static hudson.plugins.ec2.EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED; -import static hudson.plugins.ec2.EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT; -import static hudson.plugins.ec2.EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED; -import static hudson.plugins.ec2.EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED; - import com.amazonaws.AmazonClientException; import com.amazonaws.AmazonServiceException; import com.amazonaws.auth.AWSCredentialsProvider; @@ -363,7 +357,7 @@ public SlaveTemplate( if (StringUtils.isNotBlank(javaPath)) { this.javaPath = javaPath; } else { - this.javaPath = DEFAULT_JAVA_PATH; + this.javaPath = EC2AbstractSlave.DEFAULT_JAVA_PATH; } this.jvmopts = jvmopts; @@ -409,12 +403,16 @@ public SlaveTemplate( : HostKeyVerificationStrategyEnum.CHECK_NEW_SOFT; this.tenancy = tenancy != null ? tenancy : Tenancy.Default; this.ebsEncryptRootVolume = ebsEncryptRootVolume != null ? ebsEncryptRootVolume : EbsEncryptRootVolume.DEFAULT; - this.metadataSupported = metadataSupported != null ? metadataSupported : DEFAULT_METADATA_SUPPORTED; - this.metadataEndpointEnabled = - metadataEndpointEnabled != null ? metadataEndpointEnabled : DEFAULT_METADATA_ENDPOINT_ENABLED; - this.metadataTokensRequired = - metadataTokensRequired != null ? metadataTokensRequired : DEFAULT_METADATA_TOKENS_REQUIRED; - this.metadataHopsLimit = metadataHopsLimit != null ? metadataHopsLimit : DEFAULT_METADATA_HOPS_LIMIT; + this.metadataSupported = + metadataSupported != null ? metadataSupported : EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED; + this.metadataEndpointEnabled = metadataEndpointEnabled != null + ? metadataEndpointEnabled + : EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED; + this.metadataTokensRequired = metadataTokensRequired != null + ? metadataTokensRequired + : EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED; + this.metadataHopsLimit = + metadataHopsLimit != null ? metadataHopsLimit : EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT; readResolve(); // initialize } @@ -481,7 +479,7 @@ public SlaveTemplate( numExecutors, remoteAdmin, amiType, - DEFAULT_JAVA_PATH, + EC2AbstractSlave.DEFAULT_JAVA_PATH, jvmopts, stopOnTerminate, subnetId, @@ -508,7 +506,7 @@ public SlaveTemplate( metadataEndpointEnabled, metadataTokensRequired, metadataHopsLimit, - DEFAULT_METADATA_SUPPORTED); + EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED); } @Deprecated @@ -569,7 +567,7 @@ public SlaveTemplate( numExecutors, remoteAdmin, amiType, - DEFAULT_JAVA_PATH, + EC2AbstractSlave.DEFAULT_JAVA_PATH, jvmopts, stopOnTerminate, subnetId, @@ -593,10 +591,10 @@ public SlaveTemplate( hostKeyVerificationStrategy, tenancy, null, - DEFAULT_METADATA_ENDPOINT_ENABLED, - DEFAULT_METADATA_TOKENS_REQUIRED, - DEFAULT_METADATA_HOPS_LIMIT, - DEFAULT_METADATA_SUPPORTED); + EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED, + EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED, + EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT, + EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED); } @Deprecated @@ -2687,7 +2685,7 @@ protected Object readResolve() { metadataHopsLimit = EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT; } if (StringUtils.isBlank(javaPath)) { - javaPath = DEFAULT_JAVA_PATH; + javaPath = EC2AbstractSlave.DEFAULT_JAVA_PATH; } return this; diff --git a/src/main/java/hudson/plugins/ec2/SpotConfiguration.java b/src/main/java/hudson/plugins/ec2/SpotConfiguration.java index ee5a1bb52..577a55370 100644 --- a/src/main/java/hudson/plugins/ec2/SpotConfiguration.java +++ b/src/main/java/hudson/plugins/ec2/SpotConfiguration.java @@ -1,7 +1,5 @@ package hudson.plugins.ec2; -import static hudson.Functions.checkPermission; - import com.amazonaws.AmazonServiceException; import com.amazonaws.auth.AWSCredentialsProvider; import com.amazonaws.services.ec2.AmazonEC2; @@ -11,6 +9,7 @@ import com.amazonaws.services.ec2.model.InstanceType; import com.amazonaws.services.ec2.model.SpotPrice; import hudson.Extension; +import hudson.Functions; import hudson.model.AbstractDescribableImpl; import hudson.model.Descriptor; import hudson.plugins.ec2.util.AmazonEC2Factory; @@ -150,7 +149,7 @@ public FormValidation doCurrentSpotPrice( @QueryParameter String ami) throws IOException, ServletException { - checkPermission(EC2Cloud.PROVISION); + Functions.checkPermission(EC2Cloud.PROVISION); String cp = ""; String zoneStr = ""; diff --git a/src/main/java/hudson/plugins/ec2/ssh/EC2MacLauncher.java b/src/main/java/hudson/plugins/ec2/ssh/EC2MacLauncher.java index c26805e23..9ab15d263 100644 --- a/src/main/java/hudson/plugins/ec2/ssh/EC2MacLauncher.java +++ b/src/main/java/hudson/plugins/ec2/ssh/EC2MacLauncher.java @@ -26,20 +26,37 @@ import com.amazonaws.AmazonClientException; import com.amazonaws.services.ec2.model.Instance; import com.amazonaws.services.ec2.model.KeyPair; -import com.trilead.ssh2.*; +import com.trilead.ssh2.Connection; +import com.trilead.ssh2.HTTPProxyData; +import com.trilead.ssh2.SCPClient; +import com.trilead.ssh2.ServerHostKeyVerifier; +import com.trilead.ssh2.Session; import hudson.FilePath; import hudson.ProxyConfiguration; import hudson.Util; import hudson.model.Descriptor; import hudson.model.TaskListener; -import hudson.plugins.ec2.*; +import hudson.plugins.ec2.ConnectionStrategy; +import hudson.plugins.ec2.EC2AbstractSlave; +import hudson.plugins.ec2.EC2Cloud; +import hudson.plugins.ec2.EC2Computer; +import hudson.plugins.ec2.EC2ComputerLauncher; +import hudson.plugins.ec2.EC2HostAddressProvider; +import hudson.plugins.ec2.EC2PrivateKey; +import hudson.plugins.ec2.EC2Readiness; +import hudson.plugins.ec2.EC2SpotSlave; +import hudson.plugins.ec2.SlaveTemplate; import hudson.plugins.ec2.ssh.verifiers.HostKey; import hudson.plugins.ec2.ssh.verifiers.Messages; import hudson.remoting.Channel; import hudson.remoting.Channel.Listener; import hudson.slaves.CommandLauncher; import hudson.slaves.ComputerLauncher; -import java.io.*; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.PrintStream; import java.net.InetSocketAddress; import java.net.Proxy; import java.nio.charset.StandardCharsets; diff --git a/src/main/java/hudson/plugins/ec2/ssh/EC2UnixLauncher.java b/src/main/java/hudson/plugins/ec2/ssh/EC2UnixLauncher.java index c81803fa5..f6194df8e 100644 --- a/src/main/java/hudson/plugins/ec2/ssh/EC2UnixLauncher.java +++ b/src/main/java/hudson/plugins/ec2/ssh/EC2UnixLauncher.java @@ -36,7 +36,16 @@ import hudson.Util; import hudson.model.Descriptor; import hudson.model.TaskListener; -import hudson.plugins.ec2.*; +import hudson.plugins.ec2.ConnectionStrategy; +import hudson.plugins.ec2.EC2AbstractSlave; +import hudson.plugins.ec2.EC2Cloud; +import hudson.plugins.ec2.EC2Computer; +import hudson.plugins.ec2.EC2ComputerLauncher; +import hudson.plugins.ec2.EC2HostAddressProvider; +import hudson.plugins.ec2.EC2PrivateKey; +import hudson.plugins.ec2.EC2Readiness; +import hudson.plugins.ec2.EC2SpotSlave; +import hudson.plugins.ec2.SlaveTemplate; import hudson.plugins.ec2.ssh.verifiers.HostKey; import hudson.plugins.ec2.ssh.verifiers.HostKeyHelper; import hudson.plugins.ec2.ssh.verifiers.Messages; diff --git a/src/main/java/hudson/plugins/ec2/util/EC2AgentFactory.java b/src/main/java/hudson/plugins/ec2/util/EC2AgentFactory.java index aca9d136d..21dd3f56d 100644 --- a/src/main/java/hudson/plugins/ec2/util/EC2AgentFactory.java +++ b/src/main/java/hudson/plugins/ec2/util/EC2AgentFactory.java @@ -1,7 +1,8 @@ package hudson.plugins.ec2.util; import hudson.model.Descriptor; -import hudson.plugins.ec2.*; +import hudson.plugins.ec2.EC2OndemandSlave; +import hudson.plugins.ec2.EC2SpotSlave; import java.io.IOException; import jenkins.model.Jenkins; diff --git a/src/main/java/hudson/plugins/ec2/util/EC2AgentFactoryImpl.java b/src/main/java/hudson/plugins/ec2/util/EC2AgentFactoryImpl.java index 3e1dd6d95..1f73e6400 100644 --- a/src/main/java/hudson/plugins/ec2/util/EC2AgentFactoryImpl.java +++ b/src/main/java/hudson/plugins/ec2/util/EC2AgentFactoryImpl.java @@ -2,7 +2,8 @@ import hudson.Extension; import hudson.model.Descriptor; -import hudson.plugins.ec2.*; +import hudson.plugins.ec2.EC2OndemandSlave; +import hudson.plugins.ec2.EC2SpotSlave; import java.io.IOException; @Extension diff --git a/src/main/java/hudson/plugins/ec2/win/EC2WindowsLauncher.java b/src/main/java/hudson/plugins/ec2/win/EC2WindowsLauncher.java index 4f6951535..a91a54c6c 100644 --- a/src/main/java/hudson/plugins/ec2/win/EC2WindowsLauncher.java +++ b/src/main/java/hudson/plugins/ec2/win/EC2WindowsLauncher.java @@ -9,7 +9,12 @@ import hudson.model.Descriptor; import hudson.model.TaskListener; import hudson.os.WindowsUtil; -import hudson.plugins.ec2.*; +import hudson.plugins.ec2.EC2AbstractSlave; +import hudson.plugins.ec2.EC2Computer; +import hudson.plugins.ec2.EC2ComputerLauncher; +import hudson.plugins.ec2.EC2HostAddressProvider; +import hudson.plugins.ec2.EC2PrivateKey; +import hudson.plugins.ec2.SlaveTemplate; import hudson.plugins.ec2.win.winrm.WindowsProcess; import hudson.remoting.Channel; import hudson.remoting.Channel.Listener; diff --git a/src/main/java/hudson/plugins/ec2/win/winrm/NegotiateNTLMSchemaFactory.java b/src/main/java/hudson/plugins/ec2/win/winrm/NegotiateNTLMSchemaFactory.java index 749f331d7..9c0b7e7a5 100644 --- a/src/main/java/hudson/plugins/ec2/win/winrm/NegotiateNTLMSchemaFactory.java +++ b/src/main/java/hudson/plugins/ec2/win/winrm/NegotiateNTLMSchemaFactory.java @@ -2,7 +2,11 @@ import org.apache.http.Header; import org.apache.http.HttpRequest; -import org.apache.http.auth.*; +import org.apache.http.auth.AuthScheme; +import org.apache.http.auth.AuthSchemeProvider; +import org.apache.http.auth.AuthenticationException; +import org.apache.http.auth.Credentials; +import org.apache.http.auth.NTCredentials; import org.apache.http.client.config.AuthSchemes; import org.apache.http.impl.auth.NTLMScheme; import org.apache.http.message.BufferedHeader; diff --git a/src/test/java/hudson/plugins/ec2/AmazonEC2CloudTest.java b/src/test/java/hudson/plugins/ec2/AmazonEC2CloudTest.java index 716b3f929..9defc3ee2 100644 --- a/src/test/java/hudson/plugins/ec2/AmazonEC2CloudTest.java +++ b/src/test/java/hudson/plugins/ec2/AmazonEC2CloudTest.java @@ -24,7 +24,8 @@ package hudson.plugins.ec2; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; diff --git a/src/test/java/hudson/plugins/ec2/AmazonEC2CloudUnitTest.java b/src/test/java/hudson/plugins/ec2/AmazonEC2CloudUnitTest.java index 08a2bbdee..fd285cc2e 100644 --- a/src/test/java/hudson/plugins/ec2/AmazonEC2CloudUnitTest.java +++ b/src/test/java/hudson/plugins/ec2/AmazonEC2CloudUnitTest.java @@ -23,7 +23,6 @@ */ package hudson.plugins.ec2; -import static hudson.plugins.ec2.EC2Cloud.DEFAULT_EC2_ENDPOINT; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -56,8 +55,8 @@ public class AmazonEC2CloudUnitTest { public void testEC2EndpointURLCreation() throws MalformedURLException { AmazonEC2Cloud.DescriptorImpl descriptor = new AmazonEC2Cloud.DescriptorImpl(); - assertEquals(new URL(DEFAULT_EC2_ENDPOINT), descriptor.determineEC2EndpointURL(null)); - assertEquals(new URL(DEFAULT_EC2_ENDPOINT), descriptor.determineEC2EndpointURL("")); + assertEquals(new URL(EC2Cloud.DEFAULT_EC2_ENDPOINT), descriptor.determineEC2EndpointURL(null)); + assertEquals(new URL(EC2Cloud.DEFAULT_EC2_ENDPOINT), descriptor.determineEC2EndpointURL("")); assertEquals(new URL("https://www.abc.com"), descriptor.determineEC2EndpointURL("https://www.abc.com")); } diff --git a/src/test/java/hudson/plugins/ec2/ConfigurationAsCodeTest.java b/src/test/java/hudson/plugins/ec2/ConfigurationAsCodeTest.java index 7f188817b..24aa6d8fa 100644 --- a/src/test/java/hudson/plugins/ec2/ConfigurationAsCodeTest.java +++ b/src/test/java/hudson/plugins/ec2/ConfigurationAsCodeTest.java @@ -1,8 +1,5 @@ package hudson.plugins.ec2; -import static io.jenkins.plugins.casc.misc.Util.getJenkinsRoot; -import static io.jenkins.plugins.casc.misc.Util.toStringFromYamlFile; -import static io.jenkins.plugins.casc.misc.Util.toYamlString; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; @@ -17,6 +14,7 @@ import io.jenkins.plugins.casc.ConfiguratorRegistry; import io.jenkins.plugins.casc.misc.ConfiguredWithCode; import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule; +import io.jenkins.plugins.casc.misc.Util; import io.jenkins.plugins.casc.model.CNode; import java.time.LocalTime; import java.util.Arrays; @@ -144,9 +142,9 @@ public void testBackwardsCompatibleConnectionStrategy() throws Exception { public void testConfigAsCodeExport() throws Exception { ConfiguratorRegistry registry = ConfiguratorRegistry.get(); ConfigurationContext context = new ConfigurationContext(registry); - CNode clouds = getJenkinsRoot(context).get("clouds"); - String exported = toYamlString(clouds); - String expected = toStringFromYamlFile(this, "UnixDataExport.yml"); + CNode clouds = Util.getJenkinsRoot(context).get("clouds"); + String exported = Util.toYamlString(clouds); + String expected = Util.toStringFromYamlFile(this, "UnixDataExport.yml"); assertEquals(expected, exported); } @@ -155,9 +153,9 @@ public void testConfigAsCodeExport() throws Exception { public void testConfigAsCodeWithAltEndpointAndJavaPathExport() throws Exception { ConfiguratorRegistry registry = ConfiguratorRegistry.get(); ConfigurationContext context = new ConfigurationContext(registry); - CNode clouds = getJenkinsRoot(context).get("clouds"); - String exported = toYamlString(clouds); - String expected = toStringFromYamlFile(this, "UnixDataExport-withAltEndpointAndJavaPath.yml"); + CNode clouds = Util.getJenkinsRoot(context).get("clouds"); + String exported = Util.toYamlString(clouds); + String expected = Util.toStringFromYamlFile(this, "UnixDataExport-withAltEndpointAndJavaPath.yml"); assertEquals(expected, exported); } @@ -280,9 +278,9 @@ public void testMac() throws Exception { public void testMacCloudConfigAsCodeExport() throws Exception { ConfiguratorRegistry registry = ConfiguratorRegistry.get(); ConfigurationContext context = new ConfigurationContext(registry); - CNode clouds = getJenkinsRoot(context).get("clouds"); - String exported = toYamlString(clouds); - String expected = toStringFromYamlFile(this, "MacDataExport.yml"); + CNode clouds = Util.getJenkinsRoot(context).get("clouds"); + String exported = Util.toYamlString(clouds); + String expected = Util.toStringFromYamlFile(this, "MacDataExport.yml"); assertEquals(expected, exported); } } diff --git a/src/test/java/hudson/plugins/ec2/EC2AbstractSlaveTest.java b/src/test/java/hudson/plugins/ec2/EC2AbstractSlaveTest.java index 1cd1374ac..96baff2ab 100644 --- a/src/test/java/hudson/plugins/ec2/EC2AbstractSlaveTest.java +++ b/src/test/java/hudson/plugins/ec2/EC2AbstractSlaveTest.java @@ -1,9 +1,5 @@ package hudson.plugins.ec2; -import static hudson.plugins.ec2.EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED; -import static hudson.plugins.ec2.EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT; -import static hudson.plugins.ec2.EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED; -import static hudson.plugins.ec2.EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED; import static org.junit.Assert.assertEquals; import com.amazonaws.services.ec2.model.InstanceType; @@ -49,10 +45,10 @@ public void testGetLaunchTimeoutInMillisShouldNotOverflow() throws Exception { ConnectionStrategy.PRIVATE_IP, -1, Tenancy.Default, - DEFAULT_METADATA_ENDPOINT_ENABLED, - DEFAULT_METADATA_TOKENS_REQUIRED, - DEFAULT_METADATA_HOPS_LIMIT, - DEFAULT_METADATA_SUPPORTED) { + EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED, + EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED, + EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT, + EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED) { @Override public void terminate() { @@ -114,10 +110,10 @@ public void testMaxUsesBackwardCompat() throws Exception { HostKeyVerificationStrategyEnum.CHECK_NEW_HARD, Tenancy.Default, EbsEncryptRootVolume.DEFAULT, - DEFAULT_METADATA_ENDPOINT_ENABLED, - DEFAULT_METADATA_TOKENS_REQUIRED, - DEFAULT_METADATA_HOPS_LIMIT, - DEFAULT_METADATA_SUPPORTED); + EC2AbstractSlave.DEFAULT_METADATA_ENDPOINT_ENABLED, + EC2AbstractSlave.DEFAULT_METADATA_TOKENS_REQUIRED, + EC2AbstractSlave.DEFAULT_METADATA_HOPS_LIMIT, + EC2AbstractSlave.DEFAULT_METADATA_SUPPORTED); List templates = new ArrayList<>(); templates.add(orig); String cloudName = "us-east-1"; diff --git a/src/test/java/hudson/plugins/ec2/EC2CloudMigrationTest.java b/src/test/java/hudson/plugins/ec2/EC2CloudMigrationTest.java index ae0382c6c..bb2eebd0d 100644 --- a/src/test/java/hudson/plugins/ec2/EC2CloudMigrationTest.java +++ b/src/test/java/hudson/plugins/ec2/EC2CloudMigrationTest.java @@ -1,6 +1,8 @@ package hudson.plugins.ec2; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey; import com.cloudbees.plugins.credentials.SystemCredentialsProvider; diff --git a/src/test/java/hudson/plugins/ec2/EC2CloudTest.java b/src/test/java/hudson/plugins/ec2/EC2CloudTest.java index 68c672fd3..60c37cb4a 100644 --- a/src/test/java/hudson/plugins/ec2/EC2CloudTest.java +++ b/src/test/java/hudson/plugins/ec2/EC2CloudTest.java @@ -1,6 +1,8 @@ package hudson.plugins.ec2; -import static org.junit.Assert.*; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; diff --git a/src/test/java/hudson/plugins/ec2/EC2HostAddressProviderTest.java b/src/test/java/hudson/plugins/ec2/EC2HostAddressProviderTest.java index e8b6fec9c..7ea9e3c71 100644 --- a/src/test/java/hudson/plugins/ec2/EC2HostAddressProviderTest.java +++ b/src/test/java/hudson/plugins/ec2/EC2HostAddressProviderTest.java @@ -1,6 +1,5 @@ package hudson.plugins.ec2; -import static hudson.plugins.ec2.EC2HostAddressProvider.*; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; @@ -18,7 +17,7 @@ public void unix_publicDnsStrategy_isPresent() { when(instance.getPublicDnsName()).thenReturn("ec2-0-0-0-0.compute-1.amazonaws.com"); - assertThat(unix(instance, strategy), equalTo("ec2-0-0-0-0.compute-1.amazonaws.com")); + assertThat(EC2HostAddressProvider.unix(instance, strategy), equalTo("ec2-0-0-0-0.compute-1.amazonaws.com")); } @Test @@ -29,7 +28,7 @@ public void unix_publicDnsStrategy_notPresent() { when(instance.getPublicDnsName()).thenReturn(""); when(instance.getPublicIpAddress()).thenReturn("0.0.0.0"); - assertThat(unix(instance, strategy), equalTo("0.0.0.0")); + assertThat(EC2HostAddressProvider.unix(instance, strategy), equalTo("0.0.0.0")); } @Test @@ -39,7 +38,7 @@ public void unix_publicIpStrategy() { when(instance.getPublicIpAddress()).thenReturn("0.0.0.0"); - assertThat(unix(instance, strategy), equalTo("0.0.0.0")); + assertThat(EC2HostAddressProvider.unix(instance, strategy), equalTo("0.0.0.0")); } @Test @@ -49,7 +48,7 @@ public void unix_privateDnsStrategy_isPresent() { when(instance.getPrivateDnsName()).thenReturn("0-0-0-0.ec2.internal"); - assertThat(unix(instance, strategy), equalTo("0-0-0-0.ec2.internal")); + assertThat(EC2HostAddressProvider.unix(instance, strategy), equalTo("0-0-0-0.ec2.internal")); } @Test @@ -60,7 +59,7 @@ public void unix_privateDnsStrategy_notPresent() { when(instance.getPrivateDnsName()).thenReturn(""); when(instance.getPrivateIpAddress()).thenReturn("0.0.0.0"); - assertThat(unix(instance, strategy), equalTo("0.0.0.0")); + assertThat(EC2HostAddressProvider.unix(instance, strategy), equalTo("0.0.0.0")); } @Test @@ -70,7 +69,7 @@ public void unix_privateIpStrategy() { when(instance.getPrivateIpAddress()).thenReturn("0.0.0.0"); - assertThat(unix(instance, strategy), equalTo("0.0.0.0")); + assertThat(EC2HostAddressProvider.unix(instance, strategy), equalTo("0.0.0.0")); } @Test @@ -81,7 +80,7 @@ public void windows_privateDnsStrategy() { when(instance.getPrivateDnsName()).thenReturn("0-0-0-0.ec2.internal"); when(instance.getPrivateIpAddress()).thenReturn("0.0.0.0"); - assertThat(windows(instance, strategy), equalTo("0.0.0.0")); + assertThat(EC2HostAddressProvider.windows(instance, strategy), equalTo("0.0.0.0")); } @Test @@ -92,7 +91,7 @@ public void windows_privateIpStrategy() { when(instance.getPrivateDnsName()).thenReturn(""); when(instance.getPrivateIpAddress()).thenReturn("0.0.0.0"); - assertThat(windows(instance, strategy), equalTo("0.0.0.0")); + assertThat(EC2HostAddressProvider.windows(instance, strategy), equalTo("0.0.0.0")); } @Test @@ -103,7 +102,7 @@ public void windows_publicDnsStrategy() { when(instance.getPublicDnsName()).thenReturn("ec2-0-0-0-0.compute-1.amazonaws.com"); when(instance.getPublicIpAddress()).thenReturn("0.0.0.0"); - assertThat(windows(instance, strategy), equalTo("0.0.0.0")); + assertThat(EC2HostAddressProvider.windows(instance, strategy), equalTo("0.0.0.0")); } @Test @@ -114,6 +113,6 @@ public void windows_publicIpStrategy() { when(instance.getPublicDnsName()).thenReturn(""); when(instance.getPublicIpAddress()).thenReturn("0.0.0.0"); - assertThat(windows(instance, strategy), equalTo("0.0.0.0")); + assertThat(EC2HostAddressProvider.windows(instance, strategy), equalTo("0.0.0.0")); } } diff --git a/src/test/java/hudson/plugins/ec2/SlaveTemplateUnitTest.java b/src/test/java/hudson/plugins/ec2/SlaveTemplateUnitTest.java index 5ed327b4e..b43487263 100644 --- a/src/test/java/hudson/plugins/ec2/SlaveTemplateUnitTest.java +++ b/src/test/java/hudson/plugins/ec2/SlaveTemplateUnitTest.java @@ -11,7 +11,14 @@ import com.amazonaws.AmazonServiceException; import com.amazonaws.services.ec2.AmazonEC2; import com.amazonaws.services.ec2.AmazonEC2Client; -import com.amazonaws.services.ec2.model.*; +import com.amazonaws.services.ec2.model.BlockDeviceMapping; +import com.amazonaws.services.ec2.model.CreateTagsResult; +import com.amazonaws.services.ec2.model.DescribeImagesRequest; +import com.amazonaws.services.ec2.model.EbsBlockDevice; +import com.amazonaws.services.ec2.model.Filter; +import com.amazonaws.services.ec2.model.Image; +import com.amazonaws.services.ec2.model.InstanceType; +import com.amazonaws.services.ec2.model.Tag; import hudson.model.Node; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; diff --git a/src/test/java/hudson/plugins/ec2/util/AmazonEC2FactoryMockImpl.java b/src/test/java/hudson/plugins/ec2/util/AmazonEC2FactoryMockImpl.java index 6b1b7f7e1..f7dd1c87b 100644 --- a/src/test/java/hudson/plugins/ec2/util/AmazonEC2FactoryMockImpl.java +++ b/src/test/java/hudson/plugins/ec2/util/AmazonEC2FactoryMockImpl.java @@ -5,7 +5,39 @@ import com.amazonaws.auth.AWSCredentialsProvider; import com.amazonaws.services.ec2.AmazonEC2; import com.amazonaws.services.ec2.AmazonEC2Client; -import com.amazonaws.services.ec2.model.*; +import com.amazonaws.services.ec2.model.BlockDeviceMapping; +import com.amazonaws.services.ec2.model.DescribeImagesRequest; +import com.amazonaws.services.ec2.model.DescribeImagesResult; +import com.amazonaws.services.ec2.model.DescribeInstancesRequest; +import com.amazonaws.services.ec2.model.DescribeInstancesResult; +import com.amazonaws.services.ec2.model.DescribeKeyPairsResult; +import com.amazonaws.services.ec2.model.DescribeRegionsResult; +import com.amazonaws.services.ec2.model.DescribeSecurityGroupsRequest; +import com.amazonaws.services.ec2.model.DescribeSecurityGroupsResult; +import com.amazonaws.services.ec2.model.DescribeSpotInstanceRequestsRequest; +import com.amazonaws.services.ec2.model.DescribeSpotInstanceRequestsResult; +import com.amazonaws.services.ec2.model.DescribeSubnetsRequest; +import com.amazonaws.services.ec2.model.DescribeSubnetsResult; +import com.amazonaws.services.ec2.model.EbsBlockDevice; +import com.amazonaws.services.ec2.model.Image; +import com.amazonaws.services.ec2.model.Instance; +import com.amazonaws.services.ec2.model.InstanceState; +import com.amazonaws.services.ec2.model.InstanceStateChange; +import com.amazonaws.services.ec2.model.InstanceStateName; +import com.amazonaws.services.ec2.model.KeyPairInfo; +import com.amazonaws.services.ec2.model.Region; +import com.amazonaws.services.ec2.model.Reservation; +import com.amazonaws.services.ec2.model.RunInstancesRequest; +import com.amazonaws.services.ec2.model.RunInstancesResult; +import com.amazonaws.services.ec2.model.SecurityGroup; +import com.amazonaws.services.ec2.model.SpotInstanceRequest; +import com.amazonaws.services.ec2.model.SpotInstanceState; +import com.amazonaws.services.ec2.model.SpotInstanceType; +import com.amazonaws.services.ec2.model.Subnet; +import com.amazonaws.services.ec2.model.Tag; +import com.amazonaws.services.ec2.model.TagSpecification; +import com.amazonaws.services.ec2.model.TerminateInstancesRequest; +import com.amazonaws.services.ec2.model.TerminateInstancesResult; import edu.umd.cs.findbugs.annotations.Nullable; import hudson.Extension; import hudson.plugins.ec2.AmazonEC2Cloud; diff --git a/src/test/java/hudson/plugins/ec2/util/EC2AgentFactoryMockImpl.java b/src/test/java/hudson/plugins/ec2/util/EC2AgentFactoryMockImpl.java index ffdeda1f7..9ffbeda9f 100644 --- a/src/test/java/hudson/plugins/ec2/util/EC2AgentFactoryMockImpl.java +++ b/src/test/java/hudson/plugins/ec2/util/EC2AgentFactoryMockImpl.java @@ -4,7 +4,14 @@ import hudson.Extension; import hudson.model.Computer; import hudson.model.Descriptor; -import hudson.plugins.ec2.*; +import hudson.plugins.ec2.AMITypeData; +import hudson.plugins.ec2.ConnectionStrategy; +import hudson.plugins.ec2.EC2AbstractSlave; +import hudson.plugins.ec2.EC2Computer; +import hudson.plugins.ec2.EC2OndemandSlave; +import hudson.plugins.ec2.EC2SpotSlave; +import hudson.plugins.ec2.EC2Tag; +import hudson.plugins.ec2.Tenancy; import hudson.slaves.NodeProperty; import java.io.IOException; import java.util.List; diff --git a/src/test/java/hudson/plugins/ec2/win/WinConnectionTest.java b/src/test/java/hudson/plugins/ec2/win/WinConnectionTest.java index 61d56c64f..257189afa 100644 --- a/src/test/java/hudson/plugins/ec2/win/WinConnectionTest.java +++ b/src/test/java/hudson/plugins/ec2/win/WinConnectionTest.java @@ -1,8 +1,8 @@ package hudson.plugins.ec2.win; -import static junit.framework.TestCase.assertTrue; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeThat; import hudson.plugins.ec2.win.winrm.WindowsProcess;