From eeac80127ba66eb1dcd2eea37b934c14fa7b7a48 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Sat, 6 Feb 2021 04:04:27 -0500 Subject: [PATCH] Clean up some Deprecation warnings (#4407) Co-authored-by: Jesse Glick Co-authored-by: Oleg Nenashev --- .../java/hudson/DescriptorExtensionList.java | 1 + core/src/main/java/hudson/Functions.java | 2 +- .../java/hudson/model/AbstractProject.java | 3 +- core/src/main/java/hudson/model/Computer.java | 2 +- .../src/main/java/hudson/model/LargeText.java | 6 +- core/src/main/java/hudson/model/Node.java | 2 +- core/src/main/java/hudson/model/Queue.java | 6 -- .../security/MasterToSlaveCallable.java | 4 +- core/src/test/java/hudson/UtilTest.java | 4 +- .../java/hudson/logging/LogRecorderTest.java | 1 + .../java/hudson/model/ActionableTest.java | 1 + .../hudson/model/DisplayNameListenerTest.java | 2 +- core/src/test/java/hudson/model/RunTest.java | 8 ++- .../BuildStepCompatibilityLayerTest.java | 2 + .../util/LineEndNormalizingWriterTest.java | 70 ------------------- .../test/java/hudson/util/RunListTest.java | 2 + .../java/hudson/util/SecretRewriterTest.java | 5 +- .../src/test/java/hudson/util/SecretTest.java | 1 + .../java/jenkins/model/IdStrategyTest.java | 5 ++ .../jenkins/model/lazy/FakeMapBuilder.java | 3 +- .../jenkins/triggers/SCMTriggerItemTest.java | 3 +- .../java/jenkins/util/VirtualFileTest.java | 11 +-- test/src/test/java/hudson/ProcTest.java | 4 +- .../test/java/hudson/cli/CLIActionTest.java | 4 +- .../test/java/hudson/model/ProjectTest.java | 4 +- 25 files changed, 50 insertions(+), 106 deletions(-) delete mode 100644 core/src/test/java/hudson/util/LineEndNormalizingWriterTest.java diff --git a/core/src/main/java/hudson/DescriptorExtensionList.java b/core/src/main/java/hudson/DescriptorExtensionList.java index ec0b76337c..fac8fbaeed 100644 --- a/core/src/main/java/hudson/DescriptorExtensionList.java +++ b/core/src/main/java/hudson/DescriptorExtensionList.java @@ -179,6 +179,7 @@ public class DescriptorExtensionList, D extends Descrip } @Override + @SuppressWarnings("deprecation") public boolean add(D d) { boolean r = super.add(d); getDescriptorExtensionList().add(d); diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index 82e8b579c1..4327eabedd 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -158,7 +158,7 @@ import org.kohsuke.stapler.Ancestor; import org.kohsuke.stapler.Stapler; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; -import org.kohsuke.stapler.jelly.InternationalizedStringExpression.RawHtmlArgument; +import org.kohsuke.stapler.RawHtmlArgument; import hudson.model.PasswordParameterDefinition; import hudson.util.RunList; diff --git a/core/src/main/java/hudson/model/AbstractProject.java b/core/src/main/java/hudson/model/AbstractProject.java index 419b2d94b6..52623e775f 100644 --- a/core/src/main/java/hudson/model/AbstractProject.java +++ b/core/src/main/java/hudson/model/AbstractProject.java @@ -39,7 +39,6 @@ import hudson.Functions; import hudson.Launcher; import hudson.Util; import hudson.cli.declarative.CLIResolver; -import hudson.model.Cause.LegacyCodeCause; import hudson.model.Descriptor.FormException; import hudson.model.Fingerprint.RangeSet; import hudson.model.Node.Mode; @@ -832,7 +831,7 @@ public abstract class AbstractProject

,R extends A @SuppressWarnings("deprecation") @WithBridgeMethods(Future.class) public QueueTaskFuture scheduleBuild2(int quietPeriod) { - return scheduleBuild2(quietPeriod, new LegacyCodeCause()); + return scheduleBuild2(quietPeriod, new hudson.model.Cause.LegacyCodeCause()); } /** diff --git a/core/src/main/java/hudson/model/Computer.java b/core/src/main/java/hudson/model/Computer.java index cbf495d3ce..0880279697 100644 --- a/core/src/main/java/hudson/model/Computer.java +++ b/core/src/main/java/hudson/model/Computer.java @@ -326,7 +326,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces * Gets the string representation of the agent log. */ public String getLog() throws IOException { - return Util.loadFile(getLogFile()); + return Util.loadFile(getLogFile(), /* TODO switch agent logs to UTF-8 */ Charset.defaultCharset()); } /** diff --git a/core/src/main/java/hudson/model/LargeText.java b/core/src/main/java/hudson/model/LargeText.java index 0d63147adc..450794b215 100644 --- a/core/src/main/java/hudson/model/LargeText.java +++ b/core/src/main/java/hudson/model/LargeText.java @@ -24,10 +24,10 @@ package hudson.model; import hudson.util.ByteBuffer; -import hudson.util.CharSpool; -import hudson.util.LineEndNormalizingWriter; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; +import org.kohsuke.stapler.framework.io.CharSpool; +import org.kohsuke.stapler.framework.io.LineEndNormalizingWriter; import org.kohsuke.stapler.framework.io.WriterOutputStream; import org.apache.commons.io.output.CountingOutputStream; @@ -81,6 +81,7 @@ public class LargeText { this.completed = completed; } + @SuppressWarnings("deprecation") public LargeText(final ByteBuffer memory, boolean completed) { this.source = new Source() { public Session open() throws IOException { @@ -347,6 +348,7 @@ public class LargeText { private static final class BufferSession implements Session { private final InputStream in; + @SuppressWarnings("deprecation") public BufferSession(ByteBuffer buf) { this.in = buf.newInputStream(); } diff --git a/core/src/main/java/hudson/model/Node.java b/core/src/main/java/hudson/model/Node.java index 2dc51c426d..8ed4831d7b 100644 --- a/core/src/main/java/hudson/model/Node.java +++ b/core/src/main/java/hudson/model/Node.java @@ -526,7 +526,7 @@ public abstract class Node extends AbstractModelObject implements Reconfigurable final JSONObject jsonForProperties = form.optJSONObject("nodeProperties"); final AtomicReference old = new AtomicReference<>(); - old.set(req.setBindListener(new BindInterceptor() { + old.set(req.setBindInterceptor(new BindInterceptor() { @Override public Object onConvert(Type targetType, Class targetTypeErasure, Object jsonSource) { if (jsonForProperties != jsonSource) { diff --git a/core/src/main/java/hudson/model/Queue.java b/core/src/main/java/hudson/model/Queue.java index eed63045bd..0449dcc0b9 100644 --- a/core/src/main/java/hudson/model/Queue.java +++ b/core/src/main/java/hudson/model/Queue.java @@ -41,7 +41,6 @@ import static hudson.util.Iterators.reverse; import hudson.cli.declarative.CLIResolver; import hudson.model.labels.LabelAssignmentAction; -import hudson.model.queue.AbstractQueueTask; import hudson.model.queue.Executables; import hudson.model.queue.QueueListener; import hudson.model.queue.QueueTaskFuture; @@ -1841,11 +1840,6 @@ public class Queue extends ResourceController implements Saveable { * transient Task, extend {@link TransientTask} marker interface. * *

- * Plugins are encouraged to extend from {@link AbstractQueueTask} - * instead of implementing this interface directly, to maintain - * compatibility with future changes to this interface. - * - *

* Plugins are encouraged to implement {@link AccessControlled} otherwise * the tasks will be hidden from display in the queue. * diff --git a/core/src/main/java/jenkins/security/MasterToSlaveCallable.java b/core/src/main/java/jenkins/security/MasterToSlaveCallable.java index 2ff780689f..99cd80b8e1 100644 --- a/core/src/main/java/jenkins/security/MasterToSlaveCallable.java +++ b/core/src/main/java/jenkins/security/MasterToSlaveCallable.java @@ -31,7 +31,7 @@ public abstract class MasterToSlaveCallable implements C public Channel getChannelOrFail() throws ChannelClosedException { final Channel ch = Channel.current(); if (ch == null) { - throw new ChannelClosedException(new IllegalStateException("No channel associated with the thread")); + throw new ChannelClosedException(ch, new IllegalStateException("No channel associated with the thread")); } return ch; } @@ -41,7 +41,7 @@ public abstract class MasterToSlaveCallable implements C public Channel getOpenChannelOrFail() throws ChannelClosedException { final Channel ch = getChannelOrFail(); if (ch.isClosingOrClosed()) { // TODO: Since Remoting 2.33, we still need to explicitly declare minimum Remoting version - throw new ChannelClosedException(new IllegalStateException("The associated channel " + ch + " is closing down or has closed down", ch.getCloseRequestCause())); + throw new ChannelClosedException(ch, new IllegalStateException("The associated channel " + ch + " is closing down or has closed down", ch.getCloseRequestCause())); } return ch; } diff --git a/core/src/test/java/hudson/UtilTest.java b/core/src/test/java/hudson/UtilTest.java index 6c29a9f19a..91a24cc97c 100644 --- a/core/src/test/java/hudson/UtilTest.java +++ b/core/src/test/java/hudson/UtilTest.java @@ -40,6 +40,7 @@ import org.jvnet.hudson.test.Issue; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.attribute.PosixFilePermissions; @@ -355,6 +356,7 @@ public class UtilTest { } @Test + @SuppressWarnings("deprecation") public void testIsAbsoluteUri() { assertTrue(Util.isAbsoluteUri("http://foobar/")); assertTrue(Util.isAbsoluteUri("mailto:kk@kohsuke.org")); @@ -562,7 +564,7 @@ public class UtilTest { File aa = new File(a, "aa"); aa.mkdirs(); File aaTxt = new File(aa, "aa.txt"); - FileUtils.write(aaTxt, "aa"); + FileUtils.write(aaTxt, "aa", StandardCharsets.US_ASCII, false); File b = new File(root, "b"); b.mkdir(); diff --git a/core/src/test/java/hudson/logging/LogRecorderTest.java b/core/src/test/java/hudson/logging/LogRecorderTest.java index 8e014d1e3c..80ada65a82 100644 --- a/core/src/test/java/hudson/logging/LogRecorderTest.java +++ b/core/src/test/java/hudson/logging/LogRecorderTest.java @@ -137,6 +137,7 @@ public class LogRecorderTest { return r; } + @SuppressWarnings("deprecation") /* testing deprecated variant */ private static boolean includes(String target, String logger) { LogRecord r = createLogRecord(logger, Level.INFO, "whatever"); return new LogRecorder.Target(target, Level.INFO).includes(r); diff --git a/core/src/test/java/hudson/model/ActionableTest.java b/core/src/test/java/hudson/model/ActionableTest.java index 7628460c11..f48ea6e77f 100644 --- a/core/src/test/java/hudson/model/ActionableTest.java +++ b/core/src/test/java/hudson/model/ActionableTest.java @@ -70,6 +70,7 @@ public class ActionableTest { return "morenope"; } + @SuppressWarnings("deprecation") @Override @NonNull public List getActions() { diff --git a/core/src/test/java/hudson/model/DisplayNameListenerTest.java b/core/src/test/java/hudson/model/DisplayNameListenerTest.java index 16d80e7ea1..f4b7beb6e0 100644 --- a/core/src/test/java/hudson/model/DisplayNameListenerTest.java +++ b/core/src/test/java/hudson/model/DisplayNameListenerTest.java @@ -46,7 +46,7 @@ public class DisplayNameListenerTest { // make sure the displayname is equals to the name as it should be null assertEquals(dest.getName(), dest.getDisplayName()); } - + @Test public void testOnRenamedOldNameEqualsDisplayName() throws Exception { DisplayNameListener listener = new DisplayNameListener(); diff --git a/core/src/test/java/hudson/model/RunTest.java b/core/src/test/java/hudson/model/RunTest.java index 9ec56c738d..80fbb305f2 100644 --- a/core/src/test/java/hudson/model/RunTest.java +++ b/core/src/test/java/hudson/model/RunTest.java @@ -59,7 +59,8 @@ public class RunTest { @Issue("JENKINS-15816") @SuppressWarnings({"unchecked", "rawtypes"}) - @Test public void timezoneOfID() throws Exception { + @Test + public void timezoneOfID() throws Exception { TimeZone origTZ = TimeZone.getDefault(); try { final Run r; @@ -135,7 +136,7 @@ public class RunTest { } @Issue("JENKINS-26777") - @SuppressWarnings({"unchecked", "rawtypes"}) + @SuppressWarnings({"unchecked", "rawtypes", "deprecation"}) @Test public void getDurationString() throws IOException { LocaleProvider providerToRestore = LocaleProvider.getProvider(); @@ -163,6 +164,7 @@ public class RunTest { } @Issue("JENKINS-27441") + @SuppressWarnings("deprecation") @Test public void getLogReturnsAnEmptyListWhenCalledWith0() throws Exception { Job j = Mockito.mock(Job.class); @@ -178,6 +180,7 @@ public class RunTest { assertTrue(logLines.isEmpty()); } + @SuppressWarnings("deprecation") @Test public void getLogReturnsAnRightOrder() throws Exception { Job j = Mockito.mock(Job.class); @@ -202,6 +205,7 @@ public class RunTest { assertEquals("[...truncated "+truncatedCount+" B...]", logLines.get(0)); } + @SuppressWarnings("deprecation") @Test public void getLogReturnsAllLines() throws Exception { Job j = Mockito.mock(Job.class); diff --git a/core/src/test/java/hudson/tasks/BuildStepCompatibilityLayerTest.java b/core/src/test/java/hudson/tasks/BuildStepCompatibilityLayerTest.java index 66fc80c93f..53e7911e7e 100644 --- a/core/src/test/java/hudson/tasks/BuildStepCompatibilityLayerTest.java +++ b/core/src/test/java/hudson/tasks/BuildStepCompatibilityLayerTest.java @@ -16,6 +16,7 @@ public class BuildStepCompatibilityLayerTest { @Issue("JENKINS-18734") @Test(expected = AbstractMethodError.class) + @SuppressWarnings("deprecation") /* testing deprecated variant */ public void testPerformExpectAbstractMethodError() throws InterruptedException, IOException { FreeStyleBuild mock = Mockito.mock(FreeStyleBuild.class, Mockito.CALLS_REAL_METHODS); @@ -26,6 +27,7 @@ public class BuildStepCompatibilityLayerTest { @Issue("JENKINS-18734") @Test + @SuppressWarnings("deprecation") public void testPerform() throws InterruptedException, IOException { FreeStyleBuild mock = Mockito.mock(FreeStyleBuild.class, Mockito.CALLS_REAL_METHODS); diff --git a/core/src/test/java/hudson/util/LineEndNormalizingWriterTest.java b/core/src/test/java/hudson/util/LineEndNormalizingWriterTest.java deleted file mode 100644 index 5c593ba5d0..0000000000 --- a/core/src/test/java/hudson/util/LineEndNormalizingWriterTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package hudson.util; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import java.io.StringWriter; -import java.io.Writer; -import java.io.IOException; - -/** - * @author Kohsuke Kawaguchi - */ -public class LineEndNormalizingWriterTest { - - @Test - public void test1() throws IOException { - StringWriter sw = new StringWriter(); - Writer w = new LineEndNormalizingWriter(sw); - - w.write("abc\r\ndef\r"); - w.write("\n"); - - assertEquals(sw.toString(),"abc\r\ndef\r\n"); - } - - @Test - public void test2() throws IOException { - StringWriter sw = new StringWriter(); - Writer w = new LineEndNormalizingWriter(sw); - - w.write("abc\ndef\n"); - w.write("\n"); - - assertEquals(sw.toString(),"abc\r\ndef\r\n\r\n"); - } - - @Test - public void test3() throws IOException { - StringWriter sw = new StringWriter(); - Writer w = new LineEndNormalizingWriter(sw); - - w.write("\r\n\n"); - - assertEquals(sw.toString(),"\r\n\r\n"); - } -} diff --git a/core/src/test/java/hudson/util/RunListTest.java b/core/src/test/java/hudson/util/RunListTest.java index ad78a3d933..ba133eb9fe 100644 --- a/core/src/test/java/hudson/util/RunListTest.java +++ b/core/src/test/java/hudson/util/RunListTest.java @@ -77,6 +77,7 @@ public class RunListTest { @Issue("JENKINS-21159") @PrepareForTest({Run.class}) @Test + @SuppressWarnings("deprecation") public void byTimestampFirstRun() { setUpByTimestampRuns(); // Only r1 @@ -87,6 +88,7 @@ public class RunListTest { @PrepareForTest({Run.class}) @Test + @SuppressWarnings("deprecation") public void byTimestampLastRun() { setUpByTimestampRuns(); // Only r2 diff --git a/core/src/test/java/hudson/util/SecretRewriterTest.java b/core/src/test/java/hudson/util/SecretRewriterTest.java index dac0948247..6a84192eae 100644 --- a/core/src/test/java/hudson/util/SecretRewriterTest.java +++ b/core/src/test/java/hudson/util/SecretRewriterTest.java @@ -49,14 +49,15 @@ public class SecretRewriterTest { } private String roundtrip(String before) throws Exception { - SecretRewriter sr = new SecretRewriter(null); + SecretRewriter sr = new SecretRewriter(); File f = File.createTempFile("test", "xml", tmp.getRoot()); FileUtils.write(f, before, Charset.defaultCharset()); - sr.rewrite(f, null); + sr.rewrite(f); //assert after.replaceAll(System.getProperty("line.separator"), "\n").trim()==f.text.replaceAll(System.getProperty("line.separator"), "\n").trim() return FileUtils.readFileToString(f, Charset.defaultCharset()).replaceAll(System.getProperty("line.separator"), "\n").trim(); } + @SuppressWarnings("deprecation") private String encryptOld(String str) throws Exception { Cipher cipher = Secret.getCipher("AES"); cipher.init(Cipher.ENCRYPT_MODE, HistoricalSecrets.getLegacyKey()); diff --git a/core/src/test/java/hudson/util/SecretTest.java b/core/src/test/java/hudson/util/SecretTest.java index 2092b8a9a4..d5bdcd33e7 100644 --- a/core/src/test/java/hudson/util/SecretTest.java +++ b/core/src/test/java/hudson/util/SecretTest.java @@ -121,6 +121,7 @@ public class SecretTest { * Secret persisted with Jenkins.getSecretKey() should still decrypt OK. */ @Test + @SuppressWarnings("deprecation") public void migrationFromLegacyKeyToConfidentialStore() throws Exception { SecretKey legacy = HistoricalSecrets.getLegacyKey(); for (String str : new String[] {"Hello world", "", "\u0000unprintable"}) { diff --git a/core/src/test/java/jenkins/model/IdStrategyTest.java b/core/src/test/java/jenkins/model/IdStrategyTest.java index c2315ff3cf..157c1e4dc2 100644 --- a/core/src/test/java/jenkins/model/IdStrategyTest.java +++ b/core/src/test/java/jenkins/model/IdStrategyTest.java @@ -10,6 +10,7 @@ import static org.junit.Assert.assertTrue; public class IdStrategyTest { + @SuppressWarnings("deprecation") @Test public void caseInsensitive() { IdStrategy idStrategy = new IdStrategy.CaseInsensitive(); @@ -45,6 +46,7 @@ public class IdStrategyTest { assertThat(idStrategy.idFromFilename("rrr$t123"), is("rrr$t123")); } + @SuppressWarnings("deprecation") @Test public void caseInsensitivePassesThroughOldLegacy() { IdStrategy idStrategy = new IdStrategy.CaseInsensitive(); @@ -55,6 +57,7 @@ public class IdStrategyTest { assertThat(idStrategy.idFromFilename("~1fred"), is("~1fred")); } + @SuppressWarnings("deprecation") @Test public void caseSensitive() { IdStrategy idStrategy = new IdStrategy.CaseSensitive(); @@ -93,6 +96,7 @@ public class IdStrategyTest { assertThat(idStrategy.idFromFilename("iiii _-@$007~ea"), is("iiii _-@$007Ea")); } + @SuppressWarnings("deprecation") @Test public void caseSensitivePassesThroughOldLegacy() { IdStrategy idStrategy = new IdStrategy.CaseSensitive(); @@ -204,6 +208,7 @@ public class IdStrategyTest { assertTrue(idStrategy.compare("john.smith@acme.org", "John.Smith@acme.org") > 0); } + @SuppressWarnings("deprecation") private void assertRestrictedNames(IdStrategy idStrategy) { assertThat(idStrategy.idFromFilename("$002f"), is("/")); diff --git a/core/src/test/java/jenkins/model/lazy/FakeMapBuilder.java b/core/src/test/java/jenkins/model/lazy/FakeMapBuilder.java index 8a9aeb262f..79eba9d62a 100644 --- a/core/src/test/java/jenkins/model/lazy/FakeMapBuilder.java +++ b/core/src/test/java/jenkins/model/lazy/FakeMapBuilder.java @@ -30,6 +30,7 @@ import org.junit.runners.model.Statement; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; /** * Builder for creating a {@link FakeMap} @@ -48,7 +49,7 @@ public class FakeMapBuilder implements TestRule { public FakeMapBuilder add(int n) throws IOException { File build = new File(dir, Integer.toString(n)); - FileUtils.writeStringToFile(new File(build, "n"), Integer.toString(n)); + FileUtils.writeStringToFile(new File(build, "n"), Integer.toString(n), StandardCharsets.US_ASCII); build.mkdir(); return this; } diff --git a/core/src/test/java/jenkins/triggers/SCMTriggerItemTest.java b/core/src/test/java/jenkins/triggers/SCMTriggerItemTest.java index 5e7b336a17..0f55d59381 100644 --- a/core/src/test/java/jenkins/triggers/SCMTriggerItemTest.java +++ b/core/src/test/java/jenkins/triggers/SCMTriggerItemTest.java @@ -12,7 +12,6 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import hudson.model.Item; -import hudson.model.SCMedItem; import hudson.model.TaskListener; import jenkins.scm.SCMDecisionHandler; @@ -27,7 +26,7 @@ public class SCMTriggerItemTest { // given PowerMockito.mockStatic(SCMDecisionHandler.class); PowerMockito.when(SCMDecisionHandler.firstShouldPollVeto(any(Item.class))).thenReturn(null); - SCMedItem scMedItem = Mockito.mock(SCMedItem.class); + hudson.model.SCMedItem scMedItem = Mockito.mock(hudson.model.SCMedItem.class); TaskListener listener = Mockito.mock(TaskListener.class); // when diff --git a/core/src/test/java/jenkins/util/VirtualFileTest.java b/core/src/test/java/jenkins/util/VirtualFileTest.java index 62af1ebb03..9e8a74109d 100644 --- a/core/src/test/java/jenkins/util/VirtualFileTest.java +++ b/core/src/test/java/jenkins/util/VirtualFileTest.java @@ -47,6 +47,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URI; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.attribute.PosixFilePermissions; @@ -77,10 +78,10 @@ public class VirtualFileTest { @Test public void outsideSymlinks() throws Exception { assumeFalse("Symlinks don't work well on Windows", Functions.isWindows()); File ws = tmp.newFolder("ws"); - FileUtils.write(new File(ws, "safe"), "safe"); + FileUtils.write(new File(ws, "safe"), "safe", StandardCharsets.US_ASCII, false); Util.createSymlink(ws, "safe", "supported", TaskListener.NULL); File other = tmp.newFolder("other"); - FileUtils.write(new File(other, "secret"), "s3cr3t"); + FileUtils.write(new File(other, "secret"), "s3cr3t", StandardCharsets.US_ASCII, false); Util.createSymlink(ws, "../other/secret", "hack", TaskListener.NULL); VirtualFile root = VirtualFile.forFile(ws); VirtualFile supported = root.child("supported"); @@ -731,19 +732,19 @@ public class VirtualFileTest { File aaa = new File(aa, "aaa"); aaa.mkdirs(); File aaTxt = new File(aa, "aa.txt"); - FileUtils.write(aaTxt, "aa"); + FileUtils.write(aaTxt, "aa", StandardCharsets.US_ASCII, false); File ab = new File(a, "ab"); ab.mkdirs(); File abTxt = new File(ab, "ab.txt"); - FileUtils.write(abTxt, "ab"); + FileUtils.write(abTxt, "ab", StandardCharsets.US_ASCII, false); File b = new File(root, "b"); File ba = new File(b, "ba"); ba.mkdirs(); File baTxt = new File(ba, "ba.txt"); - FileUtils.write(baTxt, "ba"); + FileUtils.write(baTxt, "ba", StandardCharsets.US_ASCII, false); File _a = new File(b, "_a"); new FilePath(_a).symlinkTo(a.getAbsolutePath(), TaskListener.NULL); diff --git a/test/src/test/java/hudson/ProcTest.java b/test/src/test/java/hudson/ProcTest.java index 4f7133ccff..cc8bd3f7b9 100644 --- a/test/src/test/java/hudson/ProcTest.java +++ b/test/src/test/java/hudson/ProcTest.java @@ -6,7 +6,7 @@ import static org.junit.Assume.assumeFalse; import hudson.Launcher.LocalLauncher; import hudson.Launcher.RemoteLauncher; -import hudson.Proc.RemoteProc; +import hudson.Launcher.RemoteLauncher.ProcImpl; import hudson.remoting.Pipe; import hudson.remoting.VirtualChannel; import hudson.slaves.DumbSlave; @@ -34,7 +34,7 @@ public class ProcTest { public JenkinsRule j = new JenkinsRule(); /** - * Makes sure that the output flushing and {@link RemoteProc#join()} is synced. + * Makes sure that the output flushing and {@link ProcImpl#join()} is synced. */ @Test public void remoteProcOutputSync() throws Exception { diff --git a/test/src/test/java/hudson/cli/CLIActionTest.java b/test/src/test/java/hudson/cli/CLIActionTest.java index f9d18b47e0..5b6cf9820a 100644 --- a/test/src/test/java/hudson/cli/CLIActionTest.java +++ b/test/src/test/java/hudson/cli/CLIActionTest.java @@ -39,8 +39,6 @@ import org.jvnet.hudson.test.JenkinsRule; import org.jvnet.hudson.test.LoggerRule; import org.jvnet.hudson.test.MockAuthorizationStrategy; import org.jvnet.hudson.test.TestExtension; -import org.jvnet.hudson.test.recipes.PresetData; -import org.jvnet.hudson.test.recipes.PresetData.DataSet; public class CLIActionTest { @Rule @@ -53,7 +51,7 @@ public class CLIActionTest { public LoggerRule logging = new LoggerRule(); @Test - @PresetData(DataSet.NO_ANONYMOUS_READACCESS) + @org.jvnet.hudson.test.recipes.PresetData(org.jvnet.hudson.test.recipes.PresetData.DataSet.NO_ANONYMOUS_READACCESS) @Issue("SECURITY-192") public void serveCliActionToAnonymousUserWithoutPermissions() throws Exception { JenkinsRule.WebClient wc = j.createWebClient(); diff --git a/test/src/test/java/hudson/model/ProjectTest.java b/test/src/test/java/hudson/model/ProjectTest.java index a8937f23fd..feab5129d5 100644 --- a/test/src/test/java/hudson/model/ProjectTest.java +++ b/test/src/test/java/hudson/model/ProjectTest.java @@ -53,7 +53,7 @@ import jenkins.model.WorkspaceWriter; import jenkins.model.Jenkins; import antlr.ANTLRException; import hudson.triggers.SCMTrigger; -import hudson.model.Cause.LegacyCodeCause; +import hudson.model.Cause.UserIdCause; import com.gargoylesoftware.htmlunit.html.HtmlElement; import com.gargoylesoftware.htmlunit.html.HtmlForm; import com.gargoylesoftware.htmlunit.html.HtmlPage; @@ -303,7 +303,7 @@ public class ProjectTest { public void testScheduleBuild2() throws IOException, InterruptedException{ FreeStyleProject p = j.createFreeStyleProject("project"); p.setAssignedLabel(j.jenkins.getLabel("nonExist")); - p.scheduleBuild(0, new LegacyCodeCause(), new Action[0]); + p.scheduleBuild(0, new UserIdCause(), new Action[0]); assertNotNull("Project should be in queue.", Queue.getInstance().getItem(p)); p.setAssignedLabel(null); int count = 0;