From ee24685ca39a7936180a413bfa73914daa5ee994 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Tue, 15 Dec 2020 16:46:59 -0800 Subject: [PATCH 01/16] Replace explicit type with diamond operator --- core/src/main/java/org/jenkins/ui/icon/Icon.java | 4 ++-- core/src/main/java/org/jenkins/ui/icon/IconSet.java | 8 ++++---- test/src/test/java/hudson/ExtensionListTest.java | 8 ++++---- .../test/java/hudson/bugs/DateConversionTest.java | 2 +- .../hudson/model/AutoCompletionCandidatesTest.java | 2 +- .../test/java/hudson/model/DownloadService2Test.java | 2 +- .../test/java/hudson/model/DownloadServiceTest.java | 2 +- test/src/test/java/hudson/model/FingerprintTest.java | 2 +- test/src/test/java/hudson/model/NodeTest.java | 8 ++++---- test/src/test/java/hudson/model/ProjectTest.java | 8 ++++---- test/src/test/java/hudson/model/QueueTest.java | 4 ++-- test/src/test/java/hudson/model/SimpleJobTest.java | 12 ++++++------ test/src/test/java/hudson/model/UpdateSiteTest.java | 4 ++-- .../java/hudson/model/queue/LoadPredictorTest.java | 2 +- test/src/test/java/hudson/search/SearchTest.java | 2 +- .../test/java/hudson/slaves/JNLPLauncherTest.java | 4 ++-- .../test/java/hudson/slaves/NodeProvisionerTest.java | 4 ++-- .../src/test/java/hudson/tasks/BuildTriggerTest.java | 4 ++-- .../test/java/hudson/triggers/TriggerStartTest.java | 4 ++-- test/src/test/java/hudson/util/BootFailureTest.java | 4 ++-- .../src/test/java/jenkins/model/ContextMenuTest.java | 2 +- .../security/SecurityContextExecutorServiceTest.java | 2 +- .../test/java/lib/form/RepeatablePropertyTest.java | 8 ++++---- test/src/test/java/lib/form/RepeatableTest.java | 4 ++-- .../test/java/lib/hudson/ListScmBrowsersTest.java | 2 +- 25 files changed, 54 insertions(+), 54 deletions(-) diff --git a/core/src/main/java/org/jenkins/ui/icon/Icon.java b/core/src/main/java/org/jenkins/ui/icon/Icon.java index 974dcc0295..1a29fb340e 100644 --- a/core/src/main/java/org/jenkins/ui/icon/Icon.java +++ b/core/src/main/java/org/jenkins/ui/icon/Icon.java @@ -45,7 +45,7 @@ public class Icon { public static final String ICON_LARGE_STYLE = "width: 32px; height: 32px;"; public static final String ICON_XLARGE_STYLE = "width: 48px; height: 48px;"; - private static final Map iconDims = new HashMap(); + private static final Map iconDims = new HashMap<>(); static { iconDims.put("16x16", "icon-sm"); @@ -216,7 +216,7 @@ public class Icon { } String[] classNameTokA = classNames.split(" "); - List classNameTokL = new ArrayList(); + List classNameTokL = new ArrayList<>(); // Trim all tokens first for (String classNameTok : classNameTokA) { diff --git a/core/src/main/java/org/jenkins/ui/icon/IconSet.java b/core/src/main/java/org/jenkins/ui/icon/IconSet.java index 8daf513e94..9dbdd46bf2 100644 --- a/core/src/main/java/org/jenkins/ui/icon/IconSet.java +++ b/core/src/main/java/org/jenkins/ui/icon/IconSet.java @@ -37,10 +37,10 @@ public class IconSet { public static final IconSet icons = new IconSet(); - private Map iconsByCSSSelector = new ConcurrentHashMap(); - private Map iconsByUrl = new ConcurrentHashMap(); - private Map iconsByClassSpec = new ConcurrentHashMap(); - private Map coreIcons = new ConcurrentHashMap(); + private Map iconsByCSSSelector = new ConcurrentHashMap<>(); + private Map iconsByUrl = new ConcurrentHashMap<>(); + private Map iconsByClassSpec = new ConcurrentHashMap<>(); + private Map coreIcons = new ConcurrentHashMap<>(); private static final Icon NO_ICON = new Icon("_", "_", "_"); diff --git a/test/src/test/java/hudson/ExtensionListTest.java b/test/src/test/java/hudson/ExtensionListTest.java index ae48d2b642..680c7327ec 100644 --- a/test/src/test/java/hudson/ExtensionListTest.java +++ b/test/src/test/java/hudson/ExtensionListTest.java @@ -130,7 +130,7 @@ public class ExtensionListTest { @Test public void fishDiscovery() throws Exception { // imagine that this is a static instance, like it is in many LIST static field in Hudson. - DescriptorList LIST = new DescriptorList(Fish.class); + DescriptorList LIST = new DescriptorList<>(Fish.class); DescriptorExtensionList> list = j.jenkins.getDescriptorList(Fish.class); assertEquals(2,list.size()); @@ -149,7 +149,7 @@ public class ExtensionListTest { assertNotNull(LIST.findByName(Saba.class.getName())); // DescriptorList can be gone and new one created but it should still have the same list - LIST = new DescriptorList(Fish.class); + LIST = new DescriptorList<>(Fish.class); assertEquals(3,LIST.size()); assertNotNull(LIST.findByName(Tai.class.getName())); assertNotNull(LIST.findByName(Sishamo.class.getName())); @@ -159,7 +159,7 @@ public class ExtensionListTest { @Test public void legacyDescriptorList() throws Exception { // created in a legacy fashion without any tie to ExtensionList - DescriptorList LIST = new DescriptorList(); + DescriptorList LIST = new DescriptorList<>(); // we won't auto-discover anything assertEquals(0,LIST.size()); @@ -170,7 +170,7 @@ public class ExtensionListTest { assertNotNull(LIST.findByName(Sishamo.class.getName())); // create a new list and it forgets everything. - LIST = new DescriptorList(); + LIST = new DescriptorList<>(); assertEquals(0,LIST.size()); } diff --git a/test/src/test/java/hudson/bugs/DateConversionTest.java b/test/src/test/java/hudson/bugs/DateConversionTest.java index d5daea7aa2..a06d4100fc 100644 --- a/test/src/test/java/hudson/bugs/DateConversionTest.java +++ b/test/src/test/java/hudson/bugs/DateConversionTest.java @@ -48,7 +48,7 @@ public class DateConversionTest { final DateConverter dc =new DateConverter(); ExecutorService es = Executors.newFixedThreadPool(10); - List futures = new ArrayList(); + List futures = new ArrayList<>(); for(int i=0;i<10;i++) { futures.add(es.submit(new Callable() { public Object call() throws Exception { diff --git a/test/src/test/java/hudson/model/AutoCompletionCandidatesTest.java b/test/src/test/java/hudson/model/AutoCompletionCandidatesTest.java index 7f81ffc3d4..4e61dcb6f9 100644 --- a/test/src/test/java/hudson/model/AutoCompletionCandidatesTest.java +++ b/test/src/test/java/hudson/model/AutoCompletionCandidatesTest.java @@ -61,6 +61,6 @@ public class AutoCompletionCandidatesTest { } private void assertContains(AutoCompletionCandidates c, String... values) { - assertEquals(new TreeSet(Arrays.asList(values)), new TreeSet(c.getValues())); + assertEquals(new TreeSet<>(Arrays.asList(values)), new TreeSet<>(c.getValues())); } } diff --git a/test/src/test/java/hudson/model/DownloadService2Test.java b/test/src/test/java/hudson/model/DownloadService2Test.java index d02f07cf83..7185752550 100644 --- a/test/src/test/java/hudson/model/DownloadService2Test.java +++ b/test/src/test/java/hudson/model/DownloadService2Test.java @@ -60,7 +60,7 @@ public class DownloadService2Test { assertNotNull(file, resource); JSONObject json = JSONObject.fromObject(DownloadService.loadJSONHTML(resource)); @SuppressWarnings("unchecked") Set keySet = json.keySet(); - assertEquals(expected, new TreeSet(keySet).toString()); + assertEquals(expected, new TreeSet<>(keySet).toString()); } } diff --git a/test/src/test/java/hudson/model/DownloadServiceTest.java b/test/src/test/java/hudson/model/DownloadServiceTest.java index 7323e343c9..33f28ab986 100644 --- a/test/src/test/java/hudson/model/DownloadServiceTest.java +++ b/test/src/test/java/hudson/model/DownloadServiceTest.java @@ -31,7 +31,7 @@ public class DownloadServiceTest extends HudsonTestCase { assertNotNull(file, resource); JSONObject json = JSONObject.fromObject(DownloadService.loadJSON(resource)); @SuppressWarnings("unchecked") Set keySet = json.keySet(); - assertEquals(expected, new TreeSet(keySet).toString()); + assertEquals(expected, new TreeSet<>(keySet).toString()); } public void testReduceFunctionWithMavenJsons() throws Exception { diff --git a/test/src/test/java/hudson/model/FingerprintTest.java b/test/src/test/java/hudson/model/FingerprintTest.java index cd4a0a17b5..869ef32b2e 100644 --- a/test/src/test/java/hudson/model/FingerprintTest.java +++ b/test/src/test/java/hudson/model/FingerprintTest.java @@ -419,7 +419,7 @@ public class FingerprintTest { throws IOException { assertThat("Cannot assign the property twice", job.getProperty(AuthorizationMatrixProperty.class), nullValue()); - Map> permissions = new HashMap>(); + Map> permissions = new HashMap<>(); HashSet userSpec = new HashSet<>(Collections.singletonList(username)); for (Permission p : s) { diff --git a/test/src/test/java/hudson/model/NodeTest.java b/test/src/test/java/hudson/model/NodeTest.java index 331e05672d..32d9d7f8ff 100644 --- a/test/src/test/java/hudson/model/NodeTest.java +++ b/test/src/test/java/hudson/model/NodeTest.java @@ -200,9 +200,9 @@ public class NodeTest { FreeStyleProject project2 = j.createFreeStyleProject(); FreeStyleProject project3 = j.createFreeStyleProject(); project3.setAssignedLabel(j.jenkins.getLabel("notContained")); - Queue.BuildableItem item = new Queue.BuildableItem(new WaitingItem(new GregorianCalendar(), project, new ArrayList())); - Queue.BuildableItem item2 = new Queue.BuildableItem(new WaitingItem(new GregorianCalendar(), project2, new ArrayList())); - Queue.BuildableItem item3 = new Queue.BuildableItem(new WaitingItem(new GregorianCalendar(), project3, new ArrayList())); + Queue.BuildableItem item = new Queue.BuildableItem(new WaitingItem(new GregorianCalendar(), project, new ArrayList<>())); + Queue.BuildableItem item2 = new Queue.BuildableItem(new WaitingItem(new GregorianCalendar(), project2, new ArrayList<>())); + Queue.BuildableItem item3 = new Queue.BuildableItem(new WaitingItem(new GregorianCalendar(), project3, new ArrayList<>())); assertNull("Node should take project which is assigned to its label.", node.canTake(item)); assertNull("Node should take project which is assigned to its label.", node.canTake(item2)); assertNotNull("Node should not take project which is not assigned to its label.", node.canTake(item3)); @@ -506,7 +506,7 @@ public class NodeTest { @Override public Collection findLabels(Node node) { - List atoms = new ArrayList(); + List atoms = new ArrayList<>(); if(addDynamicLabel){ atoms.add(Jenkins.get().getLabelAtom("dynamicLabel")); } diff --git a/test/src/test/java/hudson/model/ProjectTest.java b/test/src/test/java/hudson/model/ProjectTest.java index b60d8748bc..a8937f23fd 100644 --- a/test/src/test/java/hudson/model/ProjectTest.java +++ b/test/src/test/java/hudson/model/ProjectTest.java @@ -836,7 +836,7 @@ public class ProjectTest { @Override public Collection createFor(AbstractProject target) { - List actions = new ArrayList(); + List actions = new ArrayList<>(); if(createAction) actions.add(new TransientAction()); return actions; @@ -922,7 +922,7 @@ public class ProjectTest { @Override public Collection getSubTasks() { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); list.add(new SubTaskImpl()); return list; } @@ -935,7 +935,7 @@ public class ProjectTest { @Override public Collection forProject(AbstractProject p) { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); if(createSubTask){ list.add(new SubTaskImpl2()); } @@ -1008,7 +1008,7 @@ public class ProjectTest { @Override public Collection provision(Label label, int excessWorkload) { - List r = new ArrayList(); + List r = new ArrayList<>(); //Always provision...even if there is no workload. while(excessWorkload >= 0) { diff --git a/test/src/test/java/hudson/model/QueueTest.java b/test/src/test/java/hudson/model/QueueTest.java index df016ad001..10715e20fa 100644 --- a/test/src/test/java/hudson/model/QueueTest.java +++ b/test/src/test/java/hudson/model/QueueTest.java @@ -422,7 +422,7 @@ public class QueueTest { } m.setAxes(new AxisList(new TextAxis("DoesntMatter", "aaa","bbb"))); - List> futures = new ArrayList>(); + List> futures = new ArrayList<>(); for (int i = 0; i < 3; i++) { futures.add(m.scheduleBuild2(0, new UserIdCause(), new ParametersAction(new StringParameterValue("FOO", "value" + i)))); @@ -994,7 +994,7 @@ public class QueueTest { FreeStyleProject project = r.createFreeStyleProject("project"); - Map> permissions = new HashMap>(); + Map> permissions = new HashMap<>(); permissions.put(Item.READ, Collections.singleton("bob")); permissions.put(Item.DISCOVER, Collections.singleton("james")); AuthorizationMatrixProperty prop1 = new AuthorizationMatrixProperty(permissions); diff --git a/test/src/test/java/hudson/model/SimpleJobTest.java b/test/src/test/java/hudson/model/SimpleJobTest.java index 0ccc8b28c0..108eb9fe9d 100644 --- a/test/src/test/java/hudson/model/SimpleJobTest.java +++ b/test/src/test/java/hudson/model/SimpleJobTest.java @@ -23,7 +23,7 @@ public class SimpleJobTest { @Test public void testGetEstimatedDuration() throws IOException { - final SortedMap runs = new TreeMap(); + final SortedMap runs = new TreeMap<>(); Job project = createMockProject(runs); @@ -45,7 +45,7 @@ public class SimpleJobTest { @Test public void testGetEstimatedDurationWithOneRun() throws IOException { - final SortedMap runs = new TreeMap(); + final SortedMap runs = new TreeMap<>(); Job project = createMockProject(runs); @@ -57,7 +57,7 @@ public class SimpleJobTest { public void testGetEstimatedDurationWithFailedRun() throws IOException { - final SortedMap runs = new TreeMap(); + final SortedMap runs = new TreeMap<>(); Job project = createMockProject(runs); @@ -70,7 +70,7 @@ public class SimpleJobTest { @Test public void testGetEstimatedDurationWithNoRuns() throws IOException { - final SortedMap runs = new TreeMap(); + final SortedMap runs = new TreeMap<>(); Job project = createMockProject(runs); @@ -80,7 +80,7 @@ public class SimpleJobTest { @Test public void testGetEstimatedDurationIfPrevious3BuildsFailed() throws IOException { - final SortedMap runs = new TreeMap(); + final SortedMap runs = new TreeMap<>(); Job project = createMockProject(runs); @@ -109,7 +109,7 @@ public class SimpleJobTest { @Test public void testGetEstimatedDurationIfNoSuccessfulBuildTakeDurationOfFailedBuild() throws IOException { - final SortedMap runs = new TreeMap(); + final SortedMap runs = new TreeMap<>(); Job project = createMockProject(runs); diff --git a/test/src/test/java/hudson/model/UpdateSiteTest.java b/test/src/test/java/hudson/model/UpdateSiteTest.java index 02b2be30e1..9fbae8a7ae 100644 --- a/test/src/test/java/hudson/model/UpdateSiteTest.java +++ b/test/src/test/java/hudson/model/UpdateSiteTest.java @@ -125,7 +125,7 @@ public class UpdateSiteTest { Data data = site.getData(); assertNotNull(data); assertEquals(new URL(url, "jenkins.war").toString(), data.core.url); - assertEquals(new HashSet(Arrays.asList("tasks", "dummy")), data.plugins.keySet()); + assertEquals(new HashSet<>(Arrays.asList("tasks", "dummy")), data.plugins.keySet()); assertEquals(new URL(url, "tasks.jpi").toString(), data.plugins.get("tasks").url); assertEquals("http://nowhere.net/dummy.hpi", data.plugins.get("dummy").url); @@ -248,7 +248,7 @@ public class UpdateSiteTest { null, new File("/tmp/" + name + ".jpi.disabled"), null, - new ArrayList() + new ArrayList<>() ); } } diff --git a/test/src/test/java/hudson/model/queue/LoadPredictorTest.java b/test/src/test/java/hudson/model/queue/LoadPredictorTest.java index 71da0a6626..ae4ddf5d3b 100644 --- a/test/src/test/java/hudson/model/queue/LoadPredictorTest.java +++ b/test/src/test/java/hudson/model/queue/LoadPredictorTest.java @@ -93,7 +93,7 @@ public class LoadPredictorTest { } private BuildableItem wrap(Queue.Task t) { - return new BuildableItem(new WaitingItem(new GregorianCalendar(),t,new ArrayList())); + return new BuildableItem(new WaitingItem(new GregorianCalendar(),t,new ArrayList<>())); } /** diff --git a/test/src/test/java/hudson/search/SearchTest.java b/test/src/test/java/hudson/search/SearchTest.java index c6642fd434..ef26ddcce2 100644 --- a/test/src/test/java/hudson/search/SearchTest.java +++ b/test/src/test/java/hudson/search/SearchTest.java @@ -441,7 +441,7 @@ public class SearchTest { } private List suggest(SearchIndex index, String term) { - List result = new ArrayList(); + List result = new ArrayList<>(); index.suggest(term, result); return result; } diff --git a/test/src/test/java/hudson/slaves/JNLPLauncherTest.java b/test/src/test/java/hudson/slaves/JNLPLauncherTest.java index 1d2cced055..b366003640 100644 --- a/test/src/test/java/hudson/slaves/JNLPLauncherTest.java +++ b/test/src/test/java/hudson/slaves/JNLPLauncherTest.java @@ -268,10 +268,10 @@ public class JNLPLauncherTest { * Adds an Inbound TCP agent to the system and returns it. */ private Computer addTestAgent(ComputerLauncher launcher) throws Exception { - List agents = new ArrayList(j.jenkins.getNodes()); + List agents = new ArrayList<>(j.jenkins.getNodes()); File dir = Util.createTempDir(); agents.add(new DumbSlave("test","dummy",dir.getAbsolutePath(),"1", Mode.NORMAL, "", - launcher, RetentionStrategy.INSTANCE, new ArrayList>())); + launcher, RetentionStrategy.INSTANCE, new ArrayList<>())); j.jenkins.setNodes(agents); Computer c = j.jenkins.getComputer("test"); assertNotNull(c); diff --git a/test/src/test/java/hudson/slaves/NodeProvisionerTest.java b/test/src/test/java/hudson/slaves/NodeProvisionerTest.java index dc425490d8..46eca9df61 100644 --- a/test/src/test/java/hudson/slaves/NodeProvisionerTest.java +++ b/test/src/test/java/hudson/slaves/NodeProvisionerTest.java @@ -190,7 +190,7 @@ public class NodeProvisionerTest { } private List create5SlowJobs(Latch l) throws IOException { - List jobs = new ArrayList(); + List jobs = new ArrayList<>(); for( int i=0; i> buildAll(List jobs) { System.out.println("Scheduling builds for "+jobs.size()+" jobs"); - List> builds = new ArrayList>(); + List> builds = new ArrayList<>(); for (FreeStyleProject job : jobs) builds.add(job.scheduleBuild2(0)); return builds; diff --git a/test/src/test/java/hudson/tasks/BuildTriggerTest.java b/test/src/test/java/hudson/tasks/BuildTriggerTest.java index 062f210c0d..ee1f393228 100644 --- a/test/src/test/java/hudson/tasks/BuildTriggerTest.java +++ b/test/src/test/java/hudson/tasks/BuildTriggerTest.java @@ -214,7 +214,7 @@ public class BuildTriggerTest { final FreeStyleProject upstream =j. createFreeStyleProject("upstream"); org.acegisecurity.Authentication alice = User.get("alice").impersonate(); QueueItemAuthenticatorConfiguration.get().getAuthenticators().add(new MockQueueItemAuthenticator(Collections.singletonMap("upstream", alice))); - Map> perms = new HashMap>(); + Map> perms = new HashMap<>(); perms.put(Item.READ, Collections.singleton("alice")); perms.put(Item.CONFIGURE, Collections.singleton("alice")); upstream.addProperty(new AuthorizationMatrixProperty(perms)); @@ -242,7 +242,7 @@ public class BuildTriggerTest { j.waitUntilNoActivity(); assertNull(downstream.getLastBuild()); // If we can see them, but not build them, that is a warning (but this is in cleanUp so the build is still considered a success): - Map> grantedPermissions = new HashMap>(); + Map> grantedPermissions = new HashMap<>(); grantedPermissions.put(Item.READ, Collections.singleton("alice")); AuthorizationMatrixProperty amp = new AuthorizationMatrixProperty(grantedPermissions); downstream.addProperty(amp); diff --git a/test/src/test/java/hudson/triggers/TriggerStartTest.java b/test/src/test/java/hudson/triggers/TriggerStartTest.java index 68d6da7ab5..975d158044 100644 --- a/test/src/test/java/hudson/triggers/TriggerStartTest.java +++ b/test/src/test/java/hudson/triggers/TriggerStartTest.java @@ -107,7 +107,7 @@ public class TriggerStartTest { public static class MockTrigger extends Trigger { - public transient List calls = new ArrayList(); + public transient List calls = new ArrayList<>(); @DataBoundConstructor public MockTrigger() {} @@ -117,7 +117,7 @@ public class TriggerStartTest { } @Override protected Object readResolve() throws ObjectStreamException { - calls = new ArrayList(); + calls = new ArrayList<>(); return super.readResolve(); } diff --git a/test/src/test/java/hudson/util/BootFailureTest.java b/test/src/test/java/hudson/util/BootFailureTest.java index dd546b9c0a..b55eee37fe 100644 --- a/test/src/test/java/hudson/util/BootFailureTest.java +++ b/test/src/test/java/hudson/util/BootFailureTest.java @@ -140,7 +140,7 @@ public class BootFailureTest { // second failed boot problem = null; - runRecord = new ArrayList(); + runRecord = new ArrayList<>(); assertNull(j.newHudson()); assertEquals(2, bootFailures(home)); assertEquals(Arrays.asList("1", "2"), runRecord); @@ -184,6 +184,6 @@ public class BootFailureTest { // to be set by the script public static Exception problem; - public static List runRecord = new ArrayList(); + public static List runRecord = new ArrayList<>(); } diff --git a/test/src/test/java/jenkins/model/ContextMenuTest.java b/test/src/test/java/jenkins/model/ContextMenuTest.java index a890dac491..b3233e98dd 100644 --- a/test/src/test/java/jenkins/model/ContextMenuTest.java +++ b/test/src/test/java/jenkins/model/ContextMenuTest.java @@ -94,7 +94,7 @@ public class ContextMenuTest { } private static Map parse(ContextMenu menu) { - Map r = new TreeMap(); + Map r = new TreeMap<>(); for (MenuItem mi : menu.items) { r.put(mi.url.replaceFirst("^.*/(.)", "$1"), mi.displayName); } diff --git a/test/src/test/java/jenkins/security/SecurityContextExecutorServiceTest.java b/test/src/test/java/jenkins/security/SecurityContextExecutorServiceTest.java index 816e23967a..090b6e5de8 100644 --- a/test/src/test/java/jenkins/security/SecurityContextExecutorServiceTest.java +++ b/test/src/test/java/jenkins/security/SecurityContextExecutorServiceTest.java @@ -133,7 +133,7 @@ public class SecurityContextExecutorServiceTest { @Test @PresetData(PresetData.DataSet.NO_ANONYMOUS_READACCESS) public void testCallableCollectionAgainstAllContexts() throws Exception { - Collection> callables = new LinkedList>(); + Collection> callables = new LinkedList<>(); Callable c = new Callable() { public SecurityContext call() throws Exception { return SecurityContextHolder.getContext(); diff --git a/test/src/test/java/lib/form/RepeatablePropertyTest.java b/test/src/test/java/lib/form/RepeatablePropertyTest.java index 3872f49f8e..e30406ce4f 100644 --- a/test/src/test/java/lib/form/RepeatablePropertyTest.java +++ b/test/src/test/java/lib/form/RepeatablePropertyTest.java @@ -61,7 +61,7 @@ public class RepeatablePropertyTest extends HudsonTestCase implements Describabl } public void testNullFieldNoDefault() throws Exception { - assertFormContents(VIEW_WITHOUT_DEFAULT, new ArrayList()); + assertFormContents(VIEW_WITHOUT_DEFAULT, new ArrayList<>()); } public void testNullFieldWithDefault() throws Exception { @@ -71,7 +71,7 @@ public class RepeatablePropertyTest extends HudsonTestCase implements Describabl public void testFieldNotNullWithDefaultIgnoresDefaults() throws Exception { testRepeatable = createRepeatable(); - defaults = new ArrayList(Arrays.asList( + defaults = new ArrayList<>(Arrays.asList( new ExcitingObject("This default should be ignored"), new ExcitingObject("Ignore me too") )); @@ -114,7 +114,7 @@ public class RepeatablePropertyTest extends HudsonTestCase implements Describabl private List toTextInputList(final List inputs) { assertNotNull(inputs); - final List textInputList = new ArrayList(); + final List textInputList = new ArrayList<>(); for (HtmlElement input : inputs) { assertTrue(input instanceof HtmlTextInput); textInputList.add((HtmlTextInput) input); @@ -123,7 +123,7 @@ public class RepeatablePropertyTest extends HudsonTestCase implements Describabl } private ArrayList createRepeatable() { - return new ArrayList(Arrays.asList( + return new ArrayList<>(Arrays.asList( new ExcitingObject("A nice thing"), new ExcitingObject("I'm even better"), new ExcitingObject("Don't bother, I'm not exciting at all") diff --git a/test/src/test/java/lib/form/RepeatableTest.java b/test/src/test/java/lib/form/RepeatableTest.java index 22bd02b667..66327fbb11 100644 --- a/test/src/test/java/lib/form/RepeatableTest.java +++ b/test/src/test/java/lib/form/RepeatableTest.java @@ -54,7 +54,7 @@ public class RepeatableTest extends HudsonTestCase { private JSONObject formData; private Class bindClass; private List bindResult; - public List list = new ArrayList(); + public List list = new ArrayList<>(); public List defaults = null; public Integer minimum = null; @@ -206,7 +206,7 @@ public class RepeatableTest extends HudsonTestCase { } private void addDefaults() { - defaults = new ArrayList(); + defaults = new ArrayList<>(); defaults.add(new Foo("default one", true)); defaults.add(new Foo("default two", false)); } diff --git a/test/src/test/java/lib/hudson/ListScmBrowsersTest.java b/test/src/test/java/lib/hudson/ListScmBrowsersTest.java index d4848d43f2..5befd7bb56 100644 --- a/test/src/test/java/lib/hudson/ListScmBrowsersTest.java +++ b/test/src/test/java/lib/hudson/ListScmBrowsersTest.java @@ -47,7 +47,7 @@ public class ListScmBrowsersTest { List selects = DomNodeUtil.selectNodes(page, "//select"); assertTrue(selects.size()>0); for (HtmlSelect select : selects) { - Set title = new HashSet(); + Set title = new HashSet<>(); for(HtmlOption o : select.getOptions()) { assertTrue("Duplicate entry: "+o.getText(),title.add(o.getText())); } From 406cefcd7359c84915677e4ff2f2477ca50d6476 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Tue, 15 Dec 2020 16:50:48 -0800 Subject: [PATCH 02/16] Replace anonymous types with method references --- core/src/main/java/hudson/model/LoadBalancer.java | 6 +----- core/src/main/java/hudson/util/ProcessTree.java | 6 +----- .../test/java/jenkins/security/ApiTokenPropertyTest.java | 6 +----- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/core/src/main/java/hudson/model/LoadBalancer.java b/core/src/main/java/hudson/model/LoadBalancer.java index 37446a181e..22a4b4097c 100644 --- a/core/src/main/java/hudson/model/LoadBalancer.java +++ b/core/src/main/java/hudson/model/LoadBalancer.java @@ -83,11 +83,7 @@ public abstract class LoadBalancer implements ExtensionPoint { // build consistent hash for each work chunk List> hashes = new ArrayList<>(ws.works.size()); for (int i=0; i hash = new ConsistentHash<>(new Hash() { - public String hash(ExecutorChunk node) { - return node.getName(); - } - }); + ConsistentHash hash = new ConsistentHash<>(ExecutorChunk::getName); // Build a Map to pass in rather than repeatedly calling hash.add() because each call does lots of expensive work List chunks = ws.works(i).applicableExecutorChunks(); diff --git a/core/src/main/java/hudson/util/ProcessTree.java b/core/src/main/java/hudson/util/ProcessTree.java index 0b35c67da3..e7bd30cc27 100644 --- a/core/src/main/java/hudson/util/ProcessTree.java +++ b/core/src/main/java/hudson/util/ProcessTree.java @@ -741,11 +741,7 @@ public abstract class ProcessTree implements Iterable, IProcessTree, ProcfsUnix(boolean vetoersExist) { super(vetoersExist); - File[] processes = new File("/proc").listFiles(new FileFilter() { - public boolean accept(File f) { - return f.isDirectory(); - } - }); + File[] processes = new File("/proc").listFiles(File::isDirectory); if(processes==null) { LOGGER.info("No /proc"); return; diff --git a/test/src/test/java/jenkins/security/ApiTokenPropertyTest.java b/test/src/test/java/jenkins/security/ApiTokenPropertyTest.java index dd017c7f27..7368140592 100644 --- a/test/src/test/java/jenkins/security/ApiTokenPropertyTest.java +++ b/test/src/test/java/jenkins/security/ApiTokenPropertyTest.java @@ -84,11 +84,7 @@ public class ApiTokenPropertyTest { // test the authentication via Token WebClient wc = createClientForUser("foo"); - assertEquals(u, wc.executeOnServer(new Callable() { - public User call() throws Exception { - return User.current(); - } - })); + assertEquals(u, wc.executeOnServer(User::current)); // Make sure the UI shows the token to the user HtmlPage config = wc.goTo(u.getUrl() + "/configure"); From e83bde4ca244af79ff9d7d9a975bc3917cfa639c Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Tue, 15 Dec 2020 16:51:28 -0800 Subject: [PATCH 03/16] Replace ThreadLocal#initialValue with ThreadLocal#withInitial --- core/src/main/java/hudson/model/Items.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/core/src/main/java/hudson/model/Items.java b/core/src/main/java/hudson/model/Items.java index e21efe6d5b..7a98e3c639 100644 --- a/core/src/main/java/hudson/model/Items.java +++ b/core/src/main/java/hudson/model/Items.java @@ -76,11 +76,7 @@ public class Items { * @see Trigger#start * @since 1.482 */ - private static final ThreadLocal updatingByXml = new ThreadLocal() { - @Override protected Boolean initialValue() { - return false; - } - }; + private static final ThreadLocal updatingByXml = ThreadLocal.withInitial(() -> false); /** * A comparator of {@link Item} instances that uses a case-insensitive comparison of {@link Item#getName()}. * If you are replacing {@link #getAllItems(ItemGroup, Class)} with {@link #allItems(ItemGroup, Class)} and From b4a4e5d8ee8f7029cfc666822f2b9cf1cfc44089 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Tue, 15 Dec 2020 17:22:19 -0800 Subject: [PATCH 04/16] Replace toString() on an array with Arrays#toString() --- test/src/test/java/hudson/model/QueueTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/src/test/java/hudson/model/QueueTest.java b/test/src/test/java/hudson/model/QueueTest.java index 10715e20fa..f9dfca8dba 100644 --- a/test/src/test/java/hudson/model/QueueTest.java +++ b/test/src/test/java/hudson/model/QueueTest.java @@ -446,7 +446,7 @@ public class QueueTest { try { build = m.scheduleBuild2(0).get(60, TimeUnit.SECONDS); } catch (TimeoutException x) { - throw new AssertionError(r.jenkins.getQueue().getItems().toString(), x); + throw new AssertionError(Arrays.toString(r.jenkins.getQueue().getItems()), x); } r.assertBuildStatusSuccess(build); assertEquals("", build.getBuiltOnStr()); From a51b2116615af5f57296d720a67177ac17c03a82 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Tue, 15 Dec 2020 17:23:05 -0800 Subject: [PATCH 05/16] Remove getClass() call on Class instance --- .../test/java/hudson/cli/handlers/ViewOptionHandlerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/test/java/hudson/cli/handlers/ViewOptionHandlerTest.java b/core/src/test/java/hudson/cli/handlers/ViewOptionHandlerTest.java index 39eeeb3e8a..33793bea5b 100644 --- a/core/src/test/java/hudson/cli/handlers/ViewOptionHandlerTest.java +++ b/core/src/test/java/hudson/cli/handlers/ViewOptionHandlerTest.java @@ -249,7 +249,7 @@ public class ViewOptionHandlerTest { return ex.getMessage(); } - fail("No exception thrown. Expected " + type.getClass()); + fail("No exception thrown. Expected " + type); return null; } From e1c76367c10ee78882e55e55fb039b3eec0a9f52 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Tue, 15 Dec 2020 18:03:35 -0800 Subject: [PATCH 06/16] Remove unused labels --- test/src/test/java/lib/form/TextAreaTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/src/test/java/lib/form/TextAreaTest.java b/test/src/test/java/lib/form/TextAreaTest.java index 1c99d796cf..bb355931c8 100644 --- a/test/src/test/java/lib/form/TextAreaTest.java +++ b/test/src/test/java/lib/form/TextAreaTest.java @@ -72,7 +72,7 @@ public class TextAreaTest { @Issue("JENKINS-27505") @Test public void text() throws Exception { - T1: { + { String TEXT_TO_TEST = "some\nvalue\n"; FreeStyleProject p = j.createFreeStyleProject(); TextareaTestBuilder target = new TextareaTestBuilder(TEXT_TO_TEST); @@ -82,7 +82,7 @@ public class TextAreaTest { } // test for a textarea beginning with a empty line. - T2: { + { String TEXT_TO_TEST = "\nbegin\n\nwith\nempty\nline\n\n"; FreeStyleProject p = j.createFreeStyleProject(); TextareaTestBuilder target = new TextareaTestBuilder(TEXT_TO_TEST); @@ -92,7 +92,7 @@ public class TextAreaTest { } // test for a textarea beginning with two empty lines. - T3: { + { String TEXT_TO_TEST = "\n\nbegin\n\nwith\ntwo\nempty\nline\n\n"; FreeStyleProject p = j.createFreeStyleProject(); TextareaTestBuilder target = new TextareaTestBuilder(TEXT_TO_TEST); From e8bc4e47265b887c1ef334a013de48a5b5f6f2e5 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Tue, 15 Dec 2020 17:26:10 -0800 Subject: [PATCH 07/16] Simplify JUnit assertions --- .../cli/handlers/ViewOptionHandlerTest.java | 5 ++-- .../hudson/model/RunParameterValueTest.java | 5 ++-- core/src/test/java/hudson/model/RunTest.java | 4 ++-- .../java/hudson/model/UpdateCenterTest.java | 4 ++-- .../java/jenkins/model/IdStrategyTest.java | 23 ++++++++++--------- .../jenkins/util/ResourceBundleUtilTest.java | 2 +- .../org/acegisecurity/AuthenticationTest.java | 5 ++-- .../src/test/java/hudson/model/QueueTest.java | 7 +++--- .../hudson/model/TimeZonePropertyTest.java | 4 ++-- test/src/test/java/hudson/model/UserTest.java | 2 +- test/src/test/java/hudson/model/ViewTest.java | 2 +- .../test/java/hudson/search/SearchTest.java | 6 ++--- .../jenkins/install/InstallStateTest.java | 5 ++-- .../jenkins/install/UpgradeWizardTest.java | 3 ++- .../test/java/jenkins/model/JenkinsTest.java | 9 ++++---- .../java/lib/form/RowVisibilityGroupTest.java | 2 +- 16 files changed, 48 insertions(+), 40 deletions(-) diff --git a/core/src/test/java/hudson/cli/handlers/ViewOptionHandlerTest.java b/core/src/test/java/hudson/cli/handlers/ViewOptionHandlerTest.java index 33793bea5b..f404aeb726 100644 --- a/core/src/test/java/hudson/cli/handlers/ViewOptionHandlerTest.java +++ b/core/src/test/java/hudson/cli/handlers/ViewOptionHandlerTest.java @@ -24,6 +24,7 @@ package hudson.cli.handlers; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.verify; @@ -163,13 +164,13 @@ public class ViewOptionHandlerTest { } @Test public void reportEmptyViewNameRequestAsNull() throws Exception { - assertEquals(handler.getView(""), null); + assertNull(handler.getView("")); verifyZeroInteractions(setter); } @Test public void reportViewSpaceNameRequestAsIAE() throws Exception { try { - assertEquals(handler.getView(" "), null); + assertNull(handler.getView(" ")); fail("No exception thrown. Expected IllegalArgumentException"); } catch (IllegalArgumentException e) { assertEquals("No view named inside view Jenkins", e.getMessage()); diff --git a/core/src/test/java/hudson/model/RunParameterValueTest.java b/core/src/test/java/hudson/model/RunParameterValueTest.java index 981742970c..ce34590540 100644 --- a/core/src/test/java/hudson/model/RunParameterValueTest.java +++ b/core/src/test/java/hudson/model/RunParameterValueTest.java @@ -26,6 +26,7 @@ package hudson.model; import org.junit.Test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; public class RunParameterValueTest { @@ -56,8 +57,8 @@ public class RunParameterValueTest { } rpv = (RunParameterValue) Run.XSTREAM2.fromXML("whateverbogus"); assertEquals("whatever", rpv.getName()); - assertEquals(null, rpv.getJobName()); - assertEquals(null, rpv.getNumber()); + assertNull(rpv.getJobName()); + assertNull(rpv.getNumber()); } } diff --git a/core/src/test/java/hudson/model/RunTest.java b/core/src/test/java/hudson/model/RunTest.java index ef1715a2f8..9ec56c738d 100644 --- a/core/src/test/java/hudson/model/RunTest.java +++ b/core/src/test/java/hudson/model/RunTest.java @@ -239,7 +239,7 @@ public class RunTest { treeSet.add(r2); assertTrue(r1.compareTo(r2) < 0); - assertTrue(treeSet.size() == 2); + assertEquals(2, treeSet.size()); } @Issue("JENKINS-42319") @@ -264,7 +264,7 @@ public class RunTest { treeSet.add(r2); assertTrue(r1.compareTo(r2) != 0); - assertTrue(treeSet.size() == 2); + assertEquals(2, treeSet.size()); } @Test diff --git a/core/src/test/java/hudson/model/UpdateCenterTest.java b/core/src/test/java/hudson/model/UpdateCenterTest.java index d5bebba503..14959d48b7 100644 --- a/core/src/test/java/hudson/model/UpdateCenterTest.java +++ b/core/src/test/java/hudson/model/UpdateCenterTest.java @@ -114,7 +114,7 @@ public class UpdateCenterTest { buildEntryWithExpectedChecksums(null, null, EMPTY_SHA512), new File("example")); fail(); } catch (Exception e) { - assertTrue(e.getMessage().equals("Unable to confirm integrity of downloaded file, refusing installation")); + assertEquals("Unable to confirm integrity of downloaded file, refusing installation", e.getMessage()); } } @@ -126,7 +126,7 @@ public class UpdateCenterTest { buildEntryWithExpectedChecksums(null, EMPTY_SHA256, EMPTY_SHA512), new File("example")); fail(); } catch (Exception e) { - assertTrue(e.getMessage().equals("Unable to confirm integrity of downloaded file, refusing installation")); + assertEquals("Unable to confirm integrity of downloaded file, refusing installation", e.getMessage()); } } diff --git a/core/src/test/java/jenkins/model/IdStrategyTest.java b/core/src/test/java/jenkins/model/IdStrategyTest.java index fa26420f1f..c2315ff3cf 100644 --- a/core/src/test/java/jenkins/model/IdStrategyTest.java +++ b/core/src/test/java/jenkins/model/IdStrategyTest.java @@ -3,6 +3,7 @@ package jenkins.model; import org.junit.Test; import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertTrue; @@ -170,10 +171,10 @@ public class IdStrategyTest { IdStrategy idStrategy = IdStrategy.CASE_INSENSITIVE; assertTrue(idStrategy.compare("user1", "user2") < 0); assertTrue(idStrategy.compare("user2", "user1") > 0); - assertTrue(idStrategy.compare("user1", "user1") == 0); + assertEquals(0, idStrategy.compare("user1", "user1")); assertTrue(idStrategy.compare("USER1", "user2") < 0); assertTrue(idStrategy.compare("USER2", "user1") > 0); - assertTrue(idStrategy.compare("User1", "user1") == 0); + assertEquals(0, idStrategy.compare("User1", "user1")); } @Test @@ -181,7 +182,7 @@ public class IdStrategyTest { IdStrategy idStrategy = new IdStrategy.CaseSensitive(); assertTrue(idStrategy.compare("user1", "user2") < 0); assertTrue(idStrategy.compare("user2", "user1") > 0); - assertTrue(idStrategy.compare("user1", "user1") == 0); + assertEquals(0, idStrategy.compare("user1", "user1")); assertTrue(idStrategy.compare("USER1", "user2") < 0); assertTrue(idStrategy.compare("USER2", "user1") < 0); assertTrue(idStrategy.compare("User1", "user1") < 0); @@ -190,14 +191,14 @@ public class IdStrategyTest { @Test public void testCompareCaseSensitiveEmail() { IdStrategy idStrategy = new IdStrategy.CaseSensitiveEmailAddress(); - assertTrue(idStrategy.compare("john.smith@acme.org", "john.smith@acme.org") == 0); - assertTrue(idStrategy.compare("John.Smith@acme.org", "John.Smith@acme.org") == 0); - assertTrue(idStrategy.compare("John.Smith@ACME.org", "John.Smith@acme.org") == 0); - assertTrue(idStrategy.compare("John.Smith@acme.ORG", "John.Smith@acme.org") == 0); - assertTrue(idStrategy.compare("john.smith", "john.smith") == 0); - assertTrue(idStrategy.compare("John.Smith", "John.Smith") == 0); - assertTrue(idStrategy.compare("john@smith@acme.org", "john@smith@acme.org") == 0); - assertTrue(idStrategy.compare("John@Smith@acme.org", "John@Smith@acme.org") == 0); + assertEquals(0, idStrategy.compare("john.smith@acme.org", "john.smith@acme.org")); + assertEquals(0, idStrategy.compare("John.Smith@acme.org", "John.Smith@acme.org")); + assertEquals(0, idStrategy.compare("John.Smith@ACME.org", "John.Smith@acme.org")); + assertEquals(0, idStrategy.compare("John.Smith@acme.ORG", "John.Smith@acme.org")); + assertEquals(0, idStrategy.compare("john.smith", "john.smith")); + assertEquals(0, idStrategy.compare("John.Smith", "John.Smith")); + assertEquals(0, idStrategy.compare("john@smith@acme.org", "john@smith@acme.org")); + assertEquals(0, idStrategy.compare("John@Smith@acme.org", "John@Smith@acme.org")); assertTrue(idStrategy.compare("John.Smith@acme.org", "john.smith@acme.org") < 0); assertTrue(idStrategy.compare("john.smith@acme.org", "John.Smith@acme.org") > 0); diff --git a/core/src/test/java/jenkins/util/ResourceBundleUtilTest.java b/core/src/test/java/jenkins/util/ResourceBundleUtilTest.java index 137bffb09b..5954ff8be4 100644 --- a/core/src/test/java/jenkins/util/ResourceBundleUtilTest.java +++ b/core/src/test/java/jenkins/util/ResourceBundleUtilTest.java @@ -46,7 +46,7 @@ public class ResourceBundleUtilTest { Assert.assertEquals("Inicializando registros de log", bundle.getString("LogRecorderManager.init")); // Test caching - should get the same bundle instance back... - Assert.assertTrue(ResourceBundleUtil.getBundle("hudson.logging.Messages", new Locale("pt")) == bundle); + Assert.assertSame(ResourceBundleUtil.getBundle("hudson.logging.Messages", new Locale("pt")), bundle); } /** diff --git a/core/src/test/java/org/acegisecurity/AuthenticationTest.java b/core/src/test/java/org/acegisecurity/AuthenticationTest.java index 577a779414..abfe17b8b1 100644 --- a/core/src/test/java/org/acegisecurity/AuthenticationTest.java +++ b/core/src/test/java/org/acegisecurity/AuthenticationTest.java @@ -40,6 +40,7 @@ import static org.hamcrest.Matchers.instanceOf; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.function.Executable; @@ -49,8 +50,8 @@ public class AuthenticationTest { @Test public void system() { assertEquality(ACL.SYSTEM, ACL.SYSTEM2); - assertTrue(ACL.SYSTEM == org.acegisecurity.Authentication.fromSpring(ACL.SYSTEM2), "old code often compares a == SYSTEM"); - assertTrue(ACL.SYSTEM2 == ACL.SYSTEM.toSpring()); + assertSame(ACL.SYSTEM, org.acegisecurity.Authentication.fromSpring(ACL.SYSTEM2), "old code often compares a == SYSTEM"); + assertSame(ACL.SYSTEM2, ACL.SYSTEM.toSpring()); } diff --git a/test/src/test/java/hudson/model/QueueTest.java b/test/src/test/java/hudson/model/QueueTest.java index f9dfca8dba..2cae64611e 100644 --- a/test/src/test/java/hudson/model/QueueTest.java +++ b/test/src/test/java/hudson/model/QueueTest.java @@ -141,6 +141,7 @@ import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNull; @@ -773,7 +774,7 @@ public class QueueTest { //project2 should not be in pendings List items = Queue.getInstance().getPendingItems(); for(Queue.BuildableItem item : items){ - assertFalse("Project " + project2.getDisplayName() + " stuck in pendings",item.task.getName().equals(project2.getName())); + assertNotEquals("Project " + project2.getDisplayName() + " stuck in pendings", item.task.getName(), project2.getName()); } } @@ -948,7 +949,7 @@ public class QueueTest { Thread.sleep(10); } assertTrue(Queue.getInstance().getItems()[0].isBlocked()); - assertTrue(Queue.getInstance().getBlockedItems().get(0).task.getDisplayName().equals(matrixProject.displayName)); + assertEquals(Queue.getInstance().getBlockedItems().get(0).task.getDisplayName(), matrixProject.displayName); //once the upstream is completed, the downstream can join the buildable queue again. r.assertBuildStatusSuccess(upstream); @@ -957,7 +958,7 @@ public class QueueTest { } assertFalse(Queue.getInstance().getItems()[0].isBlocked()); assertTrue(Queue.getInstance().getBlockedItems().isEmpty()); - assertTrue(Queue.getInstance().getBuildableItems().get(0).task.getDisplayName().equals(matrixProject.displayName)); + assertEquals(Queue.getInstance().getBuildableItems().get(0).task.getDisplayName(), matrixProject.displayName); } //let's make sure that the downstream project is not started before the upstream --> we want to simulate diff --git a/test/src/test/java/hudson/model/TimeZonePropertyTest.java b/test/src/test/java/hudson/model/TimeZonePropertyTest.java index 3f2c192991..881827d5b3 100644 --- a/test/src/test/java/hudson/model/TimeZonePropertyTest.java +++ b/test/src/test/java/hudson/model/TimeZonePropertyTest.java @@ -34,7 +34,7 @@ public class TimeZonePropertyTest { TimeZoneProperty tzp = new TimeZoneProperty("InvalidTimeZoneName"); user.addProperty(tzp); - assertEquals(null, TimeZoneProperty.forCurrentUser()); + assertNull(TimeZoneProperty.forCurrentUser()); } @Test @@ -45,7 +45,7 @@ public class TimeZonePropertyTest { User user = User.get("John Smith", true, java.util.Collections.emptyMap()); SecurityContextHolder.getContext().setAuthentication(user.impersonate2()); - assertEquals(null, TimeZoneProperty.forCurrentUser()); + assertNull(TimeZoneProperty.forCurrentUser()); TimeZoneProperty tzp = new TimeZoneProperty(timeZone); user.addProperty(tzp); assertEquals(TimeZone.getDefault().getID(), TimeZoneProperty.forCurrentUser()); diff --git a/test/src/test/java/hudson/model/UserTest.java b/test/src/test/java/hudson/model/UserTest.java index 6ad924ba33..850aac07cc 100644 --- a/test/src/test/java/hudson/model/UserTest.java +++ b/test/src/test/java/hudson/model/UserTest.java @@ -605,7 +605,7 @@ public class UserTest { attacker1.setFullName("victim1"); User victim1 = User.get("victim1"); assertEquals("victim1 is a real user ID, we must ignore the attacker1’s fullName", "victim1", victim1.getId()); - assertEquals("a recursive call to User.get was OK", null, victim1.getProperty(MyViewsProperty.class).getPrimaryViewName()); + assertNull("a recursive call to User.get was OK", victim1.getProperty(MyViewsProperty.class).getPrimaryViewName()); assertEquals("(though the realm mistakenly added metadata to the attacker)", "victim1", attacker1.getProperty(MyViewsProperty.class).getPrimaryViewName()); User.get("attacker2").setFullName("nonexistent"); assertEquals("but if we cannot find such a user ID, allow the fullName", "attacker2", User.get("nonexistent").getId()); diff --git a/test/src/test/java/hudson/model/ViewTest.java b/test/src/test/java/hudson/model/ViewTest.java index b38fdeed3a..54506d2275 100644 --- a/test/src/test/java/hudson/model/ViewTest.java +++ b/test/src/test/java/hudson/model/ViewTest.java @@ -289,7 +289,7 @@ public class ViewTest { req.setRequestBody(xml); req.setEncodingType(null); wc.getPage(req); - assertEquals(null, view.getDescription()); // did not work + assertNull(view.getDescription()); // did not work xml = new XmlFile(Jenkins.XSTREAM, new File(j.jenkins.getRootDir(), "config.xml")).asString(); assertThat(xml, not(containsString(""))); // did not work assertEquals(j.jenkins, view.getOwner()); diff --git a/test/src/test/java/hudson/search/SearchTest.java b/test/src/test/java/hudson/search/SearchTest.java index ef26ddcce2..2b6678d289 100644 --- a/test/src/test/java/hudson/search/SearchTest.java +++ b/test/src/test/java/hudson/search/SearchTest.java @@ -120,7 +120,7 @@ public class SearchTest { j.assertGoodStatus(result); URL resultUrl = result.getUrl(); - assertTrue(resultUrl.toString().equals(j.getInstance().getRootUrl() + myFreeStyleProject.getUrl())); + assertEquals(j.getInstance().getRootUrl() + myFreeStyleProject.getUrl(), resultUrl.toString()); } @Issue("JENKINS-24433") @@ -136,7 +136,7 @@ public class SearchTest { j.assertGoodStatus(result); URL resultUrl = result.getUrl(); - assertTrue(resultUrl.toString().equals(j.getInstance().getRootUrl() + myFreeStyleProject.getUrl())); + assertEquals(j.getInstance().getRootUrl() + myFreeStyleProject.getUrl(), resultUrl.toString()); } @Test @@ -482,6 +482,6 @@ public class SearchTest { j.assertGoodStatus(searchResult); URL resultUrl = searchResult.getUrl(); - assertTrue(resultUrl.toString().equals(j.getInstance().getRootUrl() + freeStyleProject.getUrl())); + assertEquals(j.getInstance().getRootUrl() + freeStyleProject.getUrl(), resultUrl.toString()); } } diff --git a/test/src/test/java/jenkins/install/InstallStateTest.java b/test/src/test/java/jenkins/install/InstallStateTest.java index d81dc4c14a..da33779dd1 100644 --- a/test/src/test/java/jenkins/install/InstallStateTest.java +++ b/test/src/test/java/jenkins/install/InstallStateTest.java @@ -28,6 +28,7 @@ import jenkins.model.Jenkins; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import org.junit.Rule; import org.junit.Test; @@ -56,8 +57,8 @@ public class InstallStateTest { // It also prevents occasional name duplications assertThat("State after the roundtrip must be equal to the original state", afterRoundtrip, equalTo(state)); - assertTrue("State " + state + " should return the extension point instance after deserialization", - afterRoundtrip == state); + assertSame("State " + state + " should return the extension point instance after deserialization", + afterRoundtrip, state); } } diff --git a/test/src/test/java/jenkins/install/UpgradeWizardTest.java b/test/src/test/java/jenkins/install/UpgradeWizardTest.java index af64f67769..6ec717cc3f 100644 --- a/test/src/test/java/jenkins/install/UpgradeWizardTest.java +++ b/test/src/test/java/jenkins/install/UpgradeWizardTest.java @@ -20,6 +20,7 @@ import java.lang.reflect.Field; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -92,7 +93,7 @@ public class UpgradeWizardTest { j.executeOnServer(new Callable() { @Override public Void call() throws Exception { - assertTrue(j.jenkins.getUpdateCenter().getJobs().size() == 0); + assertEquals(0, j.jenkins.getUpdateCenter().getJobs().size()); writeVersion("1.5"); assertTrue(getInstance().isDue()); diff --git a/test/src/test/java/jenkins/model/JenkinsTest.java b/test/src/test/java/jenkins/model/JenkinsTest.java index de190a9e8f..8f2ac3289b 100644 --- a/test/src/test/java/jenkins/model/JenkinsTest.java +++ b/test/src/test/java/jenkins/model/JenkinsTest.java @@ -28,6 +28,7 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertEquals; @@ -530,7 +531,7 @@ public class JenkinsTest { j.jenkins.reload(); final Set reloadedProtocols = j.jenkins.getAgentProtocols(); - assertFalse("The protocol list must have been really reloaded", agentProtocolsBeforeReload == reloadedProtocols); + assertNotSame("The protocol list must have been really reloaded", agentProtocolsBeforeReload, reloadedProtocols); assertThat("We should have additional enabled protocol", reloadedProtocols.size(), equalTo(defaultProtocols.size() + 1)); assertProtocolEnabled(MockOptInProtocol1.NAME, "after the roundtrip"); @@ -550,7 +551,7 @@ public class JenkinsTest { final Set agentProtocolsBeforeReload = j.jenkins.getAgentProtocols(); j.jenkins.reload(); - assertFalse("The protocol list must have been really refreshed", agentProtocolsBeforeReload == j.jenkins.getAgentProtocols()); + assertNotSame("The protocol list must have been really refreshed", agentProtocolsBeforeReload, j.jenkins.getAgentProtocols()); assertThat("We should have disabled one protocol", j.jenkins.getAgentProtocols().size(), equalTo(defaultProtocols.size() - 1)); @@ -574,7 +575,7 @@ public class JenkinsTest { j.jenkins.reload(); final Set reloadedProtocols = j.jenkins.getAgentProtocols(); - assertFalse("The protocol list must have been really reloaded", agentProtocolsBeforeReload == reloadedProtocols); + assertNotSame("The protocol list must have been really reloaded", agentProtocolsBeforeReload, reloadedProtocols); assertThat("There should be two additional enabled protocols", reloadedProtocols.size(), equalTo(defaultProtocols.size() + 2)); assertProtocolEnabled(MockOptInProtocol1.NAME, "after the roundtrip"); @@ -598,7 +599,7 @@ public class JenkinsTest { final Set agentProtocolsBeforeReload = j.jenkins.getAgentProtocols(); j.jenkins.reload(); - assertFalse("The protocol list must have been really reloaded", agentProtocolsBeforeReload == j.jenkins.getAgentProtocols()); + assertNotSame("The protocol list must have been really reloaded", agentProtocolsBeforeReload, j.jenkins.getAgentProtocols()); assertThat("We should have disabled two protocols", j.jenkins.getAgentProtocols().size(), equalTo(defaultProtocols.size() - 2)); assertProtocolDisabled(protocolToDisable1, "after the roundtrip"); diff --git a/test/src/test/java/lib/form/RowVisibilityGroupTest.java b/test/src/test/java/lib/form/RowVisibilityGroupTest.java index ab7c120e7c..4af875d3e4 100644 --- a/test/src/test/java/lib/form/RowVisibilityGroupTest.java +++ b/test/src/test/java/lib/form/RowVisibilityGroupTest.java @@ -82,7 +82,7 @@ public class RowVisibilityGroupTest extends HudsonTestCase implements Describabl List textboxes = DomNodeUtil.selectNodes(p, "//INPUT[@name='_.textbox2']"); assertEquals(2,textboxes.size()); for (HtmlInput e : textboxes) - assertTrue(!e.isDisplayed()); + assertFalse(e.isDisplayed()); // reveal the text box List checkboxes = DomNodeUtil.selectNodes(p, "//INPUT[@name='inner']"); From 0fc068b82d16d8b78bda7dd35912fe77e5ffd677 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Tue, 15 Dec 2020 17:27:51 -0800 Subject: [PATCH 08/16] Remove redundant type argument --- test/src/test/java/hudson/model/QueueTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/src/test/java/hudson/model/QueueTest.java b/test/src/test/java/hudson/model/QueueTest.java index 2cae64611e..f7d7d93a12 100644 --- a/test/src/test/java/hudson/model/QueueTest.java +++ b/test/src/test/java/hudson/model/QueueTest.java @@ -440,7 +440,7 @@ public class QueueTest { cloud.label = r.jenkins.getLabel("remote"); r.jenkins.clouds.add(cloud); r.jenkins.setNumExecutors(0); - r.jenkins.setNodes(Collections.emptyList()); + r.jenkins.setNodes(Collections.emptyList()); MatrixProject m = r.jenkins.createProject(MatrixProject.class, "p"); m.setAxes(new AxisList(new LabelAxis("label", Collections.singletonList("remote")))); MatrixBuild build; From c7c623d502640ebf266b9226936746d944d4cfff Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Tue, 15 Dec 2020 18:08:31 -0800 Subject: [PATCH 09/16] Add missing @Test annotations --- core/src/test/java/hudson/FilePathTest.java | 2 +- test/src/test/java/hudson/model/SimpleJobTest.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/test/java/hudson/FilePathTest.java b/core/src/test/java/hudson/FilePathTest.java index e4d63df2c3..aa6723f609 100644 --- a/core/src/test/java/hudson/FilePathTest.java +++ b/core/src/test/java/hudson/FilePathTest.java @@ -556,7 +556,7 @@ public class FilePathTest { } @Issue("JENKINS-5253") - public void testValidateCaseSensitivity() throws Exception { + @Test public void testValidateCaseSensitivity() throws Exception { File tmp = Util.createTempDir(); try { FilePath d = new FilePath(channels.french, tmp.getPath()); diff --git a/test/src/test/java/hudson/model/SimpleJobTest.java b/test/src/test/java/hudson/model/SimpleJobTest.java index 108eb9fe9d..679ca797b2 100644 --- a/test/src/test/java/hudson/model/SimpleJobTest.java +++ b/test/src/test/java/hudson/model/SimpleJobTest.java @@ -55,6 +55,7 @@ public class SimpleJobTest { assertEquals(42, project.getEstimatedDuration()); } + @Test public void testGetEstimatedDurationWithFailedRun() throws IOException { final SortedMap runs = new TreeMap<>(); @@ -64,7 +65,7 @@ public class SimpleJobTest { TestBuild lastBuild = new TestBuild(project, Result.FAILURE, 42, null); runs.put(1, lastBuild); - assertEquals(-1, project.getEstimatedDuration()); + assertEquals(42, project.getEstimatedDuration()); } @Test From d20533ef603c7f708e250258c43e2fe02ed04f6b Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Fri, 7 Aug 2020 21:46:11 -0700 Subject: [PATCH 10/16] Remove duplicate @param tag --- core/src/main/java/hudson/model/Items.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/model/Items.java b/core/src/main/java/hudson/model/Items.java index 7a98e3c639..14108a6041 100644 --- a/core/src/main/java/hudson/model/Items.java +++ b/core/src/main/java/hudson/model/Items.java @@ -468,8 +468,8 @@ public class Items { * * @param root the root. * @param type the type. + * @param pred the predicate. * @param the type. - * @param the predicate. * @return An {@link Iterable} for all items. * @since 2.221 */ From 2d11c081913067e394b5b22fe785860c7f0718dd Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sat, 19 Dec 2020 12:57:36 -0800 Subject: [PATCH 11/16] Remove break statements from infinite loops --- test/src/test/java/hudson/cli/OnlineNodeCommandTest.java | 6 +----- .../test/java/hudson/cli/WaitNodeOfflineCommandTest.java | 8 ++------ .../test/java/hudson/cli/WaitNodeOnlineCommandTest.java | 4 +--- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/test/src/test/java/hudson/cli/OnlineNodeCommandTest.java b/test/src/test/java/hudson/cli/OnlineNodeCommandTest.java index 5712b6cfb1..1f0a8e57a5 100644 --- a/test/src/test/java/hudson/cli/OnlineNodeCommandTest.java +++ b/test/src/test/java/hudson/cli/OnlineNodeCommandTest.java @@ -336,11 +336,7 @@ public class OnlineNodeCommandTest { Node node = build.getBuiltOn(); block.signal(); // we are safe to be interrupted - for (;;) { - // Go out if we should finish - if (finish.isSignaled()) - break; - + while (!finish.isSignaled()) { // Keep using the channel channel.call(node.getClockDifferenceCallable()); Thread.sleep(100); diff --git a/test/src/test/java/hudson/cli/WaitNodeOfflineCommandTest.java b/test/src/test/java/hudson/cli/WaitNodeOfflineCommandTest.java index 0e77a21940..a55f89fe69 100644 --- a/test/src/test/java/hudson/cli/WaitNodeOfflineCommandTest.java +++ b/test/src/test/java/hudson/cli/WaitNodeOfflineCommandTest.java @@ -73,9 +73,7 @@ public class WaitNodeOfflineCommandTest { public void waitNodeOfflineShouldSucceedOnOfflineNode() throws Exception { DumbSlave slave = j.createSlave("aNode", "", null); slave.toComputer().setTemporarilyOffline(true); - while (true) { - if(slave.toComputer().isOffline()) - break; + while (!slave.toComputer().isOffline()) { Thread.sleep(100); } @@ -102,9 +100,7 @@ public class WaitNodeOfflineCommandTest { public void waitNodeOfflineShouldSucceedOnDisconnectedNode() throws Exception { DumbSlave slave = j.createSlave("aNode", "", null); slave.toComputer().disconnect(); - while (true) { - if(slave.toComputer().isOffline()) - break; + while (!slave.toComputer().isOffline()) { Thread.sleep(100); } diff --git a/test/src/test/java/hudson/cli/WaitNodeOnlineCommandTest.java b/test/src/test/java/hudson/cli/WaitNodeOnlineCommandTest.java index 795fd4e6de..71bfee0fc7 100644 --- a/test/src/test/java/hudson/cli/WaitNodeOnlineCommandTest.java +++ b/test/src/test/java/hudson/cli/WaitNodeOnlineCommandTest.java @@ -166,9 +166,7 @@ public class WaitNodeOnlineCommandTest { public void waitNodeOnlineShouldSuccessOnOnlineNode() throws Exception { DumbSlave slave = j.createSlave("aNode", "", null); slave.toComputer().waitUntilOnline(); - while (true) { - if(slave.toComputer().isOnline()) - break; + while (!slave.toComputer().isOnline()) { Thread.sleep(100); } From 1858b72014e2d19d32ce233f08c5a0011b00363c Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sat, 19 Dec 2020 13:01:04 -0800 Subject: [PATCH 12/16] Access static method via class reference rather than instance reference --- test/src/test/java/jenkins/model/JenkinsTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/src/test/java/jenkins/model/JenkinsTest.java b/test/src/test/java/jenkins/model/JenkinsTest.java index 8f2ac3289b..59cbb7fa8c 100644 --- a/test/src/test/java/jenkins/model/JenkinsTest.java +++ b/test/src/test/java/jenkins/model/JenkinsTest.java @@ -385,7 +385,7 @@ public class JenkinsTest { } public HttpResponse doDynamic() { - assertEquals("anonymous", Jenkins.get().getAuthentication2().getName()); + assertEquals("anonymous", Jenkins.getAuthentication2().getName()); count++; return HttpResponses.html("OK"); } From 7876e3ca85495414b1224373b4179e8bf52cf285 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sat, 19 Dec 2020 13:04:30 -0800 Subject: [PATCH 13/16] Use JUnit 5 assertions from JUnit 5 test --- core/src/test/java/hudson/EnvVarsTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/test/java/hudson/EnvVarsTest.java b/core/src/test/java/hudson/EnvVarsTest.java index 2a219de589..28538034d7 100644 --- a/core/src/test/java/hudson/EnvVarsTest.java +++ b/core/src/test/java/hudson/EnvVarsTest.java @@ -34,9 +34,9 @@ import java.util.TreeMap; import com.google.common.collect.Sets; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** From f31107fac2ef9e6f4b3b8ad8305e976680a6bba2 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sat, 19 Dec 2020 13:08:37 -0800 Subject: [PATCH 14/16] Consolidate duplicate branches in switch statement --- core/src/main/java/hudson/Functions.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index 67dc2f5a9d..8b4fbea69c 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -1541,9 +1541,6 @@ public class Functions { sb.append('\n'); break; case WAITING: - sb.append("\t- waiting on ").append(ti.getLockInfo()); - sb.append('\n'); - break; case TIMED_WAITING: sb.append("\t- waiting on ").append(ti.getLockInfo()); sb.append('\n'); From 4e125678813c4a4fe36c259d0d5f275baf5732d5 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sat, 19 Dec 2020 13:09:23 -0800 Subject: [PATCH 15/16] Remove unnecessary return --- core/src/main/java/hudson/PluginManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index be380989ce..9dda49e0cd 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -555,7 +555,6 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas activePlugins.remove(p); plugins.remove(p); LOGGER.log(Level.SEVERE, "Failed to install {0}: {1}", new Object[] { p.getShortName(), e.getMessage() }); - return; } catch (IOException e) { failedPlugins.add(new FailedPlugin(p.getShortName(), e)); activePlugins.remove(p); From 64dbdbc4f59cbd9160cbf47a8fc0049ec0171438 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Tue, 15 Dec 2020 17:29:48 -0800 Subject: [PATCH 16/16] Remove unused imports --- core/src/main/java/hudson/PluginManager.java | 1 - core/src/main/java/hudson/PluginWrapper.java | 1 - core/src/main/java/hudson/cli/BuildCommand.java | 1 - core/src/main/java/hudson/model/Fingerprint.java | 1 - core/src/main/java/hudson/model/Label.java | 1 - core/src/main/java/hudson/model/LoadBalancer.java | 1 - .../main/java/hudson/model/WorkspaceCleanupThread.java | 1 - core/src/main/java/hudson/util/ProcessTree.java | 1 - core/src/main/java/hudson/util/RingBufferLogHandler.java | 3 --- core/src/main/java/jenkins/model/IdStrategy.java | 1 - .../jenkins/security/s2m/MasterKillSwitchWarning.java | 1 - .../java/jenkins/slaves/systemInfo/SlaveSystemInfo.java | 2 -- .../java/jenkins/util/xml/FilteredFunctionContext.java | 1 - .../org/acegisecurity/context/SecurityContextHolder.java | 1 - .../providers/UsernamePasswordAuthenticationToken.java | 1 - core/src/main/java/org/jenkins/ui/icon/IconType.java | 1 - .../org/springframework/dao/DataAccessException.java | 1 - core/src/test/java/hudson/model/FingerprintTest.java | 2 -- .../hudson/slaves/CloudProvisioningListenerTest.java | 2 -- core/src/test/java/hudson/util/XStream2Test.java | 1 - test/src/test/java/hudson/PluginTest.java | 1 - test/src/test/java/hudson/cli/RunRangeCommandTest.java | 1 - .../java/hudson/diagnosis/TooManyJobsButNoViewTest.java | 1 - test/src/test/java/hudson/init/InitMilestoneTest.java | 1 - test/src/test/java/hudson/model/AbstractProjectTest.java | 1 - test/src/test/java/hudson/model/ComputerTest.java | 1 - test/src/test/java/hudson/model/FingerprintTest.java | 1 - test/src/test/java/hudson/model/ItemGroupMixInTest.java | 1 - test/src/test/java/hudson/model/UpdateSiteTest.java | 1 - test/src/test/java/hudson/model/UserTest.java | 1 - .../test/java/hudson/model/queue/LoadPredictorTest.java | 2 -- .../src/test/java/hudson/security/SecurityRealmTest.java | 1 - test/src/test/java/hudson/security/WhoAmITest.java | 1 - .../security/csrf/DefaultCrumbIssuerSEC1704Test.java | 9 --------- test/src/test/java/hudson/tasks/BuildTriggerTest.java | 3 --- .../test/java/hudson/tasks/CommandInterpreterTest.java | 1 - .../test/java/hudson/tools/InstallerTranslatorTest.java | 1 - .../java/hudson/tools/ZipExtractionInstallerTest.java | 1 - test/src/test/java/hudson/views/StatusFilterTest.java | 1 - test/src/test/java/jenkins/ExtensionFilterTest.java | 1 - test/src/test/java/jenkins/install/InstallStateTest.java | 1 - .../java/jenkins/model/JenkinsManagePermissionTest.java | 7 ------- .../test/java/jenkins/security/ApiTokenPropertyTest.java | 1 - .../test/java/jenkins/tasks/SimpleBuildWrapperTest.java | 2 -- .../tasks/filters/impl/RetainVariablesLocalRuleTest.java | 1 - .../java/jenkins/triggers/ReverseBuildTriggerTest.java | 1 - .../HistoryPageFilterCaseSensitiveSearchTest.java | 1 - 47 files changed, 70 deletions(-) diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index 9dda49e0cd..3ce68f3487 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -125,7 +125,6 @@ import java.net.URL; import java.net.URLClassLoader; import java.net.URLConnection; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Enumeration; diff --git a/core/src/main/java/hudson/PluginWrapper.java b/core/src/main/java/hudson/PluginWrapper.java index cde7c9b6f5..8866bf6769 100644 --- a/core/src/main/java/hudson/PluginWrapper.java +++ b/core/src/main/java/hudson/PluginWrapper.java @@ -61,7 +61,6 @@ import java.net.URL; import java.nio.file.Files; import java.nio.file.InvalidPathException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Enumeration; diff --git a/core/src/main/java/hudson/cli/BuildCommand.java b/core/src/main/java/hudson/cli/BuildCommand.java index 42611e90fb..dc6917b596 100644 --- a/core/src/main/java/hudson/cli/BuildCommand.java +++ b/core/src/main/java/hudson/cli/BuildCommand.java @@ -49,7 +49,6 @@ import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.Option; -import java.util.Collections; import java.util.Map; import java.util.HashMap; import java.util.List; diff --git a/core/src/main/java/hudson/model/Fingerprint.java b/core/src/main/java/hudson/model/Fingerprint.java index b3480b7029..ece1d3fd18 100644 --- a/core/src/main/java/hudson/model/Fingerprint.java +++ b/core/src/main/java/hudson/model/Fingerprint.java @@ -46,7 +46,6 @@ import hudson.util.XStream2; import jenkins.fingerprints.FileFingerprintStorage; import jenkins.fingerprints.FingerprintStorage; -import jenkins.fingerprints.GlobalFingerprintConfiguration; import jenkins.model.FingerprintFacet; import jenkins.model.Jenkins; import jenkins.model.TransientFingerprintFacetFactory; diff --git a/core/src/main/java/hudson/model/Label.java b/core/src/main/java/hudson/model/Label.java index d2865ef9dc..a92dce8a97 100644 --- a/core/src/main/java/hudson/model/Label.java +++ b/core/src/main/java/hudson/model/Label.java @@ -64,7 +64,6 @@ import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.Stack; import java.util.TreeSet; import java.util.stream.Collectors; import java.util.stream.StreamSupport; diff --git a/core/src/main/java/hudson/model/LoadBalancer.java b/core/src/main/java/hudson/model/LoadBalancer.java index 22a4b4097c..bd1d0b7c63 100644 --- a/core/src/main/java/hudson/model/LoadBalancer.java +++ b/core/src/main/java/hudson/model/LoadBalancer.java @@ -31,7 +31,6 @@ import hudson.model.queue.MappingWorksheet; import hudson.model.queue.MappingWorksheet.ExecutorChunk; import hudson.model.queue.MappingWorksheet.Mapping; import hudson.util.ConsistentHash; -import hudson.util.ConsistentHash.Hash; import java.util.ArrayList; import java.util.List; diff --git a/core/src/main/java/hudson/model/WorkspaceCleanupThread.java b/core/src/main/java/hudson/model/WorkspaceCleanupThread.java index 524f6bd331..3f017caee2 100644 --- a/core/src/main/java/hudson/model/WorkspaceCleanupThread.java +++ b/core/src/main/java/hudson/model/WorkspaceCleanupThread.java @@ -29,7 +29,6 @@ import hudson.FilePath; import hudson.Functions; import jenkins.util.SystemProperties; import hudson.Util; -import hudson.slaves.WorkspaceList; import java.io.IOException; import java.util.ArrayList; import java.util.Date; diff --git a/core/src/main/java/hudson/util/ProcessTree.java b/core/src/main/java/hudson/util/ProcessTree.java index e7bd30cc27..412f51ba1d 100644 --- a/core/src/main/java/hudson/util/ProcessTree.java +++ b/core/src/main/java/hudson/util/ProcessTree.java @@ -48,7 +48,6 @@ import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.File; -import java.io.FileFilter; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; diff --git a/core/src/main/java/hudson/util/RingBufferLogHandler.java b/core/src/main/java/hudson/util/RingBufferLogHandler.java index 0e0b88f77b..159cf61e0a 100644 --- a/core/src/main/java/hudson/util/RingBufferLogHandler.java +++ b/core/src/main/java/hudson/util/RingBufferLogHandler.java @@ -23,9 +23,6 @@ */ package hudson.util; -import org.kohsuke.accmod.Restricted; -import org.kohsuke.accmod.restrictions.NoExternalUse; - import java.util.AbstractList; import java.util.List; import java.util.logging.Handler; diff --git a/core/src/main/java/jenkins/model/IdStrategy.java b/core/src/main/java/jenkins/model/IdStrategy.java index dafa0700a6..2352f6c53e 100644 --- a/core/src/main/java/jenkins/model/IdStrategy.java +++ b/core/src/main/java/jenkins/model/IdStrategy.java @@ -27,7 +27,6 @@ import hudson.DescriptorExtensionList; import hudson.Extension; import hudson.ExtensionPoint; import hudson.model.AbstractDescribableImpl; -import hudson.util.CaseInsensitiveComparator; import org.apache.commons.lang.StringUtils; import org.jenkinsci.Symbol; import org.kohsuke.accmod.Restricted; diff --git a/core/src/main/java/jenkins/security/s2m/MasterKillSwitchWarning.java b/core/src/main/java/jenkins/security/s2m/MasterKillSwitchWarning.java index 75d2b0ad3e..e2042beab8 100644 --- a/core/src/main/java/jenkins/security/s2m/MasterKillSwitchWarning.java +++ b/core/src/main/java/jenkins/security/s2m/MasterKillSwitchWarning.java @@ -2,7 +2,6 @@ package jenkins.security.s2m; import hudson.Extension; import hudson.model.AdministrativeMonitor; -import org.apache.tools.ant.taskdefs.condition.IsSet; import org.kohsuke.stapler.HttpResponse; import org.kohsuke.stapler.HttpResponses; import org.kohsuke.stapler.QueryParameter; diff --git a/core/src/main/java/jenkins/slaves/systemInfo/SlaveSystemInfo.java b/core/src/main/java/jenkins/slaves/systemInfo/SlaveSystemInfo.java index 69e32120bc..fb3ac639dc 100644 --- a/core/src/main/java/jenkins/slaves/systemInfo/SlaveSystemInfo.java +++ b/core/src/main/java/jenkins/slaves/systemInfo/SlaveSystemInfo.java @@ -3,9 +3,7 @@ package jenkins.slaves.systemInfo; import hudson.ExtensionList; import hudson.ExtensionPoint; import hudson.model.Computer; -import hudson.model.ManageJenkinsAction; import hudson.security.Permission; -import jenkins.model.Jenkins; /** * Extension point that contributes to the system information page of {@link Computer}. diff --git a/core/src/main/java/jenkins/util/xml/FilteredFunctionContext.java b/core/src/main/java/jenkins/util/xml/FilteredFunctionContext.java index 06383e134a..f05fcf72be 100644 --- a/core/src/main/java/jenkins/util/xml/FilteredFunctionContext.java +++ b/core/src/main/java/jenkins/util/xml/FilteredFunctionContext.java @@ -31,7 +31,6 @@ import org.jaxen.XPathFunctionContext; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; -import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Locale; diff --git a/core/src/main/java/org/acegisecurity/context/SecurityContextHolder.java b/core/src/main/java/org/acegisecurity/context/SecurityContextHolder.java index db619d69cc..7bd62fc814 100644 --- a/core/src/main/java/org/acegisecurity/context/SecurityContextHolder.java +++ b/core/src/main/java/org/acegisecurity/context/SecurityContextHolder.java @@ -26,7 +26,6 @@ package org.acegisecurity.context; import hudson.model.User; import hudson.security.ACL; -import org.acegisecurity.Authentication; /** * @deprecated Use {@link ACL#as(User)} or {@link org.springframework.security.core.context.SecurityContext}. diff --git a/core/src/main/java/org/acegisecurity/providers/UsernamePasswordAuthenticationToken.java b/core/src/main/java/org/acegisecurity/providers/UsernamePasswordAuthenticationToken.java index 4edb89d8b0..ad56d529c0 100644 --- a/core/src/main/java/org/acegisecurity/providers/UsernamePasswordAuthenticationToken.java +++ b/core/src/main/java/org/acegisecurity/providers/UsernamePasswordAuthenticationToken.java @@ -24,7 +24,6 @@ package org.acegisecurity.providers; -import hudson.security.ACL; import org.acegisecurity.Authentication; import org.acegisecurity.GrantedAuthority; import org.acegisecurity.userdetails.UserDetails; diff --git a/core/src/main/java/org/jenkins/ui/icon/IconType.java b/core/src/main/java/org/jenkins/ui/icon/IconType.java index 99f68c2696..9837902c0b 100644 --- a/core/src/main/java/org/jenkins/ui/icon/IconType.java +++ b/core/src/main/java/org/jenkins/ui/icon/IconType.java @@ -24,7 +24,6 @@ package org.jenkins.ui.icon; import org.apache.commons.jelly.JellyContext; -import org.kohsuke.stapler.Stapler; /** * Icon type. diff --git a/core/src/main/java/org/springframework/dao/DataAccessException.java b/core/src/main/java/org/springframework/dao/DataAccessException.java index d3220ff361..c1ad8e62ab 100644 --- a/core/src/main/java/org/springframework/dao/DataAccessException.java +++ b/core/src/main/java/org/springframework/dao/DataAccessException.java @@ -26,7 +26,6 @@ package org.springframework.dao; import hudson.security.UserMayOrMayNotExistException2; import org.springframework.core.NestedRuntimeException; -import org.springframework.security.core.userdetails.UsernameNotFoundException; /** * @deprecated no replacement diff --git a/core/src/test/java/hudson/model/FingerprintTest.java b/core/src/test/java/hudson/model/FingerprintTest.java index 368339b64c..47a553acea 100644 --- a/core/src/test/java/hudson/model/FingerprintTest.java +++ b/core/src/test/java/hudson/model/FingerprintTest.java @@ -23,12 +23,10 @@ */ package hudson.model; -import hudson.Util; import hudson.model.Fingerprint.RangeSet; import java.io.File; import jenkins.fingerprints.FileFingerprintStorage; -import jenkins.model.FingerprintFacet; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; diff --git a/core/src/test/java/hudson/slaves/CloudProvisioningListenerTest.java b/core/src/test/java/hudson/slaves/CloudProvisioningListenerTest.java index 641706f887..c4b95ecc44 100644 --- a/core/src/test/java/hudson/slaves/CloudProvisioningListenerTest.java +++ b/core/src/test/java/hudson/slaves/CloudProvisioningListenerTest.java @@ -4,9 +4,7 @@ import hudson.model.Messages; import hudson.model.queue.CauseOfBlockage; import org.junit.Test; import org.jvnet.hudson.test.Issue; -import org.jvnet.localizer.Localizable; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; diff --git a/core/src/test/java/hudson/util/XStream2Test.java b/core/src/test/java/hudson/util/XStream2Test.java index e32f5d3e26..e6d7253486 100644 --- a/core/src/test/java/hudson/util/XStream2Test.java +++ b/core/src/test/java/hudson/util/XStream2Test.java @@ -36,7 +36,6 @@ import com.google.common.collect.ImmutableMap; import com.thoughtworks.xstream.XStreamException; import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.mapper.CannotResolveClassException; -import com.thoughtworks.xstream.security.ForbiddenClassException; import hudson.model.Result; import hudson.model.Run; import java.io.StringReader; diff --git a/test/src/test/java/hudson/PluginTest.java b/test/src/test/java/hudson/PluginTest.java index f73a550a54..f90aab2ab9 100644 --- a/test/src/test/java/hudson/PluginTest.java +++ b/test/src/test/java/hudson/PluginTest.java @@ -27,7 +27,6 @@ package hudson; import hudson.model.UpdateCenter; import jenkins.model.Jenkins; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.concurrent.Future; diff --git a/test/src/test/java/hudson/cli/RunRangeCommandTest.java b/test/src/test/java/hudson/cli/RunRangeCommandTest.java index e4cb7fc0c7..3fb55eea7e 100644 --- a/test/src/test/java/hudson/cli/RunRangeCommandTest.java +++ b/test/src/test/java/hudson/cli/RunRangeCommandTest.java @@ -34,7 +34,6 @@ import org.junit.ClassRule; import org.junit.Test; import org.jvnet.hudson.test.JenkinsRule; -import java.io.IOException; import java.util.List; import static hudson.cli.CLICommandInvoker.Matcher.failedWith; diff --git a/test/src/test/java/hudson/diagnosis/TooManyJobsButNoViewTest.java b/test/src/test/java/hudson/diagnosis/TooManyJobsButNoViewTest.java index dff96e1ec8..076a719d4a 100644 --- a/test/src/test/java/hudson/diagnosis/TooManyJobsButNoViewTest.java +++ b/test/src/test/java/hudson/diagnosis/TooManyJobsButNoViewTest.java @@ -13,7 +13,6 @@ import java.net.URL; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertNotNull; diff --git a/test/src/test/java/hudson/init/InitMilestoneTest.java b/test/src/test/java/hudson/init/InitMilestoneTest.java index 97088a4ebd..073502f1f5 100644 --- a/test/src/test/java/hudson/init/InitMilestoneTest.java +++ b/test/src/test/java/hudson/init/InitMilestoneTest.java @@ -1,6 +1,5 @@ package hudson.init; -import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.jvnet.hudson.test.JenkinsRule; diff --git a/test/src/test/java/hudson/model/AbstractProjectTest.java b/test/src/test/java/hudson/model/AbstractProjectTest.java index 4688970eb3..a2ee086ee5 100644 --- a/test/src/test/java/hudson/model/AbstractProjectTest.java +++ b/test/src/test/java/hudson/model/AbstractProjectTest.java @@ -55,7 +55,6 @@ import hudson.util.OneShotEvent; import hudson.util.StreamTaskListener; import java.io.OutputStream; -import java.lang.reflect.Array; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; diff --git a/test/src/test/java/hudson/model/ComputerTest.java b/test/src/test/java/hudson/model/ComputerTest.java index d6cb0e84a3..e4280ff56b 100644 --- a/test/src/test/java/hudson/model/ComputerTest.java +++ b/test/src/test/java/hudson/model/ComputerTest.java @@ -39,7 +39,6 @@ import java.io.File; import java.net.HttpURLConnection; import java.nio.charset.StandardCharsets; -import hudson.model.labels.LabelAtom; import jenkins.model.Jenkins; import hudson.slaves.DumbSlave; import hudson.slaves.OfflineCause; diff --git a/test/src/test/java/hudson/model/FingerprintTest.java b/test/src/test/java/hudson/model/FingerprintTest.java index 869ef32b2e..eedcc9f8c2 100644 --- a/test/src/test/java/hudson/model/FingerprintTest.java +++ b/test/src/test/java/hudson/model/FingerprintTest.java @@ -36,7 +36,6 @@ import hudson.tasks.Fingerprinter; import java.io.File; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; diff --git a/test/src/test/java/hudson/model/ItemGroupMixInTest.java b/test/src/test/java/hudson/model/ItemGroupMixInTest.java index 419bb88a01..3e44222c7b 100644 --- a/test/src/test/java/hudson/model/ItemGroupMixInTest.java +++ b/test/src/test/java/hudson/model/ItemGroupMixInTest.java @@ -38,7 +38,6 @@ import org.apache.commons.io.FileUtils; import java.io.ByteArrayInputStream; import java.io.IOException; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/test/src/test/java/hudson/model/UpdateSiteTest.java b/test/src/test/java/hudson/model/UpdateSiteTest.java index 9fbae8a7ae..a5b94b21d0 100644 --- a/test/src/test/java/hudson/model/UpdateSiteTest.java +++ b/test/src/test/java/hudson/model/UpdateSiteTest.java @@ -25,7 +25,6 @@ package hudson.model; import hudson.PluginWrapper; -import hudson.PluginWrapper.Dependency; import hudson.model.UpdateSite.Data; import hudson.util.FormValidation; import hudson.util.PersistedList; diff --git a/test/src/test/java/hudson/model/UserTest.java b/test/src/test/java/hudson/model/UserTest.java index 850aac07cc..c46a730535 100644 --- a/test/src/test/java/hudson/model/UserTest.java +++ b/test/src/test/java/hudson/model/UserTest.java @@ -80,7 +80,6 @@ import org.jvnet.hudson.test.recipes.LocalData; import org.springframework.security.access.AccessDeniedException; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; -import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; diff --git a/test/src/test/java/hudson/model/queue/LoadPredictorTest.java b/test/src/test/java/hudson/model/queue/LoadPredictorTest.java index ae4ddf5d3b..399a066abd 100644 --- a/test/src/test/java/hudson/model/queue/LoadPredictorTest.java +++ b/test/src/test/java/hudson/model/queue/LoadPredictorTest.java @@ -23,13 +23,11 @@ */ package hudson.model.queue; -import static java.util.Arrays.asList; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import hudson.model.Action; import hudson.model.Computer; import hudson.model.Executor; import hudson.model.Node; diff --git a/test/src/test/java/hudson/security/SecurityRealmTest.java b/test/src/test/java/hudson/security/SecurityRealmTest.java index 73d38a1950..7e9a66c07a 100644 --- a/test/src/test/java/hudson/security/SecurityRealmTest.java +++ b/test/src/test/java/hudson/security/SecurityRealmTest.java @@ -42,7 +42,6 @@ import java.util.Collections; import java.util.Date; import java.util.Random; import jenkins.model.Jenkins; -import org.acegisecurity.Authentication; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; diff --git a/test/src/test/java/hudson/security/WhoAmITest.java b/test/src/test/java/hudson/security/WhoAmITest.java index b2087d085b..4fec99a95f 100644 --- a/test/src/test/java/hudson/security/WhoAmITest.java +++ b/test/src/test/java/hudson/security/WhoAmITest.java @@ -29,7 +29,6 @@ import com.gargoylesoftware.htmlunit.html.HtmlPage; import hudson.model.User; import jenkins.model.Jenkins; import jenkins.security.ApiTokenProperty; -import jenkins.security.apitoken.ApiTokenStore; import jenkins.security.apitoken.TokenUuidAndPlainValue; import org.junit.Rule; import org.junit.Test; diff --git a/test/src/test/java/hudson/security/csrf/DefaultCrumbIssuerSEC1704Test.java b/test/src/test/java/hudson/security/csrf/DefaultCrumbIssuerSEC1704Test.java index 35fa9ae30f..769370bedf 100644 --- a/test/src/test/java/hudson/security/csrf/DefaultCrumbIssuerSEC1704Test.java +++ b/test/src/test/java/hudson/security/csrf/DefaultCrumbIssuerSEC1704Test.java @@ -6,24 +6,15 @@ package hudson.security.csrf; -import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; import com.gargoylesoftware.htmlunit.WebResponse; -import com.gargoylesoftware.htmlunit.html.DomElement; -import com.gargoylesoftware.htmlunit.html.HtmlPage; -import hudson.model.FreeStyleProject; -import hudson.model.User; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.jvnet.hudson.test.Issue; import org.jvnet.hudson.test.JenkinsRule; -import org.jvnet.hudson.test.JenkinsRule.WebClient; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertEquals; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; /** * diff --git a/test/src/test/java/hudson/tasks/BuildTriggerTest.java b/test/src/test/java/hudson/tasks/BuildTriggerTest.java index ee1f393228..17e76f1ea3 100644 --- a/test/src/test/java/hudson/tasks/BuildTriggerTest.java +++ b/test/src/test/java/hudson/tasks/BuildTriggerTest.java @@ -85,9 +85,6 @@ import org.jvnet.hudson.test.TestBuilder; import org.jvnet.hudson.test.MockBuilder; import org.jvnet.hudson.test.MockQueueItemAuthenticator; import org.jvnet.hudson.test.ToolInstallations; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContext; -import org.springframework.security.core.context.SecurityContextHolder; import org.xml.sax.SAXException; public class BuildTriggerTest { diff --git a/test/src/test/java/hudson/tasks/CommandInterpreterTest.java b/test/src/test/java/hudson/tasks/CommandInterpreterTest.java index 1e90ddc07b..72263544a7 100644 --- a/test/src/test/java/hudson/tasks/CommandInterpreterTest.java +++ b/test/src/test/java/hudson/tasks/CommandInterpreterTest.java @@ -3,7 +3,6 @@ package hudson.tasks; import hudson.FilePath; import hudson.model.AbstractProject; import hudson.model.FreeStyleProject; -import org.hamcrest.MatcherAssert; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; diff --git a/test/src/test/java/hudson/tools/InstallerTranslatorTest.java b/test/src/test/java/hudson/tools/InstallerTranslatorTest.java index e6df77e970..25cbef83f9 100644 --- a/test/src/test/java/hudson/tools/InstallerTranslatorTest.java +++ b/test/src/test/java/hudson/tools/InstallerTranslatorTest.java @@ -31,7 +31,6 @@ import hudson.model.JDK; import hudson.model.Node; import hudson.slaves.DumbSlave; import hudson.slaves.JNLPLauncher; -import hudson.slaves.NodeProperty; import hudson.slaves.RetentionStrategy; import hudson.tasks.BatchFile; import hudson.tasks.Shell; diff --git a/test/src/test/java/hudson/tools/ZipExtractionInstallerTest.java b/test/src/test/java/hudson/tools/ZipExtractionInstallerTest.java index 67aef2f7b5..3885d1e103 100644 --- a/test/src/test/java/hudson/tools/ZipExtractionInstallerTest.java +++ b/test/src/test/java/hudson/tools/ZipExtractionInstallerTest.java @@ -51,7 +51,6 @@ import java.net.URLDecoder; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; diff --git a/test/src/test/java/hudson/views/StatusFilterTest.java b/test/src/test/java/hudson/views/StatusFilterTest.java index 8a13a67b19..b5c4859be2 100644 --- a/test/src/test/java/hudson/views/StatusFilterTest.java +++ b/test/src/test/java/hudson/views/StatusFilterTest.java @@ -1,7 +1,6 @@ package hudson.views; import hudson.model.FreeStyleProject; -import hudson.model.ListView; import hudson.model.TopLevelItem; import org.junit.Rule; import org.junit.Test; diff --git a/test/src/test/java/jenkins/ExtensionFilterTest.java b/test/src/test/java/jenkins/ExtensionFilterTest.java index 227add1324..d5cb126c29 100644 --- a/test/src/test/java/jenkins/ExtensionFilterTest.java +++ b/test/src/test/java/jenkins/ExtensionFilterTest.java @@ -8,7 +8,6 @@ import hudson.ExtensionComponent; import hudson.console.ConsoleAnnotatorFactory; import hudson.model.PageDecorator; import jenkins.install.SetupWizard; -import org.hamcrest.Matchers; import org.junit.Rule; import org.junit.Test; import org.jvnet.hudson.test.JenkinsRule; diff --git a/test/src/test/java/jenkins/install/InstallStateTest.java b/test/src/test/java/jenkins/install/InstallStateTest.java index da33779dd1..c3920019a2 100644 --- a/test/src/test/java/jenkins/install/InstallStateTest.java +++ b/test/src/test/java/jenkins/install/InstallStateTest.java @@ -29,7 +29,6 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; diff --git a/test/src/test/java/jenkins/model/JenkinsManagePermissionTest.java b/test/src/test/java/jenkins/model/JenkinsManagePermissionTest.java index 5405564076..cd8a490896 100644 --- a/test/src/test/java/jenkins/model/JenkinsManagePermissionTest.java +++ b/test/src/test/java/jenkins/model/JenkinsManagePermissionTest.java @@ -20,7 +20,6 @@ import org.jvnet.hudson.test.recipes.WithPlugin; import hudson.PluginWrapper; import hudson.cli.CLICommandInvoker; import hudson.cli.DisablePluginCommand; -import hudson.lifecycle.RestartNotSupportedException; import hudson.model.Descriptor; import hudson.model.MyView; import hudson.model.User; @@ -29,23 +28,17 @@ import hudson.security.HudsonPrivateSecurityRealm; import hudson.security.ProjectMatrixAuthorizationStrategy; import hudson.tasks.Shell; -import jenkins.security.ApiTokenProperty; - import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.notNullValue; import static org.junit.Assert.assertEquals; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static hudson.cli.CLICommandInvoker.Matcher.failedWith; -import static hudson.cli.CLICommandInvoker.Matcher.hasNoErrorOutput; import static hudson.cli.CLICommandInvoker.Matcher.hasNoStandardOutput; -import static hudson.cli.CLICommandInvoker.Matcher.succeeded; /** * As Jenkins.MANAGE can be enabled on startup with jenkins.security.ManagePermission property, we need a test class diff --git a/test/src/test/java/jenkins/security/ApiTokenPropertyTest.java b/test/src/test/java/jenkins/security/ApiTokenPropertyTest.java index 7368140592..eee20517fe 100644 --- a/test/src/test/java/jenkins/security/ApiTokenPropertyTest.java +++ b/test/src/test/java/jenkins/security/ApiTokenPropertyTest.java @@ -45,7 +45,6 @@ import org.jvnet.hudson.test.JenkinsRule.WebClient; import java.util.Collection; import java.util.List; -import java.util.concurrent.Callable; import java.util.function.Predicate; import java.util.stream.Collectors; import edu.umd.cs.findbugs.annotations.NonNull; diff --git a/test/src/test/java/jenkins/tasks/SimpleBuildWrapperTest.java b/test/src/test/java/jenkins/tasks/SimpleBuildWrapperTest.java index 630b47651e..2124e4b2e1 100644 --- a/test/src/test/java/jenkins/tasks/SimpleBuildWrapperTest.java +++ b/test/src/test/java/jenkins/tasks/SimpleBuildWrapperTest.java @@ -48,14 +48,12 @@ import hudson.scm.ChangeLogParser; import hudson.scm.SCM; import hudson.scm.SCMRevisionState; import hudson.slaves.ComputerLauncher; -import hudson.slaves.NodeProperty; import hudson.slaves.RetentionStrategy; import hudson.slaves.SlaveComputer; import hudson.tasks.BuildWrapperDescriptor; import hudson.tasks.Maven; import hudson.tasks.Shell; import hudson.tasks.Maven.MavenInstallation; -import jenkins.model.Jenkins; import java.io.File; import java.io.IOException; diff --git a/test/src/test/java/jenkins/tasks/filters/impl/RetainVariablesLocalRuleTest.java b/test/src/test/java/jenkins/tasks/filters/impl/RetainVariablesLocalRuleTest.java index b2bc601842..912cfdc338 100644 --- a/test/src/test/java/jenkins/tasks/filters/impl/RetainVariablesLocalRuleTest.java +++ b/test/src/test/java/jenkins/tasks/filters/impl/RetainVariablesLocalRuleTest.java @@ -35,7 +35,6 @@ import hudson.model.StringParameterDefinition; import hudson.model.StringParameterValue; import hudson.tasks.BatchFile; import hudson.tasks.Shell; -import jenkins.tasks.filters.EnvVarsFilterGlobalConfiguration; import org.junit.Rule; import org.junit.Test; import org.jvnet.hudson.test.JenkinsRule; diff --git a/test/src/test/java/jenkins/triggers/ReverseBuildTriggerTest.java b/test/src/test/java/jenkins/triggers/ReverseBuildTriggerTest.java index cedbfe591e..2815fbce50 100644 --- a/test/src/test/java/jenkins/triggers/ReverseBuildTriggerTest.java +++ b/test/src/test/java/jenkins/triggers/ReverseBuildTriggerTest.java @@ -43,7 +43,6 @@ import java.util.HashMap; import java.util.Map; import jenkins.model.Jenkins; import jenkins.security.QueueItemAuthenticatorConfiguration; -import org.acegisecurity.Authentication; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.core.IsNot.not; diff --git a/test/src/test/java/jenkins/widgets/HistoryPageFilterCaseSensitiveSearchTest.java b/test/src/test/java/jenkins/widgets/HistoryPageFilterCaseSensitiveSearchTest.java index 58b422e813..043475384c 100644 --- a/test/src/test/java/jenkins/widgets/HistoryPageFilterCaseSensitiveSearchTest.java +++ b/test/src/test/java/jenkins/widgets/HistoryPageFilterCaseSensitiveSearchTest.java @@ -14,7 +14,6 @@ import org.mockito.Mockito; import com.google.common.collect.ImmutableList; import hudson.model.Job; import hudson.model.ModelObject; -import hudson.model.Queue; import hudson.model.Result; import hudson.model.Run; import hudson.model.User;