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
@@ -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.eager.bean;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import jakarta.enterprise.util.AnnotationLiteral;
import jakarta.inject.Qualifier;

@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER })
public @interface AQualifier {
final class Literal extends AnnotationLiteral<AQualifier> implements AQualifier {
static final AQualifier INSTANCE = new Literal();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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.eager.bean;

import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.Eager;

@ApplicationScoped
@Eager
public class EagerBean {
public static boolean constructed = false;

@PostConstruct
public void setup() {
constructed = true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* 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.eager.bean;

import static org.jboss.cdi.tck.cdi.Sections.BEAN;
import static org.jboss.cdi.tck.cdi.Sections.EAGER_INITIALIZATION;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;

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 EagerBeanTest extends AbstractTest {
@Deployment
public static WebArchive createTestArchive() {
return new WebArchiveBuilder()
.withTestClassPackage(EagerBeanTest.class)
.build();
}

@Test
@SpecAssertion(section = EAGER_INITIALIZATION, id = "aa")
@SpecAssertion(section = EAGER_INITIALIZATION, id = "b")
@SpecAssertion(section = EAGER_INITIALIZATION, id = "c")
public void testUnqualified() {
assertTrue(EagerBean.constructed);

assertFalse(LazyBean.constructed);
Comment thread
Azquelt marked this conversation as resolved.
LazyBean reference = getContextualReference(LazyBean.class);
assertNotNull(reference);
assertFalse(LazyBean.constructed);
assertNotNull(reference.toString());
assertTrue(LazyBean.constructed);
}

@Test
@SpecAssertion(section = EAGER_INITIALIZATION, id = "aa")
@SpecAssertion(section = EAGER_INITIALIZATION, id = "b")
@SpecAssertion(section = EAGER_INITIALIZATION, id = "c")
public void testQualified() {
assertTrue(QualifiedEagerBean.constructed);

assertFalse(QualifiedLazyBean.constructed);
QualifiedLazyBean reference = getContextualReference(QualifiedLazyBean.class, AQualifier.Literal.INSTANCE);
assertNotNull(reference);
assertFalse(QualifiedLazyBean.constructed);
assertNotNull(reference.toString());
assertTrue(QualifiedLazyBean.constructed);
}

@Test
@SpecAssertion(section = BEAN, id = "bf")
public void testMetadata() {
assertTrue(getUniqueBean(EagerBean.class).isEager());
assertTrue(getUniqueBean(QualifiedEagerBean.class, AQualifier.Literal.INSTANCE).isEager());

assertFalse(getUniqueBean(LazyBean.class).isEager());
assertFalse(getUniqueBean(QualifiedLazyBean.class, AQualifier.Literal.INSTANCE).isEager());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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.eager.bean;

import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.ApplicationScoped;

@ApplicationScoped
public class LazyBean {
public static boolean constructed = false;

@PostConstruct
public void setup() {
constructed = true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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.eager.bean;

import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.Eager;

@ApplicationScoped
@Eager
@AQualifier
public class QualifiedEagerBean {
public static boolean constructed = false;

@PostConstruct
public void setup() {
constructed = true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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.eager.bean;

import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.ApplicationScoped;

@ApplicationScoped
@AQualifier
public class QualifiedLazyBean {
public static boolean constructed = false;

@PostConstruct
public void setup() {
constructed = true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* 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.eager.broken.dependent;

import jakarta.enterprise.context.Dependent;
import jakarta.enterprise.context.Eager;

@Dependent
@Eager
public class DependentEagerBean {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.eager.broken.dependent;

import static org.jboss.cdi.tck.cdi.Sections.EAGER_INITIALIZATION;

import jakarta.enterprise.inject.spi.DefinitionException;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
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 DependentEagerBeanTest extends AbstractTest {
@Deployment
@ShouldThrowException(DefinitionException.class)
public static WebArchive createTestArchive() {
return new WebArchiveBuilder()
.withTestClassPackage(DependentEagerBeanTest.class)
.build();
}

@Test
@SpecAssertion(section = EAGER_INITIALIZATION, id = "db")
public void trigger() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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.eager.broken.requestScoped;

public class EagerClass {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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.eager.broken.requestScoped;

import jakarta.enterprise.context.Dependent;
import jakarta.enterprise.context.Eager;
import jakarta.enterprise.context.RequestScoped;
import jakarta.enterprise.inject.Produces;

@Dependent
public class ProducerMethod {
@RequestScoped
@Eager
@Produces
public EagerClass produceEager() {
return new EagerClass();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.eager.broken.requestScoped;

import static org.jboss.cdi.tck.cdi.Sections.EAGER_INITIALIZATION;

import jakarta.enterprise.inject.spi.DefinitionException;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
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 RequestScopedEagerBeanTest extends AbstractTest {
@Deployment
@ShouldThrowException(DefinitionException.class)
public static WebArchive createTestArchive() {
return new WebArchiveBuilder()
.withTestClassPackage(RequestScopedEagerBeanTest.class)
.build();
}

@Test
@SpecAssertion(section = EAGER_INITIALIZATION, id = "da")
public void trigger() {
}
}
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.eager.producer.field;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import jakarta.enterprise.util.AnnotationLiteral;
import jakarta.inject.Qualifier;

@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER })
public @interface AQualifier {
final class Literal extends AnnotationLiteral<AQualifier> implements AQualifier {
static final AQualifier INSTANCE = new Literal();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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.eager.producer.field;

public class EagerClass {
public static boolean constructed = false;

public EagerClass() {
}

// the parameter only exists to distinguish a non-default constructor
// that is used to create the contextual instance
// (the client proxy uses the default constructor)
public EagerClass(int unused) {
constructed = true;
}
}
Loading