1 /* 2 * Copyright 2023 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; 18 19 import static org.mockito.Mockito.verify; 20 21 import java.lang.reflect.Method; 22 import java.util.Collections; 23 import org.junit.Before; 24 import org.junit.Rule; 25 import org.junit.Test; 26 import org.junit.runner.RunWith; 27 import org.junit.runners.JUnit4; 28 import org.mockito.Mock; 29 import org.mockito.junit.MockitoJUnit; 30 import org.mockito.junit.MockitoRule; 31 32 /** 33 * Unit tests for {@link ForwardingServerCall}. 34 */ 35 @RunWith(JUnit4.class) 36 public class ForwardingServerCallTest { 37 @Rule 38 public final MockitoRule mocks = MockitoJUnit.rule(); 39 40 @Mock private ServerCall<Integer, Integer> serverCall; 41 private ForwardingServerCall<Integer, Integer> forwarder; 42 43 @Before setUp()44 public void setUp() { 45 forwarder = 46 new ForwardingServerCall<Integer, Integer>() { 47 @Override 48 protected ServerCall<Integer, Integer> delegate() { 49 return serverCall; 50 } 51 }; 52 } 53 54 @Test allMethodsForwarded()55 public void allMethodsForwarded() throws Exception { 56 ForwardingTestUtil.testMethodsForwarded( 57 ServerCall.class, serverCall, forwarder, Collections.<Method>emptyList()); 58 } 59 60 @Test sendMessage()61 public void sendMessage() { 62 forwarder.sendMessage(12345); 63 64 verify(serverCall).sendMessage(12345); 65 } 66 } 67 68