From 5cf339c18596005130f7d8f1a482074a4dd3fb20 Mon Sep 17 00:00:00 2001 From: Scott M Stark Date: Thu, 12 May 2022 21:47:21 -0500 Subject: [PATCH] Update ejblitejsf vehicle, #970 Signed-off-by: Scott M Stark --- install/jakartaee/other/vehicle.properties | 9 +- .../lite/basic/common/JsfClientBase.java | 123 ++++++++++++++++++ .../ejb30/lite/basic/singleton/JsfClient.java | 89 +++++++++++++ .../ejb30/lite/basic/stateful/JsfClient.java | 88 +++++++++++++ .../ejb30/lite/basic/stateless/JsfClient.java | 90 +++++++++++++ 5 files changed, 398 insertions(+), 1 deletion(-) create mode 100644 src/com/sun/ts/tests/ejb30/lite/basic/common/JsfClientBase.java create mode 100644 src/com/sun/ts/tests/ejb30/lite/basic/singleton/JsfClient.java create mode 100644 src/com/sun/ts/tests/ejb30/lite/basic/stateful/JsfClient.java create mode 100644 src/com/sun/ts/tests/ejb30/lite/basic/stateless/JsfClient.java diff --git a/install/jakartaee/other/vehicle.properties b/install/jakartaee/other/vehicle.properties index 9057698209..dcbb4f6783 100644 --- a/install/jakartaee/other/vehicle.properties +++ b/install/jakartaee/other/vehicle.properties @@ -175,7 +175,14 @@ com/sun/ts/tests/ejb30/lite/tx/cm/stateful/webrw = ejbliteservlet ejbliteservlet com/sun/ts/tests/ejb30/lite/packaging/embed = ejbembed com/sun/ts/tests/ejb30/lite/packaging/war = ejbliteservlet ejbliteservlet2 ejblitejsf ejblitejsp com/sun/ts/tests/ejb30/lite/packaging/war/datasource/global = ejblitejsf -com/sun/ts/tests/ejb30/lite/basic/mock = ejbliteservlet ejbliteservlet2 ejblitejsf ejblitejsp + +com/sun/ts/tests/ejb30/lite/basic/singleton/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp +com/sun/ts/tests/ejb30/lite/basic/singleton/JsfClient.java = ejblitejsf +com/sun/ts/tests/ejb30/lite/basic/stateful/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp +com/sun/ts/tests/ejb30/lite/basic/stateful/JsfClient.java = ejblitejsf +com/sun/ts/tests/ejb30/lite/basic/stateless/Client.java = ejbliteservlet ejbliteservlet2 ejblitejsp +com/sun/ts/tests/ejb30/lite/basic/stateless/JsfClient.java = ejblitejsf + com/sun/ts/tests/ejb30/lite/naming/context/Client.java#lookup = ejbliteservlet ejbliteservlet2 ejblitejsf ejblitejsp com/sun/ts/tests/ejb30/timer = ejbliteservlet diff --git a/src/com/sun/ts/tests/ejb30/lite/basic/common/JsfClientBase.java b/src/com/sun/ts/tests/ejb30/lite/basic/common/JsfClientBase.java new file mode 100644 index 0000000000..637ddb21ee --- /dev/null +++ b/src/com/sun/ts/tests/ejb30/lite/basic/common/JsfClientBase.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ +package com.sun.ts.tests.ejb30.lite.basic.common; + +import com.sun.ts.tests.ejb30.common.helper.Helper; +import com.sun.ts.tests.ejb30.common.lite.EJBLiteJsfClientBase; + +import jakarta.annotation.PostConstruct; +import jakarta.annotation.PreDestroy; +import jakarta.ejb.EJB; + +abstract public class JsfClientBase extends EJBLiteJsfClientBase { + protected static final String appName = null; + + protected BasicBeanBase basicBean; + + // beanName is needed since both OneInterfaceBasicBean and + // TwoInterfacesBasicBean + // implements Basic1IF + @EJB(beanName = "OneInterfaceBasicBean", name = "oneInterfaceBasicBeanBoth") + private Basic1IF oneInterfaceBasicBean; + + @EJB(beanName = "OneInterfaceBasicBean", name = "oneInterfaceBasicBeanBoth") + private Basic1IF oneInterfaceBasicBeanAgain; + + @EJB(beanName = "TwoInterfacesBasicBean") + private Basic1IF twoInterfacesBasicBean1; + + @EJB(name = "twoInterfacesBasicBean2Both", beanName = "TwoInterfacesBasicBean") + private Basic2IF twoInterfacesBasicBean2; + + @EJB(name = "twoInterfacesBasicBean2Both", beanName = "TwoInterfacesBasicBean") + private Basic2IF twoInterfacesBasicBean2Again; + + public void add() { + int a = -2, b = -3; + int expected = a + b; + assertEquals("Verify BasicBean.add ", expected, basicBean.add(a, b)); + assertEquals("Verify OneInterfaceBasicBean.add ", expected, + oneInterfaceBasicBean.add(a, b)); + assertEquals("Verify oneInterfaceBasicBeanAgain.add ", expected, + oneInterfaceBasicBeanAgain.add(a, b)); + assertEquals("Verify TwoInterfaceBasicBean(1).add ", expected, + twoInterfacesBasicBean1.add(a, b)); + assertEquals("Verify TwoInterfaceBasicBean(2).add ", expected, + twoInterfacesBasicBean2.add(a, b)); + assertEquals("Verify twoInterfacesBasicBean2Again(2).add ", expected, + twoInterfacesBasicBean2Again.add(a, b)); + } + + public void globalJNDI() { + BasicBeanHelper.globalJNDI(appName, getModuleName(), + basicBean.getBusinessInterface(), getReasonBuffer(), + (jakarta.ejb.EJBContext) null, getContext()); + } + + public void globalJNDI2() { + appendReason(basicBean.globalJNDI(appName, getModuleName())); + } + + public void appJNDI() { + if (getContainer() != null) { + return; + } + BasicBeanHelper.appJNDI(getModuleName(), basicBean.getBusinessInterface(), + getReasonBuffer()); + } + + public void appJNDI2() { + appendReason(basicBean.appJNDI(getModuleName())); + } + + public void moduleJNDI() { + if (getContainer() != null) { + return; + } + BasicBeanHelper.moduleJNDI(basicBean.getBusinessInterface(), + getReasonBuffer()); + } + + public void moduleJNDI2() { + appendReason(basicBean.moduleJNDI()); + } + + @SuppressWarnings("unused") + @PostConstruct + private void postConstruct() { + Helper.getLogger().info("In postConstruct of " + this); + assertNotEquals("check oneInterfaceBasicBean not null", null, + oneInterfaceBasicBean); + assertNotEquals("check oneInterfaceBasicBeanAgain not null", null, + oneInterfaceBasicBeanAgain); + assertNotEquals("check twoInterfacesBasicBean1 not null", null, + twoInterfacesBasicBean1); + assertNotEquals("check twoInterfacesBasicBean2 not null", null, + twoInterfacesBasicBean2); + assertNotEquals("check twoInterfacesBasicBean2Again not null", null, + twoInterfacesBasicBean2Again); + } + + @SuppressWarnings("unused") + @PreDestroy + private void preDestroy() { + Helper.getLogger().info("In preDestroy of " + this); + } +} diff --git a/src/com/sun/ts/tests/ejb30/lite/basic/singleton/JsfClient.java b/src/com/sun/ts/tests/ejb30/lite/basic/singleton/JsfClient.java new file mode 100644 index 0000000000..c1fa96a560 --- /dev/null +++ b/src/com/sun/ts/tests/ejb30/lite/basic/singleton/JsfClient.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ +package com.sun.ts.tests.ejb30.lite.basic.singleton; + +import java.io.Serializable; + +import com.sun.ts.tests.ejb30.lite.basic.common.JsfClientBase; + +import jakarta.ejb.EJB; + +@jakarta.inject.Named("client") +@jakarta.enterprise.context.RequestScoped +public class JsfClient extends JsfClientBase implements Serializable { + + private static final long serialVersionUID = 1L; + + @SuppressWarnings("unused") + @EJB(beanInterface = BasicBean.class, beanName = "BasicBean") + private void setBasicBean(BasicBean b) { + basicBean = b; + } + + /* + * @testName: add + * + * @test_Strategy: a simple no-interface local singleton bean. The bean field + * (basicBean, of type BasicBeanBase) is declared in superclass (ClientBase), + * and the setter injection is in subclass (Client). Besides, one-interface + * local singleton bean, accessed with Basic1IF; two-interface local singleton + * bean, accessed with Basic1IF; two-interface local singleton bean, accessed + * with Basic2IF. + */ + /* + * @testName: globalJNDI + * + * @test_Strategy: lookup portable global jndi names of various beans from web + * components or standalone client. + */ + /* + * @testName: globalJNDI2 + * + * @test_Strategy: lookup portable global jndi names of various beans from ejb + * bean class + */ + /* + * @testName: appJNDI + * + * @test_Strategy: lookup portable app jndi names of various beans from web + * component client (not standalone client). + */ + + /* + * @testName: appJNDI2 + * + * @test_Strategy: lookup portable app jndi names of various beans from ejb + * bean class + */ + + /* + * @testName: moduleJNDI + * + * @test_Strategy: lookup portable module jndi names of various beans from web + * component client (not standalone client). + */ + + /* + * @testName: moduleJNDI2 + * + * @test_Strategy: lookup portable module jndi names of various beans from ejb + * bean class + */ +} diff --git a/src/com/sun/ts/tests/ejb30/lite/basic/stateful/JsfClient.java b/src/com/sun/ts/tests/ejb30/lite/basic/stateful/JsfClient.java new file mode 100644 index 0000000000..5fe121eb56 --- /dev/null +++ b/src/com/sun/ts/tests/ejb30/lite/basic/stateful/JsfClient.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ +package com.sun.ts.tests.ejb30.lite.basic.stateful; + +import java.io.Serializable; + +import com.sun.ts.tests.ejb30.lite.basic.common.JsfClientBase; +import jakarta.ejb.EJB; + +@jakarta.inject.Named("client") +@jakarta.enterprise.context.RequestScoped +public class JsfClient extends JsfClientBase implements Serializable { + + private static final long serialVersionUID = 1L; + + @SuppressWarnings("unused") + @EJB(beanInterface = BasicBean.class, beanName = "BasicBean") + private void setBasicBean(BasicBean b) { + basicBean = b; + } + + /* + * @testName: add + * + * @test_Strategy: a simple no-interface local singleton bean. The bean field + * (basicBean, of type BasicBeanBase) is declared in superclass (ClientBase), + * and the setter injection is in subclass (Client). Besides, one-interface + * local singleton bean, accessed with Basic1IF; two-interface local singleton + * bean, accessed with Basic1IF; two-interface local singleton bean, accessed + * with Basic2IF. + */ + /* + * @testName: globalJNDI + * + * @test_Strategy: lookup portable global jndi names of various beans from web + * components or standalone client. + */ + /* + * @testName: globalJNDI2 + * + * @test_Strategy: lookup portable global jndi names of various beans from ejb + * bean class + */ + /* + * @testName: appJNDI + * + * @test_Strategy: lookup portable app jndi names of various beans from web + * component client (not standalone client). + */ + + /* + * @testName: appJNDI2 + * + * @test_Strategy: lookup portable app jndi names of various beans from ejb + * bean class + */ + + /* + * @testName: moduleJNDI + * + * @test_Strategy: lookup portable module jndi names of various beans from web + * component client (not standalone client). + */ + + /* + * @testName: moduleJNDI2 + * + * @test_Strategy: lookup portable module jndi names of various beans from ejb + * bean class + */ +} diff --git a/src/com/sun/ts/tests/ejb30/lite/basic/stateless/JsfClient.java b/src/com/sun/ts/tests/ejb30/lite/basic/stateless/JsfClient.java new file mode 100644 index 0000000000..1c118ff862 --- /dev/null +++ b/src/com/sun/ts/tests/ejb30/lite/basic/stateless/JsfClient.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ +package com.sun.ts.tests.ejb30.lite.basic.stateless; + +import java.io.Serializable; + +import com.sun.ts.tests.ejb30.lite.basic.common.JsfClientBase; +import jakarta.ejb.EJB; + +@jakarta.inject.Named("client") +@jakarta.enterprise.context.RequestScoped +public class JsfClient extends JsfClientBase implements Serializable { + + private static final long serialVersionUID = 1L; + + @SuppressWarnings("unused") + @EJB(beanInterface = BasicBean.class, beanName = "BasicBean") + private void setBasicBean(BasicBean b) { + basicBean = b; + } + + /* + * @testName: add + * + * @test_Strategy: a simple no-interface local singleton bean. The bean field + * (basicBean, of type BasicBeanBase) is declared in superclass (ClientBase), + * and the setter injection is in subclass (Client). Besides, one-interface + * local singleton bean, accessed with Basic1IF; two-interface local singleton + * bean, accessed with Basic1IF; two-interface local singleton bean, accessed + * with Basic2IF. + */ + /* + * @testName: globalJNDI + * + * @test_Strategy: lookup portable global jndi names of various beans from web + * components or standalone client. + */ + /* + * @testName: globalJNDI2 + * + * @test_Strategy: lookup portable global jndi names of various beans from ejb + * bean class + */ + + /* + * @testName: appJNDI + * + * @test_Strategy: lookup portable app jndi names of various beans from web + * component client (not standalone client). + */ + + /* + * @testName: appJNDI2 + * + * @test_Strategy: lookup portable app jndi names of various beans from ejb + * bean class + */ + + /* + * @testName: moduleJNDI + * + * @test_Strategy: lookup portable module jndi names of various beans from web + * component client (not standalone client). + */ + + /* + * @testName: moduleJNDI2 + * + * @test_Strategy: lookup portable module jndi names of various beans from ejb + * bean class + */ + +}