You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "spark shen (JIRA)" <ji...@apache.org> on 2007/07/16 07:47:04 UTC

[jira] Closed: (HARMONY-4344) [classlib][beans] BeanContextServicesSupport.serviceAvailable will add duplicate service class

     [ https://issues.apache.org/jira/browse/HARMONY-4344?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

spark shen closed HARMONY-4344.
-------------------------------


Verified at r556507. Thanks.

>  [classlib][beans] BeanContextServicesSupport.serviceAvailable will add duplicate service class
> -----------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4344
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4344
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: spark shen
>            Assignee: Leo Li
>         Attachments: HY-4344.diff
>
>
> The following test case will fail on Harmony but pass on RI:
>         static int serviceRevoked = 0;
> 	static int serviceAvailable = 0;
> 	private static class MyListener implements BeanContextServicesListener {
> 		public void serviceRevoked(BeanContextServiceRevokedEvent event) {
> 			serviceRevoked++;
> 		}
> 		public void serviceAvailable(BeanContextServiceAvailableEvent event) {
> 			serviceAvailable++;
> 		}
> 	}
> 	private static class MySupport extends BeanContextServicesSupport {
> 		public void serviceRevoked(BeanContextServiceRevokedEvent event) {
> 			serviceRevoked++;
> 		}
> 		
> 		public void serviceAvailable(BeanContextServiceAvailableEvent event) {
> 			serviceAvailable++;
> 		}
> 	}
> 	private static class MyProvider implements BeanContextServiceProvider {
> 		public void releaseService(BeanContextServices s, Object requestor,
> 				Object service) {
> 		}
> 		public Iterator getCurrentServiceSelectors(BeanContextServices s,
> 				Class serviceClass) {
> 			return null;
> 		}
> 		public Object getService(BeanContextServices s, Object requestor,
> 				Class serviceClass, Object serviceSelector) {
> 			return null;
> 		}
> 	}
>     public void test_serviceAvailable_LBeanContextServiceRevokedEvent() {
> 		BeanContextServicesSupport support = new BeanContextServicesSupport();
> 		support.add(new MySupport());
> 		support.addBeanContextServicesListener(new MyListener());
> 		Class c = Object.class;
> 		support.addService(c, new MyProvider());
> 		BeanContextServiceAvailableEvent availableEvent = new BeanContextServiceAvailableEvent(
> 				support, c);
> 	        support.serviceAvailable(availableEvent);
>                 assertEquals(2, serviceAvailable);
>         
> 	}
> Seems that serviceAvailable method does not judge whether the availableEvent.serviceClass has already be registered.
> BeanContextServicesSupport.serviceRevoked method has similar defect. It can be revealed by the following test case:
> public void test_serviceRevoked_LBeanContextServiceRevokedEvent() {
> 		BeanContextServicesSupport support = new BeanContextServicesSupport();
> 		support.add(new MySupport());
> 		support.addBeanContextServicesListener(new MyListener());
> 		Class c = Object.class;
> 		support.addService(c, new MyProvider());
> 		BeanContextServiceRevokedEvent revokeEvent = new BeanContextServiceRevokedEvent(
> 				support, c, false);
> 		support.serviceRevoked(revokeEvent);
>         assertEquals(0, serviceRevoked);
>  }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.