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, #983
Signed-off-by: Scott M Stark <starksm64@gmail.com>
- Loading branch information
Showing
4 changed files
with
385 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
105 changes: 105 additions & 0 deletions
105
src/com/sun/ts/tests/ejb30/lite/nointerface/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,105 @@ | ||
/* | ||
* 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.nointerface.annotated; | ||
|
||
import java.io.Serializable; | ||
|
||
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(name = "ejb/stateless", beanName = "NoInterfaceStatelessBean") | ||
private void setStateless(NoInterfaceStatelessBean stateless) { | ||
this.stateless = stateless; | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
@EJB(name = "ejb/stateful", beanName = "NoInterfaceStatefulBean") | ||
private void setStateful(NoInterfaceStatefulBean stateful) { | ||
this.stateful = stateful; | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
@EJB(name = "ejb/statefulToBeRemoved", beanName = "NoInterfaceStatefulBean") | ||
private void setStatefulToBeRemoved( | ||
NoInterfaceStatefulBean statefulToBeRemoved) { | ||
this.statefulToBeRemoved = statefulToBeRemoved; | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
@EJB(name = "ejb/singleton", beanName = "NoInterfaceSingletonBean") | ||
private void setSingleton(NoInterfaceSingletonBean singleton) { | ||
this.singleton = singleton; | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
@EJB(beanName = "HasInterfaceSingletonBean") | ||
private void setHasInterfaceSingleton(HasInterface hasInterfaceSingleton) { | ||
this.hasInterfaceSingleton = hasInterfaceSingleton; | ||
} | ||
|
||
/* | ||
* @testName: nonBusinessMethods | ||
* | ||
* @test_Strategy: Invoking non-public methods results in EJBException. | ||
*/ | ||
|
||
/* | ||
* @testName: invokeRemovedStateful | ||
* | ||
* @test_Strategy: Invoking a removed stateful no-interface bean results in | ||
* jakarta.ejb.NoSuchEJBException. | ||
*/ | ||
|
||
/* | ||
* @testName: passAsParam | ||
* | ||
* @test_Strategy: no-interface view bean reference can be passed by param of | ||
* any local business interface or no-interface method. Using varargs... | ||
*/ | ||
|
||
/* | ||
* @testName: passAsReturn | ||
* | ||
* @test_Strategy: no-interface view bean reference can be passed by param of | ||
* any local business interface or no-interface method. Using covariant return | ||
* types. Also tests that injected no-interface beans can be looked up via | ||
* jndi. | ||
*/ | ||
|
||
/* | ||
* @testName: passEnumAsParams | ||
* | ||
* @test_Strategy: pass (NumberEnum, NumberIF) to each bean, which returns the | ||
* sum. | ||
*/ | ||
|
||
/* | ||
* @testName: passEnumAsReturn | ||
* | ||
* @test_Strategy: pass (NumberEnum, NumberIF) to each bean, which returns the | ||
* sum. | ||
*/ | ||
} |
168 changes: 168 additions & 0 deletions
168
src/com/sun/ts/tests/ejb30/lite/nointerface/annotated/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,168 @@ | ||
/* | ||
* 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.nointerface.annotated; | ||
|
||
import com.sun.ts.tests.ejb30.common.lite.EJBLiteJsfClientBase; | ||
import com.sun.ts.tests.ejb30.common.lite.NumberEnum; | ||
import jakarta.ejb.EJBException; | ||
import jakarta.ejb.NoSuchEJBException; | ||
|
||
/** | ||
* no interface view EJBs are used in many other test directories. This | ||
* directory covers uncommon requirements. | ||
*/ | ||
public class JsfClientBase extends EJBLiteJsfClientBase { | ||
protected BeanBase stateless; | ||
|
||
protected BeanBase stateful; | ||
|
||
protected BeanBase statefulToBeRemoved; | ||
|
||
protected BeanBase singleton; | ||
|
||
protected HasInterface hasInterfaceSingleton; | ||
|
||
private String nonBusinessMethods(BeanBase b) throws RuntimeException { | ||
String result = ""; | ||
try { | ||
throw new RuntimeException(b.nonBusinessMethod()); | ||
} catch (EJBException expected) { | ||
result += " Got expected when invoking a protected method on no interface bean:" | ||
+ expected; | ||
} | ||
try { | ||
throw new RuntimeException(b.nonBusinessMethod2()); | ||
} catch (EJBException expected) { | ||
result += " Got expected when invoking a package-default-access method on no interface bean:" | ||
+ expected; | ||
} | ||
return result; | ||
} | ||
|
||
/* | ||
* testName: nonBusinessMethods | ||
* | ||
* @test_Strategy: Invoking non-public methods results in EJBException. | ||
*/ | ||
public void nonBusinessMethods() { | ||
appendReason(nonBusinessMethods(stateless), nonBusinessMethods(stateful), | ||
nonBusinessMethods(singleton)); | ||
} | ||
|
||
/* | ||
* testName: invokeRemovedStateful | ||
* | ||
* @test_Strategy: Invoking a removed stateful no-interface bean results in | ||
* jakarta.ejb.NoSuchEJBException. Also verify the overloaded method with same | ||
* method name but different params is not considered a remove-method. | ||
*/ | ||
public void invokeRemovedStateful() { | ||
statefulToBeRemoved.remove(false); | ||
statefulToBeRemoved.remove(false); | ||
statefulToBeRemoved.remove(); | ||
try { | ||
String result = statefulToBeRemoved.passAsParam(singleton); | ||
throw new RuntimeException( | ||
"Expected jakarta.ejb.NoSuchEJBException when invoking a removed stateful no-interface bean, but got " | ||
+ result); | ||
} catch (NoSuchEJBException expected) { | ||
appendReason( | ||
"Got expected when invoking a removed stateful no-interface bean", | ||
expected); | ||
} | ||
} | ||
|
||
/* | ||
* testName: passAsParam | ||
* | ||
* @test_Strategy: no-interface view bean reference can be passed by param of | ||
* any local business interface or no-interface method. Using varargs... | ||
*/ | ||
public void passAsParam() { | ||
appendReason(stateless.passAsParam(stateless), | ||
stateless.passAsParam(stateful), stateless.passAsParam(singleton), | ||
stateless.passAsParam(stateless, stateful, singleton), | ||
stateful.passAsParam(stateless), stateful.passAsParam(stateful), | ||
stateful.passAsParam(singleton), | ||
stateful.passAsParam(stateless, stateful, singleton), | ||
singleton.passAsParam(stateless), singleton.passAsParam(stateful), | ||
singleton.passAsParam(singleton), | ||
singleton.passAsParam(stateless, stateful, singleton), | ||
hasInterfaceSingleton.passAsParam(stateless), | ||
hasInterfaceSingleton.passAsParam(stateful), | ||
hasInterfaceSingleton.passAsParam(singleton), | ||
hasInterfaceSingleton.passAsParam(stateless, stateful, singleton)); | ||
} | ||
|
||
/* | ||
* testName: passAsReturn | ||
* | ||
* @test_Strategy: no-interface view bean reference can be passed by param of | ||
* any local business interface or no-interface method. Using covariant return | ||
* types. Also tests that injected no-interface beans can be looked up via | ||
* jndi. | ||
*/ | ||
public void passAsReturn() { | ||
BeanBase less = (BeanBase) lookup("ejb/stateless", | ||
"NoInterfaceStatelessBean", null); | ||
BeanBase ful = (BeanBase) lookup("ejb/stateful", "NoInterfaceStatefulBean", | ||
null); | ||
BeanBase sing = (BeanBase) lookup("ejb/singleton", | ||
"NoInterfaceSingletonBean", null); | ||
appendReason(less.passAsReturn(), ful.passAsReturn(), sing.passAsReturn(), | ||
hasInterfaceSingleton.passAsReturn()); | ||
} | ||
|
||
/* | ||
* testName: passEnumAsParams | ||
* | ||
* @test_Strategy: pass (NumberEnum, NumberIF) to each bean, which returns the | ||
* sum. | ||
*/ | ||
public void passEnumAsParams() { | ||
int expected = NumberEnum.ONE.add(NumberEnum.TWO.getNumber()); | ||
assertEquals(null, expected, | ||
stateless.passEnumAsParams(NumberEnum.ONE, NumberEnum.TWO)); | ||
assertEquals(null, expected, | ||
stateful.passEnumAsParams(NumberEnum.ONE, NumberEnum.TWO)); | ||
assertEquals(null, expected, | ||
singleton.passEnumAsParams(NumberEnum.ONE, NumberEnum.TWO)); | ||
assertEquals(null, expected, | ||
hasInterfaceSingleton.passEnumAsParams(NumberEnum.ONE, NumberEnum.TWO)); | ||
} | ||
|
||
/* | ||
* testName: passEnumAsReturn | ||
* | ||
* @test_Strategy: pass (NumberEnum, NumberIF) to each bean, which returns the | ||
* sum. | ||
*/ | ||
public void passEnumAsReturn() { | ||
NumberEnum expected = NumberEnum.THREE; | ||
assertEquals(null, expected, | ||
stateless.passEnumAsReturn(expected.getNumber())); | ||
assertEquals(null, expected, | ||
stateful.passEnumAsReturn(expected.getNumber())); | ||
assertEquals(null, expected, | ||
singleton.passEnumAsReturn(expected.getNumber())); | ||
assertEquals(null, expected, | ||
hasInterfaceSingleton.passEnumAsReturn(expected.getNumber())); | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
src/com/sun/ts/tests/ejb30/lite/nointerface/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,107 @@ | ||
/* | ||
* 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.nointerface.descriptor; | ||
|
||
import java.io.Serializable; | ||
|
||
import com.sun.ts.tests.ejb30.lite.nointerface.annotated.HasInterface; | ||
import jakarta.ejb.EJB; | ||
|
||
@jakarta.inject.Named("client") | ||
@jakarta.enterprise.context.RequestScoped | ||
public class JsfClient | ||
extends com.sun.ts.tests.ejb30.lite.nointerface.annotated.JsfClientBase implements Serializable { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@SuppressWarnings("unused") | ||
@EJB(name = "ejb/stateless", beanName = "NoInterfaceStatelessBean") | ||
private void setStateless(NoInterfaceStatelessBean stateless) { | ||
this.stateless = stateless; | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
@EJB(name = "ejb/stateful", beanName = "NoInterfaceStatefulBean") | ||
private void setStateful(NoInterfaceStatefulBean stateful) { | ||
this.stateful = stateful; | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
@EJB(name = "ejb/statefulToBeRemoved", beanName = "NoInterfaceStatefulBean") | ||
private void setStatefulToBeRemoved( | ||
NoInterfaceStatefulBean statefulToBeRemoved) { | ||
this.statefulToBeRemoved = statefulToBeRemoved; | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
@EJB(name = "ejb/singleton", beanName = "NoInterfaceSingletonBean") | ||
private void setSingleton(NoInterfaceSingletonBean singleton) { | ||
this.singleton = singleton; | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
@EJB(beanName = "HasInterfaceSingletonBean") | ||
private void setHasInterfaceSingleton(HasInterface hasInterfaceSingleton) { | ||
this.hasInterfaceSingleton = hasInterfaceSingleton; | ||
} | ||
|
||
/* | ||
* @testName: nonBusinessMethods | ||
* | ||
* @test_Strategy: Invoking non-public methods results in EJBException. | ||
*/ | ||
|
||
/* | ||
* @testName: invokeRemovedStateful | ||
* | ||
* @test_Strategy: Invoking a removed stateful no-interface bean results in | ||
* jakarta.ejb.NoSuchEJBException. | ||
*/ | ||
|
||
/* | ||
* @testName: passAsParam | ||
* | ||
* @test_Strategy: no-interface view bean reference can be passed by param of | ||
* any local business interface or no-interface method. Using varargs... | ||
*/ | ||
|
||
/* | ||
* @testName: passAsReturn | ||
* | ||
* @test_Strategy: no-interface view bean reference can be passed by param of | ||
* any local business interface or no-interface method. Using covariant return | ||
* types. Also tests that injected no-interface beans can be looked up via | ||
* jndi. | ||
*/ | ||
|
||
/* | ||
* @testName: passEnumAsParams | ||
* | ||
* @test_Strategy: pass (NumberEnum, NumberIF) to each bean, which returns the | ||
* sum. | ||
*/ | ||
|
||
/* | ||
* @testName: passEnumAsReturn | ||
* | ||
* @test_Strategy: pass (NumberEnum, NumberIF) to each bean, which returns the | ||
* sum. | ||
*/ | ||
} |