mirror of https://github.com/grpc/grpc-java.git
Move StubConfigTest to third_party
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=79430433
This commit is contained in:
parent
2a93c47657
commit
ba653d4bd0
|
|
@ -0,0 +1,48 @@
|
|||
package com.google.net.stubby.stub;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.net.stubby.Call;
|
||||
import com.google.net.stubby.Channel;
|
||||
import com.google.net.stubby.MethodDescriptor;
|
||||
import com.google.net.stubby.testing.integration.TestServiceGrpc;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Tests for stub reconfiguration
|
||||
*/
|
||||
@RunWith(JUnit4.class)
|
||||
public class StubConfigTest {
|
||||
|
||||
@Test
|
||||
public void testConfigureTimeout() {
|
||||
// Create a default stub
|
||||
TestServiceGrpc.TestServiceBlockingStub stub =
|
||||
TestServiceGrpc.newBlockingStub(new FakeChannel());
|
||||
assertEquals(TimeUnit.SECONDS.toMicros(1),
|
||||
stub.getServiceDescriptor().fullDuplexCall.getTimeout());
|
||||
// Reconfigure it
|
||||
stub = stub.configureNewStub()
|
||||
.setTimeout(2, TimeUnit.SECONDS)
|
||||
.build();
|
||||
// New altered config
|
||||
assertEquals(TimeUnit.SECONDS.toMicros(2),
|
||||
stub.getServiceDescriptor().fullDuplexCall.getTimeout());
|
||||
// Default config unchanged
|
||||
assertEquals(TimeUnit.SECONDS.toMicros(1),
|
||||
TestServiceGrpc.CONFIG.fullDuplexCall.getTimeout());
|
||||
}
|
||||
|
||||
|
||||
private static class FakeChannel implements Channel {
|
||||
@Override
|
||||
public <ReqT, RespT> Call<ReqT, RespT> newCall(MethodDescriptor<ReqT, RespT> method) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue