harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "spark shen (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-4344) [classlib][beans] BeanContextServicesSupport.serviceAvailable will add duplicate service class
Date Thu, 05 Jul 2007 06:17:04 GMT
 [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


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.


Mime
View raw message