captor = ArgumentCaptor.forClass(Installable.class);
verify(installer).isUpToDate(any(FilePath.class), captor.capture());
- Assertions.assertThat(captor.getValue().url).startsWith("http://user:password@npm.taobao.org/mirrors/node/node-v8.2.1");
+ assertThat(captor.getValue().url).startsWith("http://user:password@npm.taobao.org/mirrors/node/node-v8.2.1");
}
}
diff --git a/src/test/java/jenkins/plugins/nodejs/tools/NodeJSInstallationMockitoTest.java b/src/test/java/jenkins/plugins/nodejs/tools/NodeJSInstallationMockitoTest.java
index 7a1b5b3..a16943e 100644
--- a/src/test/java/jenkins/plugins/nodejs/tools/NodeJSInstallationMockitoTest.java
+++ b/src/test/java/jenkins/plugins/nodejs/tools/NodeJSInstallationMockitoTest.java
@@ -24,8 +24,7 @@
package jenkins.plugins.nodejs.tools;
import static jenkins.plugins.nodejs.NodeJSConstants.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.anyMap;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.never;
@@ -34,21 +33,21 @@
import hudson.EnvVars;
import hudson.Functions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.jvnet.hudson.test.Issue;
-public class NodeJSInstallationMockitoTest {
+class NodeJSInstallationMockitoTest {
/**
* Ensure the use of {@link EnvVars#put(String, String)} instead
* {@code EnvVars#override(String, String)} to respect the
- * {@link ToolInstallation#buildEnvVars(EnvVars)) API documentation.
+ * {@link hudson.tools.ToolInstallation#buildEnvVars(EnvVars)) API documentation.
*
* A lot stuff rely on that logic.
*/
@Issue("JENKINS-41947")
@Test
- public void test_installer_environment() throws Exception {
+ void test_installer_environment() {
String nodeJSHome = "/home/nodejs";
String bin = nodeJSHome + "/bin";
@@ -59,10 +58,11 @@ public void test_installer_environment() throws Exception {
verify(env, never()).override(anyString(), anyString());
verify(env, never()).overrideAll(anyMap());
- assertEquals("Unexpected value for " + ENVVAR_NODEJS_HOME, nodeJSHome, env.get(ENVVAR_NODEJS_HOME));
- assertEquals("Unexpected value for " + ENVVAR_NODE_HOME, nodeJSHome, env.get(ENVVAR_NODE_HOME));
- assertEquals("Unexpected value for " + ENVVAR_NODEJS_PATH, Functions.isWindows() ? nodeJSHome : bin, env.get(ENVVAR_NODEJS_PATH));
- assertNull("PATH variable should not appear in this environment", env.get("PATH"));
+ assertThat(env)
+ .as("Unexpected value for " + ENVVAR_NODEJS_HOME).containsEntry(ENVVAR_NODEJS_HOME, nodeJSHome)
+ .as("Unexpected value for " + ENVVAR_NODE_HOME).containsEntry(ENVVAR_NODE_HOME, nodeJSHome)
+ .as("Unexpected value for " + ENVVAR_NODEJS_PATH).containsEntry(ENVVAR_NODEJS_PATH, Functions.isWindows() ? nodeJSHome : bin)
+ .as("PATH variable should not appear in this environment").doesNotContainKey("PATH");
}
}
\ No newline at end of file
diff --git a/src/test/java/jenkins/plugins/nodejs/tools/NodeJSInstallationTest.java b/src/test/java/jenkins/plugins/nodejs/tools/NodeJSInstallationTest.java
index 8e00bf9..a26d798 100644
--- a/src/test/java/jenkins/plugins/nodejs/tools/NodeJSInstallationTest.java
+++ b/src/test/java/jenkins/plugins/nodejs/tools/NodeJSInstallationTest.java
@@ -36,37 +36,39 @@
import java.lang.reflect.Method;
import jenkins.model.Jenkins;
import jenkins.plugins.nodejs.tools.NodeJSInstallation.DescriptorImpl;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
+import org.jvnet.hudson.test.junit.jupiter.WithJenkins;
import org.jvnet.hudson.test.recipes.LocalData;
import org.xml.sax.SAXException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
-public class NodeJSInstallationTest {
+@WithJenkins
+class NodeJSInstallationTest {
- @Rule
- public JenkinsRule r = new JenkinsRule();
+ private JenkinsRule r;
+
+ @BeforeEach
+ void setUp(JenkinsRule rule) {
+ r = rule;
+ }
/**
- * Verify node executable is begin initialised correctly on a slave
+ * Verify node executable is being initialised correctly on a slave
* node where {@link Computer#currentComputer()} is {@code null}.
*/
@Issue("JENKINS-42232")
@Test
- public void test_executable_resolved_on_slave_node() throws Exception {
- assertNull(Computer.currentComputer());
+ void test_executable_resolved_on_slave_node() throws Exception {
+ assertThat(Computer.currentComputer()).isNull();
NodeJSInstallation installation = new NodeJSInstallation("test_executable_resolved_on_slave_node", "/home/nodejs", null);
Method method = installation.getClass().getDeclaredMethod("getPlatform");
method.setAccessible(true);
Platform platform = (Platform) method.invoke(installation);
- assertEquals(Platform.current(), platform);
+ assertThat(platform).isEqualTo(Platform.current());
}
/**
@@ -76,11 +78,11 @@ public void test_executable_resolved_on_slave_node() throws Exception {
@LocalData
@Test
@Issue("JENKINS-41535")
- public void test_load_at_startup() throws Exception {
+ void test_load_at_startup() throws Exception {
File jenkinsHome = r.jenkins.getRootDir();
File installationsFile = new File(jenkinsHome, NodeJSInstallation.class.getName() + ".xml");
- assertTrue("NodeJS installations file has not been copied", installationsFile.exists());
+ assertThat(installationsFile).as("NodeJS installations file has not been copied").exists();
verify();
}
@@ -90,11 +92,11 @@ public void test_load_at_startup() throws Exception {
*/
@Test
@Issue("JENKINS-41535")
- public void test_persist_of_nodejs_installation() throws Exception {
+ void test_persist_of_nodejs_installation() throws Exception {
File jenkinsHome = r.jenkins.getRootDir();
File installationsFile = new File(jenkinsHome, NodeJSInstallation.class.getName() + ".xml");
- assertFalse("NodeJS installations file already exists", installationsFile.exists());
+ assertThat(installationsFile).as("NodeJS installations file already exists").doesNotExist();
HtmlPage p = getConfigurePage();
HtmlForm f = p.getFormByName("config");
@@ -105,7 +107,7 @@ public void test_persist_of_nodejs_installation() throws Exception {
r.submit(f);
verify();
- assertTrue("NodeJS installations file has not been saved", installationsFile.exists());
+ assertThat(installationsFile).as("NodeJS installations file has not been saved").exists();
// another submission and verify it survives a roundtrip
p = getConfigurePage();
@@ -122,15 +124,15 @@ private HtmlPage getConfigurePage() throws IOException, SAXException {
private void verify() throws Exception {
NodeJSInstallation[] l = r.get(DescriptorImpl.class).getInstallations();
- assertEquals(1, l.length);
+ assertThat(l).hasSize(1);
r.assertEqualBeans(l[0], new NodeJSInstallation("myNode", "/tmp/foo", JenkinsRule.NO_PROPERTIES), "name,home");
// by default we should get the auto installer
DescribableList, ToolPropertyDescriptor> props = l[0].getProperties();
- assertEquals(1, props.size());
+ assertThat(props).hasSize(1);
InstallSourceProperty isp = props.get(InstallSourceProperty.class);
- assertEquals(1, isp.installers.size());
- assertNotNull(isp.installers.get(NodeJSInstaller.class));
+ assertThat(isp.installers).hasSize(1);
+ assertThat(isp.installers.get(NodeJSInstaller.class)).isNotNull();
}
}
\ No newline at end of file
diff --git a/src/test/java/jenkins/plugins/nodejs/tools/NodeJSInstallerProxyTest.java b/src/test/java/jenkins/plugins/nodejs/tools/NodeJSInstallerProxyTest.java
index 5427149..2661e04 100644
--- a/src/test/java/jenkins/plugins/nodejs/tools/NodeJSInstallerProxyTest.java
+++ b/src/test/java/jenkins/plugins/nodejs/tools/NodeJSInstallerProxyTest.java
@@ -24,16 +24,12 @@
package jenkins.plugins.nodejs.tools;
import java.lang.reflect.Method;
-import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;
-import org.assertj.core.api.Assertions;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
@@ -41,19 +37,14 @@
import hudson.ProxyConfiguration;
import hudson.model.StreamBuildListener;
import hudson.model.TaskListener;
+import org.jvnet.hudson.test.junit.jupiter.WithJenkins;
-@RunWith(Parameterized.class)
-public class NodeJSInstallerProxyTest {
+import static org.assertj.core.api.Assertions.assertThat;
- @Parameters(name = "proxy url = {0}")
- public static String[][] data() throws MalformedURLException {
- return new String[][] { { "http://proxy.example.org:8080", "*.npm.org\n\nregistry.npm.org" },
- { "http://user:password@proxy.example.org:8080", "*.npm.org\n\nregistry.npm.org" }
- };
- }
+@WithJenkins
+class NodeJSInstallerProxyTest {
- @ClassRule
- public static JenkinsRule r = new JenkinsRule();
+ private static JenkinsRule r;
private String host;
private int port;
@@ -61,14 +52,24 @@ public static String[][] data() throws MalformedURLException {
private String password;
private String expectedURL;
private TaskListener log;
- private String noProxy;
- public NodeJSInstallerProxyTest(String url, String noProxy) throws Exception {
+ @BeforeAll
+ static void setUp(JenkinsRule rule) {
+ r = rule;
+ }
+
+ static String[][] data() {
+ return new String[][] {
+ { "http://proxy.example.org:8080", "*.npm.org\n\nregistry.npm.org" },
+ { "http://user:password@proxy.example.org:8080", "*.npm.org\n\nregistry.npm.org" }
+ };
+ }
+
+ private void init(String url) throws Exception {
URL proxyURL = new URL(url);
this.log = new StreamBuildListener(System.out, Charset.defaultCharset());
this.expectedURL = url;
- this.noProxy = noProxy;
this.host = proxyURL.getHost();
this.port = proxyURL.getPort();
if (proxyURL.getUserInfo() != null) {
@@ -79,8 +80,11 @@ public NodeJSInstallerProxyTest(String url, String noProxy) throws Exception {
}
@Issue("JENKINS-29266")
- @Test
- public void test_proxy_settings() throws Exception {
+ @ParameterizedTest(name = "proxy url = {0}")
+ @MethodSource("data")
+ void test_proxy_settings(String url, String noProxy) throws Exception {
+ init(url);
+
r.getInstance().proxy = new ProxyConfiguration(host, port, username, password);
NodeJSInstaller installer = new NodeJSInstaller("test-id", "grunt", NodeJSInstaller.DEFAULT_NPM_PACKAGES_REFRESH_HOURS);
@@ -89,14 +93,17 @@ public void test_proxy_settings() throws Exception {
method.setAccessible(true);
method.invoke(installer, env, log);
- Assertions.assertThat(env.keySet()).contains("HTTP_PROXY", "HTTPS_PROXY");
- Assertions.assertThat(env.get("HTTP_PROXY")).isEqualTo(expectedURL);
- Assertions.assertThat(env.get("HTTPS_PROXY")).isEqualTo(expectedURL);
- Assertions.assertThat(env.keySet()).doesNotContain("NO_PROXY");
+ assertThat(env)
+ .containsEntry("HTTP_PROXY", expectedURL)
+ .containsEntry("HTTPS_PROXY", expectedURL)
+ .doesNotContainKey("NO_PROXY");
}
- @Test
- public void test_no_proxy_settings() throws Exception {
+ @ParameterizedTest(name = "proxy url = {0}")
+ @MethodSource("data")
+ void test_no_proxy_settings(String url, String noProxy) throws Exception {
+ init(url);
+
r.getInstance().proxy = new ProxyConfiguration(host, port, username, password, noProxy);
NodeJSInstaller installer = new NodeJSInstaller("test-id", "grunt", NodeJSInstaller.DEFAULT_NPM_PACKAGES_REFRESH_HOURS);
@@ -105,8 +112,8 @@ public void test_no_proxy_settings() throws Exception {
method.setAccessible(true);
method.invoke(installer, env, log);
- Assertions.assertThat(env.keySet()).contains("HTTP_PROXY", "HTTPS_PROXY");
- Assertions.assertThat(env.get("NO_PROXY")).isEqualTo("*.npm.org,registry.npm.org");
+ assertThat(env).containsKeys("HTTP_PROXY", "HTTPS_PROXY")
+ .containsEntry("NO_PROXY", "*.npm.org,registry.npm.org");
}
}
\ No newline at end of file
diff --git a/src/test/java/jenkins/plugins/nodejs/tools/NodeJSInstallerTest.java b/src/test/java/jenkins/plugins/nodejs/tools/NodeJSInstallerTest.java
index e9ca745..2e1a1bb 100644
--- a/src/test/java/jenkins/plugins/nodejs/tools/NodeJSInstallerTest.java
+++ b/src/test/java/jenkins/plugins/nodejs/tools/NodeJSInstallerTest.java
@@ -23,6 +23,7 @@
*/
package jenkins.plugins.nodejs.tools;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
@@ -45,10 +46,8 @@
import org.apache.tools.tar.TarInputStream;
import org.apache.tools.tar.TarOutputStream;
import org.assertj.core.api.AssertDelegateTarget;
-import org.assertj.core.api.Assertions;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.jvnet.hudson.test.Issue;
import org.mockito.MockedStatic;
@@ -59,18 +58,18 @@
import hudson.tools.DownloadFromUrlInstaller.Installable;
import hudson.util.StreamTaskListener;
-public class NodeJSInstallerTest {
+class NodeJSInstallerTest {
private static class TarFileAssert implements AssertDelegateTarget {
- private File file;
+ private final File file;
public TarFileAssert(File file) {
this.file = file;
}
void hasEntry(String path) throws IOException {
- Assertions.assertThat(file).exists();
+ assertThat(file).exists();
try (TarInputStream zf = new TarInputStream(new GZIPInputStream(new FileInputStream(file)))) {
TarEntry entry;
while ((entry = zf.getNextEntry()) != null) {
@@ -78,16 +77,16 @@ void hasEntry(String path) throws IOException {
break;
}
}
- Assertions.assertThat(entry).as("Entry " + path + " not found.").isNotNull();
+ assertThat(entry).as("Entry " + path + " not found.").isNotNull();
}
}
}
- @Rule
- public TemporaryFolder fileRule = new TemporaryFolder();
+ @TempDir
+ private File fileRule;
@SuppressWarnings("deprecation")
- private TaskListener taskListener = new StreamTaskListener(new NullPrintStream());
+ private final TaskListener taskListener = new StreamTaskListener(new NullPrintStream());
/**
* Verify that the installer skip install of global package also if
@@ -100,13 +99,13 @@ void hasEntry(String path) throws IOException {
*/
@Issue("JENKINS-41876")
@Test
- public void test_skip_install_global_packages_when_empty() throws Exception {
- File cache = new File(fileRule.getRoot(), "test.tar.gz");
+ void test_skip_install_global_packages_when_empty() throws Exception {
+ File cache = new File(fileRule, "test.tar.gz");
IOUtils.copy(getClass().getResource("test.tar.gz"), cache);
String expectedPackages = " ";
int expectedRefreshHours = NodeJSInstaller.DEFAULT_NPM_PACKAGES_REFRESH_HOURS;
Node currentNode = mock(Node.class);
- when(currentNode.getRootPath()).thenReturn(new FilePath(fileRule.newFolder()));
+ when(currentNode.getRootPath()).thenReturn(new FilePath(newFolder(fileRule, "junit")));
// create partial mock
NodeJSInstaller installer = new NodeJSInstaller("test-id", expectedPackages, expectedRefreshHours);
@@ -115,7 +114,7 @@ public void test_skip_install_global_packages_when_empty() throws Exception {
// use Mockito to set up your expectation
doReturn(cache).when(spy).getLocalCacheFile(any(), any());
Installable installable = new Installable();
- installable.url = fileRule.newFile().toURI().toString();
+ installable.url = File.createTempFile("junit", null, fileRule).toURI().toString();
doReturn(installable).when(spy).getInstallable();
when(spy.getNpmPackages()).thenReturn(expectedPackages);
@@ -132,13 +131,13 @@ public void test_skip_install_global_packages_when_empty() throws Exception {
}
@Test
- public void verify_cache_is_build() throws Exception {
- File cache = new File(fileRule.getRoot(), "test.tar.gz");
+ void verify_cache_is_build() throws Exception {
+ File cache = new File(fileRule, "test.tar.gz");
IOUtils.copy(getClass().getResource("test.tar.gz"), cache);
String expectedPackages = " ";
int expectedRefreshHours = NodeJSInstaller.DEFAULT_NPM_PACKAGES_REFRESH_HOURS;
Node currentNode = mock(Node.class);
- when(currentNode.getRootPath()).thenReturn(new FilePath(fileRule.newFolder()));
+ when(currentNode.getRootPath()).thenReturn(new FilePath(newFolder(fileRule, "junit")));
// create partial mock
NodeJSInstaller installer = new NodeJSInstaller("test-id", expectedPackages, expectedRefreshHours);
@@ -147,7 +146,7 @@ public void verify_cache_is_build() throws Exception {
// use Mockito to set up your expectation
doReturn(cache).when(spy).getLocalCacheFile(any(), any());
Installable installable = new Installable();
- File downloadURL = fileRule.newFile("nodejs.tar.gz");
+ File downloadURL = File.createTempFile("nodejs.tar.gz", null, fileRule);
fillArchive(downloadURL, "nodejs/bin/npm.sh", "echo \"hello\"".getBytes());
installable.url = downloadURL.toURI().toString();
doReturn(installable).when(spy).getInstallable();
@@ -162,27 +161,27 @@ public void verify_cache_is_build() throws Exception {
// execute test
spy.performInstallation(toolInstallation, currentNode, taskListener);
- Assertions.assertThat(new TarFileAssert(cache)).hasEntry("bin/npm.sh");
+ assertThat(new TarFileAssert(cache)).hasEntry("bin/npm.sh");
}
}
@Test
- public void test_cache_archive_is_used() throws Exception {
+ void test_cache_archive_is_used() throws Exception {
String expectedPackages = " ";
int expectedRefreshHours = NodeJSInstaller.DEFAULT_NPM_PACKAGES_REFRESH_HOURS;
Node currentNode = mock(Node.class);
- when(currentNode.getRootPath()).thenReturn(new FilePath(fileRule.newFolder()));
+ when(currentNode.getRootPath()).thenReturn(new FilePath(newFolder(fileRule, "junit")));
// create partial mock
NodeJSInstaller installer = new NodeJSInstaller("test-id", expectedPackages, expectedRefreshHours);
NodeJSInstaller spy = spy(installer);
// use Mockito to set up your expectation
- File cache = fileRule.newFile();
+ File cache = File.createTempFile("junit", null, fileRule);
fillArchive(cache, "nodejs.txt", "test".getBytes());
doReturn(cache).when(spy).getLocalCacheFile(any(), any());
Installable installable = new Installable();
- installable.url = fileRule.newFile().toURI().toString();
+ installable.url = File.createTempFile("junit", null, fileRule).toURI().toString();
doReturn(installable).when(spy).getInstallable();
when(spy.getNpmPackages()).thenReturn(expectedPackages);
@@ -195,7 +194,7 @@ public void test_cache_archive_is_used() throws Exception {
// execute test
FilePath expected = spy.performInstallation(toolInstallation, currentNode, taskListener);
- Assertions.assertThat(expected.list("nodejs.txt")).isNotEmpty();
+ assertThat(expected.list("nodejs.txt")).isNotEmpty();
}
}
@@ -211,23 +210,23 @@ private void fillArchive(File file, String fileEntry, byte[] content) throws IOE
@Issue("JENKINS-56895")
@Test
- public void verify_global_packages_are_refreshed_also_if_nodejs_installation_is_uptodate() throws Exception {
+ void verify_global_packages_are_refreshed_also_if_nodejs_installation_is_uptodate() throws Exception {
String expectedPackages = "npm@6.7.0";
int expectedRefreshHours = NodeJSInstaller.DEFAULT_NPM_PACKAGES_REFRESH_HOURS;
Node currentNode = mock(Node.class);
- when(currentNode.getRootPath()).thenReturn(new FilePath(fileRule.newFolder()));
+ when(currentNode.getRootPath()).thenReturn(new FilePath(newFolder(fileRule, "junit")));
// create partial mock
NodeJSInstaller installer = new NodeJSInstaller("test-id", expectedPackages, expectedRefreshHours) {
@Override
public Installable getInstallable() throws IOException {
Installable installable = new Installable();
- installable.url = fileRule.newFile().toURI().toString();
+ installable.url = File.createTempFile("junit", null, fileRule).toURI().toString();
return installable;
}
@Override
- protected boolean isUpToDate(FilePath expectedLocation, Installable i) throws IOException, InterruptedException {
+ protected boolean isUpToDate(FilePath expectedLocation, Installable i) {
return true;
}
};
@@ -245,4 +244,13 @@ protected boolean isUpToDate(FilePath expectedLocation, Installable i) throws IO
verify(spy).refreshGlobalPackages(any(Node.class), any(TaskListener.class), any(FilePath.class));
}
+ private static File newFolder(File root, String... subDirs) throws IOException {
+ String subFolder = String.join("/", subDirs);
+ File result = new File(root, subFolder);
+ if (!result.mkdirs()) {
+ throw new IOException("Couldn't create folders " + root);
+ }
+ return result;
+ }
+
}
\ No newline at end of file
diff --git a/src/test/java/jenkins/plugins/nodejs/tools/ToolsUtilsTest.java b/src/test/java/jenkins/plugins/nodejs/tools/ToolsUtilsTest.java
index a80fb64..53fe63f 100644
--- a/src/test/java/jenkins/plugins/nodejs/tools/ToolsUtilsTest.java
+++ b/src/test/java/jenkins/plugins/nodejs/tools/ToolsUtilsTest.java
@@ -23,64 +23,64 @@
*/
package jenkins.plugins.nodejs.tools;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;
import hudson.model.Node;
-import org.assertj.core.api.Assertions;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
-public class ToolsUtilsTest {
+class ToolsUtilsTest {
private MockedStatic staticCpu;
- @Before
- public void setup() {
+ @BeforeEach
+ void setup() {
CPU[] cpuValues = CPU.values();
staticCpu = mockStatic(CPU.class);
staticCpu.when(CPU::values).thenReturn(cpuValues);
}
- @After
- public void tearDown() {
+ @AfterEach
+ void tearDown() {
staticCpu.close();
}
@Test
- public void nodejs_supports_32bit_64bit_on_windows_linux_mac() throws Exception {
+ void nodejs_supports_32bit_64bit_on_windows_linux_mac() throws Exception {
Node currentNode = mock(Node.class);
-
+
when(CPU.of(currentNode)).thenReturn(CPU.amd64);
CPU cpu = ToolsUtils.getCPU(currentNode, true);
- Assertions.assertThat(cpu).isEqualTo(CPU.i386);
+ assertThat(cpu).isEqualTo(CPU.i386);
cpu = ToolsUtils.getCPU(currentNode);
- Assertions.assertThat(cpu).isEqualTo(CPU.amd64);
+ assertThat(cpu).isEqualTo(CPU.amd64);
}
- @Test(expected = DetectionFailedException.class)
- public void nodejs_doesn_t_supports_32bit_on_armv64() throws Exception {
+ @Test
+ void nodejs_doesn_t_supports_32bit_on_armv64() throws Exception {
Node currentNode = mock(Node.class);
-
when(CPU.of(currentNode)).thenReturn(CPU.arm64);
- ToolsUtils.getCPU(currentNode, true);
+ assertThatThrownBy(() -> ToolsUtils.getCPU(currentNode, true)).isInstanceOf(DetectionFailedException.class);
}
@Test
- public void nodejs_supports_32bit_on_armv6_armv7() throws Exception {
+ void nodejs_supports_32bit_on_armv6_armv7() throws Exception {
Node currentNode = mock(Node.class);
when(CPU.of(currentNode)).thenReturn(CPU.armv7l);
CPU cpu = ToolsUtils.getCPU(currentNode, true);
- Assertions.assertThat(cpu).isEqualTo(CPU.armv7l);
+ assertThat(cpu).isEqualTo(CPU.armv7l);
when(CPU.of(currentNode)).thenReturn(CPU.armv6l);
cpu = ToolsUtils.getCPU(currentNode, true);
- Assertions.assertThat(cpu).isEqualTo(CPU.armv6l);
+ assertThat(cpu).isEqualTo(CPU.armv6l);
}
}
\ No newline at end of file