-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WELD-2775 Make sure BM#getEvent() adds @default qualifier correctly
- Loading branch information
Showing
5 changed files
with
162 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
tests-arquillian/src/test/java/org/jboss/weld/tests/event/ObservingBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package org.jboss.weld.tests.event; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.util.Set; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.event.Observes; | ||
import jakarta.enterprise.event.ObservesAsync; | ||
import jakarta.enterprise.inject.Default; | ||
import jakarta.enterprise.inject.spi.EventMetadata; | ||
|
||
@ApplicationScoped | ||
public class ObservingBean { | ||
|
||
private volatile int defaultObjectNotified = 0; | ||
private volatile int defaultObjectAsyncNotified = 0; | ||
private volatile int defaultPayloadNotified = 0; | ||
private volatile int defaultPayloadAsyncNotified = 0; | ||
private volatile Set<Annotation> defaultObjectQualifiers; | ||
private volatile Set<Annotation> defaultObjectAsyncQualifiers; | ||
private volatile Set<Annotation> defaultPayloadQualifiers; | ||
private volatile Set<Annotation> defaultPayloadAsyncQualifiers; | ||
|
||
public void observeDefaultObject(@Observes @Default Object payload, EventMetadata em) { | ||
// object type is very broad, only look for Payload runtime type | ||
if (em.getType().equals(Payload.class)) { | ||
this.defaultObjectNotified++; | ||
this.defaultObjectQualifiers = em.getQualifiers(); | ||
} | ||
} | ||
|
||
public void observeDefaultPayload(@Observes @Default Payload payload, EventMetadata em) { | ||
this.defaultPayloadNotified++; | ||
this.defaultPayloadQualifiers = em.getQualifiers(); | ||
} | ||
|
||
public void observeDefaultObjectAsync(@ObservesAsync @Default Object payload, EventMetadata em) { | ||
// object type is very broad, only look for Payload runtime type | ||
if (em.getType().equals(Payload.class)) { | ||
this.defaultObjectAsyncNotified++; | ||
this.defaultObjectAsyncQualifiers = em.getQualifiers(); | ||
} | ||
} | ||
|
||
public void observeDefaultPayloadAsync(@ObservesAsync @Default Payload payload, EventMetadata em) { | ||
this.defaultPayloadAsyncNotified++; | ||
this.defaultPayloadAsyncQualifiers = em.getQualifiers(); | ||
} | ||
|
||
public int getDefaultObjectNotified() { | ||
return defaultObjectNotified; | ||
} | ||
|
||
public int getDefaultPayloadNotified() { | ||
return defaultPayloadNotified; | ||
} | ||
|
||
public Set<Annotation> getDefaultObjectQualifiers() { | ||
return defaultObjectQualifiers; | ||
} | ||
|
||
public Set<Annotation> getDefaultPayloadQualifiers() { | ||
return defaultPayloadQualifiers; | ||
} | ||
|
||
public int getDefaultObjectAsyncNotified() { | ||
return defaultObjectAsyncNotified; | ||
} | ||
|
||
public int getDefaultPayloadAsyncNotified() { | ||
return defaultPayloadAsyncNotified; | ||
} | ||
|
||
public Set<Annotation> getDefaultObjectAsyncQualifiers() { | ||
return defaultObjectAsyncQualifiers; | ||
} | ||
|
||
public Set<Annotation> getDefaultPayloadAsyncQualifiers() { | ||
return defaultPayloadAsyncQualifiers; | ||
} | ||
|
||
public void reset() { | ||
this.defaultPayloadNotified = 0; | ||
this.defaultPayloadAsyncNotified = 0; | ||
this.defaultObjectNotified = 0; | ||
this.defaultObjectAsyncNotified = 0; | ||
this.defaultObjectQualifiers = null; | ||
this.defaultObjectAsyncQualifiers = null; | ||
this.defaultPayloadQualifiers = null; | ||
this.defaultPayloadAsyncQualifiers = null; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
tests-arquillian/src/test/java/org/jboss/weld/tests/event/Payload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.jboss.weld.tests.event; | ||
|
||
// serves as an event payload | ||
public class Payload { | ||
} |