Skip to content

Commit

Permalink
Update JavaDoc and fix some IntelliJ warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
centic9 committed Oct 11, 2019
1 parent a286e61 commit 1ef3325
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -130,7 +131,7 @@ public void run() {
}

// Get the input and output streams
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8")); // NOSONAR - test class works only locally anyway
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8)); // NOSONAR - test class works only locally anyway
PrintWriter out = new PrintWriter(socket.getOutputStream()); // NOSONAR - test class works only locally anyway

synchronized (this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ public class PrivateConstructorCoverage {
*
* Template:
*
* <code>
* <pre>
// helper method to get coverage of the unused constructor
// helper method to get coverage of the unused constructor
{@literal @}Test
public void testPrivateConstructor() throws Exception {
org.dstadler.commons.testing.PrivateConstructorCoverage.executePrivateConstructor(yourclass.class);
}
public void testPrivateConstructor() throws Exception {
org.dstadler.commons.testing.PrivateConstructorCoverage.executePrivateConstructor(yourclass.class);
}
</code>
</pre>
*
* @param <T> The type of class to cover.
* @param targetClass The class to cover.
Expand Down
18 changes: 8 additions & 10 deletions src/main/java/org/dstadler/commons/testing/ThreadDump.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,14 @@ public static String threadInfoToString(ThreadInfo info) {
LockInfo lockInfo = info.getLockInfo();
long lockId = lockInfo.getIdentityHashCode();
switch (ts) {
case BLOCKED:
sb.append("\t- waiting to lock ").append('<').append(toHexString(lockId)).append("> (a ").append(lockInfo.getClassName()).append(")\n");
break;
case WAITING:
sb.append("\t- parking to wait for ").append('<').append(toHexString(lockId)).append("> (a ").append(lockInfo.getClassName()).append(")\n");
break;
case TIMED_WAITING:
sb.append("\t- parking to wait for ").append('<').append(toHexString(lockId)).append("> (a ").append(lockInfo.getClassName()).append(")\n");
break;
default:
case BLOCKED:
sb.append("\t- waiting to lock ").append('<').append(toHexString(lockId)).append("> (a ").append(lockInfo.getClassName()).append(")\n");
break;
case WAITING:
case TIMED_WAITING:
sb.append("\t- parking to wait for ").append('<').append(toHexString(lockId)).append("> (a ").append(lockInfo.getClassName()).append(")\n");
break;
default:
}
}

Expand Down
26 changes: 15 additions & 11 deletions src/main/java/org/dstadler/commons/testing/ThreadTestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,24 @@
* Sample usage is as follows:
*
* <pre>
private static final int NUMBER_OF_THREADS = 10;
private static final int NUMBER_OF_TESTS = 100;
{@literal @}Test
public void testMultipleThreads() throws Throwable {
ThreadTestHelper helper =
new ThreadTestHelper(NUMBER_OF_THREADS, NUMBER_OF_TESTS);
public void testMultipleThreads() throws Throwable {
ThreadTestHelper helper =
new ThreadTestHelper(NUMBER_OF_THREADS, NUMBER_OF_TESTS);
helper.executeTest(new ThreadTestHelper.TestRunnable() {
helper.executeTest(new ThreadTestHelper.TestRunnable() {
{@literal @}Override
public void doEnd(int threadNum) throws Exception {
// do stuff at the end ...
}
public void doEnd(int threadNum) throws Exception {
// do stuff at the end ...
}
{@literal @}Override
public void run(int threadNum, int itNum) throws Exception {
// do the actual threaded work ...
}
public void run(int threadNum, int itNum) throws Exception {
// do the actual threaded work ...
}
});
}
</pre>
Expand Down Expand Up @@ -189,7 +192,7 @@ public interface TestRunnable {
* to create a thread, starting the thread causes the object's <code>run</code> method to be called in that separately
* executing
* thread.
* <p>
*
* The general contract of the method <code>run</code> is that it may take any action whatsoever.
*
* @param threadNum
Expand All @@ -213,6 +216,7 @@ public interface TestRunnable {
* The number of the thread executing this doEnd()
* @throws Exception Thrown on any failure during running the test
*/
@SuppressWarnings("RedundantThrows")
default void doEnd(int threadNum) throws Exception {
// default empty implementation as this is often not needed
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void testCreateTestDirectory() throws Exception {
}

@Test
public void testGetTestDirectory() throws Exception {
public void testGetTestDirectory() {
File directory = TestEnvironment.getTestDirectory(TestEnvironment.class);
assertNotNull(directory);
assertFalse(directory.exists());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public Object clone() {
return new CloneableImplementation();
}

@SuppressWarnings({"EqualsWhichDoesntCheckParameterClass", "Contract"})
@SuppressWarnings({"EqualsWhichDoesntCheckParameterClass"})
@Override
public boolean equals(Object obj) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public void testExecuteTestTestRunnable() throws Throwable {
final AtomicInteger endCount = new AtomicInteger();
helper.executeTest(new ThreadTestHelper.TestRunnable() {
@Override
public void doEnd(int threadNum) throws Exception {
public void doEnd(int threadNum) {
endCount.incrementAndGet();
}

@Override
public void run(int threadNum, int iter) throws Exception {
public void run(int threadNum, int iter) {
count.incrementAndGet();
}
});
Expand Down

0 comments on commit 1ef3325

Please sign in to comment.