1 /* 2 * Copyright 2016 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.internal; 18 19 import io.grpc.Metadata; 20 import io.grpc.MethodDescriptor; 21 import io.grpc.ServerCall; 22 import io.grpc.Status; 23 24 /** 25 * {@link NoopServerCall} is a class that is designed for use in tests. It is designed to be used 26 * in places where a scriptable call is necessary. By default, all methods are noops, and designed 27 * to be overridden. 28 */ 29 public class NoopServerCall<ReqT, RespT> extends ServerCall<ReqT, RespT> { 30 31 /** 32 * {@link NoopServerCall.NoopServerCallListener} is a class that is designed for use in tests. 33 * It is designed to be used in places where a scriptable call listener is necessary. By 34 * default, all methods are noops, and designed to be overridden. 35 */ 36 public static class NoopServerCallListener<T> extends ServerCall.Listener<T> { 37 } 38 39 @Override 40 public void request(int numMessages) {} 41 42 @Override 43 public void sendHeaders(Metadata headers) {} 44 45 @Override 46 public void sendMessage(RespT message) {} 47 48 @Override 49 public void close(Status status, Metadata trailers) {} 50 51 @Override 52 public boolean isCancelled() { 53 return false; 54 } 55 56 @Override 57 public MethodDescriptor<ReqT, RespT> getMethodDescriptor() { 58 return null; 59 } 60 } 61