jakartaee / faces

Jakarta Faces
Other
109 stars 55 forks source link

Correct applicationSubscribeToEventNPETest #1897

Closed pnicolucci closed 9 months ago

pnicolucci commented 9 months ago

fixes #1711

The following tests are being updated. Below are the tests without modification for discussion:

    out.append("Running==> application.subscribeToEvent(Class, "
        + "SystemEventListener, null)" + JSFTestUtil.NL);
    JSFTestUtil.checkForNPE(application, "subscribeToEvent",
        new Class<?>[] { Class.class, Class.class, SystemEventListener.class },
        new Object[] { TCKSystemEvent.class, srcClass, null }, out);

    out.append("Running==> application.subscribeToEvent(Class, null, null)"
        + JSFTestUtil.NL);
    JSFTestUtil.checkForNPE(application, "subscribeToEvent",
        new Class<?>[] { Class.class, Class.class, SystemEventListener.class },
        new Object[] { TCKSystemEvent.class, srcClass, null }, out);

Details on the first test:

Details on the second test:

API for reference: https://jakarta.ee/specifications/faces/4.0/apidocs/jakarta/faces/application/application#subscribeToEvent(java.lang.Class,java.lang.Class,jakarta.faces.event.SystemEventListener)

public void subscribeToEvent(Class<? extends SystemEvent> systemEventClass, Class<?> sourceClass, SystemEventListener listener)

Install the listener instance referenced by argument listener into the application as a listener for events of type systemEventClass that originate from objects of type sourceClass.

If argument sourceClass is non-null, sourceClass and systemEventClass must be used to store the argument listener in the application in such a way that the listener can be quickly looked up by the implementation of publishEvent(jakarta.faces.context.FacesContext, java.lang.Class<? extends jakarta.faces.event.SystemEvent>, java.lang.Object) given systemEventClass and an instance of the Class referenced by sourceClass. If argument sourceClass is null, the listener must be discoverable by the implementation of publishEvent(jakarta.faces.context.FacesContext, java.lang.Class<? extends jakarta.faces.event.SystemEvent>, java.lang.Object) given only systemEventClass.

It is valid to call this method during the processing of an event which was subscribed to by a previous call to this method.

Parameters: systemEventClass - the Class of event for which listener must be fired. sourceClass - the Class of the instance which causes events of type systemEventClass to be fired. May be null. listener - the implementation of SystemEventListener whose SystemEventListener.processEvent(jakarta.faces.event.SystemEvent) method must be called when events of type systemEventClass are fired. Throws: NullPointerException - if any combination of systemEventClass, or listener are null. Since: 2.0

pnicolucci commented 9 months ago

I just updated the copyright date range of the file I updated.

I'll merge this later today if no objections @arjantijms. Thanks!

pnicolucci commented 9 months ago

Thanks @BalusC for the review!