Skip to content

Commit 249af00

Browse files
committed
---
yaml --- r: 5309 b: refs/heads/master c: 7c1c98e h: refs/heads/master i: 5307: f00756e
1 parent a453826 commit 249af00

4 files changed

Lines changed: 44 additions & 35 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 56c29a4a23edb1d7e4f746199ca0e30eeefcce2d
2+
refs/heads/master: 7c1c98ed53460dcb20ee3686cbec339279237f74
33
refs/heads/travis: dae77e558b884bc1b165155482d76c8e40b0fca4
44
refs/heads/gh-pages: 229631582f8957646f81e92ae5a326504f48ee5b
55
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444

trunk/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/FakeScheduledExecutorService.java

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,40 @@ public FakeScheduledExecutorService() {
5353
DateTimeUtils.setCurrentMillisFixed(currentTime.getMillis());
5454
}
5555

56+
@Override
57+
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
58+
return schedulePendingCallable(
59+
new PendingCallable<>(
60+
new Duration(unit.toMillis(delay)), command, PendingCallableType.NORMAL));
61+
}
62+
63+
@Override
64+
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
65+
return schedulePendingCallable(
66+
new PendingCallable<>(
67+
new Duration(unit.toMillis(delay)), callable, PendingCallableType.NORMAL));
68+
}
69+
70+
@Override
71+
public ScheduledFuture<?> scheduleAtFixedRate(
72+
Runnable command, long initialDelay, long period, TimeUnit unit) {
73+
return schedulePendingCallable(
74+
new PendingCallable<>(
75+
new Duration(unit.toMillis(initialDelay)), command, PendingCallableType.FIXED_RATE));
76+
}
77+
78+
@Override
79+
public ScheduledFuture<?> scheduleWithFixedDelay(
80+
Runnable command, long initialDelay, long delay, TimeUnit unit) {
81+
return schedulePendingCallable(
82+
new PendingCallable<>(
83+
new Duration(unit.toMillis(initialDelay)), command, PendingCallableType.FIXED_DELAY));
84+
}
85+
86+
public void tick(long time, TimeUnit unit) {
87+
advanceTime(Duration.millis(unit.toMillis(time)));
88+
}
89+
5690
/**
5791
* This will advance the reference time of the executor and execute (in the same thread) any
5892
* outstanding callable which execution time has passed.
@@ -134,36 +168,6 @@ public void execute(Runnable command) {
134168
delegate.execute(command);
135169
}
136170

137-
@Override
138-
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
139-
return schedulePendingCallable(
140-
new PendingCallable<>(
141-
new Duration(unit.toMillis(delay)), command, PendingCallableType.NORMAL));
142-
}
143-
144-
@Override
145-
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
146-
return schedulePendingCallable(
147-
new PendingCallable<>(
148-
new Duration(unit.toMillis(delay)), callable, PendingCallableType.NORMAL));
149-
}
150-
151-
@Override
152-
public ScheduledFuture<?> scheduleAtFixedRate(
153-
Runnable command, long initialDelay, long period, TimeUnit unit) {
154-
return schedulePendingCallable(
155-
new PendingCallable<>(
156-
new Duration(unit.toMillis(initialDelay)), command, PendingCallableType.FIXED_RATE));
157-
}
158-
159-
@Override
160-
public ScheduledFuture<?> scheduleWithFixedDelay(
161-
Runnable command, long initialDelay, long delay, TimeUnit unit) {
162-
return schedulePendingCallable(
163-
new PendingCallable<>(
164-
new Duration(unit.toMillis(initialDelay)), command, PendingCallableType.FIXED_DELAY));
165-
}
166-
167171
<V> ScheduledFuture<V> schedulePendingCallable(PendingCallable<V> callable) {
168172
if (shutdown.get()) {
169173
throw new IllegalStateException("This executor has been shutdown");

trunk/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/FlowControllerTest.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,21 @@ public void testInvalidArguments() throws Exception {
5050
try {
5151
flowController.reserve(-1, 1);
5252
fail("Must have thrown an illegal argument error");
53-
} catch (IllegalArgumentException expected) { }
53+
} catch (IllegalArgumentException expected) {
54+
// Expected
55+
}
5456
try {
5557
flowController.reserve(1, -1);
5658
fail("Must have thrown an illegal argument error");
57-
} catch (IllegalArgumentException expected) { }
59+
} catch (IllegalArgumentException expected) {
60+
// Expected
61+
}
5862
try {
5963
flowController.reserve(0, 1);
6064
fail("Must have thrown an illegal argument error");
61-
} catch (IllegalArgumentException expected) { }
65+
} catch (IllegalArgumentException expected) {
66+
// Expected
67+
}
6268
}
6369

6470
@Test

trunk/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/SubscriberImplTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.google.cloud.pubsub;
1818

1919
import static org.junit.Assert.assertEquals;
20-
import static org.junit.Assert.fail;
2120

2221
import com.google.cloud.pubsub.FakeSubscriberServiceImpl.ModifyAckDeadline;
2322
import com.google.cloud.pubsub.Subscriber.Builder;

0 commit comments

Comments
 (0)