@@ -128,15 +128,30 @@ public Object aroundHelloService(ProceedingJoinPoint pjp) throws Throwable {
128128 @ DubboReference (version = "2" , url = "dubbo://127.0.0.1:12345?version=2" , tag = "demo_tag" )
129129 private HelloService helloService2 ;
130130
131- // #7 ReferenceBean (Method Injection #3)
131+ // #7 ReferenceBean (Field Injection #5)
132+ // The HelloService is the same as above service(#6 ReferenceBean (Field Injection #4)), helloService3 will be registered as an alias of helloService2
133+ @ DubboReference (version = "2" , url = "dubbo://127.0.0.1:12345?version=2" , tag = "demo_tag" )
134+ private HelloService helloService3 ;
135+
136+ // #8 ReferenceBean (Method Injection #3)
132137 @ DubboReference (version = "3" , url = "dubbo://127.0.0.1:12345?version=2" , tag = "demo_tag" )
133138 public void setHelloService2 (HelloService helloService2 ) {
134139 // The helloService2 beanName is the same as above(#6 ReferenceBean (Field Injection #4)), and this will rename to helloService2#2
135140 renamedHelloService2 = helloService2 ;
136141 }
137142
143+ // #9 ReferenceBean (Method Injection #4)
144+ @ DubboReference (version = "4" , url = "dubbo://127.0.0.1:12345?version=2" )
145+ public void setHelloService3 (DemoService helloService3 ){
146+ // The helloService3 beanName is the same as above(#7 ReferenceBean (Field Injection #5) is an alias),
147+ // The current beanName(helloService3) is not registered in the beanDefinitionMap, but it is already an alias. so this will rename to helloService3#2
148+ this .renamedHelloService3 = helloService3 ;
149+ }
150+
138151 private HelloService renamedHelloService2 ;
139152
153+ private DemoService renamedHelloService3 ;
154+
140155 @ Test
141156 void testAop () throws Exception {
142157
@@ -150,7 +165,7 @@ void testAop() throws Exception {
150165 Assertions .assertNotNull (testBean .getDemoServiceFromParent ());
151166 Assertions .assertNotNull (testBean .getDemoService ());
152167 Assertions .assertNotNull (testBean .myDemoService );
153- Assertions .assertEquals (2 , demoServicesMap .size ());
168+ Assertions .assertEquals (3 , demoServicesMap .size ());
154169
155170 Assertions .assertNotNull (context .getBean ("demoServiceImpl" ));
156171 Assertions .assertNotNull (context .getBean ("myDemoService" ));
@@ -189,12 +204,13 @@ void testGetInjectedFieldReferenceBeanMap() {
189204 Map <InjectionMetadata .InjectedElement , ReferenceBean <?>> referenceBeanMap =
190205 beanPostProcessor .getInjectedFieldReferenceBeanMap ();
191206
192- Assertions .assertEquals (4 , referenceBeanMap .size ());
207+ Assertions .assertEquals (5 , referenceBeanMap .size ());
193208
194209 Map <String , Integer > checkingFieldNames = new HashMap <>();
195210 checkingFieldNames .put ("private org.apache.dubbo.config.spring.api.HelloService org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessorTest$MyConfiguration.helloService" , 0 );
196211 checkingFieldNames .put ("private org.apache.dubbo.config.spring.api.HelloService org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessorTest.helloService" , 0 );
197212 checkingFieldNames .put ("private org.apache.dubbo.config.spring.api.HelloService org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessorTest.helloService2" , 0 );
213+ checkingFieldNames .put ("private org.apache.dubbo.config.spring.api.HelloService org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessorTest.helloService3" , 0 );
198214 checkingFieldNames .put ("private org.apache.dubbo.config.spring.api.DemoService org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessorTest$ParentBean.demoServiceFromParent" , 0 );
199215
200216 for (Map .Entry <InjectionMetadata .InjectedElement , ReferenceBean <?>> entry : referenceBeanMap .entrySet ()) {
@@ -222,12 +238,13 @@ void testGetInjectedMethodReferenceBeanMap() {
222238 Map <InjectionMetadata .InjectedElement , ReferenceBean <?>> referenceBeanMap =
223239 beanPostProcessor .getInjectedMethodReferenceBeanMap ();
224240
225- Assertions .assertEquals (3 , referenceBeanMap .size ());
241+ Assertions .assertEquals (4 , referenceBeanMap .size ());
226242
227243 Map <String , Integer > checkingMethodNames = new HashMap <>();
228244 checkingMethodNames .put ("setDemoServiceFromAncestor" , 0 );
229245 checkingMethodNames .put ("setDemoService" , 0 );
230246 checkingMethodNames .put ("setHelloService2" , 0 );
247+ checkingMethodNames .put ("setHelloService3" , 0 );
231248
232249 for (Map .Entry <InjectionMetadata .InjectedElement , ReferenceBean <?>> entry : referenceBeanMap .entrySet ()) {
233250
@@ -252,7 +269,7 @@ void testReferenceBeansMethodAnnotation() {
252269
253270 Collection <ReferenceBean > referenceBeans = referenceBeanManager .getReferences ();
254271
255- Assertions .assertEquals (4 , referenceBeans .size ());
272+ Assertions .assertEquals (5 , referenceBeans .size ());
256273
257274 for (ReferenceBean referenceBean : referenceBeans ) {
258275 ReferenceConfig referenceConfig = referenceBean .getReferenceConfig ();
@@ -350,4 +367,4 @@ public TestBean testBean() {
350367 }
351368
352369 }
353- }
370+ }
0 commit comments