Remove trailing whitespace (#6138)

This commit is contained in:
Basil Crow authored and GitHub committed 2021-12-31 07:54:03 -08:00
1 parent 30bde02e7c
commit b25b45bc90
235 files changed
+2798 -2797

No files matched your search

+30 -30
View File
@@ -1,18 +1,18 @@
/*
* The MIT License
*
*
* Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, Alan Harder
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -140,9 +140,9 @@ public class FilePathTest {
final File tmp = temp.newFile();
int fileSize = 90000;
givenSomeContentInFile(tmp, fileSize);
List<Future<Integer>> results = whenFileIsCopied100TimesConcurrently(tmp);
// THEN copied count was always equal the expected size
@@ -158,7 +158,7 @@ public class FilePathTest {
os.write(buf);
}
}
private List<Future<Integer>> whenFileIsCopied100TimesConcurrently(final File file) throws InterruptedException {
List<Callable<Integer>> r = new ArrayList<>();
for (int i=0; i<100; i++) {
@@ -342,17 +342,17 @@ public class FilePathTest {
FileUtils.touch(building);
return new FilePath(building);
}
/**
* Performs round-trip archiving for Tar handling methods.
* @throws Exception test failure
*/
@Test public void compressTarUntarRoundTrip() throws Exception {
checkTarUntarRoundTrip("compressTarUntarRoundTrip_zero", 0);
checkTarUntarRoundTrip("compressTarUntarRoundTrip_small", 100);
checkTarUntarRoundTrip("compressTarUntarRoundTrip_medium", 50000);
checkTarUntarRoundTrip("compressTarUntarRoundTrip_zero", 0);
checkTarUntarRoundTrip("compressTarUntarRoundTrip_small", 100);
checkTarUntarRoundTrip("compressTarUntarRoundTrip_medium", 50000);
}
/**
* Checks that big files (greater than 8GB) can be archived and then unpacked.
* This test is disabled by default due the impact on RAM.
@@ -366,7 +366,7 @@ public class FilePathTest {
final String filePrefix = "JENKINS-10629";
checkTarUntarRoundTrip(filePrefix, largeFileSize);
}
private void checkTarUntarRoundTrip(String filePrefix, long fileSize) throws Exception {
final File tmpDir = temp.newFolder(filePrefix);
final File tempFile = new File(tmpDir, filePrefix + ".log");
@@ -436,13 +436,13 @@ public class FilePathTest {
FilePath middle = new FilePath(base, "jdk/jdk1.6.0_21/label/sqlserver/profile/sqlserver");
FilePath full = new FilePath(middle, "acceptance-tests\\distribution.zip");
assertFalse(full.isUnix());
FilePath unixPath = new FilePath(dummy,
"/home/test");
assertTrue(unixPath.isUnix());
}
/**
* Tests that permissions are kept when using {@link FilePath#copyToWithPermission(FilePath)}.
* Also tries to check that a problem with setting the last-modified date on Windows doesn't fail the whole copy
@@ -453,21 +453,21 @@ public class FilePathTest {
File child = new File(tmp,"child");
FilePath childP = new FilePath(child);
childP.touch(4711);
Chmod chmodTask = new Chmod();
chmodTask.setProject(new Project());
chmodTask.setFile(child);
chmodTask.setPerm("0400");
chmodTask.execute();
FilePath copy = new FilePath(channels.british, tmp.getPath()).child("copy");
childP.copyToWithPermission(copy);
assertEquals(childP.mode(),copy.mode());
if (!Functions.isWindows()) {
assertEquals(childP.lastModified(),copy.lastModified());
}
// JENKINS-11073:
// Windows seems to have random failures when setting the timestamp on newly generated
// files. So test that:
@@ -504,7 +504,7 @@ public class FilePathTest {
in.mkdirs();
in.child("c").touch(0);
in.child("b").symlinkTo("c", TaskListener.NULL);
FilePath tar = tmp.child("test.tar");
in.tar(tar.write(), "**/*");
@@ -566,7 +566,7 @@ public class FilePathTest {
assertEquals(Messages.FilePath_validateAntFileMask_portionMatchButPreviousNotMatchAndSuggest("**/*.js", "**", "**/*.js"), d.validateAntFileMask("**/*.js", 1000));
assertThrows(InterruptedException.class, () -> d.validateAntFileMask("**/*.js", 10));
}
@Issue("JENKINS-5253")
@Test public void testValidateCaseSensitivity() throws Exception {
File tmp = Util.createTempDir();
@@ -585,27 +585,27 @@ public class FilePathTest {
Util.deleteRecursive(tmp);
}
}
@Issue("JENKINS-15418")
@Test public void deleteLongPathOnWindows() throws Exception {
File tmp = temp.getRoot();
FilePath d = new FilePath(channels.french, tmp.getPath());
// construct a very long path
StringBuilder sb = new StringBuilder();
while(sb.length() + tmp.getPath().length() < 260 - "very/".length()) {
sb.append("very/");
}
sb.append("pivot/very/very/long/path");
FilePath longPath = d.child(sb.toString());
FilePath longPath = d.child(sb.toString());
longPath.mkdirs();
FilePath childInLongPath = longPath.child("file.txt");
childInLongPath.touch(0);
File firstDirectory = new File(tmp.getAbsolutePath() + "/very");
Util.deleteRecursive(firstDirectory);
assertFalse("Could not delete directory!", firstDirectory.exists());
}
@@ -723,7 +723,7 @@ public class FilePathTest {
final FilePath src = new FilePath(sub);
final FilePath dst = new FilePath(top);
// test conflict subdir
src.moveAllChildrenTo(dst);
}
@@ -828,7 +828,7 @@ public class FilePathTest {
FilePath textTempFile = suffix.createTextTempFile("tmp", null, "dummy", true);
assertThat(textTempFile.exists(), is(true));
filePath.deleteSuffixesRecursive();
assertThat(textTempFile.exists(), is(false));
}
+6 -6
View File
@@ -124,7 +124,7 @@ public class FunctionsTest {
}
}
}
@Test
public void testGetRelativeLinkTo_JobContainedInView() {
String contextPath = "/jenkins";
@@ -187,9 +187,9 @@ public class FunctionsTest {
assertEquals("/jenkins/job/i/", result);
}
}
private interface TopLevelItemAndItemGroup <T extends TopLevelItem> extends TopLevelItem, ItemGroup<T>, ViewGroup {}
@Test
public void testGetRelativeLinkTo_JobContainedInViewWithinItemGroup() {
String contextPath = "/jenkins";
@@ -240,7 +240,7 @@ public class FunctionsTest {
when(i.getFullDisplayName()).thenReturn("displayName");
assertEquals("displayName",Functions.getRelativeDisplayNameFrom(i, null));
}
@Test
public void testGetRelativeDisplayNameInsideItemGroup() {
Item i = mock(Item.class);
@@ -265,7 +265,7 @@ public class FunctionsTest {
List<Ancestor> ancestorsList = Arrays.asList(ancestors);
when(req.getAncestors()).thenReturn(ancestorsList);
}
private TopLevelItem createMockItem(ItemGroup p, String shortUrl) {
return createMockItem(p, shortUrl, shortUrl);
}
@@ -283,7 +283,7 @@ public class FunctionsTest {
mockedJenkins.when(Jenkins::get).thenReturn(j);
return j;
}
private static Ancestor createAncestor(Object o, String relativePath) {
Ancestor a = mock(Ancestor.class);
when(a.getObject()).thenReturn(o);
@@ -87,42 +87,42 @@ public class PluginManagerTest {
assertThat(ex.getCause(), instanceOf(SAXException.class));
assertThat(ex.getCause().getMessage(), containsString("DOCTYPE is disallowed"));
}
@Test
public void shouldProperlyParseManifestFromJar() throws IOException {
File jar = createHpiWithManifest();
final Manifest manifest = PluginManager.parsePluginManifest(jar.toURI().toURL());
assertThat("manifest should have been read from the sample", manifest, notNullValue());
assertAttribute(manifest, "Created-By", "Apache Maven");
assertAttribute(manifest, "Short-Name", "matrix-auth");
// Multi-line entries
assertAttribute(manifest, "Specification-Title", "Offers matrix-based security authorization strategies (global and per-project).");
assertAttribute(manifest, "Url", "http://wiki.jenkins-ci.org/display/JENKINS/Matrix+Authorization+Strategy+Plugin");
// Empty field
assertAttribute(manifest, "Plugin-Developers", null);
}
@Test
public void shouldProperlyRetrieveModificationDate() throws IOException {
File jar = createHpiWithManifest();
URL url = toManifestUrl(jar);
assertThat("Manifest last modified date should be equal to the file date",
PluginManager.getModificationDate(url),
assertThat("Manifest last modified date should be equal to the file date",
PluginManager.getModificationDate(url),
equalTo(jar.lastModified()));
}
private static void assertAttribute(Manifest manifest, String attributeName, String value) {
Attributes attributes = manifest.getMainAttributes();
assertThat("Main attributes must not be empty", attributes, notNullValue());
assertThat("Attribute '" + attributeName + "' does not match the sample",
attributes.getValue(attributeName),
assertThat("Attribute '" + attributeName + "' does not match the sample",
attributes.getValue(attributeName),
equalTo(value));
}
private static final String SAMPLE_MANIFEST_FILE = "Manifest-Version: 1.0\n" +
"Archiver-Version: Plexus Archiver\n" +
"Created-By: Apache Maven\n" +
@@ -146,12 +146,12 @@ public class PluginManagerTest {
"Plugin-Dependencies: icon-shim:2.0.3,cloudbees-folder:5.2.2;resolution\n" +
" :=optional\n" +
"Plugin-Developers: ";
private File createHpiWithManifest() throws IOException {
String manifestPath = "META-INF/MANIFEST.MF";
new File("META-INF").mkdir();
FileUtils.write(new File(tmp.toFile(), manifestPath), SAMPLE_MANIFEST_FILE, StandardCharsets.UTF_8);
final File f = new File(tmp.toFile(), "my.hpi");
try(ZipOutputStream out = new ZipOutputStream(Files.newOutputStream(f.toPath()))) {
ZipEntry e = new ZipEntry(manifestPath);
@@ -162,10 +162,10 @@ public class PluginManagerTest {
}
return f;
}
private URL toManifestUrl(File jarFile) throws MalformedURLException {
final String manifestPath = "META-INF/MANIFEST.MF";
return new URL("jar:" + jarFile.toURI().toURL() + "!/" + manifestPath);
}
}
}
@@ -36,7 +36,7 @@ import org.mockito.stubbing.Answer;
public class PluginWrapperTest {
private static Locale loc;
@BeforeAll
public static void before() {
Jenkins.VERSION = "2.0"; // Some value needed - tests will overwrite if necessary
@@ -50,7 +50,7 @@ public class PluginWrapperTest {
Locale.setDefault(loc);
}
}
@Test
public void dependencyTest() {
String version = "plugin:0.0.2";
@@ -131,7 +131,7 @@ public class PluginWrapperTest {
assertThat("expect one more element from the updated classloader",
e2size - e1size, is(1));
}
private void assertContains(Throwable ex, String... patterns) {
String msg = ex.getMessage();
for (String pattern : patterns) {
+1 -1
View File
@@ -58,7 +58,7 @@ public class XmlFileTest {
assertThat(n.getMode().toString(), is("NORMAL"));
}
}
@Test
public void canReadXmlWithControlCharsTest() throws IOException {
URL configUrl = getClass().getResource("/hudson/config_1_1_with_special_chars.xml");
@@ -1,18 +1,18 @@
/*
* The MIT License
*
*
* Copyright (c) 2004-2010, Sun Microsystems, Inc., Alan Harder
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -26,16 +26,16 @@ public class AbstractItemTest {
public Collection<? extends Job> getAllJobs() {
return null;
}
/**
* Override save so that nothing happens when setDisplayName() is called
*/
@Override
public void save() {
}
}
@Test
public void testSetDisplayName() throws Exception {
final String displayName = "testDisplayName";
@@ -43,7 +43,7 @@ public class AbstractItemTest {
i.setDisplayName(displayName);
assertEquals(displayName, i.getDisplayName());
}
@Test
public void testGetDefaultDisplayName() {
final String name = "the item name";
@@ -51,18 +51,18 @@ public class AbstractItemTest {
i.doSetName(name);
// assert that if the displayname is not set, the name is actually returned
assertEquals(name, i.getDisplayName());
}
@Test
public void testSearchNameIsName() {
final String name = "the item name jlrtlekjtekrjkjr";
StubAbstractItem i = new StubAbstractItem();
i.doSetName(name);
assertEquals(i.getName(), i.getSearchName());
}
@Test
public void testGetDisplayNameOrNull() throws Exception {
final String projectName = "projectName";
@@ -71,7 +71,7 @@ public class AbstractItemTest {
i.doSetName(projectName);
assertEquals(projectName, i.getName());
assertNull(i.getDisplayNameOrNull());
i.setDisplayName(displayName);
assertEquals(displayName, i.getDisplayNameOrNull());
}
@@ -12,7 +12,7 @@ import org.junit.Test;
/**
* Tests {@link Run#getBuildStatusSummary()}.
*
*
* @author kutzi
*/
@SuppressWarnings("rawtypes")
@@ -25,132 +25,132 @@ public class BuildStatusSummaryTest {
public void before() {
mockBuilds(Run.class);
}
private void mockBuilds(Class<? extends Run> buildClass) {
this.build = mock(buildClass);
this.prevBuild = mock(buildClass);
when(this.build.getPreviousBuild()).thenReturn(prevBuild);
when(this.build.getBuildStatusSummary()).thenCallRealMethod();
}
@Test
public void testStatusUnknownIfRunIsStillBuilding() {
when(this.build.getResult()).thenReturn(null);
when(this.build.isBuilding()).thenReturn(true);
Summary summary = this.build.getBuildStatusSummary();
assertEquals(Messages.Run_Summary_Unknown(), summary.message);
}
@Test
public void testSuccess() {
when(this.build.getResult()).thenReturn(Result.SUCCESS);
when(this.prevBuild.getResult()).thenReturn(Result.SUCCESS);
Summary summary = this.build.getBuildStatusSummary();
assertFalse(summary.isWorse);
assertEquals(Messages.Run_Summary_Stable(), summary.message);
// same if there is no previous build
when(this.build.getPreviousBuild()).thenReturn(null);
summary = this.build.getBuildStatusSummary();
assertFalse(summary.isWorse);
assertEquals(Messages.Run_Summary_Stable(), summary.message);
// from NOT_BUILD should also mean normal success and not 'back to normal'
when(this.prevBuild.getResult()).thenReturn(Result.NOT_BUILT);
summary = this.build.getBuildStatusSummary();
assertFalse(summary.isWorse);
assertEquals(Messages.Run_Summary_Stable(), summary.message);
// same if previous one was aborted
when(this.prevBuild.getResult()).thenReturn(Result.ABORTED);
summary = this.build.getBuildStatusSummary();
assertFalse(summary.isWorse);
assertEquals(Messages.Run_Summary_Stable(), summary.message);
}
@Test
public void testFixed() {
when(this.build.getResult()).thenReturn(Result.SUCCESS);
when(this.prevBuild.getResult()).thenReturn(Result.FAILURE);
Summary summary = this.build.getBuildStatusSummary();
assertFalse(summary.isWorse);
assertEquals(Messages.Run_Summary_BackToNormal(), summary.message);
// same from unstable:
when(this.prevBuild.getResult()).thenReturn(Result.UNSTABLE);
summary = this.build.getBuildStatusSummary();
assertFalse(summary.isWorse);
assertEquals(Messages.Run_Summary_BackToNormal(), summary.message);
}
@Test
public void testFailure() {
when(this.build.getResult()).thenReturn(Result.FAILURE);
when(this.prevBuild.getResult()).thenReturn(Result.FAILURE);
Summary summary = this.build.getBuildStatusSummary();
assertFalse(summary.isWorse);
assertEquals(Messages.Run_Summary_BrokenForALongTime(), summary.message);
}
@Test
public void testBecameFailure() {
when(this.build.getResult()).thenReturn(Result.FAILURE);
when(this.prevBuild.getResult()).thenReturn(Result.SUCCESS);
when(this.build.getPreviousNotFailedBuild()).thenReturn(this.prevBuild);
Summary summary = this.build.getBuildStatusSummary();
assertTrue(summary.isWorse);
assertEquals(Messages.Run_Summary_BrokenSinceThisBuild(), summary.message);
}
@Test
public void testFailureSince() {
when(this.build.getResult()).thenReturn(Result.FAILURE);
when(this.prevBuild.getResult()).thenReturn(Result.FAILURE);
when(this.prevBuild.getDisplayName()).thenReturn("prevBuild");
Run prevPrevBuild = mock(Run.class);
when(prevPrevBuild.getNextBuild()).thenReturn(prevBuild);
when(this.build.getPreviousNotFailedBuild()).thenReturn(prevPrevBuild);
when(this.build.getPreviousNotFailedBuild()).thenReturn(prevPrevBuild);
Summary summary = this.build.getBuildStatusSummary();
assertFalse(summary.isWorse);
assertEquals(Messages.Run_Summary_BrokenSince(this.prevBuild.getDisplayName()), summary.message);
}
@Test
public void testBecameUnstable() {
when(this.build.getResult()).thenReturn(Result.UNSTABLE);
when(this.prevBuild.getResult()).thenReturn(Result.SUCCESS);
Summary summary = this.build.getBuildStatusSummary();
assertTrue(summary.isWorse);
//assertEquals(Messages.Run_Summary_Stable(), summary.message);
}
@Test
public void testUnstableAfterFailure() {
when(this.build.getResult()).thenReturn(Result.UNSTABLE);
when(this.prevBuild.getResult()).thenReturn(Result.FAILURE);
Summary summary = this.build.getBuildStatusSummary();
assertFalse(summary.isWorse);
assertEquals(Messages.Run_Summary_Unstable(), summary.message);
}
@@ -159,40 +159,40 @@ public class BuildStatusSummaryTest {
public void testNonTestRelatedUnstable() {
when(this.build.getResult()).thenReturn(Result.UNSTABLE);
when(this.prevBuild.getResult()).thenReturn(Result.UNSTABLE);
Summary summary = this.build.getBuildStatusSummary();
assertFalse(summary.isWorse);
assertEquals(Messages.Run_Summary_Unstable(), summary.message);
}
@Test
public void testNonTestRelatedBecameUnstable() {
when(this.build.getResult()).thenReturn(Result.UNSTABLE);
when(this.prevBuild.getResult()).thenReturn(Result.SUCCESS);
Summary summary = this.build.getBuildStatusSummary();
assertTrue(summary.isWorse);
//assertEquals(Messages.Run_Summary_Unstable(), summary.message);
}
@Test
public void testAborted() {
when(this.build.getResult()).thenReturn(Result.ABORTED);
Summary summary = this.build.getBuildStatusSummary();
assertFalse(summary.isWorse);
assertEquals(Messages.Run_Summary_Aborted(), summary.message);
}
@Test
public void testNotBuilt() {
when(this.build.getResult()).thenReturn(Result.NOT_BUILT);
Summary summary = this.build.getBuildStatusSummary();
assertFalse(summary.isWorse);
assertEquals(Messages.Run_Summary_NotBuilt(), summary.message);
}
}
@@ -1,18 +1,18 @@
/*
* The MIT License
*
*
* Copyright (c) 2004-2011, Yahoo!, Inc.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -38,10 +38,10 @@ public class DisplayNameListenerTest {
StubJob dest = new StubJob();
dest.doSetName("dest");
dest.setDisplayName("this should be cleared");
// make sure the displayname and the name are different at this point
assertNotEquals(dest.getName(), dest.getDisplayName());
listener.onCopied(src, dest);
// make sure the displayname is equals to the name as it should be null
assertEquals(dest.getName(), dest.getDisplayName());
@@ -52,12 +52,12 @@ public class DisplayNameListenerTest {
DisplayNameListener listener = new DisplayNameListener();
final String oldName = "old job name";
final String newName = "new job name";
StubJob src = new StubJob();
StubJob src = new StubJob();
src.doSetName(newName);
src.setDisplayName(oldName);
listener.onRenamed(src, oldName, newName);
assertEquals(newName, src.getDisplayName());
}
@@ -67,12 +67,12 @@ public class DisplayNameListenerTest {
final String oldName = "old job name";
final String newName = "new job name";
final String displayName = "the display name";
StubJob src = new StubJob();
StubJob src = new StubJob();
src.doSetName(newName);
src.setDisplayName(displayName);
listener.onRenamed(src, oldName, oldName);
// make sure displayname is still intact
assertEquals(displayName, src.getDisplayName());
}
@@ -36,29 +36,29 @@ import org.jvnet.hudson.test.Issue;
* @author Oleg Nenashev
*/
public class FileParameterValueTest {
@Issue("JENKINS-19017")
@Test public void compareParamsWithSameName() {
final String paramName = "MY_FILE_PARAM"; // Same paramName (location) reproduces the bug
final FileParameterValue param1 = new FileParameterValue(paramName, new File("ws_param1.txt"), "param1.txt");
final FileParameterValue param2 = new FileParameterValue(paramName, new File("ws_param2.txt"), "param2.txt");
assertNotEquals("Files with same locations should be considered as different", param1, param2);
assertNotEquals("Files with same locations should be considered as different", param2, param1);
}
@Test public void compareNullParams() {
final String paramName = "MY_FILE_PARAM";
final String paramName = "MY_FILE_PARAM";
FileParameterValue nonNullParam = new FileParameterValue(paramName, new File("ws_param1.txt"), "param1.txt");
FileParameterValue nullParam1 = new FileParameterValue(null, new File("null_param1.txt"), "null_param1.txt");
FileParameterValue nullParam2 = new FileParameterValue(null, new File("null_param2.txt"), "null_param2.txt");
// Combine nulls
assertEquals(nullParam1, nullParam1);
assertEquals(nullParam1, nullParam2);
assertEquals(nullParam2, nullParam1);
assertEquals(nullParam2, nullParam2);
// Compare with non-null
assertNotEquals(nullParam1, nonNullParam);
assertNotEquals(nonNullParam, nullParam1);
@@ -1,18 +1,18 @@
/*
* The MIT License
*
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -45,7 +45,7 @@ import org.junit.rules.TemporaryFolder;
public class FingerprintTest {
@Rule public TemporaryFolder tmp = new TemporaryFolder();
@Test public void rangeSet() {
RangeSet rs = new RangeSet();
assertFalse(rs.includes(0));
@@ -84,35 +84,35 @@ public class ParametersActionTest {
assertNotSame(baseParamsAB, params);
}
@Test
@Issue("JENKINS-15094")
public void checkNullParameterValues() {
SubTask subtask = mock(SubTask.class);
Build build = mock(Build.class);
// Prepare parameters Action
StringParameterValue A = new StringParameterValue("A", "foo");
StringParameterValue B = new StringParameterValue("B", "bar");
ParametersAction parametersAction = new ParametersAction(A, null, B);
ParametersAction parametersAction2 = new ParametersAction(A,null);
// Non existent parameter
assertNull(parametersAction.getParameter("C"));
assertNull(parametersAction.getParameter("C"));
assertNull(parametersAction.getAssignedLabel(subtask));
// Interaction with build
EnvVars vars = new EnvVars();
parametersAction.buildEnvironment(build, vars);
assertEquals(2, vars.size());
assertEquals(2, vars.size());
parametersAction.createVariableResolver(build);
List<BuildWrapper> wrappers = new ArrayList<>();
parametersAction.createBuildWrappers(build, wrappers);
assertEquals(0, wrappers.size());
// Merges and overrides
assertEquals(3, parametersAction.createUpdated(parametersAction2.getParameters()).getParameters().size());
assertEquals(3, parametersAction.merge(parametersAction2).getParameters().size());
assertEquals(3, parametersAction.merge(parametersAction2).getParameters().size());
}
}
@@ -31,7 +31,7 @@ import static org.junit.Assert.assertThrows;
import org.junit.Test;
public class RunParameterValueTest {
@SuppressWarnings("ResultOfObjectAllocationIgnored")
@Test public void robustness() {
RunParameterValue rpv = new RunParameterValue("whatever", "folder/job#57");
@@ -35,7 +35,7 @@ import org.jvnet.hudson.test.Issue;
* @author Oleg Nenashev
*/
public class UserTest {
@Test
@Issue("JENKINS-33600")
public void blankIdsOrFullNamesShouldNotBeAllowed() {
@@ -43,7 +43,7 @@ public class UserTest {
assertThat("Empty user IDs should not be allowed", User.isIdOrFullnameAllowed(""), is(false));
assertThat("Blank user IDs should not be allowed", User.isIdOrFullnameAllowed(" "), is(false));
}
@Test
@Issue("JENKINS-35967")
public void shouldNotAllowIllegalRestrictedNamesInWrongCase() {
@@ -53,7 +53,7 @@ public class UserTest {
assertIdOrFullNameNotAllowed("syStem");
assertIdOrFullNameNotAllowed("sYstEm");
}
@Test
@Issue("JENKINS-35967")
public void shouldNotAllowIllegalRestrictedNamesEvenIfTrimmed() {
@@ -62,13 +62,13 @@ public class UserTest {
assertIdOrFullNameNotAllowed(" " + username);
assertIdOrFullNameNotAllowed(username + " ");
assertIdOrFullNameNotAllowed(" " + username + " ");
assertIdOrFullNameNotAllowed("\t" + username + "\t");
assertIdOrFullNameNotAllowed("\t" + username + "\t");
}
}
private void assertIdOrFullNameNotAllowed(String id) {
assertThat("User ID or full name '" + id + "' should not be allowed",
assertThat("User ID or full name '" + id + "' should not be allowed",
User.isIdOrFullnameAllowed(id), is(false));
}
}
@@ -30,7 +30,7 @@ public class ViewTest {
final String displayName1 = "displayName1";
final String url2 = "url2";
final String displayName2 = "displayName2";
SearchIndexBuilder sib = new SearchIndexBuilder();
// mock the items to be indexed
TopLevelItem item1 = Mockito.mock(TopLevelItem.class);
@@ -42,7 +42,7 @@ public class ViewTest {
Collection<TopLevelItem> items = new ArrayList<>();
items.add(item1);
items.add(item2);
// mock the view class except for the addDisplayNamesToSearchIndex() call as that
// is what we are testing
View view = Mockito.mock(View.class);
@@ -51,9 +51,9 @@ public class ViewTest {
// now make the actual call to index items
view.addDisplayNamesToSearchIndex(sib, items);
// make and index with sib
// make and index with sib
SearchIndex index = sib.make();
// now make sure we can fetch item1 from the index
List<SearchItem> result = new ArrayList<>();
index.find(displayName1, result);
@@ -87,9 +87,9 @@ public class ViewTest {
final TopLevelItem rootJob = createJob("rootJob");
final TopLevelItem sharedJob = createJob("sharedJob");
rootView = rootView.withJobs(rootJob, sharedJob);
final TopLevelItem leftJob = createJob("leftJob");
final TopLevelItem rightJob = createJob("rightJob");
@@ -132,12 +132,12 @@ public class ViewTest {
super(name);
this.views = views;
}
private CompositeView withJobs(TopLevelItem... jobs) {
this.jobs = jobs;
return this;
}
@Override
public Collection<TopLevelItem> getItems() {
return Arrays.asList(this.jobs);
@@ -147,7 +147,7 @@ public class ViewTest {
public Collection<View> getViews() {
return Arrays.asList(this.views);
}
@Override
public boolean canDelete(View view) {
return false;
@@ -69,7 +69,7 @@ public class SCMListenerTest {
l.onChangeLogParsed(r, scm, tl, cls);
assertEquals("cannot handle this", 0, l.cnt);
}
private static class L extends SCMListener {
int cnt;
}
@@ -36,13 +36,13 @@ public class CronTabDayOfWeekLocaleTest {
}
return parameters;
}
private final Locale locale;
public CronTabDayOfWeekLocaleTest(Locale locale) {
this.locale = locale;
}
/**
* This unit test is an slight adaptation of the unit test found in
* HUDSON-8656.
@@ -53,220 +53,220 @@ public class CronTabDayOfWeekLocaleTest {
final Calendar cal = Calendar.getInstance(locale);
cal.set(2011, Calendar.JANUARY, 16, 0, 0, 0); // Sunday, Jan 16th 2011, 00:00
final String cronStr = "0 23 * * 1-5"; // execute on weekdays @23:00
final CronTab cron = new CronTab(cronStr);
final Calendar next = cron.ceil(cal);
final Calendar expectedDate = Calendar.getInstance();
// Expected next: Monday, Jan 17th 2011, 23:00
expectedDate.set(2011, Calendar.JANUARY, 17, 23, 0, 0);
compare(expectedDate, next);
}
@Test
public void isSundayAndNextRunIsMonday() throws Exception {
final Calendar cal = Calendar.getInstance(locale);
cal.set(2011, Calendar.JANUARY, 16, 0, 0, 0); // Sunday, Jan 16th 2011, 00:00
final String cronStr = "0 0 * * 1"; // Mondays @00:00
final CronTab cron = new CronTab(cronStr);
final Calendar actual = cron.ceil(cal);
final Calendar expected = Calendar.getInstance();
// Expected next: Monday, Jan 17th 2011, 00:00
expected.set(2011, Calendar.JANUARY, 17, 0, 0, 0);
compare(expected, actual);
}
@Test
public void isSundayAndPreviousRunIsMonday() throws Exception {
final Calendar cal = Calendar.getInstance(locale);
cal.set(2011, Calendar.JANUARY, 16, 0, 0, 0); // Sunday, Jan 16th 2011, 00:00
final String cronStr = "0 0 * * 1"; // Mondays @00:00
final CronTab cron = new CronTab(cronStr);
final Calendar actual = cron.floor(cal);
final Calendar expected = Calendar.getInstance();
// Expected next: Monday, Jan 10th 2011, 00:00
expected.set(2011, Calendar.JANUARY, 10, 0, 0, 0);
compare(expected, actual);
}
@Test
public void isSundayAndNextRunIsTuesday() throws Exception {
final Calendar cal = Calendar.getInstance(locale);
cal.set(2011, Calendar.JANUARY, 16, 0, 0, 0); // Sunday, Jan 16th 2011, 00:00
final String cronStr = "0 0 * * 2"; // Tuesdays @00:00
final CronTab cron = new CronTab(cronStr);
final Calendar actual = cron.ceil(cal);
final Calendar expected = Calendar.getInstance();
// Expected next: Tuesday, Jan 18th 2011, 00:00
expected.set(2011, Calendar.JANUARY, 18, 0, 0, 0);
compare(expected, actual);
}
@Test
public void isSundayAndPreviousRunIsTuesday() throws Exception {
final Calendar cal = Calendar.getInstance(locale);
cal.set(2011, Calendar.JANUARY, 16, 0, 0, 0); // Sunday, Jan 16th 2011, 00:00
final String cronStr = "0 0 * * 2"; // Tuesdays @00:00
final CronTab cron = new CronTab(cronStr);
final Calendar actual = cron.floor(cal);
final Calendar expected = Calendar.getInstance();
// Expected next: Tuesday, Jan 11th 2011, 00:00
expected.set(2011, Calendar.JANUARY, 11, 0, 0, 0);
compare(expected, actual);
}
@Test
public void isSundayAndNextRunIsWednesday() throws Exception {
final Calendar cal = Calendar.getInstance(locale);
cal.set(2011, Calendar.JANUARY, 16, 0, 0, 0); // Sunday, Jan 16th 2011, 00:00
final String cronStr = "0 0 * * 3"; // Wednesdays @00:00
final CronTab cron = new CronTab(cronStr);
final Calendar actual = cron.ceil(cal);
final Calendar expected = Calendar.getInstance();
// Expected next: Wednesday, Jan 19th 2011, 00:00
expected.set(2011, Calendar.JANUARY, 19, 0, 0, 0);
compare(expected, actual);
}
@Test
public void isSundayAndPreviousRunIsWednesday() throws Exception {
final Calendar cal = Calendar.getInstance(locale);
cal.set(2011, Calendar.JANUARY, 16, 0, 0, 0); // Sunday, Jan 16th 2011, 00:00
final String cronStr = "0 0 * * 3"; // Wednesdays @00:00
final CronTab cron = new CronTab(cronStr);
final Calendar actual = cron.floor(cal);
final Calendar expected = Calendar.getInstance();
// Expected next: Wednesday, Jan 12th 2011, 00:00
expected.set(2011, Calendar.JANUARY, 12, 0, 0, 0);
compare(expected, actual);
}
@Test
public void isSundayAndNextRunIsThursday() throws Exception {
final Calendar cal = Calendar.getInstance(locale);
cal.set(2011, Calendar.JANUARY, 16, 0, 0, 0); // Sunday, Jan 16th 2011, 00:00
final String cronStr = "0 0 * * 4"; // Thursdays @00:00
final CronTab cron = new CronTab(cronStr);
final Calendar actual = cron.ceil(cal);
final Calendar expected = Calendar.getInstance();
// Expected next: Thursday, Jan 20th 2011, 00:00
expected.set(2011, Calendar.JANUARY, 20, 0, 0, 0);
compare(expected, actual);
}
@Test
public void isSundayAndPreviousRunIsThursday() throws Exception {
final Calendar cal = Calendar.getInstance(locale);
cal.set(2011, Calendar.JANUARY, 16, 0, 0, 0); // Sunday, Jan 16th 2011, 00:00
final String cronStr = "0 0 * * 4"; // Thursdays @00:00
final CronTab cron = new CronTab(cronStr);
final Calendar actual = cron.floor(cal);
final Calendar expected = Calendar.getInstance();
// Expected next: Thursday, Jan 13th 2011, 00:00
expected.set(2011, Calendar.JANUARY, 13, 0, 0, 0);
compare(expected, actual);
}
@Test
public void isSundayAndNextRunIsFriday() throws Exception {
final Calendar cal = Calendar.getInstance(locale);
cal.set(2011, Calendar.JANUARY, 16, 0, 0, 0); // Sunday, Jan 16th 2011, 00:00
final String cronStr = "0 0 * * 5"; // Fridays @00:00
final CronTab cron = new CronTab(cronStr);
final Calendar actual = cron.ceil(cal);
final Calendar expected = Calendar.getInstance();
// Expected next: Friday, Jan 21th 2011, 00:00
expected.set(2011, Calendar.JANUARY, 21, 0, 0, 0);
compare(expected, actual);
}
@Test
public void isSundayAndPreviousRunIsFriday() throws Exception {
final Calendar cal = Calendar.getInstance(locale);
cal.set(2011, Calendar.JANUARY, 16, 0, 0, 0); // Sunday, Jan 16th 2011, 00:00
final String cronStr = "0 0 * * 5"; // Fridays @00:00
final CronTab cron = new CronTab(cronStr);
final Calendar actual = cron.floor(cal);
final Calendar expected = Calendar.getInstance();
// Expected next: Friday, Jan 14th 2011, 00:00
expected.set(2011, Calendar.JANUARY, 14, 0, 0, 0);
compare(expected, actual);
}
@Test
public void isSundayAndNextRunIsSaturday() throws Exception {
final Calendar cal = Calendar.getInstance(locale);
cal.set(2011, Calendar.JANUARY, 16, 0, 0, 0); // Sunday, Jan 16th 2011, 00:00
final String cronStr = "0 0 * * 6"; // Saturdays @00:00
final CronTab cron = new CronTab(cronStr);
final Calendar actual = cron.ceil(cal);
final Calendar expected = Calendar.getInstance();
// Expected next: Saturday, Jan 22th 2011, 00:00
expected.set(2011, Calendar.JANUARY, 22, 0, 0, 0);
compare(expected, actual);
}
@Test
public void isSundayAndPreviousRunIsSaturday() throws Exception {
final Calendar cal = Calendar.getInstance(locale);
cal.set(2011, Calendar.JANUARY, 16, 0, 0, 0); // Sunday, Jan 16th 2011, 00:00
final String cronStr = "0 0 * * 6"; // Saturdays @00:00
final CronTab cron = new CronTab(cronStr);
final Calendar actual = cron.floor(cal);
final Calendar expected = Calendar.getInstance();
// Expected next: Saturday, Jan 15th 2011, 00:00
expected.set(2011, Calendar.JANUARY, 15, 0, 0, 0);
compare(expected, actual);
}
@Test
public void isSundayAndNextRunIsNextSunday() throws Exception {
final Calendar cal = Calendar.getInstance(locale);
cal.set(2011, Calendar.JANUARY, 16, 1, 0, 0); // Sunday, Jan 16th 2011, 01:00
final String cronStr = "0 0 * * 0"; // Sundays @00:00
final CronTab cron = new CronTab(cronStr);
final Calendar actual = cron.ceil(cal);
final Calendar expected = Calendar.getInstance();
// Expected next: Sunday, Jan 22th 2011, 00:00
expected.set(2011, Calendar.JANUARY, 23, 0, 0, 0);
compare(expected, actual);
}
@Test
public void isSundayAndPreviousRunIsPreviousSunday() throws Exception {
final Calendar cal = Calendar.getInstance(locale);
cal.set(2011, Calendar.JANUARY, 16, 0, 0, 0); // Sunday, Jan 16th 2011, 00:00
final String cronStr = "0 1 * * 0"; // Sundays @01:00
final CronTab cron = new CronTab(cronStr);
final Calendar actual = cron.floor(cal);
final Calendar expected = Calendar.getInstance();
// Expected next: Sunday, Jan 9th 2011, 01:00
expected.set(2011, Calendar.JANUARY, 9, 1, 0, 0);
@@ -25,7 +25,7 @@ public class CronTabEventualityTest {
parameters.add(new Object[]{"seed2", Hash.from("seed2")});
return parameters;
}
private Calendar createLimit(Calendar start, int field, int amount){
Calendar limit = (Calendar)start.clone();
limit.add(field, amount);
@@ -139,7 +139,7 @@ public class ComputerLauncherTest {
"OpenJDK Runtime Environment Zulu11.35+15-CA (build 11.0.5+10-LTS)\n" +
"OpenJDK 64-Bit Server VM Zulu11.35+15-CA (build 11.0.5+10-LTS, mixed mode)", "11.0.5");
}
private static void assertChecked(String text, String spec) throws IOException {
ByteArrayOutputStream os = new ByteArrayOutputStream();
ComputerLauncher.checkJavaVersion(new PrintStream(os), "bin/java", new BufferedReader(new StringReader(text)));
@@ -1,18 +1,18 @@
/*
* The MIT License
*
*
* Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, Yahoo! Inc.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -119,15 +119,15 @@ public class ArgumentListBuilderTest {
add("-Dfoo9=%'''%%@%"); // no quotes as none of the % are followed by a letter
// By default, does not escape %VAR%
assertThat(builder.toWindowsCommand().toCommandArray(), is(new String[] { "cmd.exe", "/C",
"\"ant.bat", "-Dfoo1=abc", "\"-Dfoo2=foo bar\"", "\"-Dfoo3=/u*r\"", "\"-Dfoo4=/us?\"",
"\"-Dfoo10=bar,baz\"", "\"-Dfoo5=foo;bar^baz\"", "\"-Dfoo6=<xml>&here;</xml>\"",
"\"-Dfoo7=foo|bar\"\"baz\"", "\"-Dfoo8=% %QED% %comspec% %-%(%.%\"",
"\"ant.bat", "-Dfoo1=abc", "\"-Dfoo2=foo bar\"", "\"-Dfoo3=/u*r\"", "\"-Dfoo4=/us?\"",
"\"-Dfoo10=bar,baz\"", "\"-Dfoo5=foo;bar^baz\"", "\"-Dfoo6=<xml>&here;</xml>\"",
"\"-Dfoo7=foo|bar\"\"baz\"", "\"-Dfoo8=% %QED% %comspec% %-%(%.%\"",
"-Dfoo9=%'''%%@%", "&&", "exit", "%%ERRORLEVEL%%\"" }));
// Pass flag to escape %VAR%
assertThat(builder.toWindowsCommand(true).toCommandArray(), is(new String[] { "cmd.exe", "/C",
"\"ant.bat", "-Dfoo1=abc", "\"-Dfoo2=foo bar\"", "\"-Dfoo3=/u*r\"", "\"-Dfoo4=/us?\"",
"\"-Dfoo10=bar,baz\"", "\"-Dfoo5=foo;bar^baz\"", "\"-Dfoo6=<xml>&here;</xml>\"",
"\"-Dfoo7=foo|bar\"\"baz\"", "\"-Dfoo8=% %\"Q\"ED% %\"c\"omspec% %-%(%.%\"",
"\"ant.bat", "-Dfoo1=abc", "\"-Dfoo2=foo bar\"", "\"-Dfoo3=/u*r\"", "\"-Dfoo4=/us?\"",
"\"-Dfoo10=bar,baz\"", "\"-Dfoo5=foo;bar^baz\"", "\"-Dfoo6=<xml>&here;</xml>\"",
"\"-Dfoo7=foo|bar\"\"baz\"", "\"-Dfoo8=% %\"Q\"ED% %\"c\"omspec% %-%(%.%\"",
"-Dfoo9=%'''%%@%", "&&", "exit", "%%ERRORLEVEL%%\"" }));
// Try to hide password
builder.add("-Dpassword=hidden", true);
@@ -146,7 +146,7 @@ public class ArgumentListBuilderTest {
+ "\"\"-Dfoo8=% %\"Q\"ED% %\"c\"omspec% %-%(%.%\"\" -Dfoo9=%'''%%@% ****** "
+ "&& exit %%ERRORLEVEL%%\""));
}
@Test
@Ignore("It's only for reproduce JENKINS-28790 issue. It's added to testToWindowsCommand")
@Issue("JENKINS-28790")
@@ -189,7 +189,7 @@ public class ArgumentListBuilderTest {
assertNotNull("The mask array should not be null", array);
assertThat("The mask array was incorrect", array, is(builder.toMaskArray()));
}
private static final Map<String, String> KEY_VALUES = new LinkedHashMap<>();
static {
KEY_VALUES.put("key1", "value1");
@@ -198,7 +198,7 @@ public class ArgumentListBuilderTest {
}
private static final Set<String> MASKS = Collections.singleton("key2");
@Test
public void assertKeyValuePairsWithMask() {
ArgumentListBuilder builder = new ArgumentListBuilder();
@@ -1,18 +1,18 @@
/*
* The MIT License
*
*
* Copyright (c) 2010, Yahoo!, Inc., Alan Harder
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -1,18 +1,18 @@
/*
* The MIT License
*
*
* Copyright (c) 2011, Christoph Thelen
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -46,22 +46,22 @@ public class DirScannerTest {
FilePath git = tmp.child(".git");
git.mkdirs();
git.child("HEAD").touch(0);
DirScanner glob1 = new DirScanner.Glob("**/*", null);
DirScanner glob2 = new DirScanner.Glob("**/*", null, true);
MatchingFileVisitor gitdir = new MatchingFileVisitor("HEAD");
MatchingFileVisitor gitignore = new MatchingFileVisitor(".gitignore");
glob1.scan(new File(tmp.getRemote()), gitdir);
glob2.scan(new File(tmp.getRemote()), gitignore);
assertFalse(gitdir.found);
assertFalse(gitignore.found);
} finally {
tmp.deleteRecursive();
}
}
@Test public void globShouldIgnoreDefaultExcludesByRequest() throws Exception {
FilePath tmp = new FilePath(tmpRule.getRoot());
try {
@@ -69,31 +69,31 @@ public class DirScannerTest {
FilePath git = tmp.child(".git");
git.mkdirs();
git.child("HEAD").touch(0);
DirScanner glob = new DirScanner.Glob("**/*", null, false);
MatchingFileVisitor gitdir = new MatchingFileVisitor("HEAD");
MatchingFileVisitor gitignore = new MatchingFileVisitor(".gitignore");
glob.scan(new File(tmp.getRemote()), gitdir);
glob.scan(new File(tmp.getRemote()), gitignore);
assertTrue(gitdir.found);
assertTrue(gitignore.found);
} finally {
tmp.deleteRecursive();
}
}
private static class MatchingFileVisitor extends FileVisitor {
public boolean found = false;
public final String filename;
MatchingFileVisitor(String filename) {
this.filename = filename;
}
@Override
public void visit(File f, String relativePath) {
if (relativePath.endsWith(filename)) {
+4 -4
View File
@@ -1,18 +1,18 @@
/*
* The MIT License
*
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -28,7 +28,7 @@ public class ProcessTreeTest {
int id;
private static final long serialVersionUID = 1L;
}
@Test public void remoting() throws Exception {
Assume.assumeFalse("on some platforms where we fail to list any processes", ProcessTree.get()==ProcessTree.DEFAULT);
@@ -1,18 +1,18 @@
/*
* The MIT License
*
*
* Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -118,12 +118,12 @@ public class TarArchiverTest {
Util.createSymlink(dir, "nonexistent", "link", TaskListener.NULL);
new FilePath(dir).tar(new NullStream(), "**");
}
/**
* Test backing up an open file
*/
@Issue("JENKINS-20187")
@Test public void growingFileTar() throws Exception {
File file=new File(tmp.getRoot(),"growing.file");
@@ -132,7 +132,7 @@ public class TarArchiverTest {
t1.start();
new FilePath(tmp.getRoot()).tar(new NullStream(), "**");
runnable1.doFinish();
t1.join();
}
@@ -26,10 +26,10 @@ public class CoreEnvironmentContributorTest {
@Mock
Job job;
@Mock
TaskListener listener;
@After
public void tearDown() throws Exception {
mocks.close();
@@ -34,21 +34,21 @@ public class JDKNameTest {
public void nullIsDefaultName() {
assertThat(JDK.isDefaultName(null), is(true));
}
@Test
public void recognizeOldDefaultName() {
// DEFAULT_NAME took this value prior to 1.598.
assertThat(JDK.isDefaultName("(Default)"), is(true));
}
@Test
public void recognizeDefaultName() {
assertThat(JDK.isDefaultName(JDK.DEFAULT_NAME), is(true));
}
@Test
public void othernameNotDefault() {
assertThat(JDK.isDefaultName("I'm a customized name"), is(false));
}
}
@@ -129,7 +129,7 @@ public class JenkinsGetRootUrlTest {
rootUrlIs("https://ci/jenkins/");
}
}
@Issue("JENKINS-10675")
@Test
public void useForwardedProtoWhenPresent() {
@@ -203,7 +203,7 @@ public class JenkinsGetRootUrlTest {
}
private void rootUrlFromRequestIs(final String expectedRootUrl) {
assertThat(jenkins.getRootUrlFromRequest(), equalTo(expectedRootUrl));
}
@@ -216,7 +216,7 @@ public class JenkinsGetRootUrlTest {
when(config.getUrl()).thenReturn(configuredHost);
}
private void withHeader(String name, final String value) {
final StaplerRequest req = Stapler.getCurrentRequest();
when(req.getHeader(name)).thenReturn(value);
@@ -37,29 +37,29 @@ import org.mockito.stubbing.Answer;
* @author Oleg Nenashev
*/
public class JenkinsLocationConfigurationTest {
JenkinsLocationConfiguration config;
@Before
public void setUp() {
config = mock(JenkinsLocationConfiguration.class, Mockito.CALLS_REAL_METHODS);
Answer<String> mockVoid = invocation -> "stub";
Mockito.doAnswer(mockVoid).when(config).save();
Mockito.doAnswer(mockVoid).when(config).save();
Mockito.doAnswer(mockVoid).when(config).save();
}
@Test
public void setAdminEmail() {
final String email="test@foo.bar";
final String email2="test@bar.foo";
// Assert the default value
assertEquals(Messages.Mailer_Address_Not_Configured(), config.getAdminAddress());
// Basic case
config.setAdminAddress(email);
assertEquals(email, config.getAdminAddress());
// Quoted value
config.setAdminAddress("\""+email2+"\"");
assertEquals(email2, config.getAdminAddress());
@@ -67,16 +67,16 @@ public class JenkinsLocationConfigurationTest {
config.setAdminAddress(" test@foo.bar ");
assertEquals(email,config.getAdminAddress());
}
@Test
@Issue("JENKINS-28419")
public void resetAdminEmail() {
final String email="test@foo.bar";
// Set the e-mail
config.setAdminAddress(email);
assertEquals(email, config.getAdminAddress());
// Reset it
config.setAdminAddress(null);
assertEquals(Messages.Mailer_Address_Not_Configured(), config.getAdminAddress());
@@ -17,7 +17,7 @@ import org.junit.Before;
import org.junit.Test;
public class NewViewLinkTest {
private NewViewLink newViewLink;
private View view = mock(View.class);
@@ -1,18 +1,18 @@
/*
* The MIT License
*
*
* Copyright 2010 Yahoo! Inc.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -81,7 +81,7 @@ public class AbstractLazyLoadRunMapTest {
};
}
};
private final Map<Integer,Semaphore> slowBuilderStartSemaphores = new HashMap<>();
private final Map<Integer,Semaphore> slowBuilderEndSemaphores = new HashMap<>();
private final Map<Integer,AtomicInteger> slowBuilderLoadCount = new HashMap<>();
@@ -105,7 +105,7 @@ public class AbstractLazyLoadRunMapTest {
};
}
};
@BeforeClass
public static void setUpClass() {
AbstractLazyLoadRunMap.LOGGER.setLevel(Level.OFF);
@@ -47,7 +47,7 @@ public class SortedListTest {
assertEquals(2,l.ceil("F"));
assertEquals(3,l.ceil("G"));
}
@Test
public void testFloor() {
assertEquals(-1,l.floor("A"));
@@ -39,7 +39,7 @@ public class RedactSecretJsonInErrorMessageSanitizerTest {
"{'a': 1, 'b': '2', 'c': {'c1': 1, 'c2': '2', 'c3': ['3a', '3b']}, 'd': ['4a', {'d1': 1, 'd2': '2'}]}"
);
}
@Test
public void simpleWithSecret() {
assertRedaction(
@@ -47,7 +47,7 @@ public class RedactSecretJsonInErrorMessageSanitizerTest {
"{'a': '[value redacted]', 'b': 'other', '$redact': 'a'}"
);
}
@Test
public void singleWithRedactedInArray() {
assertRedaction(
@@ -55,7 +55,7 @@ public class RedactSecretJsonInErrorMessageSanitizerTest {
"{'a': '[value redacted]', 'b': 'other', '$redact': ['a']}"
);
}
@Test
public void objectRedactedAcceptedButNotProcessed() {
assertRedaction(
@@ -63,7 +63,7 @@ public class RedactSecretJsonInErrorMessageSanitizerTest {
"{'a': 'secret', 'b': 'other', '$redact': {'a': 'a'}}"
);
}
@Test
public void weirdValuesInRedactedAcceptedButNotProcessed() {
assertRedaction(
@@ -71,7 +71,7 @@ public class RedactSecretJsonInErrorMessageSanitizerTest {
"{'a': '[value redacted]', 'b': 'other', '$redact': [null, true, false, 1, 2, 'a']}"
);
}
@Test
public void ensureTrueAndOneAsStringAreSupportedAsRedactedKey() {
//only null is not supported, as passing 'null' is considered as null
@@ -80,7 +80,7 @@ public class RedactSecretJsonInErrorMessageSanitizerTest {
"{'true': '[value redacted]', '1': '[value redacted]', 'b': 'other', '$redact': ['true', '1']}"
);
}
@Test
public void redactFullBranch() {
assertRedaction(
@@ -88,7 +88,7 @@ public class RedactSecretJsonInErrorMessageSanitizerTest {
"{'a': '[value redacted]', 'b': '[value redacted]', 'c': 'other', '$redact': ['a', 'b']}"
);
}
@Test
public void multipleSecretAtSameLevel() {
assertRedaction(
@@ -96,7 +96,7 @@ public class RedactSecretJsonInErrorMessageSanitizerTest {
"{'a1': '[value redacted]', 'a2': '[value redacted]', 'b': 'other', '$redact': ['a1', 'a2']}"
);
}
@Test
public void redactedKeyWithoutCorrespondences() {
assertRedaction(
@@ -104,7 +104,7 @@ public class RedactSecretJsonInErrorMessageSanitizerTest {
"{'a1': '[value redacted]', 'a2': '[value redacted]', 'b': 'other', '$redact': ['a0', 'a1', 'a2', 'a3']}"
);
}
@Test
public void secretsAtMultipleLevels() {
assertRedaction(
@@ -112,7 +112,7 @@ public class RedactSecretJsonInErrorMessageSanitizerTest {
"{'a1': '[value redacted]', 'a2': '[value redacted]', 'b': 'other', '$redact': ['a1', 'a2'], 'sub': {'c1': '[value redacted]', 'c2': '[value redacted]', 'c3': 'other', '$redact': ['c1', 'c2']}}"
);
}
@Test
public void noInteractionBetweenLevels() {
assertRedaction(
@@ -120,7 +120,7 @@ public class RedactSecretJsonInErrorMessageSanitizerTest {
"{'a': '[value redacted]', 'b': 'other', 'c': 'other', '$redact': 'a', 'sub': {'a': 'other', 'b': '[value redacted]', 'c': 'other', '$redact': 'b'}}"
);
}
@Test
public void deeplyNestedObject() {
assertRedaction(
@@ -128,7 +128,7 @@ public class RedactSecretJsonInErrorMessageSanitizerTest {
"{'sub': {'arr': ['d1', 2, {'a1': 'other', 'b1':'other', 'c1': '[value redacted]', '$redact': 'c1'}, 4, {'a2': 'other', 'b2': 'other', 'c2': '[value redacted]', '$redact': 'c2'}]}, '$redact': 'b'}"
);
}
private void assertRedaction(String from, String to) {
JSONObject input = JSONObject.fromObject(from.replace('\'', '"'));
JSONObject output = RedactSecretJsonInErrorMessageSanitizer.INSTANCE.sanitize(input);
@@ -61,14 +61,14 @@ import org.mockito.Mockito;
public class ApiTokenStatsTest {
@Rule
public TemporaryFolder tmp = new TemporaryFolder();
@Before
public void prepareConfig() {
// to separate completely the class under test from its environment
ApiTokenPropertyConfiguration mockConfig = Mockito.mock(ApiTokenPropertyConfiguration.class);
}
@Test
public void regularUsage() throws Exception {
final String ID_1 = UUID.randomUUID().toString();
@@ -164,7 +164,7 @@ public class ApiTokenStatsTest {
}
}
}
@Test
public void testResilientIfFileDoesNotExist() {
ApiTokenPropertyConfiguration mockConfig = mock(ApiTokenPropertyConfiguration.class);
@@ -175,7 +175,7 @@ public class ApiTokenStatsTest {
assertNotNull(tokenStats);
}
}
@Test
public void resistantToDuplicatedUuid() throws Exception {
final String ID_1 = UUID.randomUUID().toString();
@@ -224,7 +224,7 @@ public class ApiTokenStatsTest {
}
}
}
@Test
public void resistantToDuplicatedUuid_withNull() throws Exception {
final String ID = "ID";
@@ -257,7 +257,7 @@ public class ApiTokenStatsTest {
}
}
}
@Test
@SuppressWarnings("unchecked")
public void testInternalComparator() throws Exception {
@@ -288,14 +288,14 @@ public class ApiTokenStatsTest {
assertThat(idList, contains("A", "B", "C", "D"));
}
}
private ApiTokenStats.SingleTokenStats createSingleTokenStatsByReflection(String uuid, String dateString, Integer counter) throws Exception {
Class<ApiTokenStats.SingleTokenStats> clazz = ApiTokenStats.SingleTokenStats.class;
Constructor<ApiTokenStats.SingleTokenStats> constructor = clazz.getDeclaredConstructor(String.class);
constructor.setAccessible(true);
ApiTokenStats.SingleTokenStats result = constructor.newInstance(uuid);
{
Field field = clazz.getDeclaredField("useCounter");
field.setAccessible(true);
@@ -306,10 +306,10 @@ public class ApiTokenStatsTest {
field.setAccessible(true);
field.set(result, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").parse(dateString));
}
return result;
}
@Test
public void testDayDifference() throws Exception {
final String ID = UUID.randomUUID().toString();
@@ -335,14 +335,14 @@ public class ApiTokenStatsTest {
assertThat(stats.getNumDaysUse(), greaterThanOrEqualTo(2L));
}
}
private ApiTokenStats createFromFile(File file){
ApiTokenStats result = ApiTokenStats.internalLoad(file);
if (result == null) {
result = new ApiTokenStats();
result.parent = file;
}
return result;
}
}
@@ -52,21 +52,21 @@ public class UrlHelperTest {
assertFalse(UrlHelper.isValidRootUrl("http://::::@example.com"));
assertFalse(UrlHelper.isValidRootUrl("ftp://jenkins"));
}
@Test
public void fragmentIsForbidden(){
// this url will be used as a root url and so will be concatenated with other part, fragment part is not allowed
assertFalse(UrlHelper.isValidRootUrl("http://jenkins#fragment"));
assertFalse(UrlHelper.isValidRootUrl("http://jenkins.com#fragment"));
}
@Test
public void queryIsForbidden(){
// this url will be used as a root url and so will be concatenated with other part, query part is not allowed
assertFalse(UrlHelper.isValidRootUrl("http://jenkins?param=test"));
assertFalse(UrlHelper.isValidRootUrl("http://jenkins.com?param=test"));
}
@Test
public void otherCharactersAreForbidden(){
// other characters are not allowed
@@ -80,7 +80,7 @@ public class UrlHelperTest {
assertFalse(UrlHelper.isValidRootUrl("http://jenk!ins.com"));
assertFalse(UrlHelper.isValidRootUrl("http://jenk?ins.com"));
}
@Test
public void ipv4Allowed(){
assertTrue(UrlHelper.isValidRootUrl("http://172.52.125.12"));
@@ -88,7 +88,7 @@ public class UrlHelperTest {
assertTrue(UrlHelper.isValidRootUrl("http://172.52.125.12:8080"));
assertTrue(UrlHelper.isValidRootUrl("http://172.52.125.12:8080/jenkins"));
}
@Test
public void ipv6Allowed() {
assertTrue(UrlHelper.isValidRootUrl("http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]"));
@@ -99,7 +99,7 @@ public class UrlHelperTest {
assertTrue(UrlHelper.isValidRootUrl("http://[FEDC::3210:FEDC:BA98:7654:3210]"));
// but only one sequence
assertFalse(UrlHelper.isValidRootUrl("http://[2001::85a3::ac1f]"));
// port and path are still allowed
assertTrue(UrlHelper.isValidRootUrl("http://[FEDC:0:0:3210:FEDC:BA98:7654:3210]:8001/jenkins"));
assertTrue(UrlHelper.isValidRootUrl("http://[FEDC:0:0:3210:FEDC:BA98:7654:3210]:8001"));
@@ -108,7 +108,7 @@ public class UrlHelperTest {
assertFalse(UrlHelper.isValidRootUrl("http://[FEDC:0:0:32-10:FEDC:BA98:7654:3210]:8001/jenkins"));
assertFalse(UrlHelper.isValidRootUrl("http://[FEDC:0:0:3210:-FEDC:BA98:7654:3210]:8001/jenkins"));
}
@Test
@Issue("JENKINS-51064")
public void withCustomDomain() {
@@ -118,16 +118,16 @@ public class UrlHelperTest {
assertTrue(UrlHelper.isValidRootUrl("http://my-server.domain:8080/jenkins"));
assertTrue(UrlHelper.isValidRootUrl("http://my-ser_ver.do_m-ain:8080/jenkins"));
assertTrue(UrlHelper.isValidRootUrl("http://my-ser_ver.do_m-ain:8080/jenkins"));
// forbidden to start or end domain with - or .
assertFalse(UrlHelper.isValidRootUrl("http://-jenkins.com"));
assertFalse(UrlHelper.isValidRootUrl("http://jenkins.com-"));
assertFalse(UrlHelper.isValidRootUrl("http://.jenkins.com"));
// allowed to have multiple dots in chain
assertTrue(UrlHelper.isValidRootUrl("http://jen..kins.com"));
}
@Test
public void multipleConsecutiveDashesAreAllowed() {
assertTrue(UrlHelper.isValidRootUrl("http://jenk--ins.internal/"));
@@ -135,7 +135,7 @@ public class UrlHelperTest {
// even with subdomain being just a dash
assertTrue(UrlHelper.isValidRootUrl("http://www.go.-.--.--ogle.com/"));
}
@Test
@Issue("JENKINS-51158")
public void trailingDotsAreAccepted() {
@@ -81,7 +81,7 @@ import org.jvnet.hudson.test.Issue;
public class VirtualFileTest {
@Rule public TemporaryFolder tmp = new TemporaryFolder();
@Issue("SECURITY-162")
@Test public void outsideSymlinks() throws Exception {
assumeFalse(Functions.isWindows());
@@ -144,17 +144,17 @@ public class XStreamDOMTest {
assertThat(v2, instanceOf(DomInMap.class));
assertXStreamDOMEquals(v.values.get("foo"), ((DomInMap)v2).values.get("foo"));
}
private void assertXStreamDOMEquals(XStreamDOM expected, XStreamDOM actual) {
assertEquals(expected.getTagName(), actual.getTagName());
assertEquals(expected.getValue(), actual.getValue());
assertEquals(expected.getAttributeCount(), actual.getAttributeCount());
for (int i=0; i<expected.getAttributeCount(); i++) {
assertEquals(expected.getAttributeName(i), actual.getAttributeName(i));
assertEquals(expected.getAttribute(i), actual.getAttribute(i));
}
if (expected.getChildren() == null) {
assertNull(actual.getChildren());
} else {
@@ -114,7 +114,7 @@ public class XMLUtilsTest {
Assert.assertEquals("1.480.1", XMLUtils.getValue("/hudson/version", configFile));
Assert.assertEquals("", XMLUtils.getValue("/hudson/unknown-element", configFile));
}
@Test
public void testParse_with_XXE() {
final String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
@@ -126,5 +126,5 @@ public class XMLUtilsTest {
StringReader stringReader = new StringReader(xml);
final SAXException e = assertThrows(SAXException.class, () -> XMLUtils.parse(stringReader));
assertThat(e.getMessage(), containsString("\"http://apache.org/xml/features/disallow-doctype-decl\""));
}
}
}
@@ -45,7 +45,7 @@ public class FieldUtilsTest {
public String getMyField() {
return myField;
}
}
public class InnerClassWithProtectedField {