Skip to content

Commit

Permalink
Removed CDI tests using @ManagedBean
Browse files Browse the repository at this point in the history
This had been removed from the platform.

Signed-off-by: Arjan Tijms <arjan.tijms@omnifish.ee>
  • Loading branch information
arjantijms committed Jan 3, 2024
1 parent 4aab29d commit 9580427
Show file tree
Hide file tree
Showing 113 changed files with 238 additions and 3,944 deletions.
Expand Up @@ -83,17 +83,6 @@ private void postConstruct() {

systemProcessor.pushAnnotationHandler(annotationTypeName, new LazyAnnotationHandler(descriptor));
annotationClassNames.add("L" + annotationTypeName.replace('.', '/') + ";");

// In the current set of the annotations processed by the
// deployment layer, the only annotation that should be
// processed even when metadata-complete atribute value is true
// is jakarta.annotation.ManagedBean. If there are more annotations
// falling in this category in the future, add them to this list
if (annotationTypeName.equals("jakarta.annotation.ManagedBean")) {
systemProcessorMetaDataComplete.pushAnnotationHandler(annotationTypeName,
new LazyAnnotationHandler(descriptor));
annotationClassNamesMetaDataComplete.add("L" + annotationTypeName.replace('.', '/') + ";");
}
}
}

Expand Down
1 change: 0 additions & 1 deletion appserver/tests/appserv-tests/devtests/cdi/build.xml
Expand Up @@ -68,7 +68,6 @@
<run-cdi-test path="interceptors" />
<run-cdi-test path="javaee-component-resources" />
<run-cdi-test path="javaee-integration" />
<run-cdi-test path="managed-beans" />
<run-cdi-test path="portable-extensions" />
<run-cdi-test path="producer-methods" />
<run-cdi-test path="scopes" />
Expand Down
@@ -0,0 +1,75 @@
/*
* 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
*/


import java.io.*;
import java.util.*;
import jakarta.ejb.EJB;
import javax.naming.InitialContext;
import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;

public class Client {

private static SimpleReporterAdapter stat =
new SimpleReporterAdapter("appserv-tests");

public static void main (String[] args) {

stat.addDescription("simple-ejb-implicit-cdi-deployment-opt");
Client client = new Client(args);
client.doTest();
stat.printSummary("simple-ejb-implicit-cdi-deployment-opt");
}

public Client (String[] args) {
}

private static @EJB(mappedName="Sless") Sless sless;

public void doTest() {

try {

System.out.println("Creating InitialContext()");
InitialContext ic = new InitialContext();
org.omg.CORBA.ORB orb = (org.omg.CORBA.ORB) ic.lookup("java:comp/ORB");
Sless sless = (Sless) ic.lookup("Sless");

String response = null;

response = sless.hello();
testResponse("invoking stateless", response);

System.out.println("test complete");

stat.addStatus("local main", stat.PASS);

} catch(Exception e) {
e.printStackTrace();
stat.addStatus("local main" , stat.FAIL);
}

return;
}

private void testResponse(String testDescription, String response){
// Expecting a null response because the injection should fail since implicit bean discovery
// is disabled by the deployment property implicitCdiEnabled=false
stat.addStatus(testDescription, (response == null ? stat.PASS : stat.FAIL));
}

}

@@ -0,0 +1,93 @@
/*
* Copyright (c) 2008, 2021 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
*/
import test.*;
import java.io.*;
import java.util.*;
import jakarta.ejb.EJB;
import javax.naming.InitialContext;
import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;

public class Client {

private static SimpleReporterAdapter stat = new SimpleReporterAdapter("appserv-tests");

public static void main(String[] args) {
stat.addDescription("simple-ejb-implicit-cdi");
Client client = new Client(args);
client.doTest();
stat.printSummary("simple-ejb-implicit-cdi");
}

public Client(String[] args) {
}

@EJB(mappedName = "test.Foo#test.Foo")
private static Foo sless;

//
// NOTE: Token 3700 will be replaced in @EJB annotations below
// with the value of the port from config.properties during the build
//
@EJB(mappedName = "corbaname:iiop:localhost:3700#test.Foo")
private static Foo sless2;

@EJB(mappedName = "corbaname:iiop:localhost:3700#java:global/simple-ejb-implicit-cdiApp/simple-ejb-implicit-cdi-ejb/SlessEJB!test.Foo")
private static Foo sless3;

public void doTest() {

try {
System.out.println("Creating InitialContext()");
InitialContext initialContext = new InitialContext();
org.omg.CORBA.ORB orb = (org.omg.CORBA.ORB) initialContext.lookup("java:comp/ORB");
Foo sless = (Foo) initialContext.lookup("test.Foo#test.Foo");

String response = sless.hello();
testResponse("invoking stateless", response);

response = sless2.hello();
testResponse("invoking stateless2", response);

System.out.println("ensuring that sless1 and sless2 are not equal");
if (!sless.equals(sless2)) {
stat.addStatus("ensuring that sless1 and sless2 are not equal", stat.FAIL);
throw new Exception("invalid equality checks on same " + "sless session beans");
}

response = sless3.hello();
testResponse("invoking stateless3", response);

System.out.println("test complete");

stat.addStatus("local main", stat.PASS);

} catch (Exception e) {
e.printStackTrace();
stat.addStatus("local main", stat.FAIL);
}

return;
}

private void testResponse(String testDescription, String response) {
if (response.equals("hello")) {
stat.addStatus(testDescription, stat.PASS);
} else {
stat.addStatus(testDescription, stat.FAIL);
}
}

}

