Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static WebArchive createTestArchive() {
}

@Test
@SpecAssertion(section = OBSERVER_METHOD_EVENT_PARAMETER, id = "e")
@SpecAssertion(section = OBSERVER_METHOD_EVENT_PARAMETER, id = "f")
public void testModifiedEventParameterIsPropagated() {
bm.getEvent().select(Counter.class).fire(new Counter());
Assert.assertEquals(CounterObserver02.count, 3);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* Apache Software License 2.0 which is available at:
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.jboss.cdi.tck.tests.event.observer.param.primitive;

import static org.jboss.cdi.tck.cdi.Sections.OBSERVERS_PRIMITIVE_TYPES;
import static org.jboss.cdi.tck.cdi.Sections.OBSERVER_METHOD_EVENT_PARAMETER;
import static org.testng.Assert.assertEquals;

import jakarta.inject.Inject;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.cdi.tck.AbstractTest;
import org.jboss.cdi.tck.shrinkwrap.WebArchiveBuilder;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecVersion;
import org.testng.annotations.Test;

@SpecVersion(spec = "cdi", version = "5.0")
public class PrimitiveEventTypeTest extends AbstractTest {
@Deployment
public static WebArchive createTestArchive() {
return new WebArchiveBuilder().withTestClassPackage(PrimitiveEventTypeTest.class).build();
}

@Inject
SimpleProducer producer;

@Test
@SpecAssertion(section = OBSERVERS_PRIMITIVE_TYPES, id = "a")
@SpecAssertion(section = OBSERVER_METHOD_EVENT_PARAMETER, id = "e")
public void test() {
assertEquals(SimpleConsumer.intCounter, 0);
assertEquals(SimpleConsumer.longCounter, 0);

producer.produceInt();

assertEquals(SimpleConsumer.intCounter, 1);
assertEquals(SimpleConsumer.longCounter, 0);

producer.produceInt();

assertEquals(SimpleConsumer.intCounter, 2);
assertEquals(SimpleConsumer.longCounter, 0);

producer.produceLong();

assertEquals(SimpleConsumer.intCounter, 2);
assertEquals(SimpleConsumer.longCounter, 1);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* Apache Software License 2.0 which is available at:
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.jboss.cdi.tck.tests.event.observer.param.primitive;

import jakarta.enterprise.context.Dependent;
import jakarta.enterprise.event.Observes;

@Dependent
public class SimpleConsumer {
static int intCounter = 0;
static int longCounter = 0;

public void observeInt(@Observes int value) {
intCounter++;
}

public void observeLong(@Observes long value) {
longCounter++;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* Apache Software License 2.0 which is available at:
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.jboss.cdi.tck.tests.event.observer.param.primitive;

import jakarta.enterprise.context.Dependent;
import jakarta.enterprise.event.Event;
import jakarta.inject.Inject;

@Dependent
public class SimpleProducer {
@Inject
Event<Integer> integerEvent;

@Inject
Event<Long> longEvent;

public void produceInt() {
integerEvent.fire(42);
}

public void produceLong() {
longEvent.fire(13L);
}
}
13 changes: 13 additions & 0 deletions impl/src/main/resources/tck-audit-cdi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5754,6 +5754,15 @@

</section>

<section id="observers_primitive_types" title="Primitive types" level="3">
<assertion id="a">
<text>
For the purpose of observer resolution, primitive types and their corresponding wrapper types in the package |java.lang| are considered identical and assignable.
The container performs unboxing when it invokes an observer method that declares a primitive event parameter.
</text>
</assertion>
</section>

<section id="event_qualifier_types_with_members" title="Event qualifier types with members" level="3">
<assertion id="a">
<text>The qualifier type for an |Event| qualifier may have annotation members.</text>
Expand Down Expand Up @@ -5835,6 +5844,10 @@
</group>

<assertion id="e">
<text>The event parameter type may be a primitive type.</text>
</assertion>

<assertion id="f">
<text>Modifications made to the event parameter in an observer method are propagated to following observers.</text>
</assertion>

Expand Down