use of com.google.api.gax.core.FakeApiClock in project gax-java by googleapis.
the class CancellationTest method resetClock.
@Before
public void resetClock() {
fakeClock = new FakeApiClock(System.nanoTime());
executor = RecordingScheduler.create(fakeClock);
clientContext = ClientContext.newBuilder().setExecutor(executor).setClock(fakeClock).setDefaultCallContext(FakeCallContext.createDefault()).setTransportChannel(FakeTransportChannel.create(new FakeChannel())).build();
}
use of com.google.api.gax.core.FakeApiClock in project gax-java by googleapis.
the class OperationCallableImplTest method setUp.
@Before
public void setUp() throws IOException {
initialChannel = mock(FakeChannel.class);
pollTransportChannel = mock(TransportChannel.class);
TransportChannelProvider operationsChannelProvider = mock(TransportChannelProvider.class);
when(operationsChannelProvider.getTransportChannel()).thenReturn(pollTransportChannel);
clock = new FakeApiClock(0L);
executor = RecordingScheduler.create(clock);
pollingAlgorithm = OperationTimedPollAlgorithm.create(FAST_RECHECKING_SETTINGS, clock);
UnaryCallSettings<Integer, OperationSnapshot> initialCallSettings = UnaryCallSettings.<Integer, OperationSnapshot>newUnaryCallSettingsBuilder().setRetrySettings(FAST_RETRY_SETTINGS.toBuilder().setMaxAttempts(1).build()).build();
callSettings = OperationCallSettings.<Integer, Color, Currency>newBuilder().setInitialCallSettings(initialCallSettings).setResponseTransformer(new ResponseTransformer()).setMetadataTransformer(new MetadataTransformer()).setPollingAlgorithm(pollingAlgorithm).build();
initialContext = getClientContext(initialChannel, executor);
}
use of com.google.api.gax.core.FakeApiClock in project gax-java by googleapis.
the class RetryingTest method resetClock.
@Before
public void resetClock() {
fakeClock = new FakeApiClock(System.nanoTime());
executor = RecordingScheduler.create(fakeClock);
clientContext = ClientContext.newBuilder().setExecutor(executor).setClock(fakeClock).setDefaultCallContext(FakeCallContext.createDefault()).setTransportChannel(FakeTransportChannel.create(new FakeChannel())).build();
}
use of com.google.api.gax.core.FakeApiClock in project gax-java by googleapis.
the class GrpcLongRunningTest method setUp.
@Before
public void setUp() throws IOException {
channel = mock(ManagedChannel.class);
TransportChannelProvider operationsChannelProvider = mock(TransportChannelProvider.class);
TransportChannel transportChannel = GrpcTransportChannel.newBuilder().setManagedChannel(channel).build();
when(operationsChannelProvider.getTransportChannel()).thenReturn(transportChannel);
clock = new FakeApiClock(0L);
executor = RecordingScheduler.create(clock);
pollingAlgorithm = OperationTimedPollAlgorithm.create(FAST_RETRY_SETTINGS, clock);
OperationsSettings.Builder settingsBuilder = OperationsSettings.newBuilder();
settingsBuilder.getOperationSettings().setRetrySettings(FAST_RETRY_SETTINGS.toBuilder().setMaxAttempts(1).build());
OperationsSettings settings = OperationsSettings.newBuilder().setTransportChannelProvider(operationsChannelProvider).build();
operationsStub = GrpcOperationsStub.create(((OperationsStubSettings) settings.getStubSettings()));
UnaryCallSettings<Integer, OperationSnapshot> initialCallSettings = UnaryCallSettings.<Integer, OperationSnapshot>newUnaryCallSettingsBuilder().setRetrySettings(FAST_RETRY_SETTINGS.toBuilder().setMaxAttempts(1).build()).build();
callSettings = OperationCallSettings.<Integer, Color, Money>newBuilder().setInitialCallSettings(initialCallSettings).setResponseTransformer(ProtoOperationTransformers.ResponseTransformer.create(Color.class)).setMetadataTransformer(ProtoOperationTransformers.MetadataTransformer.create(Money.class)).setPollingAlgorithm(pollingAlgorithm).build();
initialContext = ClientContext.newBuilder().setTransportChannel(GrpcTransportChannel.newBuilder().setManagedChannel(channel).build()).setExecutor(executor).setDefaultCallContext(GrpcCallContext.of(channel, CallOptions.DEFAULT)).setClock(clock).build();
}
use of com.google.api.gax.core.FakeApiClock in project gax-java by googleapis.
the class WatchdogTest method setUp.
@Before
public void setUp() {
clock = new FakeApiClock(0);
watchdog = Watchdog.create(clock, checkInterval, EXECUTOR);
callable = new MockServerStreamingCallable<>();
innerObserver = new AccumulatingObserver<>();
callable.call("request", watchdog.watch(innerObserver, waitTime, idleTime));
call = callable.popLastCall();
}
Aggregations