Skip to content

Commit

Permalink
Format java files in o.e.equinox.common.tests
Browse files Browse the repository at this point in the history
This was achieved by running:
eclipse -consolelog -nosplash -application org.eclipse.jdt.core.JavaCodeFormatter \
  -config .settings/org.eclipse.jdt.core.prefs . -data `mktemp -d`

Signed-off-by: Torbjörn SVENSSON <[email protected]>
  • Loading branch information
Torbjorn-Svensson authored and akurtakov committed Nov 4, 2023
1 parent 4f15538 commit 9e37efc
Show file tree
Hide file tree
Showing 45 changed files with 657 additions and 526 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,8 @@
import org.junit.runners.Suite.SuiteClasses;

@RunWith(Suite.class)
@SuiteClasses({
StringMatcherTests.class,
RuntimeTests.class,
AdaptableTests.class,
RegistryTests.class,
SimpleRegistryTests.class,
FileLocatorTest.class
})
@SuiteClasses({ StringMatcherTests.class, RuntimeTests.class, AdaptableTests.class, RegistryTests.class,
SimpleRegistryTests.class, FileLocatorTest.class })
public class AllTests {
// intentionally left blank
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
*/
public class CoreExceptionTest extends CoreTest {
/**
* Need a zero argument constructor to satisfy the test harness.
* This constructor should not do any real work nor should it be
* called by user code.
* Need a zero argument constructor to satisfy the test harness. This
* constructor should not do any real work nor should it be called by user code.
*/
public CoreExceptionTest() {
super(null);
Expand All @@ -35,7 +34,8 @@ public CoreExceptionTest(String name) {

public void testCoreException() {
final String MESSAGE_STRING = "An exception has occurred";
IStatus status = new Status(IStatus.ERROR, "org.eclipse.core.tests.runtime", 31415, MESSAGE_STRING, new NumberFormatException());
IStatus status = new Status(IStatus.ERROR, "org.eclipse.core.tests.runtime", 31415, MESSAGE_STRING,
new NumberFormatException());

CoreException e = new CoreException(status);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
*/
public class OperationCanceledExceptionTest extends CoreTest {
/**
* Need a zero argument constructor to satisfy the test harness.
* This constructor should not do any real work nor should it be
* called by user code.
* Need a zero argument constructor to satisfy the test harness. This
* constructor should not do any real work nor should it be called by user code.
*/
public OperationCanceledExceptionTest() {
super(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@
*/
public class PathTest extends CoreTest {
/**
* Need a zero argument constructor to satisfy the test harness.
* This constructor should not do any real work nor should it be
* called by user code.
* Need a zero argument constructor to satisfy the test harness. This
* constructor should not do any real work nor should it be called by user code.
*/
public PathTest() {
super(null);
Expand Down Expand Up @@ -102,13 +101,13 @@ public void testAppend() {
assertTrue("2.4", !IPath.ROOT.append(fore).append(aftString).hasTrailingSeparator());
assertTrue("2.5", !fore.removeTrailingSeparator().append(aftString).hasTrailingSeparator());

//ensure append preserves correct trailing separator
// ensure append preserves correct trailing separator
assertTrue("3.0", !fore.append("aft").hasTrailingSeparator());
assertTrue("3.1", fore.append("aft/").hasTrailingSeparator());
assertTrue("3.2", !fore.append("/aft").hasTrailingSeparator());
assertTrue("3.3", fore.append("/aft/").hasTrailingSeparator());
assertTrue("3.4", !fore.append("\\aft").hasTrailingSeparator());
//backslash is a trailing separator on windows only
// backslash is a trailing separator on windows only
assertTrue("3.5.win", win.append("aft\\").hasTrailingSeparator());
assertFalse("3.6.posix", posix.append("aft\\").hasTrailingSeparator());
assertTrue("3.7", !fore.append("fourth/fifth").hasTrailingSeparator());
Expand All @@ -118,7 +117,7 @@ public void testAppend() {
assertTrue("3.11", !fore.append(new Path("fourth/fifth")).hasTrailingSeparator());
assertTrue("3.12", fore.append(new Path("fourth/fifth/")).hasTrailingSeparator());

//make sure append converts backslashes appropriately
// make sure append converts backslashes appropriately
aftString = "fourth\\fifth";
assertEquals("4.0.win", combo, win.append(aftString));
assertEquals("4.1.win", combo, win.removeTrailingSeparator().append(aftString));
Expand All @@ -134,8 +133,8 @@ public void testAppend() {
IPath.forWindows("/").append("x").append("y").append("..\\..").append("x\\y"));
assertEquals("4.22.win", combo,
IPath.forWindows("/").append(win).append("..\\..").append("second\\third").append(aftString));
assertEquals("4.23.win", combo,
IPath.forWindows("/").append(win).append("..\\..\\..").append("first\\second\\third").append(aftString));
assertEquals("4.23.win", combo, IPath.forWindows("/").append(win).append("..\\..\\..")
.append("first\\second\\third").append(aftString));
assertEquals("4.24.win", combo,
IPath.forWindows("/").append(win).append("..\\..\\..").append(win).append(aftString));
assertEquals("4.25.win", combo,
Expand All @@ -150,7 +149,7 @@ public void testAppend() {
assertEquals("5.2", new Path("c:/foo/xyz"), new Path("c:/foo/bar").append("../xyz"));
assertEquals("5.3", new Path("c:/foo/bar/xyz"), new Path("c:/foo/bar").append("./xyz"));

//append preserves device and leading separator of receiver
// append preserves device and leading separator of receiver
assertEquals("6.1.win", IPath.forWindows("c:foo/bar"), IPath.forWindows("c:").append("/foo/bar"));
assertEquals("6.2.win", IPath.forWindows("c:foo/bar"), IPath.forWindows("c:").append("foo/bar"));
assertEquals("6.3.win", IPath.forWindows("c:/foo/bar"), IPath.forWindows("c:/").append("/foo/bar"));
Expand All @@ -175,13 +174,13 @@ public void testAppend() {
assertEquals("6.20", new Path("/foo/bar/"), new Path("/foo/").append(new Path("/bar/")));
assertEquals("6.21", new Path("/foo/bar/"), new Path("/foo/").append(new Path("bar/")));

//append preserves isUNC of receiver
// append preserves isUNC of receiver
assertEquals("7.0", new Path("/foo/bar"), new Path("/foo").append("//bar"));
assertEquals("7.1", new Path("/foo/bar/test"), new Path("/foo").append("bar//test"));
assertEquals("7.2", new Path("//foo/bar"), new Path("//foo").append("bar"));
assertEquals("7.3", new Path("/bar"), IPath.ROOT.append("//bar"));

//append empty path does nothing
// append empty path does nothing
assertEquals("8.0", fore, fore.append(IPath.ROOT));
assertEquals("8.1", fore, fore.append(IPath.EMPTY));
assertEquals("8.2", fore, fore.append(new Path("//")));
Expand Down Expand Up @@ -302,7 +301,8 @@ public void testConstructors() {
assertEquals("1.3", "/a", new Path("/a").toString());
assertEquals("1.4", "//", new Path("//").toString());
assertEquals("1.5", "/a/", new Path("/a/").toString());
assertEquals("1.6", "/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z", new Path("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z").toString());
assertEquals("1.6", "/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z",
new Path("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z").toString());
assertEquals("1.7", "...", new Path("...").toString());
assertEquals("1.8", "/a/b/.../c", new Path("/a/b/.../c").toString());

Expand All @@ -312,7 +312,7 @@ public void testConstructors() {
assertEquals("2.1", IPath.ROOT, new Path("/"));
assertEquals("2.2", anyPath, anyPath);

//should handle slash before the device (see bug 84697)
// should handle slash before the device (see bug 84697)
// fullPath = new java.io.File("D:\\foo\\abc.txt").toURL().getPath()
assertEquals("3.0.win", "D:/foo/abc.txt", IPath.forWindows("/D:/foo/abc.txt").toString());
// fullPath = new java.io.File("D:/").toURL().getPath()
Expand Down Expand Up @@ -466,7 +466,7 @@ public void testHasTrailingSeparator() {
assertTrue("2.4", !new Path("c:/first/second/third").hasTrailingSeparator());
assertTrue("2.5", !new Path("c:first/second/third").hasTrailingSeparator());

//paths of length 0 never have a trailing separator
// paths of length 0 never have a trailing separator
assertTrue("3.0", !new Path("/first/").removeLastSegments(1).hasTrailingSeparator());
assertTrue("3.1", !new Path("/first/").removeFirstSegments(1).hasTrailingSeparator());
assertTrue("3.2", !new Path("/").hasTrailingSeparator());
Expand Down Expand Up @@ -681,9 +681,9 @@ public void testMakeRelative() {
* Tests for {@link Path#makeRelativeTo(IPath)}.
*/
public void testMakeRelativeTo() {
//valid cases
IPath[] bases = new IPath[] {new Path("/a/"), new Path("/a/b")};
IPath[] children = new IPath[] {new Path("/a/"), new Path("/a/b"), new Path("/a/b/c")};
// valid cases
IPath[] bases = new IPath[] { new Path("/a/"), new Path("/a/b") };
IPath[] children = new IPath[] { new Path("/a/"), new Path("/a/b"), new Path("/a/b/c") };
for (int i = 0; i < bases.length; i++) {
for (int j = 0; j < children.length; j++) {
final IPath base = bases[i];
Expand All @@ -694,15 +694,15 @@ public void testMakeRelativeTo() {
}
}

//for equal/identical paths, the relative path should be empty
// for equal/identical paths, the relative path should be empty
IPath equalBase = new Path("/a/b");
assertEquals("3.1", "", new Path("/a/b").makeRelativeTo(equalBase).toString());
assertEquals("3.2", "", new Path("/a/b/").makeRelativeTo(equalBase).toString());
assertEquals("3.3", "", equalBase.makeRelativeTo(equalBase).toString());

//invalid cases (no common prefix)
bases = new IPath[] {new Path("/"), new Path("/b"), new Path("/b/c")};
children = new IPath[] {new Path("/a/"), new Path("/a/b"), new Path("/a/b/c")};
// invalid cases (no common prefix)
bases = new IPath[] { new Path("/"), new Path("/b"), new Path("/b/c") };
children = new IPath[] { new Path("/a/"), new Path("/a/b"), new Path("/a/b/c") };
for (int i = 0; i < bases.length; i++) {
for (int j = 0; j < children.length; j++) {
final IPath base = bases[i];
Expand Down Expand Up @@ -836,18 +836,20 @@ public void testRemoveFirstSegments() {
assertEquals("1.8", IPath.EMPTY, new Path("/first/second/").removeFirstSegments(3));
assertEquals("1.9", new Path("third/fourth"), new Path("/first/second/third/fourth").removeFirstSegments(2));

assertEquals("2.0.win", IPath.forWindows("c:second"), IPath.forWindows("c:/first/second").removeFirstSegments(1));
assertEquals("2.1.win", IPath.forWindows("c:second/third/"), IPath.forWindows("c:/first/second/third/")
.removeFirstSegments(1));
assertEquals("2.0.win", IPath.forWindows("c:second"),
IPath.forWindows("c:/first/second").removeFirstSegments(1));
assertEquals("2.1.win", IPath.forWindows("c:second/third/"),
IPath.forWindows("c:/first/second/third/").removeFirstSegments(1));
assertEquals("2.2.win", IPath.forWindows("c:"), IPath.forWindows("c:first").removeFirstSegments(1));
assertEquals("2.3.win", IPath.forWindows("c:"), IPath.forWindows("c:/first/").removeFirstSegments(1));
assertEquals("2.4.win", IPath.forWindows("c:second"), IPath.forWindows("c:first/second").removeFirstSegments(1));
assertEquals("2.4.win", IPath.forWindows("c:second"),
IPath.forWindows("c:first/second").removeFirstSegments(1));
assertEquals("2.5.win", IPath.forWindows("c:"), IPath.forWindows("c:").removeFirstSegments(1));
assertEquals("2.6.win", IPath.forWindows("c:"), IPath.forWindows("c:/").removeFirstSegments(1));
assertEquals("2.7.win", IPath.forWindows("c:"), IPath.forWindows("c:/first/second/").removeFirstSegments(2));
assertEquals("2.8.win", IPath.forWindows("c:"), IPath.forWindows("c:/first/second/").removeFirstSegments(3));
assertEquals("2.9.win", IPath.forWindows("c:third/fourth"), IPath.forWindows("c:/first/second/third/fourth")
.removeFirstSegments(2));
assertEquals("2.9.win", IPath.forWindows("c:third/fourth"),
IPath.forWindows("c:/first/second/third/fourth").removeFirstSegments(2));

assertEquals("3.0", new Path("second"), new Path("//first/second").removeFirstSegments(1));
assertEquals("3.1", new Path("second/third/"), new Path("//first/second/third/").removeFirstSegments(1));
Expand Down Expand Up @@ -1031,7 +1033,7 @@ public void testEquals() {

public void testUptoSegment() {

//Case 1, absolute path with no trailing separator
// Case 1, absolute path with no trailing separator
IPath anyPath = new Path("/first/second/third");

assertEquals("1.0", IPath.ROOT, anyPath.uptoSegment(0));
Expand All @@ -1040,7 +1042,7 @@ public void testUptoSegment() {
assertEquals("1.3", new Path("/first/second/third"), anyPath.uptoSegment(3));
assertEquals("1.4", new Path("/first/second/third"), anyPath.uptoSegment(4));

//Case 2, absolute path with trailing separator
// Case 2, absolute path with trailing separator
anyPath = new Path("/first/second/third/");

assertEquals("2.0", IPath.ROOT, anyPath.uptoSegment(0));
Expand All @@ -1049,7 +1051,7 @@ public void testUptoSegment() {
assertEquals("2.3", new Path("/first/second/third/"), anyPath.uptoSegment(3));
assertEquals("2.4", new Path("/first/second/third/"), anyPath.uptoSegment(4));

//Case 3, relative path with no trailing separator
// Case 3, relative path with no trailing separator
anyPath = new Path("first/second/third");

assertEquals("3.0", IPath.EMPTY, anyPath.uptoSegment(0));
Expand All @@ -1058,7 +1060,7 @@ public void testUptoSegment() {
assertEquals("3.3", new Path("first/second/third"), anyPath.uptoSegment(3));
assertEquals("3.4", new Path("first/second/third"), anyPath.uptoSegment(4));

//Case 4, relative path with trailing separator
// Case 4, relative path with trailing separator
anyPath = new Path("first/second/third/");

assertEquals("4.0", IPath.EMPTY, anyPath.uptoSegment(0));
Expand All @@ -1082,7 +1084,7 @@ public void testUptoSegment() {

public void testToPath() {

//Case 1, absolute path with no trailing separator
// Case 1, absolute path with no trailing separator
IPath anyPath = new Path("/first/second/third");

assertNotNull(anyPath.toPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class PlatformLogWriterTest extends CoreTest {
public static class TestILogListener implements ILogListener {
final AtomicReference<CountDownLatch> expected = new AtomicReference<>();
final List<IStatus> statuses = new CopyOnWriteArrayList<>();

@Override
public void logging(IStatus status, String plugin) {
CountDownLatch current = expected.get();
Expand All @@ -43,6 +44,7 @@ public void logging(IStatus status, String plugin) {
}
statuses.add(status);
}

List<IStatus> getAllExpectedStatus() throws InterruptedException {
CountDownLatch current = expected.get();
if (current != null) {
Expand All @@ -67,7 +69,6 @@ public PlatformLogWriterTest(String name) {

LogService logService;
final TestILogListener listener = new TestILogListener();


@Override
protected void setUp() {
Expand Down Expand Up @@ -100,7 +101,6 @@ public void testLogServiceLevels() throws InterruptedException {
assertStatus(allStatus.get(4), "debug", IStatus.OK);
assertStatus(allStatus.get(5), "trace", IStatus.OK);


}

private void assertStatus(IStatus status, String message, int severity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public void testConstructor() {
// should test the hashcode() method that is currently missing.
public void testEqual() {

assertTrue("1.0", new PluginVersionIdentifier(123, 456, 789).equals(new PluginVersionIdentifier("123.456.789")));
assertTrue("1.0",
new PluginVersionIdentifier(123, 456, 789).equals(new PluginVersionIdentifier("123.456.789")));
assertTrue("1.1", !new PluginVersionIdentifier(123, 456, 789).equals(new PluginVersionIdentifier("123.456")));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
*/
public class ProgressMonitorWrapperTest extends CoreTest {
/**
* Need a zero argument constructor to satisfy the test harness.
* This constructor should not do any real work nor should it be
* called by user code.
* Need a zero argument constructor to satisfy the test harness. This
* constructor should not do any real work nor should it be called by user code.
*/
public ProgressMonitorWrapperTest() {
super(null);
Expand All @@ -40,7 +39,8 @@ public ProgressMonitorWrapperTest(String name) {
public void testProgressMonitorWrapper() {
NullProgressMonitor nullMonitor = new NullProgressMonitor();
SubProgressMonitor wrapped = new SubProgressMonitor(nullMonitor, 10);
ProgressMonitorWrapper wrapper = new ProgressMonitorWrapper(wrapped) {};
ProgressMonitorWrapper wrapper = new ProgressMonitorWrapper(wrapped) {
};

assertSame("1.0", nullMonitor, wrapped.getWrappedProgressMonitor());
assertSame("1.1", wrapped, wrapper.getWrappedProgressMonitor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
public class QualifiedNameTest extends CoreTest {

/**
* Need a zero argument constructor to satisfy the test harness.
* This constructor should not do any real work nor should it be
* called by user code.
* Need a zero argument constructor to satisfy the test harness. This
* constructor should not do any real work nor should it be called by user code.
*/
public QualifiedNameTest() {
super(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,10 @@

@SuppressWarnings("deprecation")
@RunWith(Suite.class)
@SuiteClasses({
CoreExceptionTest.class,
ServiceCallerTest.class,
OperationCanceledExceptionTest.class,
PathTest.class,
PluginVersionIdentifierTest.class,
ProgressMonitorWrapperTest.class,
QualifiedNameTest.class,
SafeRunnerTest.class,
StatusTest.class,
SubMonitorSmallTicksTest.class,
SubMonitorTest.class,
SubProgressTest.class,
URIUtilTest.class,
URLTest.class,
PlatformLogWriterTest.class
})
@SuiteClasses({ CoreExceptionTest.class, ServiceCallerTest.class, OperationCanceledExceptionTest.class, PathTest.class,
PluginVersionIdentifierTest.class, ProgressMonitorWrapperTest.class, QualifiedNameTest.class,
SafeRunnerTest.class, StatusTest.class, SubMonitorSmallTicksTest.class, SubMonitorTest.class,
SubProgressTest.class, URIUtilTest.class, URLTest.class, PlatformLogWriterTest.class })
public class RuntimeTests {
// intentionally left blank
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ int getCreateCount(Bundle b) {
return result == null ? 0 : result.get();
}
}

/**
* Need a zero argument constructor to satisfy the test harness. This
* constructor should not do any real work nor should it be called by user code.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.junit.Test;


public class SliceProgressMonitorTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ protected void setUp() {
status1 = new Status(status1Severity, status1PluginId, status1Code, status1Message, status1Exception);
status2 = new Status(status2Severity, status2PluginId, status2Code, status2Message, status2Exception);

multistatus1 = new MultiStatus(multistatus1PluginId, multistatus1Code, multistatus1Children, multistatus1Message, multistatus1Exception);
multistatus1 = new MultiStatus(multistatus1PluginId, multistatus1Code, multistatus1Children,
multistatus1Message, multistatus1Exception);
multistatus2 = new MultiStatus(" ", 45, new Status[0], "", null);
multistatus2.add(status1);
multistatus2.add(status1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import org.junit.Test;

/**
* Ensures that creating a SubMonitor with a small number of
* ticks will not prevent it from reporting accurate progress.
* Ensures that creating a SubMonitor with a small number of ticks will not
* prevent it from reporting accurate progress.
*/
public class SubMonitorSmallTicksTest {

Expand Down
Loading

0 comments on commit 9e37efc

Please sign in to comment.