1
+ package com .alipay .sofa .rpc .config ;
2
+
3
+ import com .alipay .sofa .rpc .invoke .Invoker ;
4
+ import org .junit .Assert ;
5
+ import org .junit .Test ;
6
+
7
+ import java .util .ArrayList ;
8
+ import java .util .List ;
9
+
10
+ /**
11
+ * @author Even
12
+ * @date 2025/3/4 21:36
13
+ */
14
+ public class ConsumerConfigTest {
15
+
16
+ @ Test
17
+ public void testMethodTimeout () {
18
+ ConsumerConfig <Invoker > consumerConfig = new ConsumerConfig <>();
19
+ consumerConfig .setTimeout (4000 );
20
+ consumerConfig .setInterfaceId (Invoker .class .getName ());
21
+ consumerConfig .getConfigValueCache (true );
22
+ Assert .assertEquals (4000 , consumerConfig .getMethodTimeout ("invoke" ));
23
+
24
+ List <MethodConfig > methodConfigs = new ArrayList <>();
25
+ MethodConfig methodConfig = new MethodConfig ();
26
+ methodConfig .setName ("invoke" );
27
+ methodConfigs .add (methodConfig );
28
+ consumerConfig .setMethods (methodConfigs );
29
+ consumerConfig .getConfigValueCache (true );
30
+ Assert .assertEquals (4000 , consumerConfig .getMethodTimeout ("invoke" ));
31
+
32
+ methodConfig .setTimeout (5000 );
33
+ consumerConfig .getConfigValueCache (true );
34
+ Assert .assertEquals (5000 , consumerConfig .getMethodTimeout ("invoke" ));
35
+
36
+ methodConfig .setTimeout (-1 );
37
+ consumerConfig .getConfigValueCache (true );
38
+ Assert .assertEquals (-1 , consumerConfig .getMethodTimeout ("invoke" ));
39
+ }
40
+
41
+ }
0 commit comments