From c2c04d4e8d8b87d7c67ecfb63979d90910e875b2 Mon Sep 17 00:00:00 2001 From: Matej Novotny Date: Fri, 4 Dec 2020 14:57:34 +0100 Subject: [PATCH 1/2] Upgrade Weld API to 4.0.CR1. --- bom/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bom/pom.xml b/bom/pom.xml index 5d4a3111d7c..f9ef0485046 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -30,7 +30,7 @@ - 4.0.Beta1 + 4.0.CR1 1.6 https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/ https://repository.jboss.org/nexus/content/repositories/snapshots/ diff --git a/pom.xml b/pom.xml index 73c9a0de907..c596bf5a2fd 100644 --- a/pom.xml +++ b/pom.xml @@ -85,7 +85,7 @@ 3.1.4 6.14.3 1.78 - 4.0.Beta1 + 4.0.CR1 1.0.3.Final 3.0.1.Final From c2656d7b24307cd16af64a50f9f64a93d8bf7f28 Mon Sep 17 00:00:00 2001 From: Matej Novotny Date: Fri, 4 Dec 2020 17:12:55 +0100 Subject: [PATCH 2/2] Fix CustomCDIProviderTest in accordance to what new CDI API expects. Exclude incorrect TCK SE test. --- .../provider/custom/CustomCDIProvider.java | 56 ++++++++++++++++++- .../custom/CustomCDIProviderTest.java | 6 +- .../test/provider/CustomCDIProvider.java | 56 ++++++++++++++++++- .../test/provider/CustomCDIProviderTest.java | 6 +- jboss-tck-runner/src/test/tck20/tck-tests.xml | 6 ++ 5 files changed, 124 insertions(+), 6 deletions(-) diff --git a/environments/se/core/src/test/java/org/jboss/weld/environment/se/test/provider/custom/CustomCDIProvider.java b/environments/se/core/src/test/java/org/jboss/weld/environment/se/test/provider/custom/CustomCDIProvider.java index 6441f010c7f..807ef2168cc 100644 --- a/environments/se/core/src/test/java/org/jboss/weld/environment/se/test/provider/custom/CustomCDIProvider.java +++ b/environments/se/core/src/test/java/org/jboss/weld/environment/se/test/provider/custom/CustomCDIProvider.java @@ -17,9 +17,15 @@ package org.jboss.weld.environment.se.test.provider.custom; +import jakarta.enterprise.inject.Instance; import jakarta.enterprise.inject.Vetoed; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.enterprise.inject.spi.CDI; import jakarta.enterprise.inject.spi.CDIProvider; +import jakarta.enterprise.util.TypeLiteral; + +import java.lang.annotation.Annotation; +import java.util.Iterator; /** * @author Martin Kouba @@ -33,11 +39,59 @@ public class CustomCDIProvider implements CDIProvider { @Override public CDI getCDI() { isCalled = true; - return null; + // we cannot return just null, CDI checks that + return new CustomCdi(); } public static void reset() { isCalled = false; } + public class CustomCdi extends CDI { + + @Override + public BeanManager getBeanManager() { + return null; + } + + @Override + public Instance select(Annotation... qualifiers) { + return null; + } + + @Override + public Instance select(Class subtype, Annotation... qualifiers) { + return null; + } + + @Override + public Instance select(TypeLiteral subtype, Annotation... qualifiers) { + return null; + } + + @Override + public boolean isUnsatisfied() { + return false; + } + + @Override + public boolean isAmbiguous() { + return false; + } + + @Override + public void destroy(Object instance) { + + } + + @Override + public Object get() { + return null; + } + + @Override + public Iterator iterator() { + return null; + } + } } diff --git a/environments/se/core/src/test/java/org/jboss/weld/environment/se/test/provider/custom/CustomCDIProviderTest.java b/environments/se/core/src/test/java/org/jboss/weld/environment/se/test/provider/custom/CustomCDIProviderTest.java index 8f29b7e7a1b..d7c89c76a35 100644 --- a/environments/se/core/src/test/java/org/jboss/weld/environment/se/test/provider/custom/CustomCDIProviderTest.java +++ b/environments/se/core/src/test/java/org/jboss/weld/environment/se/test/provider/custom/CustomCDIProviderTest.java @@ -16,7 +16,7 @@ */ package org.jboss.weld.environment.se.test.provider.custom; -import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import jakarta.enterprise.inject.spi.CDI; @@ -34,7 +34,9 @@ public void testCustomCDIProvider() { try { CustomCDIProvider.reset(); CDI.setCDIProvider(new CustomCDIProvider()); - assertNull(CDI.current()); + CDI current = CDI.current(); + assertNotNull(current); + assertTrue(current instanceof CustomCDIProvider.CustomCdi); assertTrue(CustomCDIProvider.isCalled); } finally { // Unset the CDIProvider so that other tests are not affected diff --git a/environments/servlet/tests/base/src/main/java/org/jboss/weld/environment/servlet/test/provider/CustomCDIProvider.java b/environments/servlet/tests/base/src/main/java/org/jboss/weld/environment/servlet/test/provider/CustomCDIProvider.java index 83ef89b54a8..e4cb189fce4 100644 --- a/environments/servlet/tests/base/src/main/java/org/jboss/weld/environment/servlet/test/provider/CustomCDIProvider.java +++ b/environments/servlet/tests/base/src/main/java/org/jboss/weld/environment/servlet/test/provider/CustomCDIProvider.java @@ -17,9 +17,15 @@ package org.jboss.weld.environment.servlet.test.provider; +import jakarta.enterprise.inject.Instance; import jakarta.enterprise.inject.Vetoed; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.enterprise.inject.spi.CDI; import jakarta.enterprise.inject.spi.CDIProvider; +import jakarta.enterprise.util.TypeLiteral; + +import java.lang.annotation.Annotation; +import java.util.Iterator; /** * @author Martin Kouba @@ -33,11 +39,59 @@ public class CustomCDIProvider implements CDIProvider { @Override public CDI getCDI() { isCalled = true; - return null; + return new CustomCdi(); } public static void reset() { isCalled = false; } + public class CustomCdi extends CDI { + + @Override + public BeanManager getBeanManager() { + return null; + } + + @Override + public Instance select(Annotation... qualifiers) { + return null; + } + + @Override + public Instance select(Class subtype, Annotation... qualifiers) { + return null; + } + + @Override + public Instance select(TypeLiteral subtype, Annotation... qualifiers) { + return null; + } + + @Override + public boolean isUnsatisfied() { + return false; + } + + @Override + public boolean isAmbiguous() { + return false; + } + + @Override + public void destroy(Object instance) { + + } + + @Override + public Object get() { + return null; + } + + @Override + public Iterator iterator() { + return null; + } + } + } diff --git a/environments/servlet/tests/base/src/main/java/org/jboss/weld/environment/servlet/test/provider/CustomCDIProviderTest.java b/environments/servlet/tests/base/src/main/java/org/jboss/weld/environment/servlet/test/provider/CustomCDIProviderTest.java index bd900b76158..b7cf98c5705 100644 --- a/environments/servlet/tests/base/src/main/java/org/jboss/weld/environment/servlet/test/provider/CustomCDIProviderTest.java +++ b/environments/servlet/tests/base/src/main/java/org/jboss/weld/environment/servlet/test/provider/CustomCDIProviderTest.java @@ -17,7 +17,7 @@ package org.jboss.weld.environment.servlet.test.provider; import static org.jboss.weld.environment.servlet.test.util.Deployments.baseDeployment; -import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import jakarta.enterprise.inject.spi.CDI; @@ -41,7 +41,9 @@ public void testCustomCDIProvider() { try { CustomCDIProvider.reset(); CDI.setCDIProvider(new CustomCDIProvider()); - assertNull(CDI.current()); + CDI current = CDI.current(); + assertNotNull(current); + assertTrue(current instanceof CustomCDIProvider.CustomCdi); assertTrue(CustomCDIProvider.isCalled); } finally { // Unset the CDIProvider so that other tests are not affected diff --git a/jboss-tck-runner/src/test/tck20/tck-tests.xml b/jboss-tck-runner/src/test/tck20/tck-tests.xml index e37df38e563..e3859014c6e 100644 --- a/jboss-tck-runner/src/test/tck20/tck-tests.xml +++ b/jboss-tck-runner/src/test/tck20/tck-tests.xml @@ -26,6 +26,12 @@ + + + + + +