diff --git a/core/src/test/java/hudson/FilePathTest.java b/core/src/test/java/hudson/FilePathTest.java index 79ad7816e88558a6512d3dd4a4ddddcfe22bb2ea..73d0b6fcc7077b835a9101bc1a7a1764ed552dd3 100644 --- a/core/src/test/java/hudson/FilePathTest.java +++ b/core/src/test/java/hudson/FilePathTest.java @@ -54,7 +54,13 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; +import static org.hamcrest.MatcherAssert.assertThat; +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.junit.Assert.fail; import static org.junit.Assume.assumeFalse; import static org.junit.Assume.assumeTrue; import static org.mockito.Mockito.*; @@ -293,7 +299,7 @@ public class FilePathTest { } @Issue("JENKINS-6494") - @Test public void getParent() throws Exception { + @Test public void getParent() { FilePath fp = new FilePath((VirtualChannel)null, "/abc/def"); assertEquals("/abc", (fp = fp.getParent()).getRemote()); assertEquals("/", (fp = fp.getParent()).getRemote()); @@ -491,7 +497,7 @@ public class FilePathTest { } @Issue("JENKINS-13649") - @Test public void multiSegmentRelativePaths() throws Exception { + @Test public void multiSegmentRelativePaths() { VirtualChannel d = Mockito.mock(VirtualChannel.class); FilePath winPath = new FilePath(d, "c:\\app\\jenkins\\workspace"); FilePath nixPath = new FilePath(d, "/opt/jenkins/workspace"); diff --git a/core/src/test/java/hudson/util/ArgumentListBuilderTest.java b/core/src/test/java/hudson/util/ArgumentListBuilderTest.java index e8c58e73fcf6c8d1a694feefc299a788f0a1157b..a04c8211b00f6bd566daed8f3b07eff1d46d2593 100644 --- a/core/src/test/java/hudson/util/ArgumentListBuilderTest.java +++ b/core/src/test/java/hudson/util/ArgumentListBuilderTest.java @@ -23,8 +23,12 @@ */ package hudson.util; -import static org.junit.Assert.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.HashMap; diff --git a/core/src/test/java/hudson/util/AtomicFileWriterTest.java b/core/src/test/java/hudson/util/AtomicFileWriterTest.java index e36a325c5bce79c8dc08035d87c0d8ddad9a7a7f..72e64746a1e721801e1ba68659d6a1b7cc661218 100644 --- a/core/src/test/java/hudson/util/AtomicFileWriterTest.java +++ b/core/src/test/java/hudson/util/AtomicFileWriterTest.java @@ -22,9 +22,9 @@ import java.util.Set; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.StringContains.containsString; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.junit.Assume.assumeThat; @@ -86,7 +86,7 @@ public class AtomicFileWriterTest { } @Test - public void createFile() throws Exception { + public void createFile() { // Verify the file we created exists assertTrue(Files.exists(afw.getTemporaryPath())); } @@ -163,7 +163,7 @@ public class AtomicFileWriterTest { @Issue("JENKINS-48407") @Test - public void checkPermissionsRespectUmask() throws IOException, InterruptedException { + public void checkPermissionsRespectUmask() throws IOException { final File newFile = tmp.newFile(); boolean posixSupported = isPosixSupported(newFile); diff --git a/core/src/test/java/hudson/util/FileChannelWriterTest.java b/core/src/test/java/hudson/util/FileChannelWriterTest.java index b61cce1473b9fa86aefed638c4afbf4429c5e1a2..9d0a86675fc7e337779f73ef6ba90dbe4735b175 100644 --- a/core/src/test/java/hudson/util/FileChannelWriterTest.java +++ b/core/src/test/java/hudson/util/FileChannelWriterTest.java @@ -13,7 +13,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.StandardOpenOption; import static org.hamcrest.core.IsEqual.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; public class FileChannelWriterTest { diff --git a/core/src/test/java/jenkins/security/ClassFilterImplSanityTest.java b/core/src/test/java/jenkins/security/ClassFilterImplSanityTest.java index 7a710aaeb4ae0c0119395b6d7fed84a387dbd4e5..a917de92a0cb3ce4980c170e7dc56d41399e082c 100644 --- a/core/src/test/java/jenkins/security/ClassFilterImplSanityTest.java +++ b/core/src/test/java/jenkins/security/ClassFilterImplSanityTest.java @@ -32,7 +32,7 @@ import java.util.stream.Collectors; import jenkins.util.MemoryReductionUtil; import org.apache.commons.io.IOUtils; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import org.junit.Test; import org.jvnet.hudson.test.For; diff --git a/core/src/test/java/jenkins/security/DefaultConfidentialStoreTest.java b/core/src/test/java/jenkins/security/DefaultConfidentialStoreTest.java index f78c4969642eaf927b15ac5556639435b522946f..b7e3961473be67beb911859bcf86c1aba90a7965 100644 --- a/core/src/test/java/jenkins/security/DefaultConfidentialStoreTest.java +++ b/core/src/test/java/jenkins/security/DefaultConfidentialStoreTest.java @@ -7,7 +7,11 @@ import java.nio.charset.Charset; import org.apache.commons.io.FileUtils; import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; diff --git a/core/src/test/java/jenkins/security/apitoken/ApiTokenStatsTest.java b/core/src/test/java/jenkins/security/apitoken/ApiTokenStatsTest.java index 1c1be386c2934ce00c2eb3dc8afa30c8cd229ba4..9c95c910d4fb6909652656024f2663e0606ae8ce 100644 --- a/core/src/test/java/jenkins/security/apitoken/ApiTokenStatsTest.java +++ b/core/src/test/java/jenkins/security/apitoken/ApiTokenStatsTest.java @@ -52,10 +52,10 @@ import java.util.UUID; import java.util.stream.Collectors; import static org.hamcrest.Matchers.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; @RunWith(PowerMockRunner.class) @PrepareForTest(ApiTokenPropertyConfiguration.class) @@ -108,6 +108,7 @@ public class ApiTokenStatsTest { lastUsage = stats.getLastUseDate(); assertNotNull(lastUsage); // to avoid flaky test in case the test is run at midnight, normally it's 0 + assertThat(stats.getNumDaysUse(), lessThanOrEqualTo(1L)); } @@ -164,7 +165,7 @@ public class ApiTokenStatsTest { } @Test - public void testResilientIfFileDoesNotExist() throws Exception { + public void testResilientIfFileDoesNotExist() { ApiTokenStats tokenStats = createFromFile(tmp.getRoot()); assertNotNull(tokenStats); } @@ -193,7 +194,7 @@ public class ApiTokenStatsTest { String content = FileUtils.readFileToString(statsFile.getFile(), Charset.defaultCharset()); // now there are multiple times the same id in the file with different stats String newContentWithDuplicatedId = content.replace(ID_1, ID_2).replace(ID_3, ID_2); - FileUtils.write(statsFile.getFile(), newContentWithDuplicatedId); + FileUtils.write(statsFile.getFile(), newContentWithDuplicatedId, Charset.defaultCharset()); } {