-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate ejblitejsf vehicle tests, #981
Signed-off-by: Scott M Stark <starksm64@gmail.com>
- Loading branch information
Showing
4 changed files
with
243 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/com/sun/ts/tests/ejb30/lite/lookup/annotated/JsfClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* 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.lookup.annotated; | ||
|
||
import java.io.Serializable; | ||
|
||
@jakarta.inject.Named("client") | ||
@jakarta.enterprise.context.RequestScoped | ||
public class JsfClient | ||
extends com.sun.ts.tests.ejb30.lite.lookup.common.JsfClientBase implements Serializable { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
/* | ||
* @testName: ejbPostConstructRecords | ||
* | ||
* @test_Strategy: verify all ejbs are injected properly by the time | ||
* post-construct method is invoked. | ||
*/ | ||
|
||
/* | ||
* @testName: ejb2PostConstructRecords | ||
* | ||
* @test_Strategy: verify all ejbs are injected properly by the time | ||
* post-construct method is invoked. | ||
*/ | ||
|
||
/* | ||
* @testName: clientPostConstructRecords | ||
* | ||
* @test_Strategy: verify all ejbs injected into web client. In embeddable | ||
* usage, this test is noop. | ||
*/ | ||
|
||
} |
134 changes: 134 additions & 0 deletions
134
src/com/sun/ts/tests/ejb30/lite/lookup/common/JsfClientBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/* | ||
* 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.lookup.common; | ||
|
||
import com.sun.ts.tests.ejb30.common.helper.Helper; | ||
import com.sun.ts.tests.ejb30.common.helper.ServiceLocator; | ||
import com.sun.ts.tests.ejb30.common.lite.EJBLiteJsfClientBase; | ||
import jakarta.ejb.EJB; | ||
|
||
import static com.sun.ts.tests.ejb30.lite.lookup.common.LookupIF.LOOKUP2_BEAN; | ||
import static com.sun.ts.tests.ejb30.lite.lookup.common.LookupIF.LOOKUP_BEAN; | ||
|
||
abstract public class JsfClientBase extends EJBLiteJsfClientBase { | ||
private StringBuilder postConstructRecords = new StringBuilder(); | ||
|
||
@EJB(name = "ejb/ClientBase/lookupBean", beanName = "LookupBean") | ||
private LookupIF lookupBean; | ||
|
||
@EJB(name = "ejb/ClientBase/lookup2Bean", beanName = "Lookup2Bean") | ||
private LookupIF lookup2Bean; | ||
|
||
// It's an error to specify both lookup and beanName. To provide beanName | ||
// value | ||
// to ejbembed, beanName value is embedded inside description attribute. It is | ||
// processed in com.sun.ts.tests.common.vehicle.ejbembed.InjectionResolver, | ||
// when | ||
// the tests run in ejbembed vehicle. | ||
|
||
@EJB(lookup = "java:comp/env/ejb/ClientBase/lookupBean", description = "beanName=LookupBean") | ||
private LookupIF lookupBeanAgain; | ||
|
||
@EJB(lookup = "java:comp/env/ejb/ClientBase/lookup2Bean", description = "beanName=Lookup2Bean") | ||
private LookupIF lookup2BeanAgain; | ||
|
||
@EJB(lookup = "java:module/LookupBean", description = "beanName=LookupBean") | ||
private LookupIF lookupBeanModule; | ||
|
||
@EJB(lookup = "java:module/Lookup2Bean", description = "beanName=Lookup2Bean") | ||
private LookupIF lookup2BeanModule; | ||
|
||
@EJB(lookup = "java:module/LookupBean", description = "beanName=LookupBean") | ||
private LookupIF lookupBeanApp; | ||
|
||
@EJB(lookup = "java:module/Lookup2Bean", description = "beanName=Lookup2Bean") | ||
private LookupIF lookup2BeanApp; | ||
|
||
// setModuleName is called in vehicle class as part of request processing, | ||
// after @PostConstruct method. So change the following method to be called | ||
// at request processing time. | ||
private void nonPostConstruct() { | ||
if (getContainer() != null) { | ||
return; | ||
} | ||
Helper.assertEquals("Verify lookupBean injection", LOOKUP_BEAN, | ||
lookupBean.getName(), postConstructRecords); | ||
Helper.assertEquals("Verify lookup2Bean injection", LOOKUP2_BEAN, | ||
lookup2Bean.getName(), postConstructRecords); | ||
|
||
Helper.assertEquals("Verify lookupBeanAgain injection", LOOKUP_BEAN, | ||
lookupBeanAgain.getName(), postConstructRecords); | ||
Helper.assertEquals("Verify lookup2BeanAgain injection", LOOKUP2_BEAN, | ||
lookup2BeanAgain.getName(), postConstructRecords); | ||
|
||
Helper.assertEquals("Verify lookupBeanModule injection", LOOKUP_BEAN, | ||
lookupBeanModule.getName(), postConstructRecords); | ||
Helper.assertEquals("Verify lookup2BeanModule injection", LOOKUP2_BEAN, | ||
lookup2BeanModule.getName(), postConstructRecords); | ||
|
||
Helper.assertEquals("Verify lookupBeanApp injection", LOOKUP_BEAN, | ||
lookupBeanApp.getName(), postConstructRecords); | ||
Helper.assertEquals("Verify lookup2BeanApp injection", LOOKUP2_BEAN, | ||
lookup2BeanApp.getName(), postConstructRecords); | ||
|
||
// Just verify the lookup of ModuleName and AppName, not injections | ||
String lookup = "java:module/ModuleName"; | ||
String expected = getModuleName(); | ||
String actual = (String) ServiceLocator.lookupNoTry(lookup); | ||
Helper.assertEquals("Check " + lookup, expected, actual, | ||
postConstructRecords); | ||
|
||
lookup = "java:app/AppName"; | ||
actual = (String) ServiceLocator.lookupNoTry(lookup); | ||
Helper.assertEquals("Check " + lookup, expected, actual); | ||
} | ||
|
||
/* | ||
* testName: ejbPostConstructRecords | ||
* | ||
* @test_Strategy: verify all ejbs are injected properly by the time | ||
* post-construct method is invoked. | ||
*/ | ||
public void ejbPostConstructRecords() { | ||
appendReason(lookupBean.getPostConstructRecords()); | ||
} | ||
|
||
/* | ||
* testName: ejb2PostConstructRecords | ||
* | ||
* @test_Strategy: verify all ejbs are injected properly by the time | ||
* post-construct method is invoked. | ||
*/ | ||
public void ejb2PostConstructRecords() { | ||
appendReason(lookup2Bean.getPostConstructRecords()); | ||
} | ||
|
||
/* | ||
* testName: clientPostConstructRecords | ||
* | ||
* @test_Strategy: verify all ejbs injected into web client. In embeddable | ||
* usage, this test is noop. | ||
*/ | ||
public void clientPostConstructRecords() { | ||
nonPostConstruct(); | ||
appendReason(postConstructRecords); | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
src/com/sun/ts/tests/ejb30/lite/lookup/descriptor/JsfClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* 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.lookup.descriptor; | ||
|
||
import java.io.Serializable; | ||
|
||
@jakarta.inject.Named("client") | ||
@jakarta.enterprise.context.RequestScoped | ||
public class JsfClient | ||
extends com.sun.ts.tests.ejb30.lite.lookup.common.JsfClientBase implements Serializable { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
/* | ||
* @testName: ejbPostConstructRecords | ||
* | ||
* @test_Strategy: verify all ejbs are injected properly by the time | ||
* post-construct method is invoked. | ||
*/ | ||
|
||
/* | ||
* @testName: ejb2PostConstructRecords | ||
* | ||
* @test_Strategy: verify all ejbs are injected properly by the time | ||
* post-construct method is invoked. | ||
*/ | ||
|
||
/* | ||
* @testName: clientPostConstructRecords | ||
* | ||
* @test_Strategy: verify all ejbs injected into web client. In embeddable | ||
* usage, this test is noop. | ||
*/ | ||
|
||
} |