@@ -97,6 +97,7 @@ public void testConfig() {
9797 config .setNamingUrl ("a://b" );
9898 config .setTarget ("a://b" );
9999 config .setRequestTimeout (10 );
100+ config .setBackupRequestTimeMs (100 );
100101 config .setProtocol ("trpc" );
101102 config .setSerialization ("pb" );
102103 config .setCompressor ("gzip" );
@@ -129,6 +130,7 @@ public void testConfig() {
129130 assertEquals (70 , config .getConnsPerAddr ());
130131 assertEquals (80 , config .getConnTimeout ());
131132 assertEquals (10 , config .getRequestTimeout ());
133+ assertEquals (100 , config .getBackupRequestTimeMs ());
132134 assertEquals (true , config .isIoThreadGroupShare ());
133135 assertEquals (1000 , config .getIoThreads ());
134136 assertEquals ("/trpc" , config .getBasePath ());
@@ -149,27 +151,41 @@ public void testConfig() {
149151 }
150152
151153 @ Test
152- public void testSetCallee () {
153- ExtensionLoader
154- .registerPlugin (new PluginConfig ("attalog" , Filter .class , RemoteLoggerTest .class ));
154+ public void testNoSetCallee () {
155+ ExtensionLoader .registerPlugin (new PluginConfig ("attalog" , Filter .class , RemoteLoggerTest .class ));
155156 BackendConfig config = new BackendConfig ();
156157 config .setName ("trpc.calleeapp.calleeserver.calleeservice.calleemethod" );
157158 config .setNamingUrl ("ip://127.0.0.1:8888" );
158159 config .setExtMap (ImmutableMap .of ("attalog" , (Object ) "attalog" ));
159160 config .setFilters (Lists .newArrayList ("attalog" ));
160161 config .setGroup ("group" );
161- config .setCallee ("trpc.app.server.service" );
162162 config .init ();
163163 assertEquals (config .getCalleeApp (), "" );
164164 assertEquals (config .getCalleeServer (), "" );
165165 assertEquals (config .getCalleeService (), "" );
166166 assertEquals ("127.0.0.1:8888" , config .getCallee ());
167167 }
168168
169+ @ Test
170+ public void testSetCallee () {
171+ ExtensionLoader .registerPlugin (new PluginConfig ("attalog" , Filter .class , RemoteLoggerTest .class ));
172+ BackendConfig config = new BackendConfig ();
173+ config .setName ("trpc.calleeapp.calleeserver.calleeservice.calleemethod" );
174+ config .setNamingUrl ("ip://127.0.0.1:8888" );
175+ config .setExtMap (ImmutableMap .of ("attalog" , (Object ) "attalog" ));
176+ config .setFilters (Lists .newArrayList ("attalog" ));
177+ config .setGroup ("group" );
178+ config .setCallee ("trpc.app.server.service" );
179+ config .init ();
180+ assertEquals (config .getCalleeApp (), "app" );
181+ assertEquals (config .getCalleeServer (), "server" );
182+ assertEquals (config .getCalleeService (), "service" );
183+ assertEquals ("trpc.app.server.service" , config .getCallee ());
184+ }
185+
169186 @ Test
170187 public void testNameSpace () {
171- ExtensionLoader
172- .registerPlugin (new PluginConfig ("attalog" , Filter .class , RemoteLoggerTest .class ));
188+ ExtensionLoader .registerPlugin (new PluginConfig ("attalog" , Filter .class , RemoteLoggerTest .class ));
173189 BackendConfig config = new BackendConfig ();
174190 config .setName ("trpc.calleeapp.calleeserver.calleeservice.calleemethod" );
175191 config .setNamingUrl ("ip://127.0.0.1:8888" );
@@ -183,16 +199,15 @@ public void testNameSpace() {
183199 config .init ();
184200 config .toString ();
185201 assertEquals (0 , config .getNamingMap ().size ());
186- assertEquals (config .getCalleeApp (), "" );
187- assertEquals (config .getCalleeServer (), "" );
188- assertEquals (config .getCalleeService (), "" );
202+ assertEquals (config .getCalleeApp (), "app " );
203+ assertEquals (config .getCalleeServer (), "server " );
204+ assertEquals (config .getCalleeService (), "service " );
189205 assertEquals (config .getNamingOptions ().getExtMap ().get ("namespace" ), "abc" );
190206 }
191207
192208 @ Test
193209 public void testIp () {
194- ExtensionLoader
195- .registerPlugin (new PluginConfig ("attalog" , Filter .class , RemoteLoggerTest .class ));
210+ ExtensionLoader .registerPlugin (new PluginConfig ("attalog" , Filter .class , RemoteLoggerTest .class ));
196211 ExtensionLoader .registerPlugin (ThreadWorkerPool .newThreadWorkerPoolConfig ("thread" , 10 , Boolean .FALSE ));
197212 BackendConfig config = new BackendConfig ();
198213 config .setNamingUrl ("ip://127.0.0.1:8888" );
@@ -237,10 +252,8 @@ public void testIp() {
237252
238253 @ Test
239254 public void test () {
240- ExtensionLoader
241- .registerPlugin (new PluginConfig ("attalog" , Filter .class , RemoteLoggerTest .class ));
242- ExtensionLoader .registerPlugin (ThreadWorkerPool .newThreadWorkerPoolConfig ("thread" , 10 ,
243- 10 , Boolean .FALSE ));
255+ ExtensionLoader .registerPlugin (new PluginConfig ("attalog" , Filter .class , RemoteLoggerTest .class ));
256+ ExtensionLoader .registerPlugin (ThreadWorkerPool .newThreadWorkerPoolConfig ("thread" , 10 , Boolean .FALSE ));
244257 BackendConfig config = new BackendConfig ();
245258 config .setCallee ("trpc.calleeapp.calleeserver.calleeservice.calleemethod" );
246259 config .setNamingUrl ("ip://127.0.0.1:8888" );
@@ -273,9 +286,9 @@ public void test() {
273286 assertEquals (config .getServiceInterface (), GenericClient .class );
274287 assertEquals (config .getRequestTimeout (), 1234 );
275288 assertEquals (config .getVersion (), "v888" );
276- assertEquals (config .getCalleeApp (), "" );
277- assertEquals (config .getCalleeServer (), "" );
278- assertEquals (config .getCalleeService (), "" );
289+ assertEquals (config .getCalleeApp (), "calleeapp " );
290+ assertEquals (config .getCalleeServer (), "calleeserver " );
291+ assertEquals (config .getCalleeService (), "calleeservice " );
279292 ServiceId serviceId = config .toNamingServiceId ();
280293 assertEquals (serviceId .getGroup (), "group" );
281294 assertEquals (serviceId .getServiceName (), "127.0.0.1:8888" );
@@ -294,8 +307,7 @@ public void testGetProxy() {
294307 config .setServiceInterface (GenericClient .class );
295308 config .setName ("client" );
296309 config .setNamingUrl ("ip://127.0.0.1:12345" );
297- ConfigManager .getInstance ().getClientConfig ().getBackendConfigMap ()
298- .put ("client" , config );
310+ ConfigManager .getInstance ().getClientConfig ().getBackendConfigMap ().put ("client" , config );
299311 ConsumerConfig <GenericClient > consumerConfig = new ConsumerConfig <>();
300312 consumerConfig .setBackendConfig (config );
301313 consumerConfig .setServiceInterface (GenericClient .class );
@@ -317,8 +329,7 @@ public void testGetProxy() {
317329
318330 @ Test
319331 public void testNotDefault () {
320- ExtensionLoader
321- .registerPlugin (new PluginConfig ("attalog" , Filter .class , RemoteLoggerTest .class ));
332+ ExtensionLoader .registerPlugin (new PluginConfig ("attalog" , Filter .class , RemoteLoggerTest .class ));
322333 ExtensionLoader .registerPlugin (ThreadWorkerPool .newThreadWorkerPoolConfig ("thread" , 10 , Boolean .FALSE ));
323334 BackendConfig config = new BackendConfig ();
324335 config .setName ("trpc.calleeapp.calleeserver.calleeservice.calleemethod" );
@@ -351,6 +362,54 @@ public void testNotDefault() {
351362 }
352363 }
353364
365+ @ Test
366+ public void testSetDestinationSet () {
367+ BackendConfig config = new BackendConfig ();
368+ config .setNamingUrl ("polaris://127.0.0.1:8888" );
369+ config .setDestinationSet ("testSet" );
370+ Object metaData = config .getNamingMap ().get (Constants .METADATA );
371+ assertNotNull (metaData );
372+ assertTrue (metaData instanceof Map );
373+ assertEquals ("testSet" , ((Map <?, ?>) metaData ).get (Constants .POLARIS_PLUGIN_SET_NAME_KEY ));
374+ }
375+
376+ @ Test
377+ public void testNewConsumerConfig () {
378+ BackendConfig config = new BackendConfig ();
379+ ConsumerConfig <GenericClient > consumerConfig = config .newConsumerConfig (GenericClient .class );
380+ assertNotNull (consumerConfig );
381+ assertEquals (GenericClient .class , consumerConfig .getServiceInterface ());
382+ }
383+
384+ @ Test
385+ public void testOverrideConfigDefault () {
386+ BackendConfig config = new BackendConfig ();
387+ ClientConfig clientConfig = new ClientConfig ();
388+ clientConfig .setRequestTimeout (5000 );
389+ config .overrideConfigDefault (clientConfig );
390+ assertEquals (5000 , config .getRequestTimeout ());
391+ }
392+
393+ @ Test
394+ public void testMergeConfig () {
395+ BackendConfig config = new BackendConfig ();
396+ ClientConfig clientConfig = new ClientConfig ();
397+ clientConfig .setFilters (Lists .newArrayList ("testFilter" ));
398+ config .mergeConfig (clientConfig );
399+ assertEquals (1 , config .getFilters ().size ());
400+ assertEquals ("testFilter" , config .getFilters ().get (0 ));
401+ }
402+
403+ @ Test
404+ public void testGenerateProtocolConfig () {
405+ BackendConfig config = new BackendConfig ();
406+ ProtocolConfig protocolConfig = config .generateProtocolConfig ("127.0.0.1" , 8080 , "tcp" );
407+ assertNotNull (protocolConfig );
408+ assertEquals ("127.0.0.1" , protocolConfig .getIp ());
409+ assertEquals (8080 , protocolConfig .getPort ());
410+ assertEquals ("tcp" , protocolConfig .getNetwork ());
411+ }
412+
354413 public static final class RemoteLoggerTest extends RemoteLoggerFilter {
355414
356415 @ Override
0 commit comments