diff --git a/dev/io.openliberty.checkpoint_fat_appClientSupport/fat/src/io/openliberty/checkpoint/fat/appclientsupport/AppClientSupportTest.java b/dev/io.openliberty.checkpoint_fat_appClientSupport/fat/src/io/openliberty/checkpoint/fat/appclientsupport/AppClientSupportTest.java index 0ec76624f5ac..14f1edc14424 100755 --- a/dev/io.openliberty.checkpoint_fat_appClientSupport/fat/src/io/openliberty/checkpoint/fat/appclientsupport/AppClientSupportTest.java +++ b/dev/io.openliberty.checkpoint_fat_appClientSupport/fat/src/io/openliberty/checkpoint/fat/appclientsupport/AppClientSupportTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 IBM Corporation and others. + * Copyright (c) 2024, 2025 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -68,6 +68,27 @@ public static void afterClass() throws Exception { */ @Test public void injectGlobal_EJB() throws Exception { + checkInjection(); + } + + /** + * Tests that a remote EJB is injected. + */ + @Test + public void inject_EJB() throws Exception { + checkInjection(); + } + + // Assisted by watsonx Code Assistant + /** + * This method tests the injection of CDI. + */ + @Test + public void inject_CDI() throws Exception { + checkInjection(); + } + + private void checkInjection() throws Exception { String methodName = testName.getMethodName(); int idx = -1; if ((idx = methodName.indexOf("_EE")) != -1) { diff --git a/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppClient.jar/src/io/openliberty/checkpoint/fat/appclientsupport/InjectionClientMain.java b/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppClient.jar/src/io/openliberty/checkpoint/fat/appclientsupport/InjectionClientMain.java index 22ac7a00d799..4513d733eff2 100755 --- a/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppClient.jar/src/io/openliberty/checkpoint/fat/appclientsupport/InjectionClientMain.java +++ b/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppClient.jar/src/io/openliberty/checkpoint/fat/appclientsupport/InjectionClientMain.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024 IBM Corporation and others. + * Copyright (c) 2024, 2025 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -14,26 +14,41 @@ package io.openliberty.checkpoint.fat.appclientsupport; import javax.ejb.EJB; +import javax.inject.Inject; -import io.openliberty.checkpoint.fat.appclientsupport.view.SimpleInjectionBeanRemote; +import io.openliberty.checkpoint.fat.appclientsupport.view.SimpleCDIInjection; +import io.openliberty.checkpoint.fat.appclientsupport.view.SimpleEJBInjectionBeanRemote; +import io.openliberty.checkpoint.fat.appclientsupport.view.SimpleGlobalEJBInjectionBeanRemote; public class InjectionClientMain { - private final static String NAME_EJB_GLOBAL = "java:global/InjectionApp/InjectionAppEJB/SimpleInjectionBean!io.openliberty.checkpoint.fat.appclientsupport.view.SimpleInjectionBeanRemote"; + private final static String NAME_EJB_GLOBAL = "java:global/InjectionApp/InjectionAppEJB/SimpleGlobalEJBInjectionBean!io.openliberty.checkpoint.fat.appclientsupport.view.SimpleGlobalEJBInjectionBeanRemote"; @EJB(lookup = NAME_EJB_GLOBAL) - public static SimpleInjectionBeanRemote injectedGlobalEjb; + public static SimpleGlobalEJBInjectionBeanRemote injectedGlobalEjb; + + @EJB + public static SimpleEJBInjectionBeanRemote injectedEjb; + + @Inject + public static SimpleCDIInjection cdiBean; public static void main(String[] args) { System.out.println("main - entry"); - if (checkEJB(injectedGlobalEjb)) + if (checkEJBWithLookup(injectedGlobalEjb)) System.out.println("injectGlobal_EJB-PASSED"); + if (checkEJB(injectedEjb)) + System.out.println("inject_EJB-PASSED"); + + if (checkCDI(cdiBean)) + System.out.println("inject_CDI-PASSED"); + System.out.println("main - exit"); } - private static boolean checkEJB(SimpleInjectionBeanRemote ejb) { + private static boolean checkEJBWithLookup(SimpleGlobalEJBInjectionBeanRemote ejb) { boolean b; try { b = ejb != null && ejb.add(4, 8) == 12; @@ -44,4 +59,26 @@ private static boolean checkEJB(SimpleInjectionBeanRemote ejb) { return b; } + private static boolean checkEJB(SimpleEJBInjectionBeanRemote ejb) { + boolean b; + try { + b = ejb != null && ejb.subtract(12, 4) == 8; + } catch (Exception ex) { + ex.printStackTrace(); + b = false; + } + return b; + } + + private static boolean checkCDI(SimpleCDIInjection cdiBean) { + boolean b; + try { + b = cdiBean != null && cdiBean.multiply(2, 4) == 8; + } catch (Exception ex) { + ex.printStackTrace(); + b = false; + } + return b; + } + } diff --git a/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/resources/META-INF/beans.xml b/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/resources/META-INF/beans.xml new file mode 100644 index 000000000000..80e88c9c987e --- /dev/null +++ b/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/resources/META-INF/beans.xml @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/resources/META-INF/ejb-jar.xml b/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/resources/META-INF/ejb-jar.xml index 18e341b4246b..0b8c399a4b59 100755 --- a/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/resources/META-INF/ejb-jar.xml +++ b/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/resources/META-INF/ejb-jar.xml @@ -18,7 +18,7 @@ InjectionAppEJB - SimpleInjectionBean + SimpleGlobalEJBInjectionBean Simple entry bound in java:global java:global/env/globalEnvEntry @@ -26,5 +26,9 @@ I am global + + + SimpleEJBInjectionBean + \ No newline at end of file diff --git a/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/SimpleCDIInjectionBean.java b/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/SimpleCDIInjectionBean.java new file mode 100644 index 000000000000..dd2954f0f0fc --- /dev/null +++ b/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/SimpleCDIInjectionBean.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2025 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package io.openliberty.checkpoint.fat.appclientsupport; + +import io.openliberty.checkpoint.fat.appclientsupport.view.SimpleCDIInjection; + +public class SimpleCDIInjectionBean implements SimpleCDIInjection { + @Override + public int multiply(int x, int y) { + return x * y; + } +} diff --git a/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/SimpleEJBInjectionBean.java b/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/SimpleEJBInjectionBean.java new file mode 100644 index 000000000000..fa272bef5fc3 --- /dev/null +++ b/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/SimpleEJBInjectionBean.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2025 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package io.openliberty.checkpoint.fat.appclientsupport; + +import javax.ejb.Remote; +import javax.ejb.Singleton; + +import io.openliberty.checkpoint.fat.appclientsupport.view.SimpleEJBInjectionBeanRemote; + +@Singleton +@Remote(SimpleEJBInjectionBeanRemote.class) +public class SimpleEJBInjectionBean implements SimpleEJBInjectionBeanRemote { + + @Override + public int subtract(int x, int y) { + return x - y; + } +} diff --git a/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/SimpleInjectionBean.java b/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/SimpleGlobalEJBInjectionBean.java similarity index 83% rename from dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/SimpleInjectionBean.java rename to dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/SimpleGlobalEJBInjectionBean.java index ac7c33895c5b..4a3f7f7a33dc 100755 --- a/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/SimpleInjectionBean.java +++ b/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/SimpleGlobalEJBInjectionBean.java @@ -16,11 +16,11 @@ import javax.ejb.Remote; import javax.ejb.Singleton; -import io.openliberty.checkpoint.fat.appclientsupport.view.SimpleInjectionBeanRemote; +import io.openliberty.checkpoint.fat.appclientsupport.view.SimpleGlobalEJBInjectionBeanRemote; @Singleton -@Remote(SimpleInjectionBeanRemote.class) -public class SimpleInjectionBean implements SimpleInjectionBeanRemote { +@Remote(SimpleGlobalEJBInjectionBeanRemote.class) +public class SimpleGlobalEJBInjectionBean implements SimpleGlobalEJBInjectionBeanRemote { @Override public int add(int x, int y) { diff --git a/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/view/SimpleCDIInjection.java b/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/view/SimpleCDIInjection.java new file mode 100644 index 000000000000..52949790bf42 --- /dev/null +++ b/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/view/SimpleCDIInjection.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2025 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package io.openliberty.checkpoint.fat.appclientsupport.view; + +public interface SimpleCDIInjection { + + public int multiply(int x, int y); +} diff --git a/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/view/SimpleEJBInjectionBeanRemote.java b/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/view/SimpleEJBInjectionBeanRemote.java new file mode 100644 index 000000000000..81cd9f0e934f --- /dev/null +++ b/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/view/SimpleEJBInjectionBeanRemote.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2025 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package io.openliberty.checkpoint.fat.appclientsupport.view; + +public interface SimpleEJBInjectionBeanRemote { + + public int subtract(int x, int y); +} diff --git a/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/view/SimpleInjectionBeanRemote.java b/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/view/SimpleGlobalEJBInjectionBeanRemote.java similarity index 92% rename from dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/view/SimpleInjectionBeanRemote.java rename to dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/view/SimpleGlobalEJBInjectionBeanRemote.java index a1b28039fd45..fb830c8e3a6c 100755 --- a/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/view/SimpleInjectionBeanRemote.java +++ b/dev/io.openliberty.checkpoint_fat_appClientSupport/test-applications/InjectionAppEJB.jar/src/io/openliberty/checkpoint/fat/appclientsupport/view/SimpleGlobalEJBInjectionBeanRemote.java @@ -13,7 +13,7 @@ package io.openliberty.checkpoint.fat.appclientsupport.view; -public interface SimpleInjectionBeanRemote { +public interface SimpleGlobalEJBInjectionBeanRemote { public int add(int x, int y); }