1 /* 2 * Copyright 2015 The gRPC Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package io.grpc.testing.integration; 18 19 import io.grpc.ServerBuilder; 20 import io.grpc.inprocess.InProcessChannelBuilder; 21 import io.grpc.inprocess.InProcessServerBuilder; 22 import io.grpc.inprocess.InternalInProcessChannelBuilder; 23 import io.grpc.inprocess.InternalInProcessServerBuilder; 24 import org.junit.runner.RunWith; 25 import org.junit.runners.JUnit4; 26 27 /** Unit tests for {@link io.grpc.inprocess}. */ 28 @RunWith(JUnit4.class) 29 public class InProcessTest extends AbstractInteropTest { 30 31 private static final String SERVER_NAME = "test"; 32 33 @Override getServerBuilder()34 protected ServerBuilder<?> getServerBuilder() { 35 // Starts the in-process server. 36 InProcessServerBuilder builder = InProcessServerBuilder.forName(SERVER_NAME); 37 // Disable the default census stats tracer, use testing tracer instead. 38 InternalInProcessServerBuilder.setStatsEnabled(builder, false); 39 return builder.addStreamTracerFactory(createCustomCensusTracerFactory()); 40 } 41 42 @Override createChannelBuilder()43 protected InProcessChannelBuilder createChannelBuilder() { 44 InProcessChannelBuilder builder = InProcessChannelBuilder.forName(SERVER_NAME); 45 // Disable the default census stats interceptor, use testing interceptor instead. 46 InternalInProcessChannelBuilder.setStatsEnabled(builder, false); 47 return builder.intercept(createCensusStatsClientInterceptor()); 48 } 49 50 @Override customCensusModulePresent()51 protected boolean customCensusModulePresent() { 52 // Metrics values are not expected, but custom census module is still used. 53 return true; 54 } 55 56 @Override metricsExpected()57 protected boolean metricsExpected() { 58 // TODO(zhangkun83): InProcessTransport by-passes framer and deframer, thus message sizes are 59 // not counted. (https://github.com/grpc/grpc-java/issues/2284) 60 return false; 61 } 62 63 @Override maxInboundSize_tooBig()64 public void maxInboundSize_tooBig() { 65 // noop, not enforced. 66 } 67 68 @Override maxOutboundSize_tooBig()69 public void maxOutboundSize_tooBig() { 70 // noop, not enforced. 71 } 72 } 73