Skip to content

Commit c96366a

Browse files
committed
---
yaml --- r: 7757 b: refs/heads/tswast-patch-1 c: 7c1c98e h: refs/heads/master i: 7755: e378172
1 parent b132e3a commit c96366a

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
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: 56c29a4a23edb1d7e4f746199ca0e30eeefcce2d
60+
refs/heads/tswast-patch-1: 7c1c98ed53460dcb20ee3686cbec339279237f74
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/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");

branches/tswast-patch-1/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

branches/tswast-patch-1/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)