Cleanup test
Motivation: Saw a lot of inspector warnings Modifications: Fix inspector warnings Result: Cleaner code
This commit is contained in:
parent
5b0f60cff9
commit
3b114a51df
@ -19,7 +19,6 @@ import ch.qos.logback.classic.Logger;
|
|||||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||||
import ch.qos.logback.core.Appender;
|
import ch.qos.logback.core.Appender;
|
||||||
import io.netty.channel.local.LocalChannel;
|
import io.netty.channel.local.LocalChannel;
|
||||||
import io.netty.util.concurrent.DefaultExecutorFactory;
|
|
||||||
import io.netty.util.concurrent.EventExecutor;
|
import io.netty.util.concurrent.EventExecutor;
|
||||||
import io.netty.util.concurrent.PausableEventExecutor;
|
import io.netty.util.concurrent.PausableEventExecutor;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@ -53,9 +52,7 @@ public class SingleThreadEventLoopTest {
|
|||||||
public void run() { }
|
public void run() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
@SuppressWarnings({ "unused" })
|
|
||||||
private SingleThreadEventLoopA loopA;
|
private SingleThreadEventLoopA loopA;
|
||||||
@SuppressWarnings({ "unused" })
|
|
||||||
private SingleThreadEventLoopB loopB;
|
private SingleThreadEventLoopB loopB;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@ -428,7 +425,7 @@ public class SingleThreadEventLoopTest {
|
|||||||
int numtasks = 5;
|
int numtasks = 5;
|
||||||
|
|
||||||
final List<Queue<Long>> timestampsPerTask = new ArrayList<Queue<Long>>(numtasks);
|
final List<Queue<Long>> timestampsPerTask = new ArrayList<Queue<Long>>(numtasks);
|
||||||
final List<ScheduledFuture> scheduledFutures = new ArrayList<ScheduledFuture>(numtasks);
|
final List<ScheduledFuture<?>> scheduledFutures = new ArrayList<ScheduledFuture<?>>(numtasks);
|
||||||
|
|
||||||
// start the eventloops
|
// start the eventloops
|
||||||
loopA.execute(NOOP);
|
loopA.execute(NOOP);
|
||||||
@ -474,7 +471,7 @@ public class SingleThreadEventLoopTest {
|
|||||||
Thread.sleep(50 + 10 * 100);
|
Thread.sleep(50 + 10 * 100);
|
||||||
|
|
||||||
// Cancel all scheduled tasks.
|
// Cancel all scheduled tasks.
|
||||||
for (ScheduledFuture f : scheduledFutures) {
|
for (ScheduledFuture<?> f : scheduledFutures) {
|
||||||
assertTrue(f.cancel(true));
|
assertTrue(f.cancel(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,7 +487,7 @@ public class SingleThreadEventLoopTest {
|
|||||||
*/
|
*/
|
||||||
private static class TimestampsRunnable implements Runnable {
|
private static class TimestampsRunnable implements Runnable {
|
||||||
|
|
||||||
private Queue<Long> timestamps;
|
private final Queue<Long> timestamps;
|
||||||
|
|
||||||
TimestampsRunnable(Queue<Long> timestamps) {
|
TimestampsRunnable(Queue<Long> timestamps) {
|
||||||
assertNotNull(timestamps);
|
assertNotNull(timestamps);
|
||||||
@ -515,7 +512,7 @@ public class SingleThreadEventLoopTest {
|
|||||||
|
|
||||||
LocalChannel channel = new LocalChannel();
|
LocalChannel channel = new LocalChannel();
|
||||||
boolean firstRun = true;
|
boolean firstRun = true;
|
||||||
ScheduledFuture f = null;
|
ScheduledFuture<?> f = null;
|
||||||
while (i.incrementAndGet() < 4) {
|
while (i.incrementAndGet() < 4) {
|
||||||
ChannelPromise registerPromise = channel.newPromise();
|
ChannelPromise registerPromise = channel.newPromise();
|
||||||
channel.unsafe().register(i.intValue() % 2 == 0 ? loopA : loopB, registerPromise);
|
channel.unsafe().register(i.intValue() % 2 == 0 ? loopA : loopB, registerPromise);
|
||||||
@ -581,8 +578,8 @@ public class SingleThreadEventLoopTest {
|
|||||||
assertThat(channel.eventLoop(), instanceOf(PausableEventExecutor.class));
|
assertThat(channel.eventLoop(), instanceOf(PausableEventExecutor.class));
|
||||||
assertSame(loopA, channel.eventLoop().unwrap());
|
assertSame(loopA, channel.eventLoop().unwrap());
|
||||||
|
|
||||||
ScheduledFuture scheduleFuture;
|
ScheduledFuture<?> scheduleFuture;
|
||||||
if (PeriodicScheduleMethod.FIXED_RATE.equals(method)) {
|
if (PeriodicScheduleMethod.FIXED_RATE == method) {
|
||||||
scheduleFuture = channel.eventLoop().scheduleAtFixedRate(new Runnable() {
|
scheduleFuture = channel.eventLoop().scheduleAtFixedRate(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -629,7 +626,7 @@ public class SingleThreadEventLoopTest {
|
|||||||
verifyTimestampDeltas(timestamps, TimeUnit.MILLISECONDS.toNanos(190));
|
verifyTimestampDeltas(timestamps, TimeUnit.MILLISECONDS.toNanos(190));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static enum PeriodicScheduleMethod {
|
private enum PeriodicScheduleMethod {
|
||||||
FIXED_RATE, FIXED_DELAY
|
FIXED_RATE, FIXED_DELAY
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -659,7 +656,7 @@ public class SingleThreadEventLoopTest {
|
|||||||
assertThat(channel.eventLoop(), instanceOf(PausableEventExecutor.class));
|
assertThat(channel.eventLoop(), instanceOf(PausableEventExecutor.class));
|
||||||
assertSame(loopA, ((PausableEventExecutor) channel.eventLoop()).unwrap());
|
assertSame(loopA, ((PausableEventExecutor) channel.eventLoop()).unwrap());
|
||||||
|
|
||||||
io.netty.util.concurrent.ScheduledFuture scheduleFuture = channel.eventLoop().schedule(new Runnable() {
|
io.netty.util.concurrent.ScheduledFuture<?> scheduleFuture = channel.eventLoop().schedule(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
oneTimeScheduledTaskExecuted.set(true);
|
oneTimeScheduledTaskExecuted.set(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user