mirror of https://github.com/grpc/grpc-java.git
testing: GrpcServerRule#directExecutor can only be called at instantiation
otherwise it cannot take effect
This commit is contained in:
parent
adc2de7533
commit
55379d105d
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package io.grpc.testing;
|
package io.grpc.testing;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
|
||||||
import io.grpc.BindableService;
|
import io.grpc.BindableService;
|
||||||
import io.grpc.ExperimentalApi;
|
import io.grpc.ExperimentalApi;
|
||||||
import io.grpc.ManagedChannel;
|
import io.grpc.ManagedChannel;
|
||||||
|
|
@ -49,9 +51,10 @@ public class GrpcServerRule extends ExternalResource {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code this} configured to use a direct executor for the {@link ManagedChannel} and
|
* Returns {@code this} configured to use a direct executor for the {@link ManagedChannel} and
|
||||||
* {@link Server}.
|
* {@link Server}. This can only be called at the rule instantiation.
|
||||||
*/
|
*/
|
||||||
public final GrpcServerRule directExecutor() {
|
public final GrpcServerRule directExecutor() {
|
||||||
|
checkState(serverName == null, "directExecutor() can only be called at the rule instantiation");
|
||||||
useDirectExecutor = true;
|
useDirectExecutor = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,11 @@ public class GrpcServerRuleTest {
|
||||||
|
|
||||||
assertThat(testService.lastEmptyCallRequestThread).isNotEqualTo(Thread.currentThread());
|
assertThat(testService.lastEmptyCallRequestThread).isNotEqualTo(Thread.currentThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalStateException.class)
|
||||||
|
public void callDirectExecutorNotAtRuleInstantiation() {
|
||||||
|
grpcServerRule.directExecutor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue