Move StubConfigTest to third_party

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=79430433
This commit is contained in:
ejona 2014-11-07 10:26:37 -08:00 committed by Eric Anderson
parent 2a93c47657
commit ba653d4bd0
1 changed files with 48 additions and 0 deletions

View File

@ -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;
}
}
}