This file was deleted.

Expand Up @@ -16,7 +16,6 @@

package com.acme.servlet;


import java.io.IOException;
import java.io.PrintWriter;

Expand All @@ -34,10 +33,8 @@
import com.acme.util.TestDependentBeanInLib;
import com.acme.util.ResourcesProducer;
import com.acme.util.TestDatabase;
import com.acme.util.TestManagedBean;

@WebServlet(urlPatterns = "/HelloServlet", loadOnStartup = 1)

@SuppressWarnings("serial")
public class HelloServlet extends HttpServlet {
String msg = "";
Expand All @@ -55,47 +52,36 @@ public class HelloServlet extends HttpServlet {
@Inject
private TestDependentBeanInLib fb;

@Inject
private TestManagedBean tmb;

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("In HelloServlet::doGet");
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();

checkForNull(emf, "Injection of EMF failed in Servlet");
//ensure EMF works!

// Ensure EMF works!
emf.createEntityManager();

//call Singleton EJB
// Call Singleton EJB
String response = h.hello();
if(!response.equals(Hello.HELLO_TEST_STRING))
if (!response.equals(Hello.HELLO_TEST_STRING))
msg += "Invocation of Hello Singeton EJB failed:msg=" + response;

if (!rp.isInjectionSuccessful())
msg += "Injection of a bean in lib directory into another " +
"Bean in lib directory failed";
checkForNull(fb, "Injection of a bean that is placed in lib directory " +
"into a Servlet that is placed in a WAR failed");
checkForNull(tmb, "Injection of a Managed bean that is placed in lib directory " +
"into a Servlet that is placed in a WAR failed");

if (!rp.isInjectionSuccessful())
msg += "Injection of a bean in lib directory into another Bean " +
"in lib directory failed";
msg += "Injection of a bean in lib directory into another " + "Bean in lib directory failed";

if (!tmb.isInjectionSuccessful())
msg += "Injection of a Bean placed in lib dir into a " +
"ManagedBean placed in lib dir failed";
checkForNull(fb, "Injection of a bean that is placed in lib directory " + "into a Servlet that is placed in a WAR failed");

if (!rp.isInjectionSuccessful())
msg += "Injection of a bean in lib directory into another Bean " + "in lib directory failed";

out.println(msg);
}

protected void checkForNull(Object o, String errorMessage){
protected void checkForNull(Object o, String errorMessage) {
System.out.println("o=" + o);
if (o == null) msg += " " + errorMessage;
if (o == null)
msg += " " + errorMessage;
}
}
Expand Up @@ -30,7 +30,6 @@
import com.acme.ejb.api.Hello;
import com.acme.util.TestDatabase;
import com.acme.util.TestDependentBeanInLib;
import com.acme.util.TestManagedBean;
import com.acme.util.TestSessionScopedBeanInLib;
import com.acme.util.UtilInLibDir;

Expand All @@ -46,16 +45,12 @@ public class HelloSingleton implements Hello {
@TestDatabase
private EntityManagerFactory emf;

@Inject
TestManagedBean tmb;

@Inject
TestDependentBeanInLib tdbil;

@Inject
TestSessionScopedBeanInLib tssil;


@PostConstruct
private void init() {
System.out.println("HelloSingleton::init()");
Expand All @@ -71,9 +66,13 @@ private void init() {
public String hello() {
System.out.println("HelloSingleton::hello()");
String res = testEMF();
if (!res.equals("")) return res;
if (!res.equals(""))
return res;

res = testInjectionOfBeansInLibDir();
if (!res.equals("")) return res;
if (!res.equals(""))
return res;

UtilInLibDir uilb = new UtilInLibDir();
if (!(uilb.add(1, 2) == 3)) {
return "Can't use utility class in library directory";
Expand All @@ -82,15 +81,22 @@ public String hello() {
}

private String testInjectionOfBeansInLibDir() {
if (tmb == null) return "Injection of Managed Bean in lib into an EJB in that ear failed";
if (tdbil == null) return "Injection of Dependent Bean in lib into an EJB in that ear failed";
if (tssil == null) return "Injection of SessionScoped Bean in lib into an EJB in that ear failed";
if (tdbil == null)
return "Injection of Dependent Bean in lib into an EJB in that ear failed";

if (tssil == null)
return "Injection of SessionScoped Bean in lib into an EJB in that ear failed";

return "";
}

private String testEMF() {
if (emf == null) return "EMF injection failed, is null in Singleton EJB";
if (emf.createEntityManager() == null) return "Usage of EMF failed in Singleton EJB";
if (emf == null)
return "EMF injection failed, is null in Singleton EJB";

if (emf.createEntityManager() == null)
return "Usage of EMF failed in Singleton EJB";

return "";
}

Expand Down
Expand Up @@ -19,7 +19,6 @@
import jakarta.ejb.*;
import jakarta.annotation.*;


@Singleton
public class Singleton4 {

Expand All @@ -33,6 +32,4 @@ public void destroy() {
System.out.println("In SingletonBean4::destroy()");
}



}

0 comments on commit 9580427

Please sign in to comment.