Skip to content

Commit b4ccf94

Browse files
Ban JUnit 4 imports
1 parent 0a11fb7 commit b4ccf94

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ THE SOFTWARE.
8080
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
8181
<hpi.compatibleSinceVersion>1885</hpi.compatibleSinceVersion>
8282
<spotless.check.skip>false</spotless.check.skip>
83+
<ban-junit4-imports.skip>false</ban-junit4-imports.skip>
8384
</properties>
8485

8586
<dependencyManagement>

src/test/java/hudson/plugins/ec2/ssh/EC2SSHLauncherTest.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
package hudson.plugins.ec2.ssh;
22

3+
import static org.junit.jupiter.api.Assertions.assertTrue;
4+
35
import hudson.model.TaskListener;
46
import hudson.plugins.ec2.HostKeyVerificationStrategyEnum;
57
import hudson.plugins.ec2.MockEC2Computer;
68
import java.nio.file.Files;
79
import java.nio.file.Path;
810
import java.util.List;
911
import org.apache.sshd.common.config.keys.PublicKeyEntry;
10-
import org.junit.Assert;
11-
import org.junit.Rule;
12-
import org.junit.Test;
12+
import org.junit.jupiter.api.BeforeEach;
13+
import org.junit.jupiter.api.Test;
1314
import org.jvnet.hudson.test.JenkinsRule;
15+
import org.jvnet.hudson.test.junit.jupiter.WithJenkins;
16+
17+
@WithJenkins
18+
class EC2SSHLauncherTest {
1419

15-
public class EC2SSHLauncherTest {
20+
private JenkinsRule r;
1621

17-
@Rule
18-
public JenkinsRule r = new JenkinsRule();
22+
@BeforeEach
23+
void setUp(JenkinsRule rule) {
24+
r = rule;
25+
}
1926

2027
@Test
21-
public void testServerKeyVerifier() throws Exception {
28+
void testServerKeyVerifier() throws Exception {
2229
for (String publicKeyFile : List.of(
2330
"ssh_host_dss_1024.pub",
2431
"ssh_host_rsa_1024.pub",
@@ -41,13 +48,13 @@ public void testServerKeyVerifier() throws Exception {
4148
r.jenkins.addNode(computer.getNode());
4249

4350
computer.getSlaveTemplate().setHostKeyVerificationStrategy(HostKeyVerificationStrategyEnum.OFF);
44-
Assert.assertTrue(new EC2SSHLauncher.ServerKeyVerifierImpl(computer, TaskListener.NULL)
51+
assertTrue(new EC2SSHLauncher.ServerKeyVerifierImpl(computer, TaskListener.NULL)
4552
.verifyServerKey(
4653
null,
4754
null,
4855
PublicKeyEntry.parsePublicKeyEntry(sshHostKeyPath).resolvePublicKey(null, null, null)));
4956
computer.getSlaveTemplate().setHostKeyVerificationStrategy(HostKeyVerificationStrategyEnum.ACCEPT_NEW);
50-
Assert.assertTrue(new EC2SSHLauncher.ServerKeyVerifierImpl(computer, TaskListener.NULL)
57+
assertTrue(new EC2SSHLauncher.ServerKeyVerifierImpl(computer, TaskListener.NULL)
5158
.verifyServerKey(
5259
null,
5360
null,

src/test/java/hudson/plugins/ec2/win/winrm/WinRMClientWithFIPSTest.java

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package hudson.plugins.ec2.win.winrm;
22

33
import static org.junit.jupiter.api.Assertions.assertThrows;
4-
import static org.junit.jupiter.api.Assertions.fail;
54

65
import java.net.MalformedURLException;
76
import java.net.URL;
@@ -71,25 +70,18 @@ void testSetUseHTTPSFalseWithoutPassword() throws MalformedURLException {
7170
* It should not be allowed to disable useHTTPS only when a password is used, an {@link IllegalArgumentException} is expected
7271
*/
7372
@Test
74-
void testSetUseHTTPSFalseWithPassword() {
75-
assertThrows(
76-
IllegalArgumentException.class,
77-
() -> new WinRMClient(new URL("https://localhost"), "username", "password", false).setUseHTTPS(false));
73+
void testSetUseHTTPSFalseWithPassword() throws MalformedURLException {
74+
WinRMClient winRM = new WinRMClient(new URL("https://localhost"), "username", "password", false);
75+
assertThrows(IllegalArgumentException.class, () -> winRM.setUseHTTPS(false));
7876
}
7977

8078
/**
8179
* Password leak prevention when setUseHTTPS is not called
8280
*/
8381
@Test
84-
void testBuildWinRMClientWithoutTLS() {
85-
assertThrows(IllegalArgumentException.class, () -> {
86-
try {
87-
WinRMClient winRM = new WinRMClient(new URL("https://localhost"), "username", "password", false);
88-
// do not call winRM.setUseHTTPS(false); to avoid trigger the check
89-
winRM.openShell();
90-
} catch (WinRMConnectException e) {
91-
fail("The client should not attempt to connect");
92-
}
93-
});
82+
void testBuildWinRMClientWithoutTLS() throws MalformedURLException {
83+
WinRMClient winRM = new WinRMClient(new URL("https://localhost"), "username", "password", false);
84+
// do not call winRM.setUseHTTPS(false); to avoid trigger the check
85+
assertThrows(IllegalArgumentException.class, winRM::openShell, "The client should not attempt to connect");
9486
}
9587
}

0 commit comments

Comments
 (0)