Initial Contribution
Signed-off-by: Vinay Vishal <vinay.vishal@oracle.com>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/README
new file mode 100644
index 0000000..6c8ebfb
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/README
@@ -0,0 +1,7 @@
+- A test to check if ManagedBean, CDI Dependent Bean and a common POJO in a library jar is available for EJBs of an EAR.
+[issue GLASSFISH-11888]
+- Structure
+EAR:
+ - EJB.jar (EJB impl)
+ - WAR (uses EJB api to access EJB)
+ - lib-dir (set as library-directory through application.xml and has EJB API and lib Beans)
\ No newline at end of file
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/build.properties
new file mode 100644
index 0000000..bc15b60
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/build.properties
@@ -0,0 +1,29 @@
+<!--
+
+ Copyright (c) 2018 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
+
+-->
+
+
+<property name="module" value="bean-in-lib-dir-used-by-ejb-in-ear"/>
+<property name="appname" value="${module}"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="se.client" value="com.acme.Client"/>
+<property name="app.type" value="application"/>
+<property name="sun-application.xml" value="descriptor/sun-application.xml"/>
+<property name="application.xml" value="descriptor/application.xml"/>
+<property name="persistence.xml" value="descriptor/persistence.xml"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
+<property name="contextroot" value="${module}"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/build.xml
new file mode 100644
index 0000000..bef55c1
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/build.xml
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (c) 2010, 2018 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
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="cdi-full-ear-App" default="usage" basedir=".">
+
+ &commonSetup;
+ &commonBuild;
+ &testproperties;
+
+ <target name="all" depends="clean,build,deploy,run,undeploy" />
+
+ <target name="clean" depends="init-common">
+ <antcall target="clean-common" />
+ </target>
+
+ <target name="compile" depends="clean">
+ <!-- compile library -->
+ <antcall target="compile-common">
+ <param name="src" value="lib" />
+ </antcall>
+
+
+ <antcall target="compile-common">
+ <param name="src" value="ejb" />
+ </antcall>
+
+
+ <antcall target="compile-common">
+ <param name="src" value="war" />
+ </antcall>
+
+
+ <javac classpath="${env.S1AS_HOME}/lib/javaee.jar:${env.S1AS_HOME}/lib/gf-client.jar:${build.classes.dir}:${env.APS_HOME}/lib/reporter.jar" srcdir="client" destdir="${build.classes.dir}" debug="on" failonerror="true">
+ <compilerarg line="-endorseddirs ${env.S1AS_HOME}/modules/endorsed" />
+ </javac>
+ </target>
+
+ <target name="build" depends="compile">
+ <mkdir dir="${assemble.dir}" />
+
+ <!-- build library jar -->
+ <mkdir dir="${build.classes.dir}/META-INF" />
+ <copy file="${persistence.xml}" tofile="${build.classes.dir}/META-INF/persistence.xml" failonerror="false" />
+ <copy file="${beans.xml}" tofile="${build.classes.dir}/META-INF/beans.xml" failonerror="false" />
+ <mkdir dir="${build.classes.dir}/lib-dir" />
+ <jar jarfile="${build.classes.dir}/lib-dir/lib.jar" basedir="${build.classes.dir}" includes="com/acme/util/*.class, com/acme/ejb/api/*.class">
+ <metainf dir="${build.classes.dir}/META-INF">
+ <include name="persistence.xml" />
+ <include name="beans.xml" />
+ </metainf>
+ </jar>
+ <copy file="${env.APS_HOME}/lib/reporter.jar" todir="${build.classes.dir}/lib-dir" />
+
+ <!-- build EJB jar -->
+ <antcall target="ejb-jar-common">
+ <param name="ejbjar.classes" value="com/acme/ejb/impl/*.class" />
+ </antcall>
+
+ <!-- delete EJB impl and lib classes as WAR should not have them -->
+ <delete includeEmptyDirs="true">
+ <fileset dir="${build.classes.dir}/com/acme/ejb/" />
+ <fileset dir="${build.classes.dir}/com/acme/util/" />
+ </delete>
+
+ <!-- create WAR -->
+ <antcall target="webclient-war-common">
+ <param name="hasWebclient" value="true" />
+ </antcall>
+
+ <!-- assemble EAR -->
+ <delete file="${assemble.dir}/${appname}.ear" />
+ <mkdir dir="${assemble.dir}" />
+ <mkdir dir="${build.classes.dir}/META-INF" />
+ <copy file="${sun-application.xml}" tofile="${build.classes.dir}/META-INF/sun-application.xml" failonerror="false" />
+ <copy file="${glassfish-resources-ear.xml}" tofile="${build.classes.dir}/META-INF/glassfish-resources.xml" failonerror="false" filtering="true" />
+ <ear earfile="${assemble.dir}/${appname}App.ear" appxml="${application.xml}">
+ <fileset dir="${assemble.dir}">
+ <include name="*.jar" />
+ <include name="*.war" />
+ </fileset>
+ <fileset dir="${build.classes.dir}">
+ <include name="META-INF/sun-application.xml" />
+ <include name="META-INF/glassfish-resources.xml" />
+ </fileset>
+ <fileset dir="${build.classes.dir}" includes="lib-dir/*" />
+ </ear>
+
+ </target>
+
+ <target name="deploy" depends="init-common">
+ <antcall target="deploy-common" />
+ </target>
+
+ <target name="run" depends="init-common">
+ <java fork="on" failonerror="true" classpath="${env.S1AS_HOME}/lib/javaee.jar:${env.S1AS_HOME}/lib/gf-client.jar:${build.classes.dir}:${env.APS_HOME}/lib/reporter.jar" classname="${se.client}">
+ <arg line="${contextroot}" />
+ <arg line="${http.host}" />
+ <arg line="${http.port}" />
+ </java>
+ </target>
+
+ <target name="undeploy" depends="init-common">
+ <antcall target="undeploy-common" />
+ </target>
+
+ <target name="usage">
+ <antcall target="usage-common" />
+ </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/client/com/acme/Client.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/client/com/acme/Client.java
new file mode 100644
index 0000000..c6bdce2
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/client/com/acme/Client.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import javax.annotation.Resource;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+public class Client {
+
+ private static final String TEST_NAME = "bean-in-lib-dir-of-ear-used-by-ejb";
+
+ private static SimpleReporterAdapter stat =
+ new SimpleReporterAdapter("appserv-tests");
+
+ private static String appName;
+ private String host;
+ private String port;
+
+ @Resource(lookup = "java:app/env/value1")
+ private static Integer appLevelViaLookup;
+
+ public static void main(String args[]) {
+ appName = args[0];
+ stat.addDescription(appName);
+ Client client = new Client(args);
+ client.doTest();
+ stat.printSummary(appName + "ID");
+ System.out.println("appLevelViaLookup = '" + appLevelViaLookup + "'");
+ }
+
+ public Client(String[] args) {
+ host = args[1];
+ port = args[2];
+ }
+
+ public void doTest() {
+ try {
+ String url = "http://" + host + ":" + port + "/" + appName
+ + "/HelloServlet";
+ System.out.println("invoking webclient servlet at " + url);
+ URL u = new URL(url);
+ HttpURLConnection c1 = (HttpURLConnection) u.openConnection();
+ int code = c1.getResponseCode();
+ InputStream is = c1.getInputStream();
+ BufferedReader input = new BufferedReader(new InputStreamReader(
+ is));
+ String line = null;
+ while ((line = input.readLine()) != null) {
+ System.out.println("<response>:" + line);
+ if (line.trim().length() > 0) {
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ return;
+ }
+ }
+ if (code != 200) {
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ return;
+ }
+ stat.addStatus(TEST_NAME, stat.PASS);
+
+ } catch (Exception e) {
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/descriptor/application.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/descriptor/application.xml
new file mode 100644
index 0000000..f604093
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/descriptor/application.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (c) 2010, 2018 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
+
+-->
+
+<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="6" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd">
+ <display-name>bean-in-lib-dir-used-by-ejb-in-ear</display-name>
+ <module>
+ <ejb>bean-in-lib-dir-used-by-ejb-in-ear-ejb.jar</ejb>
+ </module>
+ <module>
+ <web>
+ <web-uri>bean-in-lib-dir-used-by-ejb-in-ear-web.war</web-uri>
+ <context-root>bean-in-lib-dir-used-by-ejb-in-ear</context-root>
+ </web>
+ </module>
+ <library-directory>lib-dir</library-directory>
+ <env-entry>
+ <env-entry-name>java:app/env/value1</env-entry-name>
+ <env-entry-type>java.lang.Integer</env-entry-type>
+ <env-entry-value>18338</env-entry-value>
+ </env-entry>
+ <env-entry>
+ <env-entry-name>java:app/env/myString</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>myString</env-entry-value>
+ </env-entry>
+</application>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/descriptor/beans.xml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/descriptor/beans.xml
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/descriptor/persistence.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/descriptor/persistence.xml
new file mode 100644
index 0000000..82f2d7b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/descriptor/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (c) 1997, 2018 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
+
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+ <persistence-unit name="pu1" transaction-type="JTA">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ <jta-data-source>jdbc/__default</jta-data-source>
+ <non-jta-data-source>jdbc/__default</non-jta-data-source>
+ <class>myapp.Department</class>
+ <class>myapp.Employee</class>
+ <properties>
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+ <property name="eclipselink.logging.level" value="INFO"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/ejb/com/acme/ejb/api/Hello.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/ejb/com/acme/ejb/api/Hello.java
new file mode 100644
index 0000000..0151798
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/ejb/com/acme/ejb/api/Hello.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme.ejb.api;
+
+public interface Hello {
+
+ public String hello();
+
+ public static final String ALL_OK_STRING = "All Iz Well!\n";
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/ejb/com/acme/ejb/api/HelloRemote.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/ejb/com/acme/ejb/api/HelloRemote.java
new file mode 100644
index 0000000..0993e59
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/ejb/com/acme/ejb/api/HelloRemote.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme.ejb.api;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface HelloRemote {
+
+ public String hello();
+
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/ejb/com/acme/ejb/impl/HelloSingleton.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/ejb/com/acme/ejb/impl/HelloSingleton.java
new file mode 100644
index 0000000..a8518c1
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/ejb/com/acme/ejb/impl/HelloSingleton.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme.ejb.impl;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import javax.ejb.DependsOn;
+import javax.ejb.SessionContext;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.inject.Inject;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+
+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;
+
+@Singleton
+@Startup
+@DependsOn("Singleton4")
+public class HelloSingleton implements Hello {
+
+ @Resource
+ SessionContext sessionCtx;
+
+ @PersistenceUnit(unitName = "pu1")
+ @TestDatabase
+ private EntityManagerFactory emf;
+
+ @Inject
+ TestManagedBean tmb;
+
+ @Inject
+ TestDependentBeanInLib tdbil;
+
+ @Inject
+ TestSessionScopedBeanInLib tssil;
+
+
+ @PostConstruct
+ private void init() {
+ System.out.println("HelloSingleton::init()");
+
+ String appName;
+ String moduleName;
+ appName = (String) sessionCtx.lookup("java:app/AppName");
+ moduleName = (String) sessionCtx.lookup("java:module/ModuleName");
+ System.out.println("AppName = " + appName);
+ System.out.println("ModuleName = " + moduleName);
+ }
+
+ public String hello() {
+ System.out.println("HelloSingleton::hello()");
+ String res = testEMF();
+ if (!res.equals("")) return res;
+ res = testInjectionOfBeansInLibDir();
+ if (!res.equals("")) return res;
+ UtilInLibDir uilb = new UtilInLibDir();
+ if (!(uilb.add(1, 2) == 3)) {
+ return "Can't use utility class in library directory";
+ }
+ return ALL_OK_STRING;
+ }
+
+ 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";
+ 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";
+ return "";
+ }
+
+ @PreDestroy
+ private void destroy() {
+ System.out.println("HelloSingleton::destroy()");
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/ejb/com/acme/ejb/impl/Singleton4.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/ejb/com/acme/ejb/impl/Singleton4.java
new file mode 100644
index 0000000..b3fd249
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/ejb/com/acme/ejb/impl/Singleton4.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme.ejb.impl;
+
+import javax.ejb.*;
+import javax.annotation.*;
+
+
+@Singleton
+public class Singleton4 {
+
+ @PostConstruct
+ public void init() {
+ System.out.println("In SingletonBean4::init()");
+ }
+
+ @PreDestroy
+ public void destroy() {
+ System.out.println("In SingletonBean4::destroy()");
+ }
+
+
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/lib/com/acme/util/ResourcesProducer.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/lib/com/acme/util/ResourcesProducer.java
new file mode 100644
index 0000000..fdc079b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/lib/com/acme/util/ResourcesProducer.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme.util;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+@Singleton
+public class ResourcesProducer {
+ @Produces
+ @PersistenceContext(unitName = "pu1")
+ @TestDatabase
+ EntityManager customerDatabasePersistenceUnit;
+
+ @Inject
+ TestDependentBeanInLib foo;
+
+ public boolean isInjectionSuccessful(){
+ return (foo != null);
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/lib/com/acme/util/TestDatabase.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/lib/com/acme/util/TestDatabase.java
new file mode 100644
index 0000000..db9e318
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/lib/com/acme/util/TestDatabase.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme.util;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface TestDatabase {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/lib/com/acme/util/TestDependentBeanInLib.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/lib/com/acme/util/TestDependentBeanInLib.java
new file mode 100644
index 0000000..9596b22
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/lib/com/acme/util/TestDependentBeanInLib.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme.util;
+
+
+public class TestDependentBeanInLib {
+ public TestDependentBeanInLib() {
+ super();
+ }
+
+ public String foo(){
+ return "foo!";
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/lib/com/acme/util/TestManagedBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/lib/com/acme/util/TestManagedBean.java
new file mode 100644
index 0000000..c650b91
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/lib/com/acme/util/TestManagedBean.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme.util;
+
+import javax.annotation.ManagedBean;
+import javax.inject.Inject;
+
+@ManagedBean
+public class TestManagedBean {
+ @Inject
+ private TestDependentBeanInLib tdb;
+
+ @Inject
+ private TestSessionScopedBeanInLib tssil;
+
+ public boolean isInjectionSuccessful(){
+ System.out.println("TestManagedBean:isInjectionSuccessful");
+ System.out.println("TestDependentBean:" + tdb);
+ System.out.println("TestSessionScopedBean:" + tssil);
+ return (tdb != null) && (tssil != null);
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/lib/com/acme/util/TestSessionScopedBeanInLib.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/lib/com/acme/util/TestSessionScopedBeanInLib.java
new file mode 100644
index 0000000..03f1071
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/lib/com/acme/util/TestSessionScopedBeanInLib.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme.util;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
+
+@SessionScoped
+public class TestSessionScopedBeanInLib implements Serializable{
+ public void m1(){
+ System.out.println("TestSessionScopedBeanInLib:m1");
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/lib/com/acme/util/UtilInLibDir.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/lib/com/acme/util/UtilInLibDir.java
new file mode 100644
index 0000000..18e76ab
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/lib/com/acme/util/UtilInLibDir.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme.util;
+
+public class UtilInLibDir {
+
+ public int add(int i1, int i2) {
+ return i1+i2;
+ }
+
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/manifest.mf b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/war/com/acme/servlet/HelloServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/war/com/acme/servlet/HelloServlet.java
new file mode 100644
index 0000000..7f9875a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/bean-in-lib-dir-used-by-ejb-in-ear/war/com/acme/servlet/HelloServlet.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme.servlet;
+
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.ejb.EJB;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.acme.ejb.api.Hello;
+import com.acme.util.TestDatabase;
+
+@WebServlet(urlPatterns = "/HelloServlet", loadOnStartup = 1)
+
+@SuppressWarnings("serial")
+public class HelloServlet extends HttpServlet {
+ String msg = "";
+
+ @EJB(name = "java:module/m1", beanName = "HelloSingleton", beanInterface = Hello.class)
+ Hello h;
+
+ @PersistenceUnit(unitName = "pu1")
+ @TestDatabase
+ private EntityManagerFactory emf;
+
+// @Inject
+// private ResourcesProducer rp;
+//
+// @Inject
+// private TestDependentBeanInLib fb;
+
+// @Inject
+// private TestManagedBean tmb;
+
+// @Inject
+// private TestSessionScopedBeanInLib tssil;
+
+ @Override
+ 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!
+ emf.createEntityManager();
+
+ //call Singleton EJB
+ String response = h.hello();
+ if(!response.equals(Hello.ALL_OK_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");
+// checkForNull(tssil, "Injection of a session scoped Bean placed in lib dir into a " +
+// "into a servlet in that ear failed");
+
+// if (!rp.isInjectionSuccessful())
+// 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";
+
+ out.println(msg);
+ }
+
+ protected void checkForNull(Object o, String errorMessage){
+ System.out.println("o=" + o);
+ if (o == null) msg += " " + errorMessage;
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/build.xml
new file mode 100644
index 0000000..08b090d
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/build.xml
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (c) 2010, 2018 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
+
+-->
+
+<project name="javaee-int-test" default="usage" basedir=".">
+
+ <property name="javaee-int-target" value="all"/>
+
+ <target name="run-test">
+ <antcall target="javaee-int">
+ <param name="javaee-int-target" value="run-test"/>
+ </antcall>
+ </target>
+
+ <target name="all">
+ <antcall target="javaee-int">
+ <param name="javaee-int-target" value="all"/>
+ </antcall>
+ </target>
+
+ <target name="clean">
+ <antcall target="javaee-int">
+ <param name="javaee-int-target" value="clean"/>
+ </antcall>
+ </target>
+
+ <target name="build">
+ <antcall target="javaee-int">
+ <param name="javaee-int-target" value="build"/>
+ </antcall>
+ </target>
+
+ <target name="setup">
+ <antcall target="javaee-int">
+ <param name="javaee-int-target" value="setup"/>
+ </antcall>
+ </target>
+
+ <target name="deploy">
+ <antcall target="javaee-int">
+ <param name="javaee-int-target" value="deploy"/>
+ </antcall>
+ </target>
+
+ <target name="undeploy">
+ <antcall target="javaee-int">
+ <param name="javaee-int-target" value="undeploy"/>
+ </antcall>
+ </target>
+
+ <target name="unsetup">
+ <antcall target="javaee-int">
+ <param name="javaee-int-target" value="unsetup"/>
+ </antcall>
+ </target>
+
+ <target name="run">
+ <antcall target="javaee-int">
+ <param name="javaee-int-target" value="run"/>
+ </antcall>
+ </target>
+
+ <target name="javaee-int">
+ <record name="javaee-int.output" action="start" />
+ <ant dir="builtin-beans" target="${javaee-int-target}"/>
+ <ant dir="servlet-context-injection-cdi" target="${javaee-int-target}"/>
+<!-- Test issue: ManagedBean need not have a no-arg constructor in CDI runtimes
+ <ant dir="simple-managed-bean-interceptor-noargconstructor-missing" target="${javaee-int-target}"/>
+-->
+ <ant dir="simple-managed-bean-interceptor-nonnull-package" target="${javaee-int-target}"/>
+ <ant dir="no-interface-local-view-proxy-serializable" target="${javaee-int-target}"/>
+ <ant dir="normal-bean-injection-ear" target="${javaee-int-target}"/>
+ <ant dir="programmatic-lookup-ear" target="${javaee-int-target}"/>
+ <ant dir="bean-in-lib-dir-used-by-ejb-in-ear" target="${javaee-int-target}"/>
+ <ant dir="cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection" target="${javaee-int-target}"/>
+ <ant dir="cdi-servlet-3.0-annotation-with-web-inf-lib-ordering" target="${javaee-int-target}"/>
+ <ant dir="cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed" target="${javaee-int-target}"/>
+ <ant dir="cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative" target="${javaee-int-target}"/>
+ <ant dir="cdi-servlet-3.0-annotation-with-web-inf-lib" target="${javaee-int-target}"/>
+ <ant dir="embedded-resource-adapter-as-bean-archive" target="${javaee-int-target}"/>
+
+ <record name="javaee-int.output" action="stop" />
+ </target>
+
+ <target name="usage">
+ <echo> Usage:
+ ant all (Executes all the javaee-int tests)
+ ant clean (cleans all the javaee-int tests)
+ ant build (builds all the javaee-int tests)
+ ant setup (sets up all resources for javaee-int tests)
+ ant deploy (deploys all the javaee-int apps)
+ ant run (Executes all the javaee-int tests)
+ ant undeploy (undeploys all the javaee-int apps)
+ ant unsetup (unsets all resources for javaee-int tests)
+ </echo>
+ </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/README
new file mode 100644
index 0000000..5b536cb
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/README
@@ -0,0 +1,7 @@
+Test
+- Java EE Integration
+ - container provides the following built-in beans with the qualifier @Default
+ - UserTransaction
+ - Principal
+ - ValidatorFactory
+ - Validator
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/build.properties
new file mode 100644
index 0000000..3543e4c
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/build.properties
@@ -0,0 +1,24 @@
+<!--
+
+ Copyright (c) 2018 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
+
+-->
+
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-typesafe-javaee-resource-injection"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/build.xml
new file mode 100644
index 0000000..295d086
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/build.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (c) 2010, 2018 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
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+ &commonSetup;
+ &commonBuild;
+ &testproperties;
+ &run;
+
+ <target name="all" depends="build,create-resources,deploy,run,undeploy,delete-resources" />
+
+ <target name="clean" depends="init-common">
+ <antcall target="clean-common" />
+ <delete>
+ <fileset dir="." includes="*.class" />
+ <fileset dir="client/test/client" includes="*.class" />
+ </delete>
+ </target>
+
+ <target name="compile" depends="clean">
+ <antcall target="compile-common">
+ <param name="src" value="servlet" />
+ </antcall>
+ </target>
+
+ <target name="build" depends="compile">
+ <property name="hasWebclient" value="yes" />
+ <antcall target="webclient-war-common">
+ <param name="hasWebclient" value="yes" />
+ <param name="webclient.war.classes" value="**/*.class" />
+ </antcall>
+
+ <javac srcdir="client" classpath="${env.APS_HOME}/lib/reportbuilder.jar" includes="test/client/WebTest.java" />
+
+ </target>
+
+ <target name="build-publish-war" depends="build, publish-war-common" />
+
+ <target name="deploy" depends="init-common">
+ <antcall target="deploy-war-common" />
+ </target>
+
+ <target name="create-resources" depends="init-common">
+ <antcall target="create-jdbc-connpool-common">
+ <param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+ </antcall>
+ <antcall target="create-jdbc-resource-common">
+ <param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+ <param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+ </antcall>
+ </target>
+
+
+ <target name="run" depends="init-common">
+ <java classname="test.client.WebTest">
+ <arg value="${http.host}" />
+ <arg value="${http.port}" />
+ <arg value="${contextroot}" />
+ <classpath>
+ <pathelement location="${env.APS_HOME}/lib/reportbuilder.jar" />
+ <pathelement location="client" />
+ </classpath>
+ </java>
+ </target>
+
+ <target name="undeploy" depends="init-common">
+ <antcall target="undeploy-war-common" />
+ </target>
+
+ <target name="delete-resources" depends="init-common">
+ <antcall target="delete-jdbc-resource-common">
+ <param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+ </antcall>
+
+ <antcall target="delete-jdbc-connpool-common">
+ <param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+ </antcall>
+ </target>
+
+ <target name="usage">
+ <antcall target="usage-common" />
+ </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/client/test/client/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/client/test/client/WebTest.java
new file mode 100644
index 0000000..bce94d2
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/client/test/client/WebTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.client;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+ private static SimpleReporterAdapter stat = new SimpleReporterAdapter(
+ "appserv-tests");
+ private static final String TEST_NAME = "javaee-integration-simple";
+
+ private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0.";
+
+ private String host;
+ private String port;
+ private String contextRoot;
+
+ public WebTest(String[] args) {
+ host = args[0];
+ port = args[1];
+ contextRoot = args[2];
+ }
+
+ public static void main(String[] args) {
+ stat.addDescription("Unit test for Java EE Integration");
+ WebTest webTest = new WebTest(args);
+ webTest.doTest();
+ stat.printSummary(TEST_NAME);
+ }
+
+ public void doTest() {
+ try {
+ invoke();
+ } catch (Exception ex) {
+ System.out.println(TEST_NAME + " test failed");
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ ex.printStackTrace();
+ }
+ }
+
+ private void invoke() throws Exception {
+
+ String url = "http://" + host + ":" + port + contextRoot + "/myurl";
+ System.out.println("opening connection to " + url);
+ HttpURLConnection conn = (HttpURLConnection) (new URL(url))
+ .openConnection();
+
+ int code = conn.getResponseCode();
+ if (code != 200) {
+ System.out.println("Unexpected return code: " + code);
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ } else {
+ InputStream is = null;
+ BufferedReader input = null;
+ String line = null;
+ try {
+ is = conn.getInputStream();
+ input = new BufferedReader(new InputStreamReader(is));
+ line = input.readLine();
+ System.out.println("line = " + line);
+ } finally {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch (IOException ioe) {
+ // ignore
+ }
+ try {
+ if (input != null) {
+ input.close();
+ }
+ } catch (IOException ioe) {
+ // ignore
+ }
+ }
+ if (EXPECTED_RESPONSE.equals(line)) {
+ stat.addStatus(TEST_NAME, stat.PASS);
+ } else {
+ System.out.println("Wrong response. Expected: "
+ + EXPECTED_RESPONSE + ", received: " + line);
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ }
+ }
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/descriptor/beans.xml
new file mode 100644
index 0000000..1d355f8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/descriptor/beans.xml
@@ -0,0 +1,25 @@
+<!--
+
+ Copyright (c) 2017, 2018 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
+
+-->
+
+<beans
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+</beans>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/servlet/test/beans/TestBeanInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/servlet/test/beans/TestBeanInterface.java
new file mode 100644
index 0000000..29e137a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/servlet/test/beans/TestBeanInterface.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans;
+
+public interface TestBeanInterface {
+ public void m1();
+ public void m2();
+
+ public String testDatasourceInjection();
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/servlet/test/beans/artifacts/Preferred.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/servlet/test/beans/artifacts/Preferred.java
new file mode 100644
index 0000000..b7584c8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/servlet/test/beans/artifacts/Preferred.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Preferred {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/servlet/test/beans/artifacts/TestDatabase.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/servlet/test/beans/artifacts/TestDatabase.java
new file mode 100644
index 0000000..b69ab8e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/servlet/test/beans/artifacts/TestDatabase.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface TestDatabase {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/servlet/test/beans/nonmock/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/servlet/test/beans/nonmock/TestBean.java
new file mode 100644
index 0000000..1947fac
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/servlet/test/beans/nonmock/TestBean.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans.nonmock;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.sql.DataSource;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+import test.beans.artifacts.TestDatabase;
+
+
+@RequestScoped
+@Preferred
+public class TestBean implements TestBeanInterface{
+ public static boolean testBeanInvoked = false;
+
+ @Inject @TestDatabase
+ DataSource ds;
+
+ @Override
+ public void m1() {
+ testBeanInvoked = true;
+ System.out.println("TestBean::m1 called");
+ }
+
+ @Override
+ public void m2() {
+ System.out.println("TestBean::m2 called");
+ }
+
+ @Override
+ public String testDatasourceInjection() {
+ return (ds==null ? "typesafe injection into testbean failed" : "");
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/servlet/test/servlet/DatabaseManager.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/servlet/test/servlet/DatabaseManager.java
new file mode 100644
index 0000000..0b4d0b3
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/servlet/test/servlet/DatabaseManager.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.servlet;
+
+import javax.annotation.Resource;
+import javax.enterprise.inject.Produces;
+import javax.sql.DataSource;
+
+import test.beans.artifacts.TestDatabase;
+
+public class DatabaseManager {
+ @Produces
+ @TestDatabase
+ @Resource(name = "jdbc/jdbc-dev-test-resource",
+ mappedName = "jdbc/jdbc-dev-test-resource")
+ DataSource ds;
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/servlet/test/servlet/SimpleJavaEEIntegrationTestServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/servlet/test/servlet/SimpleJavaEEIntegrationTestServlet.java
new file mode 100644
index 0000000..9d1e2ea
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/builtin-beans/servlet/test/servlet/SimpleJavaEEIntegrationTestServlet.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.security.Principal;
+
+import javax.inject.Inject;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.sql.DataSource;
+import javax.transaction.UserTransaction;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+import test.beans.artifacts.TestDatabase;
+
+@WebServlet(name = "mytest", urlPatterns = { "/myurl" })
+public class SimpleJavaEEIntegrationTestServlet extends HttpServlet {
+ @Inject @Preferred
+ TestBeanInterface tb;
+
+ @Inject @TestDatabase
+ DataSource ds;
+
+ // Inject the built-in beans
+ @Inject UserTransaction ut;
+ @Inject Principal principal;
+ @Inject Validator validator;
+ @Inject ValidatorFactory vf;
+
+ public void service(HttpServletRequest req, HttpServletResponse res)
+ throws IOException, ServletException {
+
+ PrintWriter writer = res.getWriter();
+ writer.write("Hello from Servlet 3.0.");
+ String msg = "";
+
+ if (ds == null)
+ msg += "typesafe Injection of datasource into a servlet failed";
+
+ if (tb == null)
+ msg += "Injection of request scoped bean failed";
+
+ if (tb.testDatasourceInjection().trim().length() != 0)
+ msg += tb.testDatasourceInjection();
+
+ System.out.println("UserTransaction: " + ut);
+ System.out.println("Principal: " + principal);
+ System.out.println("Default Validator: " + validator);
+ System.out.println("Default ValidatorFactory: " + vf);
+ if (ut == null)
+ msg += "UserTransaction not available for injection "
+ + "with the default qualifier in Servlet";
+
+ if (principal == null)
+ msg += "Caller Principal not available for injection "
+ + "with the default qualifier in Servlet";
+
+ if (validator == null)
+ msg += "Default Validator not available for injection "
+ + "with the default qualifier in Servlet";
+
+ if (vf == null)
+ msg += "ValidationFactory not available for injection "
+ + "with the default qualifier in Servlet";
+
+ writer.write(msg + "\n");
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/README
new file mode 100644
index 0000000..f98070f
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/README
@@ -0,0 +1,8 @@
+GLASSFISH-15791
+Ensure Extension in a bundled library in an archive, does not result in
+issues with Alternatives enabled in that bundled library
+
+GLASSFISH-16279
+Ensure BM injected in sub BDA is not parent BDA's BM
+Ensure alternatives enabled in sub BDA is not visible via BeanManager
+in parent BDA
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/WebTest.java
new file mode 100644
index 0000000..d1198c4
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/WebTest.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2010, 2018 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.net.*;
+
+import com.sun.ejte.ccl.reporter.*;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+ private static SimpleReporterAdapter stat
+ = new SimpleReporterAdapter("appserv-tests");
+ private static final String TEST_NAME = "cdi-servlet-annotation-with-web-inf-lib-extension-alternative";
+ private static final String EXPECTED_RESPONSE = "";
+
+ private String host;
+ private String port;
+ private String contextRoot;
+
+ public WebTest(String[] args) {
+ host = args[0];
+ port = args[1];
+ contextRoot = args[2];
+ }
+
+ public static void main(String[] args) {
+ stat.addDescription("Unit test for @WebServlet");
+ WebTest webTest = new WebTest(args);
+ webTest.doTest();
+ stat.printSummary(TEST_NAME);
+ }
+
+ public void doTest() {
+ try {
+ invoke("llinit");
+ invoke("llquery");
+ invoke("llfind");
+ invoke("llinj");
+ } catch (Exception ex) {
+ System.out.println(TEST_NAME + " test failed");
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ ex.printStackTrace();
+ }
+ }
+
+ private void invoke(String testCase) throws Exception {
+
+ String url = "http://" + host + ":" + port + contextRoot + "/myurl"
+ + "?testcase=" + testCase;
+ System.out.println("opening connection to " + url);
+ HttpURLConnection conn = (HttpURLConnection) (new URL(url))
+ .openConnection();
+
+ int code = conn.getResponseCode();
+ if (code != 200) {
+ System.out.println("Unexpected return code: " + code);
+ stat.addStatus(TEST_NAME + testCase, stat.FAIL);
+ } else {
+ InputStream is = null;
+ BufferedReader input = null;
+ String line = null;
+ try {
+ is = conn.getInputStream();
+ input = new BufferedReader(new InputStreamReader(is));
+ line = input.readLine();
+ if (line.trim().length() != 0) {
+ System.out.println("line = " + line);
+ }
+ } finally {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch (IOException ioe) {
+ // ignore
+ }
+ try {
+ if (input != null) {
+ input.close();
+ }
+ } catch (IOException ioe) {
+ // ignore
+ }
+ }
+ if (EXPECTED_RESPONSE.equals(line)) {
+ stat.addStatus(TEST_NAME + testCase, stat.PASS);
+ } else {
+ System.out.println("Wrong response. Expected: "
+ + EXPECTED_RESPONSE + ", received: " + line);
+ stat.addStatus(TEST_NAME + testCase, stat.FAIL);
+ }
+ }
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/build.properties
new file mode 100644
index 0000000..493d4a8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/build.properties
@@ -0,0 +1,25 @@
+<!--
+
+ Copyright (c) 2018 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
+
+-->
+
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-servlet-annotation-with-web-inf-lib-extension-alternative"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
+<property name="persistence.xml" value="descriptor/persistence.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/build.xml
new file mode 100644
index 0000000..e4dca16
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/build.xml
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (c) 2010, 2018 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
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+ &commonSetup;
+ &commonBuild;
+ &testproperties;
+ &run;
+
+ <target name="all" depends="build,create-resources,deploy,run,undeploy,delete-resources"/>
+
+ <target name="clean" depends="init-common">
+ <antcall target="clean-common"/>
+ <delete>
+ <fileset dir="." includes="*.class"/>
+ </delete>
+ <delete file="lib/bean-lib.jar"/>
+ </target>
+
+ <target name="compile" depends="clean">
+ <!-- create WEB-INF/lib/bean-lib.jar -->
+ <mkdir dir="${build.classes.dir}"/>
+ <mkdir dir="${build.classes.dir}/META-INF"/>
+ <javac srcdir="servlet" includes="TestBean.java" destdir="${build.classes.dir}" classpath="${s1astest.classpath}" debug="on" source="1.6"/>
+ <javac srcdir="util" destdir="${build.classes.dir}" classpath="${s1astest.classpath}" debug="on" source="1.6"/>
+ <copy file="descriptor/beans-alternative.xml" tofile="${build.classes.dir}/META-INF/beans.xml"/>
+ <mkdir dir="${build.classes.dir}/META-INF/services"/>
+ <copy file="services/javax.enterprise.inject.spi.Extension" tofile="${build.classes.dir}/META-INF/services/javax.enterprise.inject.spi.Extension"/>
+ <delete file="${build.classes.dir}/TestBean.class" /> <!-- This is included in the WAR below -->
+
+ <jar destfile="lib/bean-lib.jar">
+ <fileset dir="${build.classes.dir}"/>
+ </jar>
+ <delete dir="${build.classes.dir}"/>
+
+ <!-- compile test servlet -->
+ <mkdir dir="${build.classes.dir}"/>
+ <echo message="common.xml: Compiling test source files" level="verbose"/>
+ <mkdir dir="servlet"/>
+ <javac srcdir="servlet" destdir="${build.classes.dir}" classpath="${s1astest.classpath}:lib/bean-lib.jar" debug="on" failonerror="true"/>
+ </target>
+
+ <target name="build" depends="compile">
+ <property name="hasWebclient" value="yes"/>
+ <antcall target="webclient-war-common">
+ <param name="hasWebclient" value="yes"/>
+ <param name="webclient.war.classes" value="**/*.class"/>
+ </antcall>
+
+ <javac srcdir="." classpath="${env.APS_HOME}/lib/reportbuilder.jar"
+ includes="WebTest.java"/>
+
+ </target>
+
+ <target name="build-publish-war" depends="build, publish-war-common" />
+
+ <target name="deploy" depends="init-common">
+ <antcall target="deploy-war-common"/>
+ </target>
+
+ <target name="create-resources" depends="init-common">
+ <antcall target="create-jdbc-connpool-common">
+ <param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+ </antcall>
+ <antcall target="create-jdbc-resource-common">
+ <param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+ <param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+ </antcall>
+ </target>
+
+ <target name="run" depends="init-common">
+ <java classname="WebTest">
+ <arg value="${http.host}"/>
+ <arg value="${http.port}"/>
+ <arg value="${contextroot}"/>
+ <classpath>
+ <pathelement location="${env.APS_HOME}/lib/reportbuilder.jar"/>
+ <pathelement location="."/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="undeploy" depends="init-common">
+ <antcall target="undeploy-war-common"/>
+ </target>
+
+ <target name="delete-resources" depends="init-common">
+ <antcall target="delete-jdbc-resource-common">
+ <param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+ </antcall>
+
+ <antcall target="delete-jdbc-connpool-common">
+ <param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+ </antcall>
+ </target>
+
+ <target name="usage">
+ <antcall target="usage-common"/>
+ </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/descriptor/beans-alternative.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/descriptor/beans-alternative.xml
new file mode 100644
index 0000000..1b3ee25
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/descriptor/beans-alternative.xml
@@ -0,0 +1,26 @@
+<!--
+
+ Copyright (c) 2017, 2018 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
+
+-->
+
+<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+ <alternatives>
+ <class>test.beans.wbinflib.TestAlternativeBeanInWebInfLib</class>
+ </alternatives>
+</beans>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/descriptor/beans.xml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/descriptor/beans.xml
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/descriptor/persistence.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/descriptor/persistence.xml
new file mode 100644
index 0000000..82f2d7b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/descriptor/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (c) 1997, 2018 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
+
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+ <persistence-unit name="pu1" transaction-type="JTA">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ <jta-data-source>jdbc/__default</jta-data-source>
+ <non-jta-data-source>jdbc/__default</non-jta-data-source>
+ <class>myapp.Department</class>
+ <class>myapp.Employee</class>
+ <properties>
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+ <property name="eclipselink.logging.level" value="INFO"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/lib/slf4j-api-1.7.25.jar b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/lib/slf4j-api-1.7.25.jar
new file mode 100644
index 0000000..0143c09
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/lib/slf4j-api-1.7.25.jar
Binary files differ
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/lib/slf4j-simple-1.7.25.jar b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/lib/slf4j-simple-1.7.25.jar
new file mode 100644
index 0000000..a7260f3
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/lib/slf4j-simple-1.7.25.jar
Binary files differ
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/services/javax.enterprise.inject.spi.Extension b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/services/javax.enterprise.inject.spi.Extension
new file mode 100644
index 0000000..ac73a52
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/services/javax.enterprise.inject.spi.Extension
@@ -0,0 +1,2 @@
+test.beans.wbinflib.TestExtensionInWebInfLib
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/beans/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/beans/TestBean.java
new file mode 100644
index 0000000..34ae7eb
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/beans/TestBean.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, 2018 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
+ */
+
+package test.beans;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+import test.beans.artifacts.Preferred;
+
+
+@RequestScoped
+@Preferred
+public class TestBean implements TestBeanInterface{
+ public static boolean testBeanInvoked = false;
+
+ @Inject //@TestDatabase
+ EntityManager emf;
+
+ @Override
+ public void m1() {
+ testBeanInvoked = true;
+ System.out.println("TestBean::m1 called");
+ }
+
+ @Override
+ public void m2() {
+ System.out.println("TestBean::m2 called");
+ }
+
+ @Override
+ public String testDatasourceInjection() {
+ return (emf==null ? "typesafe injection into testbean failed" : "");
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/beans/TestBeanInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/beans/TestBeanInterface.java
new file mode 100644
index 0000000..29e137a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/beans/TestBeanInterface.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans;
+
+public interface TestBeanInterface {
+ public void m1();
+ public void m2();
+
+ public String testDatasourceInjection();
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/beans/TestLoggerProducer.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/beans/TestLoggerProducer.java
new file mode 100644
index 0000000..5d6b389
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/beans/TestLoggerProducer.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans;
+import javax.enterprise.inject.Produces;
+
+
+public class TestLoggerProducer {
+ @Produces
+ public org.jboss.logging.Logger getLogger(){
+ org.jboss.logging.Logger l = org.jboss.logging.Logger.getLogger(TestLoggerProducer.class);
+ System.out.println("getLogger:: " + l);
+ return l;
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/beans/artifacts/Preferred.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/beans/artifacts/Preferred.java
new file mode 100644
index 0000000..b7584c8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/beans/artifacts/Preferred.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Preferred {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/beans/artifacts/TestDatabase.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/beans/artifacts/TestDatabase.java
new file mode 100644
index 0000000..b69ab8e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/beans/artifacts/TestDatabase.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface TestDatabase {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/entity/Department.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/entity/Department.java
new file mode 100644
index 0000000..14191ec
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/entity/Department.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.entity;
+
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "DEPARTMENT")
+public class Department implements java.io.Serializable {
+
+ // Instance variables
+ private int id;
+ private String name;
+ private Set<Employee> employees;
+
+ public Department() {
+ }
+
+ public Department(int id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ // ===========================================================
+ // getters and setters for the state fields
+
+ @Id
+ @Column(name = "ID")
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Column(name = "NAME")
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ // ===========================================================
+ // getters and setters for the association fields
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "department")
+ public Set<Employee> getEmployees() {
+ return employees;
+ }
+
+ public void setEmployees(Set<Employee> employees) {
+ this.employees = employees;
+ }
+
+ public String toString() {
+ return "Department id=" + getId() + ", Department Name=" + getName();
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/entity/Employee.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/entity/Employee.java
new file mode 100644
index 0000000..a1820e8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/entity/Employee.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+@Entity
+@Table(name = "EMPLOYEE")
+public class Employee implements java.io.Serializable {
+
+ private int id;
+ private String firstName;
+ private String lastName;
+ private Department department;
+
+ public Employee() {
+ }
+
+ public Employee(int id, String firstName, String lastName) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+ public Employee(int id, String firstName, String lastName,
+ Department department) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.department = department;
+ }
+
+ // ===========================================================
+ // getters and setters for the state fields
+ @Id
+ @Column(name = "ID")
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Column(name = "FIRSTNAME")
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ @Column(name = "LASTNAME")
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ // ===========================================================
+ // getters and setters for the association fields
+ // @ManyToOne
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "DEPARTMENT_ID")
+ public Department getDepartment() {
+ return department;
+ }
+
+ @Transient
+ public Department getDepartmentNoWeaving() {
+ try {
+ java.lang.reflect.Field f = Employee.class
+ .getDeclaredField("department");
+ return (Department) f.get(this);
+ } catch (NoSuchFieldException e) {
+ throw new RuntimeException(
+ "Please change argument to getDeclaredField", e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void setDepartment(Department department) {
+ this.department = department;
+ }
+
+ public String toString() {
+ return "Employee id=" + getId() + ", firstName=" + getFirstName()
+ + ", lastName=" + getLastName() + ", department="
+ + getDepartment();
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/servlet/TestServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/servlet/TestServlet.java
new file mode 100644
index 0000000..d06d708
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/servlet/TestServlet.java
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Set;
+
+import javax.annotation.Resource;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Inject;
+import javax.naming.InitialContext;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebInitParam;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.transaction.UserTransaction;
+
+import test.beans.TestBean;
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+import test.beans.wbinflib.AnotherTestBeanInWebInfLib;
+import test.beans.wbinflib.TestAlternativeBeanInWebInfLib;
+import test.beans.wbinflib.TestBeanInWebInfLib;
+import test.util.JpaTest;
+
+@WebServlet(name="mytest",
+ urlPatterns={"/myurl"},
+ initParams={ @WebInitParam(name="n1", value="v1"), @WebInitParam(name="n2", value="v2") } )
+public class TestServlet extends HttpServlet {
+
+ /* Normal injection of Beans */
+ @Inject
+ private transient org.jboss.logging.Logger log;
+ @Inject BeanManager bm_at_inj;
+
+ /*Injection of Java EE resources*/
+ @PersistenceUnit(unitName = "pu1")
+ private EntityManagerFactory emf_at_pu;
+
+ @Inject //@TestDatabase
+ private EntityManager emf_at_inj;
+
+ private @Resource
+ UserTransaction utx;
+
+ @Inject @Preferred
+ TestBeanInterface tbi;
+
+ /* Injection of Beans from WEB-INF/lib */
+ @Inject TestBeanInWebInfLib tbiwil;
+ //We are injecting TestBeanInWebInfLib directly above. Since the alternative
+ //TestBean is not enabled in the WAR's BDA(beans.xml),
+ //TestBeanInWebInfLib must be injected
+
+
+ @Inject AnotherTestBeanInWebInfLib atbiwil;
+ //However in this case, when AnotherTestBeanInWebInfLib tries to inject
+ //TestBeanInWebInfLib in its bean, it must inject TestAlternativeBeanInWebInfLib
+ //as the alternative bean is enabled in the WEB-INF/lib's BDA (beans.xml)
+
+ /* Test lookup of BeanManager*/
+ BeanManager bm_lookup;
+
+
+ public void service(HttpServletRequest req, HttpServletResponse res)
+ throws IOException, ServletException {
+
+ PrintWriter writer = res.getWriter();
+ String msg = "";
+ if (tbi == null) msg += "Bean injection into Servlet failed";
+ if (tbiwil == null) msg += "Bean injection of a TestBean in WEB-INF/lib into Servlet failed";
+ System.out.println("Test Bean from WEB-INF/lib=" + tbiwil);
+
+ System.out.println("BeanManager is " + bm_at_inj);
+ System.out.println("BeanManager via lookup is " + bm_lookup);
+ if (bm_at_inj == null) msg += "BeanManager Injection via @Inject failed";
+ try {
+ bm_lookup = (BeanManager)((new InitialContext()).lookup("java:comp/BeanManager"));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ msg += "BeanManager Injection via component environment lookup failed";
+ }
+ if (bm_lookup == null) msg += "BeanManager Injection via component environment lookup failed";
+
+ //Check if Beans in WAR(WEB-INF/classes) and WEB-INF/lib/*.jar are visible
+ //via BeanManager of WAR
+ Set warBeans = bm_at_inj.getBeans(TestBean.class,new AnnotationLiteral<Any>() {});
+ if (warBeans.size() != 1) msg += "TestBean in WAR is not available via the WAR BeanManager";
+
+ Set webinfLibBeans = bm_at_inj.getBeans(TestBeanInWebInfLib.class,new AnnotationLiteral<Any>() {});
+ if (webinfLibBeans.size() != 1) msg += "TestBean in WEB-INF/lib is not available via the WAR BeanManager";
+ System.out.println("Test Bean from WEB-INF/lib via BeanManager:" + webinfLibBeans);
+
+ //Ensure Alternative Beans enabled only in the context of web-inf/lib is
+ //not visible in WAR's BM
+ Set webinfLibAltBeans = bm_at_inj.getBeans(TestAlternativeBeanInWebInfLib.class,new AnnotationLiteral<Any>() {});
+ if (webinfLibAltBeans.size() != 0) msg += "TestAlternativeBean in WEB-INF/lib is available via the WAR BeanManager";
+ System.out.println("Test Bean from WEB-INF/lib via BeanManager:" + webinfLibAltBeans);
+
+ //Test injection of a Bean in WEB-INF/lib beans into Servlet
+ //and check that the Alternative bean is not called.
+ //The alternative bean in web-inf/lib is not enabled in the WAR's beans.xml
+ //and hence must not be visible.
+ TestAlternativeBeanInWebInfLib.clearStatus(); //clear status
+
+ String injectionOfBeanInWebInfLibResult = tbiwil.testInjection();
+ System.out.println("injectionWithAlternative returned: " + injectionOfBeanInWebInfLibResult);
+ if (injectionOfBeanInWebInfLibResult.equals ("Alternative")) {
+ msg += "Expected that the original TestBeanInWebInfLib is called, " +
+ "but instead got " + injectionOfBeanInWebInfLibResult + " instead";
+ }
+
+ if(TestAlternativeBeanInWebInfLib.ALTERNATIVE_BEAN_HAS_BEEN_CALLED) {
+ msg += "Alternate Bean is called even though it is not enabled in the WAR's beans.xml";
+ }
+
+ //Test injection into a bean in web-inf/lib
+ //In this case the alternative bean must be called, as it is enabled
+ //in the library jar's beans.xml and the injection of the Bean
+ //happens in the context of the library jar
+ TestAlternativeBeanInWebInfLib.clearStatus(); //clear status
+ String injectionWithAlternative2 = atbiwil.testInjection();
+ System.out.println("injectionWithAlternative returned: " + injectionWithAlternative2);
+ if (injectionWithAlternative2.equals ("Alternative")) {
+ //test injection successful
+ } else {
+ msg += "Expected alternative, but got " + injectionWithAlternative2 + " instead";
+ }
+
+ if (!TestAlternativeBeanInWebInfLib.ALTERNATIVE_BEAN_HAS_BEEN_CALLED) {
+ msg += "Alternative Bean enabled in WEB-INF/lib was not called " +
+ "when the injection happened in the context of a " +
+ "Bean in WEB-INF/lib where the alternative Bean was enabled";
+ }
+
+
+ msg += testEMInjection(req);
+
+ writer.write(msg + "\n");
+ }
+
+
+ private String testEMInjection(HttpServletRequest request) {
+ String msg = "";
+ EntityManager em = emf_at_inj;
+ System.out.println("JPAResourceInjectionServlet::createEM" +
+ "EntityManager=" + em);
+ String testcase = request.getParameter("testcase");
+ System.out.println("testcase=" + testcase);
+
+ if (testcase != null) {
+ JpaTest jt = new JpaTest(em, utx);
+ boolean status = false;
+ if ("llinit".equals(testcase)) {
+ status = jt.lazyLoadingInit();
+ } else if ("llfind".equals(testcase)) {
+ status = jt.lazyLoadingByFind(1);
+ } else if ("llquery".equals(testcase)) {
+ status = jt.lazyLoadingByQuery("Carla");
+ } else if ("llinj".equals(testcase)){
+ status = ((tbi != null) &&
+ (tbi.testDatasourceInjection().trim().length()==0));
+ }
+ if (status) {
+ msg += "";// pass
+ } else {
+ msg += (testcase + ":fail");
+ }
+ }
+ return msg;
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/util/JPAResourceProducer.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/util/JPAResourceProducer.java
new file mode 100644
index 0000000..2cf2827
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/util/JPAResourceProducer.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.util;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Singleton;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+@Singleton
+public class JPAResourceProducer {
+ @Produces @PersistenceContext(unitName="pu1")
+ //@TestDatabase
+ EntityManager customerDatabasePersistenceUnit;
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/util/JpaTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/util/JpaTest.java
new file mode 100644
index 0000000..3d47448
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/servlet/test/util/JpaTest.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.util;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Query;
+import javax.transaction.UserTransaction;
+
+import test.entity.Department;
+import test.entity.Employee;
+
+public class JpaTest {
+
+ private EntityManager em;
+ private UserTransaction utx;
+
+ private static Department deptRef[] = new Department[2];
+ private static Employee empRef[] = new Employee[5];
+
+ public JpaTest() {
+ }
+
+ public JpaTest(EntityManager em, UserTransaction utx) {
+ this.em = em;
+ this.utx = utx;
+ }
+
+ public boolean lazyLoadingInit() {
+ boolean status = false;
+ System.out.println("-----lazeLoadingInit()---------");
+ try {
+ deptRef[0] = new Department(1, "Engineering");
+ deptRef[1] = new Department(2, "Marketing");
+ utx.begin();
+ em.joinTransaction();
+ for (int i = 0; i < 2; i++) {
+ em.persist(deptRef[i]);
+ }
+ utx.commit();
+
+ empRef[0] = new Employee(1, "Alan", "Frechette", deptRef[0]);
+ empRef[1] = new Employee(2, "Arthur", "Wesley", deptRef[0]);
+ empRef[2] = new Employee(3, "Abe", "White", deptRef[0]);
+ empRef[3] = new Employee(4, "Paul", "Hinz", deptRef[1]);
+ empRef[4] = new Employee(5, "Carla", "Calrson", deptRef[1]);
+ utx.begin();
+ em.joinTransaction();
+ for (int i = 0; i < 5; i++) {
+ em.persist(empRef[i]);
+ }
+ utx.commit();
+ status = true;
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ System.out.println("-----status = " + status + "---------");
+ return status;
+ }
+
+ public boolean lazyLoadingByFind(int employeeID) {
+
+ boolean status = true;
+ System.out.println("------------lazyLoadingAfterFind -----------");
+ System.out.println("employeeID = " + employeeID);
+ Employee emp = em.find(Employee.class, employeeID);
+
+ System.out.println("found: emp.id=" + emp.getId());
+
+ try {
+ // 1. get Department before loading
+ Department deptBL = emp.getDepartmentNoWeaving();
+ System.out.println("1. before loading: deptBL=" + deptBL);
+ String deptNameBL = null;
+ if (deptBL != null) {
+ deptNameBL = deptBL.getName();
+ System.out.println("deptNameBL=" + deptNameBL);
+ }
+ // assert deptBL == null;
+ if (deptBL != null) {
+ status = false;
+ }
+
+ // 2. loading
+ String deptName = emp.getDepartment().getName();
+ System.out.println("2. loading, deptName = " + deptName);
+
+ // 3. get Department after loading
+ Department deptAL = emp.getDepartmentNoWeaving();
+ System.out.println("3. after loading: deptAL=" + deptAL);
+ String deptNameAL = deptAL.getName();
+ System.out.println("deptNameAL=" + deptNameAL);
+ // assert deptAL != null
+ // assert deptAL.getName == deptName;
+ if (deptAL == null || deptNameAL != deptName) {
+ status = false;
+ }
+ } catch (Exception ex) {
+ status = false;
+ ex.printStackTrace();
+ }
+
+ System.out.println("-----status = " + status + "---------");
+ return status;
+ }
+
+ public boolean lazyLoadingByQuery(String fName) {
+
+ boolean status = true;
+ System.out.println("------------lazyLoadingByQuery -----------");
+ System.out.println("fName = " + fName);
+ Query query = em.createQuery(
+ "SELECT e FROM Employee e WHERE e.firstName like :firstName")
+ .setParameter("firstName", fName);
+ ;
+ Employee emp = (Employee) query.getSingleResult();
+
+ System.out.println("queried: emp.firstName=" + emp.getFirstName());
+
+ try {
+ // 1. get Department before loading
+ Department deptBL = emp.getDepartmentNoWeaving();
+ System.out.println("1. before loading: deptBL=" + deptBL);
+ String deptNameBL = null;
+ if (deptBL != null) {
+ deptNameBL = deptBL.getName();
+ System.out.println("deptNameBL=" + deptNameBL);
+ }
+ // assert deptBL == null;
+ if (deptBL != null) {
+ status = false;
+ }
+
+ // 2. loading
+ String deptName = emp.getDepartment().getName();
+ System.out.println("2. loading, deptName = " + deptName);
+
+ // 3. get Department after loading
+ Department deptAL = emp.getDepartmentNoWeaving();
+ System.out.println("3. after loading: deptAL=" + deptAL);
+ String deptNameAL = deptAL.getName();
+ System.out.println("deptNameAL=" + deptNameAL);
+ // assert deptAL != null
+ // assert deptAL.getName == deptName;
+ if (deptAL == null || deptNameAL != deptName) {
+ status = false;
+ }
+ } catch (Exception ex) {
+ status = false;
+ ex.printStackTrace();
+ }
+ System.out.println("-----status = " + status + "---------");
+ return status;
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/util/test/beans/wbinflib/AnotherTestBeanInWebInfLib.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/util/test/beans/wbinflib/AnotherTestBeanInWebInfLib.java
new file mode 100644
index 0000000..3140fe1
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/util/test/beans/wbinflib/AnotherTestBeanInWebInfLib.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2011, 2018 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
+ */
+
+package test.beans.wbinflib;
+
+import javax.inject.Inject;
+
+public class AnotherTestBeanInWebInfLib {
+ @Inject
+ TestBeanInWebInfLib twil; //Enabled alternative bean must be injected here, as this bean is within web-inf/lib BDA which has the enabled alternatives
+
+
+ public String testInjection() {
+ String ret = twil.testInjection();
+ return ret; //"Alternative"
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/util/test/beans/wbinflib/TestAlternativeBeanInWebInfLib.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/util/test/beans/wbinflib/TestAlternativeBeanInWebInfLib.java
new file mode 100644
index 0000000..45bbdb4
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/util/test/beans/wbinflib/TestAlternativeBeanInWebInfLib.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans.wbinflib;
+
+import javax.enterprise.inject.Alternative;
+
+@Alternative
+public class TestAlternativeBeanInWebInfLib extends TestBeanInWebInfLib {
+ public static boolean ALTERNATIVE_BEAN_HAS_BEEN_CALLED = false;
+ public TestAlternativeBeanInWebInfLib(){
+ System.out.println("**************** Alternative Bean in web-inf/lib created");
+ }
+
+ @Override
+ public String testInjection() {
+ ALTERNATIVE_BEAN_HAS_BEEN_CALLED = true;
+ System.out.println("*************** testinjection in alternative bean in web-inf/lib called");
+ return "Alternative";
+ }
+
+ public static void clearStatus(){
+ ALTERNATIVE_BEAN_HAS_BEEN_CALLED = false;
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/util/test/beans/wbinflib/TestBeanInWebInfLib.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/util/test/beans/wbinflib/TestBeanInWebInfLib.java
new file mode 100644
index 0000000..ccc108f
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/util/test/beans/wbinflib/TestBeanInWebInfLib.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans.wbinflib;
+import java.util.Set;
+
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+public class TestBeanInWebInfLib {
+ @Inject
+ BeanManager bm;
+
+// @Inject //@TestDatabase
+// EntityManager emf_at_inj;
+
+ @PersistenceContext(unitName="pu1")
+ EntityManager emf_at_pu;
+
+ //This test injection method would be called in the context of the servlet in WAR
+ //which does not have the alternative bean enabled in it.
+ public String testInjection() {
+ if (bm == null)
+ return "Bean Manager not injected into the TestBean in WEB-INF/lib";
+ System.out.println("BeanManager injected in WEB-INF/lib bean is " + bm);
+
+ System.out.println("EMF injected in WEB-INF/lib bean is " + emf_at_pu);
+ if (emf_at_pu == null)
+ return "EMF injected via @PersistenceContext is not injected into " +
+ "the TestBean packaged in WEB-INF/lib";
+
+ Set<Bean<?>> webinfLibBeans = bm.getBeans(TestBeanInWebInfLib.class, new AnnotationLiteral<Any>() {});
+ if (webinfLibBeans.size() != 2) //Bean and enabled Alternative
+ return "TestBean in WEB-INF/lib is not available via the WEB-INF/lib "
+ + "Bean's BeanManager";
+ System.out.println("***********************************************************");
+ printBeans(webinfLibBeans, "BeanManager.getBeans(TestBeanInWebInfLib, Any):");
+
+ Set<Bean<?>> webinfLibAltBeans = bm.getBeans(TestAlternativeBeanInWebInfLib.class, new AnnotationLiteral<Any>() {});
+ if (webinfLibBeans.size() != 1) //enabled Alternative
+ return "TestAlternativeBean in WEB-INF/lib is not available via the WEB-INF/lib "
+ + "Bean's BeanManager";
+ printBeans(webinfLibAltBeans, "BeanManager.getBeans(TestAlternativeBeanInWebInfLib, Any):");
+
+
+ Iterable<Bean<?>> accessibleBeans = ((org.jboss.weld.manager.BeanManagerImpl) bm).getAccessibleBeans();
+ printBeans(accessibleBeans, "BeanManagerImpl.getAccessibleBeans:");
+
+ Iterable<Bean<?>> beans = ((org.jboss.weld.manager.BeanManagerImpl) bm).getBeans();
+ printBeans(beans, "BeanManagerImpl.getBeans");
+ System.out.println("***********************************************************");
+
+ // success
+ return "";
+ }
+
+ private void printBeans(Iterable<Bean<?>> beans, String msg) {
+ System.out.println(msg + ":");
+ for (Bean b : beans) {
+ debug(b);
+ }
+ System.out.println();
+ }
+
+ private void debug(Bean b) {
+ String name = b.getBeanClass().getName();
+ if (name.indexOf("Test") != -1) {
+ System.out.print(name);
+ }
+
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/util/test/beans/wbinflib/TestExtensionInWebInfLib.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/util/test/beans/wbinflib/TestExtensionInWebInfLib.java
new file mode 100644
index 0000000..9f33e08
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-extension-alternative/util/test/beans/wbinflib/TestExtensionInWebInfLib.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans.wbinflib;
+
+import javax.enterprise.inject.spi.Extension;
+
+public class TestExtensionInWebInfLib implements Extension {
+//no-op
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/README
new file mode 100644
index 0000000..c4a8a73
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/README
@@ -0,0 +1 @@
+GLASSFISH-15749
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/WebTest.java
new file mode 100644
index 0000000..9eccfad
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/WebTest.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2010, 2018 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.net.*;
+
+import com.sun.ejte.ccl.reporter.*;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+ private static SimpleReporterAdapter stat
+ = new SimpleReporterAdapter("appserv-tests");
+ private static final String TEST_NAME = "cdi-servlet-annotation-with-web-inf-lib-javaee-injection";
+ private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0. initParams: n1=v1, n2=v2";
+
+ private String host;
+ private String port;
+ private String contextRoot;
+
+ public WebTest(String[] args) {
+ host = args[0];
+ port = args[1];
+ contextRoot = args[2];
+ }
+
+ public static void main(String[] args) {
+ stat.addDescription("Unit test for @WebServlet");
+ WebTest webTest = new WebTest(args);
+ webTest.doTest();
+ stat.printSummary(TEST_NAME);
+ }
+
+ public void doTest() {
+ try {
+ invoke("llinit");
+ invoke("llquery");
+ invoke("llfind");
+ invoke("llinj");
+ } catch (Exception ex) {
+ System.out.println(TEST_NAME + " test failed");
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ ex.printStackTrace();
+ }
+ }
+
+ private void invoke(String testCase) throws Exception {
+
+ String url = "http://" + host + ":" + port + contextRoot + "/myurl"
+ + "?testcase=" + testCase;
+ System.out.println("opening connection to " + url);
+ HttpURLConnection conn = (HttpURLConnection) (new URL(url))
+ .openConnection();
+
+ int code = conn.getResponseCode();
+ if (code != 200) {
+ System.out.println("Unexpected return code: " + code);
+ stat.addStatus(TEST_NAME + testCase, stat.FAIL);
+ } else {
+ InputStream is = null;
+ BufferedReader input = null;
+ String line = null;
+ try {
+ is = conn.getInputStream();
+ input = new BufferedReader(new InputStreamReader(is));
+ line = input.readLine();
+ System.out.println("line = " + line);
+ } finally {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch (IOException ioe) {
+ // ignore
+ }
+ try {
+ if (input != null) {
+ input.close();
+ }
+ } catch (IOException ioe) {
+ // ignore
+ }
+ }
+ if (EXPECTED_RESPONSE.equals(line)) {
+ stat.addStatus(TEST_NAME + testCase, stat.PASS);
+ } else {
+ System.out.println("Wrong response. Expected: "
+ + EXPECTED_RESPONSE + ", received: " + line);
+ stat.addStatus(TEST_NAME + testCase, stat.FAIL);
+ }
+ }
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/build.properties
new file mode 100644
index 0000000..cf2f0c0
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/build.properties
@@ -0,0 +1,25 @@
+<!--
+
+ Copyright (c) 2018 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
+
+-->
+
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-servlet-annotation-with-web-inf-lib-javaee-injection"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
+<property name="persistence.xml" value="descriptor/persistence.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/build.xml
new file mode 100644
index 0000000..42ccb47
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/build.xml
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (c) 2010, 2018 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
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+ &commonSetup;
+ &commonBuild;
+ &testproperties;
+ &run;
+
+ <target name="all" depends="build,create-resources,deploy,run,undeploy,delete-resources"/>
+
+ <target name="clean" depends="init-common">
+ <antcall target="clean-common"/>
+ <delete>
+ <fileset dir="." includes="*.class"/>
+ </delete>
+ <delete file="lib/bean-lib.jar"/>
+ </target>
+
+ <target name="compile" depends="clean">
+ <!-- create WEB-INF/lib/bean-lib.jar -->
+ <mkdir dir="${build.classes.dir}"/>
+ <mkdir dir="${build.classes.dir}/META-INF"/>
+ <javac srcdir="servlet" includes="TestBean.java" destdir="${build.classes.dir}" classpath="${s1astest.classpath}" debug="on" source="1.6"/>
+ <javac srcdir="util" destdir="${build.classes.dir}" classpath="${s1astest.classpath}" debug="on" source="1.6"/>
+ <copy file="descriptor/beans.xml" tofile="${build.classes.dir}/META-INF/beans.xml"/>
+ <delete file="${build.classes.dir}/TestBean.class" /> <!-- This is included in the WAR below -->
+
+ <jar destfile="lib/bean-lib.jar">
+ <fileset dir="${build.classes.dir}"/>
+ </jar>
+ <delete dir="${build.classes.dir}"/>
+
+ <!-- compile test servlet -->
+ <mkdir dir="${build.classes.dir}"/>
+ <echo message="common.xml: Compiling test source files" level="verbose"/>
+ <mkdir dir="servlet"/>
+ <javac srcdir="servlet" destdir="${build.classes.dir}" classpath="${s1astest.classpath}:lib/bean-lib.jar" debug="on" failonerror="true"/>
+ </target>
+
+ <target name="build" depends="compile">
+ <property name="hasWebclient" value="yes"/>
+ <antcall target="webclient-war-common">
+ <param name="hasWebclient" value="yes"/>
+ <param name="webclient.war.classes" value="**/*.class"/>
+ </antcall>
+
+ <javac srcdir="." classpath="${env.APS_HOME}/lib/reportbuilder.jar"
+ includes="WebTest.java"/>
+
+ </target>
+
+ <target name="build-publish-war" depends="build, publish-war-common" />
+
+ <target name="deploy" depends="init-common">
+ <antcall target="deploy-war-common"/>
+ </target>
+
+ <target name="create-resources" depends="init-common">
+ <antcall target="create-jdbc-connpool-common">
+ <param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+ </antcall>
+ <antcall target="create-jdbc-resource-common">
+ <param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+ <param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+ </antcall>
+ </target>
+
+ <target name="run" depends="init-common">
+ <java classname="WebTest">
+ <arg value="${http.host}"/>
+ <arg value="${http.port}"/>
+ <arg value="${contextroot}"/>
+ <classpath>
+ <pathelement location="${env.APS_HOME}/lib/reportbuilder.jar"/>
+ <pathelement location="."/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="undeploy" depends="init-common">
+ <antcall target="undeploy-war-common"/>
+ </target>
+
+ <target name="delete-resources" depends="init-common">
+ <antcall target="delete-jdbc-resource-common">
+ <param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+ </antcall>
+
+ <antcall target="delete-jdbc-connpool-common">
+ <param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+ </antcall>
+ </target>
+
+ <target name="usage">
+ <antcall target="usage-common"/>
+ </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/descriptor/beans.xml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/descriptor/beans.xml
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/descriptor/persistence.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/descriptor/persistence.xml
new file mode 100644
index 0000000..82f2d7b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/descriptor/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (c) 1997, 2018 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
+
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+ <persistence-unit name="pu1" transaction-type="JTA">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ <jta-data-source>jdbc/__default</jta-data-source>
+ <non-jta-data-source>jdbc/__default</non-jta-data-source>
+ <class>myapp.Department</class>
+ <class>myapp.Employee</class>
+ <properties>
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+ <property name="eclipselink.logging.level" value="INFO"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/lib/slf4j-api-1.7.25.jar b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/lib/slf4j-api-1.7.25.jar
new file mode 100644
index 0000000..0143c09
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/lib/slf4j-api-1.7.25.jar
Binary files differ
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/lib/slf4j-simple-1.7.25.jar b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/lib/slf4j-simple-1.7.25.jar
new file mode 100644
index 0000000..a7260f3
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/lib/slf4j-simple-1.7.25.jar
Binary files differ
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/beans/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/beans/TestBean.java
new file mode 100644
index 0000000..787108a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/beans/TestBean.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017, 2018 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
+ */
+
+package test.beans;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+import test.beans.artifacts.Preferred;
+
+@RequestScoped
+@Preferred
+public class TestBean implements TestBeanInterface{
+ public static boolean testBeanInvoked = false;
+
+ @Inject //@TestDatabase
+ EntityManager emf;
+
+ @Override
+ public void m1() {
+ testBeanInvoked = true;
+ System.out.println("TestBean::m1 called");
+ }
+
+ @Override
+ public void m2() {
+ System.out.println("TestBean::m2 called");
+ }
+
+ @Override
+ public String testDatasourceInjection() {
+ return (emf==null ? "typesafe injection into testbean failed" : "");
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/beans/TestBeanInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/beans/TestBeanInterface.java
new file mode 100644
index 0000000..29e137a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/beans/TestBeanInterface.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans;
+
+public interface TestBeanInterface {
+ public void m1();
+ public void m2();
+
+ public String testDatasourceInjection();
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/beans/TestLoggerProducer.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/beans/TestLoggerProducer.java
new file mode 100644
index 0000000..8be9d65
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/beans/TestLoggerProducer.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017, 2018 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
+ */
+
+package test.beans;
+
+import javax.enterprise.inject.Produces;
+
+
+public class TestLoggerProducer {
+ @Produces
+ public org.jboss.logging.Logger getLogger(){
+ org.jboss.logging.Logger l = org.jboss.logging.Logger.getLogger(TestLoggerProducer.class);
+ System.out.println("getLogger:: " + l);
+ return l;
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/beans/artifacts/Preferred.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/beans/artifacts/Preferred.java
new file mode 100644
index 0000000..b7584c8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/beans/artifacts/Preferred.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Preferred {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/beans/artifacts/TestDatabase.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/beans/artifacts/TestDatabase.java
new file mode 100644
index 0000000..b69ab8e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/beans/artifacts/TestDatabase.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface TestDatabase {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/entity/Department.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/entity/Department.java
new file mode 100644
index 0000000..14191ec
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/entity/Department.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.entity;
+
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "DEPARTMENT")
+public class Department implements java.io.Serializable {
+
+ // Instance variables
+ private int id;
+ private String name;
+ private Set<Employee> employees;
+
+ public Department() {
+ }
+
+ public Department(int id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ // ===========================================================
+ // getters and setters for the state fields
+
+ @Id
+ @Column(name = "ID")
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Column(name = "NAME")
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ // ===========================================================
+ // getters and setters for the association fields
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "department")
+ public Set<Employee> getEmployees() {
+ return employees;
+ }
+
+ public void setEmployees(Set<Employee> employees) {
+ this.employees = employees;
+ }
+
+ public String toString() {
+ return "Department id=" + getId() + ", Department Name=" + getName();
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/entity/Employee.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/entity/Employee.java
new file mode 100644
index 0000000..a1820e8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/entity/Employee.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+@Entity
+@Table(name = "EMPLOYEE")
+public class Employee implements java.io.Serializable {
+
+ private int id;
+ private String firstName;
+ private String lastName;
+ private Department department;
+
+ public Employee() {
+ }
+
+ public Employee(int id, String firstName, String lastName) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+ public Employee(int id, String firstName, String lastName,
+ Department department) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.department = department;
+ }
+
+ // ===========================================================
+ // getters and setters for the state fields
+ @Id
+ @Column(name = "ID")
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Column(name = "FIRSTNAME")
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ @Column(name = "LASTNAME")
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ // ===========================================================
+ // getters and setters for the association fields
+ // @ManyToOne
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "DEPARTMENT_ID")
+ public Department getDepartment() {
+ return department;
+ }
+
+ @Transient
+ public Department getDepartmentNoWeaving() {
+ try {
+ java.lang.reflect.Field f = Employee.class
+ .getDeclaredField("department");
+ return (Department) f.get(this);
+ } catch (NoSuchFieldException e) {
+ throw new RuntimeException(
+ "Please change argument to getDeclaredField", e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void setDepartment(Department department) {
+ this.department = department;
+ }
+
+ public String toString() {
+ return "Employee id=" + getId() + ", firstName=" + getFirstName()
+ + ", lastName=" + getLastName() + ", department="
+ + getDepartment();
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/servlet/TestServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/servlet/TestServlet.java
new file mode 100644
index 0000000..80a1932
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/servlet/TestServlet.java
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Set;
+
+import javax.annotation.Resource;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Inject;
+import javax.naming.InitialContext;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebInitParam;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.transaction.UserTransaction;
+
+import test.beans.TestBean;
+import test.beans.TestBeanInterface;
+import test.beans.artifacts.Preferred;
+import test.util.JpaTest;
+
+import test.beans.wbinflib.TestBeanInWebInfLib;
+
+@WebServlet(name="mytest",
+ urlPatterns={"/myurl"},
+ initParams={ @WebInitParam(name="n1", value="v1"), @WebInitParam(name="n2", value="v2") } )
+public class TestServlet extends HttpServlet {
+
+ /* Normal injection of Beans */
+ @Inject
+ private transient org.jboss.logging.Logger log;
+ @Inject BeanManager bm_at_inj;
+
+ /*Injection of Java EE resources*/
+ @PersistenceUnit(unitName = "pu1")
+ private EntityManagerFactory emf_at_pu;
+
+ @Inject //@TestDatabase
+ private EntityManager emf_at_inj;
+
+ private @Resource
+ UserTransaction utx;
+
+ @Inject @Preferred
+ TestBeanInterface tbi;
+
+ /* Injection of Beans from WEB-INF/lib */
+ @Inject TestBeanInWebInfLib tbiwil;
+
+ /* Test lookup of BeanManager*/
+ BeanManager bm_lookup;
+
+
+ public void service(HttpServletRequest req, HttpServletResponse res)
+ throws IOException, ServletException {
+
+ PrintWriter writer = res.getWriter();
+ writer.write("Hello from Servlet 3.0. ");
+ String msg = "n1=" + getInitParameter("n1") +
+ ", n2=" + getInitParameter("n2");
+
+ if (tbi == null) msg += "Bean injection into Servlet failed";
+ if (tbiwil == null) msg += "Bean injection of a TestBean in WEB-INF/lib into Servlet failed";
+ System.out.println("Test Bean from WEB-INF/lib=" + tbiwil);
+
+ System.out.println("BeanManager is " + bm_at_inj);
+ System.out.println("BeanManager via lookup is " + bm_lookup);
+ if (bm_at_inj == null) msg += "BeanManager Injection via @Inject failed";
+ try {
+ bm_lookup = (BeanManager)((new InitialContext()).lookup("java:comp/BeanManager"));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ msg += "BeanManager Injection via component environment lookup failed";
+ }
+ if (bm_lookup == null) msg += "BeanManager Injection via component environment lookup failed";
+
+ //Check if Beans in WAR(WEB-INF/classes) and WEB-INF/lib/*.jar are visible
+ //via BeanManager of WAR
+ Set warBeans = bm_at_inj.getBeans(TestBean.class,new AnnotationLiteral<Any>() {});
+ if (warBeans.size() != 1) msg += "TestBean in WAR is not available via the WAR BeanManager";
+
+ Set webinfLibBeans = bm_at_inj.getBeans(TestBeanInWebInfLib.class,new AnnotationLiteral<Any>() {});
+ if (webinfLibBeans.size() != 1) msg += "TestBean in WEB-INF/lib is not available via the WAR BeanManager";
+ System.out.println("Test Bean from WEB-INF/lib via BeanManager:" + webinfLibBeans);
+
+ //Test injection into WEB-INF/lib beans
+ msg += tbiwil.testInjection();
+
+ msg += testEMInjection(req);
+
+ writer.write("initParams: " + msg + "\n");
+ }
+
+
+ private String testEMInjection(HttpServletRequest request) {
+ String msg = "";
+ EntityManager em = emf_at_inj;
+ System.out.println("JPAResourceInjectionServlet::createEM" +
+ "EntityManager=" + em);
+ String testcase = request.getParameter("testcase");
+ System.out.println("testcase=" + testcase);
+
+ if (testcase != null) {
+ JpaTest jt = new JpaTest(em, utx);
+ boolean status = false;
+ if ("llinit".equals(testcase)) {
+ status = jt.lazyLoadingInit();
+ } else if ("llfind".equals(testcase)) {
+ status = jt.lazyLoadingByFind(1);
+ } else if ("llquery".equals(testcase)) {
+ status = jt.lazyLoadingByQuery("Carla");
+ } else if ("llinj".equals(testcase)){
+ status = ((tbi != null) &&
+ (tbi.testDatasourceInjection().trim().length()==0));
+ }
+ if (status) {
+ msg += "";// pass
+ } else {
+ msg += (testcase + ":fail");
+ }
+ }
+ return msg;
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/util/JPAResourceProducer.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/util/JPAResourceProducer.java
new file mode 100644
index 0000000..2cf2827
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/util/JPAResourceProducer.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.util;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Singleton;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+@Singleton
+public class JPAResourceProducer {
+ @Produces @PersistenceContext(unitName="pu1")
+ //@TestDatabase
+ EntityManager customerDatabasePersistenceUnit;
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/util/JpaTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/util/JpaTest.java
new file mode 100644
index 0000000..3d47448
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/servlet/test/util/JpaTest.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.util;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Query;
+import javax.transaction.UserTransaction;
+
+import test.entity.Department;
+import test.entity.Employee;
+
+public class JpaTest {
+
+ private EntityManager em;
+ private UserTransaction utx;
+
+ private static Department deptRef[] = new Department[2];
+ private static Employee empRef[] = new Employee[5];
+
+ public JpaTest() {
+ }
+
+ public JpaTest(EntityManager em, UserTransaction utx) {
+ this.em = em;
+ this.utx = utx;
+ }
+
+ public boolean lazyLoadingInit() {
+ boolean status = false;
+ System.out.println("-----lazeLoadingInit()---------");
+ try {
+ deptRef[0] = new Department(1, "Engineering");
+ deptRef[1] = new Department(2, "Marketing");
+ utx.begin();
+ em.joinTransaction();
+ for (int i = 0; i < 2; i++) {
+ em.persist(deptRef[i]);
+ }
+ utx.commit();
+
+ empRef[0] = new Employee(1, "Alan", "Frechette", deptRef[0]);
+ empRef[1] = new Employee(2, "Arthur", "Wesley", deptRef[0]);
+ empRef[2] = new Employee(3, "Abe", "White", deptRef[0]);
+ empRef[3] = new Employee(4, "Paul", "Hinz", deptRef[1]);
+ empRef[4] = new Employee(5, "Carla", "Calrson", deptRef[1]);
+ utx.begin();
+ em.joinTransaction();
+ for (int i = 0; i < 5; i++) {
+ em.persist(empRef[i]);
+ }
+ utx.commit();
+ status = true;
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ System.out.println("-----status = " + status + "---------");
+ return status;
+ }
+
+ public boolean lazyLoadingByFind(int employeeID) {
+
+ boolean status = true;
+ System.out.println("------------lazyLoadingAfterFind -----------");
+ System.out.println("employeeID = " + employeeID);
+ Employee emp = em.find(Employee.class, employeeID);
+
+ System.out.println("found: emp.id=" + emp.getId());
+
+ try {
+ // 1. get Department before loading
+ Department deptBL = emp.getDepartmentNoWeaving();
+ System.out.println("1. before loading: deptBL=" + deptBL);
+ String deptNameBL = null;
+ if (deptBL != null) {
+ deptNameBL = deptBL.getName();
+ System.out.println("deptNameBL=" + deptNameBL);
+ }
+ // assert deptBL == null;
+ if (deptBL != null) {
+ status = false;
+ }
+
+ // 2. loading
+ String deptName = emp.getDepartment().getName();
+ System.out.println("2. loading, deptName = " + deptName);
+
+ // 3. get Department after loading
+ Department deptAL = emp.getDepartmentNoWeaving();
+ System.out.println("3. after loading: deptAL=" + deptAL);
+ String deptNameAL = deptAL.getName();
+ System.out.println("deptNameAL=" + deptNameAL);
+ // assert deptAL != null
+ // assert deptAL.getName == deptName;
+ if (deptAL == null || deptNameAL != deptName) {
+ status = false;
+ }
+ } catch (Exception ex) {
+ status = false;
+ ex.printStackTrace();
+ }
+
+ System.out.println("-----status = " + status + "---------");
+ return status;
+ }
+
+ public boolean lazyLoadingByQuery(String fName) {
+
+ boolean status = true;
+ System.out.println("------------lazyLoadingByQuery -----------");
+ System.out.println("fName = " + fName);
+ Query query = em.createQuery(
+ "SELECT e FROM Employee e WHERE e.firstName like :firstName")
+ .setParameter("firstName", fName);
+ ;
+ Employee emp = (Employee) query.getSingleResult();
+
+ System.out.println("queried: emp.firstName=" + emp.getFirstName());
+
+ try {
+ // 1. get Department before loading
+ Department deptBL = emp.getDepartmentNoWeaving();
+ System.out.println("1. before loading: deptBL=" + deptBL);
+ String deptNameBL = null;
+ if (deptBL != null) {
+ deptNameBL = deptBL.getName();
+ System.out.println("deptNameBL=" + deptNameBL);
+ }
+ // assert deptBL == null;
+ if (deptBL != null) {
+ status = false;
+ }
+
+ // 2. loading
+ String deptName = emp.getDepartment().getName();
+ System.out.println("2. loading, deptName = " + deptName);
+
+ // 3. get Department after loading
+ Department deptAL = emp.getDepartmentNoWeaving();
+ System.out.println("3. after loading: deptAL=" + deptAL);
+ String deptNameAL = deptAL.getName();
+ System.out.println("deptNameAL=" + deptNameAL);
+ // assert deptAL != null
+ // assert deptAL.getName == deptName;
+ if (deptAL == null || deptNameAL != deptName) {
+ status = false;
+ }
+ } catch (Exception ex) {
+ status = false;
+ ex.printStackTrace();
+ }
+ System.out.println("-----status = " + status + "---------");
+ return status;
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/util/test/beans/wbinflib/TestBeanInWebInfLib.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/util/test/beans/wbinflib/TestBeanInWebInfLib.java
new file mode 100644
index 0000000..8e89576
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-javaee-injection/util/test/beans/wbinflib/TestBeanInWebInfLib.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2017, 2018 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
+ */
+
+package test.beans.wbinflib;
+
+import java.util.Set;
+
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+public class TestBeanInWebInfLib {
+ @Inject
+ BeanManager bm;
+
+// @Inject //@TestDatabase
+// EntityManager emf_at_inj;
+
+ @PersistenceContext(unitName="pu1")
+ EntityManager emf_at_pu;
+
+ public String testInjection() {
+ if (bm == null)
+ return "Bean Manager not injected into the TestBean in WEB-INF/lib";
+ System.out.println("BeanManager injected in WEB-INF/lib bean is " + bm);
+
+ System.out.println("EMF injected in WEB-INF/lib bean is " + emf_at_pu);
+ if (emf_at_pu == null)
+ return "EMF injected via @PersistenceContext is not injected into " +
+ "the TestBean packaged in WEB-INF/lib";
+
+ Set<Bean<?>> webinfLibBeans = bm.getBeans(TestBeanInWebInfLib.class, new AnnotationLiteral<Any>() {});
+ if (webinfLibBeans.size() != 1)
+ return "TestBean in WEB-INF/lib is not available via the WEB-INF/lib "
+ + "Bean's BeanManager";
+ System.out.println("BeanManager.getBeans(TestBeanInWebInfLib, Any):" + webinfLibBeans);
+ for (Bean b: webinfLibBeans) {
+ debug(b);
+ }
+
+ // Get the proxy delegate
+ org.jboss.weld.manager.BeanManagerImpl delegate =
+ ((org.jboss.weld.bean.builtin.BeanManagerProxy) bm).delegate();
+
+ Iterable<Bean<?>> accessibleBeans = delegate.getAccessibleBeans();
+ System.out.println("BeanManagerImpl.getAccessibleBeans:" + accessibleBeans);
+ for (Bean b : accessibleBeans) {
+ debug(b);
+ }
+
+ Iterable<Bean<?>> beans = delegate.getBeans();
+ System.out.println("BeanManagerImpl.getBeans:" + beans);
+ for (Bean b : beans) {
+ debug(b);
+ }
+ // success
+ return "";
+ }
+
+ private void debug(Bean b) {
+ String name = b.getBeanClass().getName();
+ if (name.indexOf("Test") != -1) {
+ System.out.println(name);
+ }
+
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/README
new file mode 100644
index 0000000..b055956
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/README
@@ -0,0 +1,5 @@
+GLASSFISH-15735 scenario
+with the ordering reversed.
+alpha.jar has "Bar"(that requires Foo to be injected)
+bravo.jar has "Foo"
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/WebTest.java
new file mode 100644
index 0000000..1481991
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/WebTest.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2010, 2018 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.net.*;
+import com.sun.ejte.ccl.reporter.*;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+ private static SimpleReporterAdapter stat
+ = new SimpleReporterAdapter("appserv-tests");
+ private static final String TEST_NAME = "cdi-servlet-annotation-with-web-inf-lib-with-ordering-reversed";
+ private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0. initParams: n1=v1, n2=v2";
+
+ private String host;
+ private String port;
+ private String contextRoot;
+
+ public WebTest(String[] args) {
+ host = args[0];
+ port = args[1];
+ contextRoot = args[2];
+ }
+
+ public static void main(String[] args) {
+ stat.addDescription("Unit test for @WebServlet");
+ WebTest webTest = new WebTest(args);
+ webTest.doTest();
+ stat.printSummary(TEST_NAME);
+ }
+
+ public void doTest() {
+ try {
+ invoke();
+ } catch (Exception ex) {
+ System.out.println(TEST_NAME + " test failed");
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ ex.printStackTrace();
+ }
+ }
+
+ private void invoke() throws Exception {
+
+ String url = "http://" + host + ":" + port + contextRoot
+ + "/myurl";
+ System.out.println("opening connection to " + url);
+ HttpURLConnection conn = (HttpURLConnection)
+ (new URL(url)).openConnection();
+
+ int code = conn.getResponseCode();
+ if (code != 200) {
+ System.out.println("Unexpected return code: " + code);
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ } else {
+ InputStream is = null;
+ BufferedReader input = null;
+ String line = null;
+ try {
+ is = conn.getInputStream();
+ input = new BufferedReader(new InputStreamReader(is));
+ line = input.readLine();
+ System.out.println("line = " + line);
+ } finally {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch(IOException ioe) {
+ // ignore
+ }
+ try {
+ if (input != null) {
+ input.close();
+ }
+ } catch(IOException ioe) {
+ // ignore
+ }
+ }
+ if (EXPECTED_RESPONSE.equals(line)) {
+ stat.addStatus(TEST_NAME, stat.PASS);
+ } else {
+ System.out.println("Wrong response. Expected: " +
+ EXPECTED_RESPONSE + ", received: " + line);
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ }
+ }
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/build.properties
new file mode 100644
index 0000000..c6b5b5a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/build.properties
@@ -0,0 +1,24 @@
+<!--
+
+ Copyright (c) 2018 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
+
+-->
+
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-servlet-annotation-with-web-inf-lib-with-ordering-reversed"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/build.xml
new file mode 100644
index 0000000..66a8829
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/build.xml
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (c) 2010, 2018 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
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+ &commonSetup;
+ &commonBuild;
+ &testproperties;
+ &run;
+
+ <target name="all" depends="build,deploy,run,undeploy"/>
+
+ <target name="clean" depends="init-common">
+ <antcall target="clean-common"/>
+ <delete>
+ <fileset dir="." includes="*.class"/>
+ </delete>
+ <delete file="lib/alpha.jar"/>
+ <delete file="lib/bravo.jar"/>
+ </target>
+
+ <target name="compile" depends="clean">
+ <!-- create WEB-INF/lib/bravo.jar -->
+ <mkdir dir="${build.classes.dir}"/>
+ <mkdir dir="${build.classes.dir}/META-INF"/>
+ <javac srcdir="util1" destdir="${build.classes.dir}" classpath="${s1astest.classpath}" debug="on" source="1.6"/>
+ <copy file="descriptor/beans.xml" tofile="${build.classes.dir}/META-INF/beans.xml"/>
+ <jar destfile="lib/bravo.jar">
+ <fileset dir="${build.classes.dir}"/>
+ </jar>
+ <delete dir="${build.classes.dir}"/>
+
+ <!-- create WEB-INF/lib/alpha.jar -->
+ <mkdir dir="${build.classes.dir}"/>
+ <mkdir dir="${build.classes.dir}/META-INF"/>
+ <javac srcdir="util1" destdir="${build.classes.dir}" classpath="${s1astest.classpath}" debug="on" source="1.6"/>
+ <javac srcdir="util2" destdir="${build.classes.dir}" classpath="${s1astest.classpath}" debug="on" source="1.6"/>
+ <delete file="${build.classes.dir}/Foo.class"/>
+ <copy file="descriptor/beans.xml" tofile="${build.classes.dir}/META-INF/beans.xml"/>
+ <jar destfile="lib/alpha.jar">
+ <fileset dir="${build.classes.dir}"/>
+ </jar>
+ <delete dir="${build.classes.dir}"/>
+
+ <!-- compile test servlet -->
+ <mkdir dir="${build.classes.dir}"/>
+ <echo message="common.xml: Compiling test source files" level="verbose"/>
+ <mkdir dir="servlet"/>
+ <javac srcdir="servlet" destdir="${build.classes.dir}" classpath="${s1astest.classpath}:lib/alpha.jar:lib/bravo.jar" debug="on" failonerror="true"/>
+ </target>
+
+ <target name="build" depends="compile">
+ <property name="hasWebclient" value="yes"/>
+ <antcall target="webclient-war-common">
+ <param name="hasWebclient" value="yes"/>
+ <param name="webclient.war.classes" value="**/*.class"/>
+ </antcall>
+
+ <javac srcdir="." classpath="${env.APS_HOME}/lib/reportbuilder.jar"
+ includes="WebTest.java"/>
+
+ </target>
+
+ <target name="build-publish-war" depends="build, publish-war-common" />
+
+ <target name="deploy" depends="init-common">
+ <antcall target="deploy-war-common"/>
+ </target>
+
+ <target name="run" depends="init-common">
+ <java classname="WebTest">
+ <arg value="${http.host}"/>
+ <arg value="${http.port}"/>
+ <arg value="${contextroot}"/>
+ <classpath>
+ <pathelement location="${env.APS_HOME}/lib/reportbuilder.jar"/>
+ <pathelement location="."/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="undeploy" depends="init-common">
+ <antcall target="undeploy-war-common"/>
+ </target>
+
+ <target name="usage">
+ <antcall target="usage-common"/>
+ </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/descriptor/beans.xml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/descriptor/beans.xml
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/lib/slf4j-api-1.7.25.jar b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/lib/slf4j-api-1.7.25.jar
new file mode 100644
index 0000000..0143c09
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/lib/slf4j-api-1.7.25.jar
Binary files differ
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/lib/slf4j-simple-1.7.25.jar b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/lib/slf4j-simple-1.7.25.jar
new file mode 100644
index 0000000..a7260f3
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/lib/slf4j-simple-1.7.25.jar
Binary files differ
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/servlet/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/servlet/TestBean.java
new file mode 100644
index 0000000..c696caf
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/servlet/TestBean.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+//Simple TestBean to test CDI.
+public class TestBean
+{
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/servlet/TestLoggerProducer.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/servlet/TestLoggerProducer.java
new file mode 100644
index 0000000..f8e08a7
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/servlet/TestLoggerProducer.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017, 2018 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 javax.enterprise.inject.Produces;
+
+
+public class TestLoggerProducer {
+ @Produces
+ public org.jboss.logging.Logger getLogger(){
+ org.jboss.logging.Logger l = org.jboss.logging.Logger.getLogger(TestLoggerProducer.class);
+ System.out.println("getLogger:: " + l);
+ return l;
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/servlet/TestServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/servlet/TestServlet.java
new file mode 100644
index 0000000..e3cf013
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/servlet/TestServlet.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2010, 2018 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.IOException;
+import java.io.PrintWriter;
+import java.util.Enumeration;
+import java.util.Set;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebInitParam;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.inject.Inject;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.naming.InitialContext;
+
+@WebServlet(name="mytest",
+ urlPatterns={"/myurl"},
+ initParams={ @WebInitParam(name="n1", value="v1"), @WebInitParam(name="n2", value="v2") } )
+public class TestServlet extends HttpServlet {
+ @Inject TestBean tb;
+ @Inject BeanManager bm;
+
+ @Inject Foo f; //from WEB-INF/lib/alpha.jar
+ @Inject Bar b; //from WEB-INF/lib/bravo.jar
+
+
+ BeanManager bm1;
+
+ @Inject
+ private transient org.jboss.logging.Logger log;
+
+ public void service(HttpServletRequest req, HttpServletResponse res)
+ throws IOException, ServletException {
+
+ PrintWriter writer = res.getWriter();
+ writer.write("Hello from Servlet 3.0. ");
+ String msg = "n1=" + getInitParameter("n1") +
+ ", n2=" + getInitParameter("n2");
+
+ //Bean Injection
+ if (tb == null) msg += "Bean injection into Servlet failed";
+
+ if (f == null) msg += "Bean injection of a TestBean(foo) in WEB-INF/lib/alpha.jar into Servlet failed";
+ System.out.println("Test Bean foo from WEB-INF/lib/alpha.jar=" + f);
+
+ if (b == null) msg += "Bean injection of a TestBean(bar) in WEB-INF/lib/bravo.jar into Servlet failed";
+ System.out.println("Test Bean foo from WEB-INF/lib/bravo.jar=" + b);
+
+ //BeanManager Injection
+ System.out.println("BeanManager is " + bm);
+ if (bm == null) msg += "BeanManager Injection via @Inject failed";
+
+ try {
+ bm1 = (BeanManager)((new InitialContext()).lookup("java:comp/BeanManager"));
+ System.out.println("BeanManager via lookup is " + bm1);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ msg += "BeanManager Injection via component environment lookup failed";
+ }
+ if (bm1 == null) msg += "BeanManager Injection via component environment lookup failed";
+
+ //Check if Beans in WAR(WEB-INF/classes) and WEB-INF/lib/*.jar are visible
+ //via BeanManager of WAR
+ Set warBeans = bm.getBeans(TestBean.class,new AnnotationLiteral<Any>() {});
+ if (warBeans.size() != 1) msg += "TestBean in WAR is not available via the WAR BeanManager";
+
+ Set webinfLibBeans = bm.getBeans(Foo.class,new AnnotationLiteral<Any>() {});
+ if (webinfLibBeans.size() != 1) msg += "TestBean Foo in WEB-INF/lib/alpha.jar is not available via the WAR BeanManager";
+ System.out.println("Test Bean Foo from WEB-INF/lib/alpha.jar via BeanManager:" + webinfLibBeans);
+
+ webinfLibBeans = bm.getBeans(Bar.class,new AnnotationLiteral<Any>() {});
+ if (webinfLibBeans.size() != 1) msg += "TestBean Bar in WEB-INF/lib/bravo.jar is not available via the WAR BeanManager";
+ System.out.println("Test Bean Bar from WEB-INF/lib/bravo.jar via BeanManager:" + webinfLibBeans);
+
+ writer.write("initParams: " + msg + "\n");
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/util1/Foo.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/util1/Foo.java
new file mode 100644
index 0000000..9ee6ebb
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/util1/Foo.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2017, 2018 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
+ */
+
+@javax.enterprise.context.RequestScoped
+public class Foo {
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/util2/Bar.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/util2/Bar.java
new file mode 100644
index 0000000..f15bc53
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering-reversed/util2/Bar.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2017, 2018 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
+ */
+
+@javax.enterprise.context.RequestScoped
+public class Bar{
+@javax.inject.Inject
+Foo f;
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/README
new file mode 100644
index 0000000..78565b8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/README
@@ -0,0 +1,2 @@
+GLASSFISH-15735
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/WebTest.java
new file mode 100644
index 0000000..0bb3666
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/WebTest.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2010, 2018 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.net.*;
+import com.sun.ejte.ccl.reporter.*;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+ private static SimpleReporterAdapter stat
+ = new SimpleReporterAdapter("appserv-tests");
+ private static final String TEST_NAME = "cdi-servlet-annotation-with-web-inf-lib-with-ordering";
+ private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0. initParams: n1=v1, n2=v2";
+
+ private String host;
+ private String port;
+ private String contextRoot;
+
+ public WebTest(String[] args) {
+ host = args[0];
+ port = args[1];
+ contextRoot = args[2];
+ }
+
+ public static void main(String[] args) {
+ stat.addDescription("Unit test for @WebServlet");
+ WebTest webTest = new WebTest(args);
+ webTest.doTest();
+ stat.printSummary(TEST_NAME);
+ }
+
+ public void doTest() {
+ try {
+ invoke();
+ } catch (Exception ex) {
+ System.out.println(TEST_NAME + " test failed");
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ ex.printStackTrace();
+ }
+ }
+
+ private void invoke() throws Exception {
+
+ String url = "http://" + host + ":" + port + contextRoot
+ + "/myurl";
+ System.out.println("opening connection to " + url);
+ HttpURLConnection conn = (HttpURLConnection)
+ (new URL(url)).openConnection();
+
+ int code = conn.getResponseCode();
+ if (code != 200) {
+ System.out.println("Unexpected return code: " + code);
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ } else {
+ InputStream is = null;
+ BufferedReader input = null;
+ String line = null;
+ try {
+ is = conn.getInputStream();
+ input = new BufferedReader(new InputStreamReader(is));
+ line = input.readLine();
+ System.out.println("line = " + line);
+ } finally {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch(IOException ioe) {
+ // ignore
+ }
+ try {
+ if (input != null) {
+ input.close();
+ }
+ } catch(IOException ioe) {
+ // ignore
+ }
+ }
+ if (EXPECTED_RESPONSE.equals(line)) {
+ stat.addStatus(TEST_NAME, stat.PASS);
+ } else {
+ System.out.println("Wrong response. Expected: " +
+ EXPECTED_RESPONSE + ", received: " + line);
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ }
+ }
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/build.properties
new file mode 100644
index 0000000..542d011
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/build.properties
@@ -0,0 +1,24 @@
+<!--
+
+ Copyright (c) 2018 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
+
+-->
+
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-servlet-annotation-with-web-inf-lib-with-ordering"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/build.xml
new file mode 100644
index 0000000..3598ebd
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/build.xml
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (c) 2010, 2018 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
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+ &commonSetup;
+ &commonBuild;
+ &testproperties;
+ &run;
+
+ <target name="all" depends="build,deploy,run,undeploy"/>
+
+ <target name="clean" depends="init-common">
+ <antcall target="clean-common"/>
+ <delete>
+ <fileset dir="." includes="*.class"/>
+ </delete>
+ <delete file="lib/alpha.jar"/>
+ <delete file="lib/bravo.jar"/>
+ </target>
+
+ <target name="compile" depends="clean">
+ <!-- create WEB-INF/lib/alpha.jar -->
+ <mkdir dir="${build.classes.dir}"/>
+ <mkdir dir="${build.classes.dir}/META-INF"/>
+ <javac srcdir="util1" destdir="${build.classes.dir}" classpath="${s1astest.classpath}" debug="on" source="1.6"/>
+ <copy file="descriptor/beans.xml" tofile="${build.classes.dir}/META-INF/beans.xml"/>
+ <jar destfile="lib/alpha.jar">
+ <fileset dir="${build.classes.dir}"/>
+ </jar>
+ <delete dir="${build.classes.dir}"/>
+
+ <!-- create WEB-INF/lib/bravo.jar -->
+ <mkdir dir="${build.classes.dir}"/>
+ <mkdir dir="${build.classes.dir}/META-INF"/>
+ <javac srcdir="util1" destdir="${build.classes.dir}" classpath="${s1astest.classpath}" debug="on" source="1.6"/>
+ <javac srcdir="util2" destdir="${build.classes.dir}" classpath="${s1astest.classpath}" debug="on" source="1.6"/>
+ <delete file="${build.classes.dir}/Foo.class"/>
+ <copy file="descriptor/beans.xml" tofile="${build.classes.dir}/META-INF/beans.xml"/>
+ <jar destfile="lib/bravo.jar">
+ <fileset dir="${build.classes.dir}"/>
+ </jar>
+ <delete dir="${build.classes.dir}"/>
+
+ <!-- compile test servlet -->
+ <mkdir dir="${build.classes.dir}"/>
+ <echo message="common.xml: Compiling test source files" level="verbose"/>
+ <mkdir dir="servlet"/>
+ <javac srcdir="servlet" destdir="${build.classes.dir}" classpath="${s1astest.classpath}:lib/alpha.jar:lib/bravo.jar" debug="on" failonerror="true"/>
+ </target>
+
+ <target name="build" depends="compile">
+ <property name="hasWebclient" value="yes"/>
+ <antcall target="webclient-war-common">
+ <param name="hasWebclient" value="yes"/>
+ <param name="webclient.war.classes" value="**/*.class"/>
+ </antcall>
+
+ <javac srcdir="." classpath="${env.APS_HOME}/lib/reportbuilder.jar"
+ includes="WebTest.java"/>
+
+ </target>
+
+ <target name="build-publish-war" depends="build, publish-war-common" />
+
+ <target name="deploy" depends="init-common">
+ <antcall target="deploy-war-common"/>
+ </target>
+
+ <target name="run" depends="init-common">
+ <java classname="WebTest">
+ <arg value="${http.host}"/>
+ <arg value="${http.port}"/>
+ <arg value="${contextroot}"/>
+ <classpath>
+ <pathelement location="${env.APS_HOME}/lib/reportbuilder.jar"/>
+ <pathelement location="."/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="undeploy" depends="init-common">
+ <antcall target="undeploy-war-common"/>
+ </target>
+
+ <target name="usage">
+ <antcall target="usage-common"/>
+ </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/descriptor/beans.xml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/descriptor/beans.xml
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/lib/slf4j-api-1.7.25.jar b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/lib/slf4j-api-1.7.25.jar
new file mode 100644
index 0000000..0143c09
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/lib/slf4j-api-1.7.25.jar
Binary files differ
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/lib/slf4j-simple-1.7.25.jar b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/lib/slf4j-simple-1.7.25.jar
new file mode 100644
index 0000000..a7260f3
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/lib/slf4j-simple-1.7.25.jar
Binary files differ
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/servlet/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/servlet/TestBean.java
new file mode 100644
index 0000000..c696caf
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/servlet/TestBean.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+//Simple TestBean to test CDI.
+public class TestBean
+{
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/servlet/TestLoggerProducer.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/servlet/TestLoggerProducer.java
new file mode 100644
index 0000000..f8e08a7
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/servlet/TestLoggerProducer.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017, 2018 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 javax.enterprise.inject.Produces;
+
+
+public class TestLoggerProducer {
+ @Produces
+ public org.jboss.logging.Logger getLogger(){
+ org.jboss.logging.Logger l = org.jboss.logging.Logger.getLogger(TestLoggerProducer.class);
+ System.out.println("getLogger:: " + l);
+ return l;
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/servlet/TestServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/servlet/TestServlet.java
new file mode 100644
index 0000000..e3cf013
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/servlet/TestServlet.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2010, 2018 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.IOException;
+import java.io.PrintWriter;
+import java.util.Enumeration;
+import java.util.Set;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebInitParam;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.inject.Inject;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.naming.InitialContext;
+
+@WebServlet(name="mytest",
+ urlPatterns={"/myurl"},
+ initParams={ @WebInitParam(name="n1", value="v1"), @WebInitParam(name="n2", value="v2") } )
+public class TestServlet extends HttpServlet {
+ @Inject TestBean tb;
+ @Inject BeanManager bm;
+
+ @Inject Foo f; //from WEB-INF/lib/alpha.jar
+ @Inject Bar b; //from WEB-INF/lib/bravo.jar
+
+
+ BeanManager bm1;
+
+ @Inject
+ private transient org.jboss.logging.Logger log;
+
+ public void service(HttpServletRequest req, HttpServletResponse res)
+ throws IOException, ServletException {
+
+ PrintWriter writer = res.getWriter();
+ writer.write("Hello from Servlet 3.0. ");
+ String msg = "n1=" + getInitParameter("n1") +
+ ", n2=" + getInitParameter("n2");
+
+ //Bean Injection
+ if (tb == null) msg += "Bean injection into Servlet failed";
+
+ if (f == null) msg += "Bean injection of a TestBean(foo) in WEB-INF/lib/alpha.jar into Servlet failed";
+ System.out.println("Test Bean foo from WEB-INF/lib/alpha.jar=" + f);
+
+ if (b == null) msg += "Bean injection of a TestBean(bar) in WEB-INF/lib/bravo.jar into Servlet failed";
+ System.out.println("Test Bean foo from WEB-INF/lib/bravo.jar=" + b);
+
+ //BeanManager Injection
+ System.out.println("BeanManager is " + bm);
+ if (bm == null) msg += "BeanManager Injection via @Inject failed";
+
+ try {
+ bm1 = (BeanManager)((new InitialContext()).lookup("java:comp/BeanManager"));
+ System.out.println("BeanManager via lookup is " + bm1);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ msg += "BeanManager Injection via component environment lookup failed";
+ }
+ if (bm1 == null) msg += "BeanManager Injection via component environment lookup failed";
+
+ //Check if Beans in WAR(WEB-INF/classes) and WEB-INF/lib/*.jar are visible
+ //via BeanManager of WAR
+ Set warBeans = bm.getBeans(TestBean.class,new AnnotationLiteral<Any>() {});
+ if (warBeans.size() != 1) msg += "TestBean in WAR is not available via the WAR BeanManager";
+
+ Set webinfLibBeans = bm.getBeans(Foo.class,new AnnotationLiteral<Any>() {});
+ if (webinfLibBeans.size() != 1) msg += "TestBean Foo in WEB-INF/lib/alpha.jar is not available via the WAR BeanManager";
+ System.out.println("Test Bean Foo from WEB-INF/lib/alpha.jar via BeanManager:" + webinfLibBeans);
+
+ webinfLibBeans = bm.getBeans(Bar.class,new AnnotationLiteral<Any>() {});
+ if (webinfLibBeans.size() != 1) msg += "TestBean Bar in WEB-INF/lib/bravo.jar is not available via the WAR BeanManager";
+ System.out.println("Test Bean Bar from WEB-INF/lib/bravo.jar via BeanManager:" + webinfLibBeans);
+
+ writer.write("initParams: " + msg + "\n");
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/util1/Foo.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/util1/Foo.java
new file mode 100644
index 0000000..9ee6ebb
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/util1/Foo.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2017, 2018 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
+ */
+
+@javax.enterprise.context.RequestScoped
+public class Foo {
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/util2/Bar.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/util2/Bar.java
new file mode 100644
index 0000000..f15bc53
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib-ordering/util2/Bar.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2017, 2018 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
+ */
+
+@javax.enterprise.context.RequestScoped
+public class Bar{
+@javax.inject.Inject
+Foo f;
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/README
new file mode 100644
index 0000000..b004f04
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/README
@@ -0,0 +1,4 @@
+A simple WAR with a bean archive in WEB-INF/lib. The visibility of the Bean bundled in WAR(WEB-INF/classes) and WEB-INF/lib
+is tested in the WAR's BeanManager
+
+GLASSFISH-15721
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/WebTest.java
new file mode 100644
index 0000000..1ea710b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/WebTest.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2010, 2018 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.net.*;
+import com.sun.ejte.ccl.reporter.*;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+ private static SimpleReporterAdapter stat
+ = new SimpleReporterAdapter("appserv-tests");
+ private static final String TEST_NAME = "cdi-servlet-annotation-with-web-inf-lib";
+ private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0. initParams: n1=v1, n2=v2";
+
+ private String host;
+ private String port;
+ private String contextRoot;
+
+ public WebTest(String[] args) {
+ host = args[0];
+ port = args[1];
+ contextRoot = args[2];
+ }
+
+ public static void main(String[] args) {
+ stat.addDescription("Unit test for @WebServlet");
+ WebTest webTest = new WebTest(args);
+ webTest.doTest();
+ stat.printSummary(TEST_NAME);
+ }
+
+ public void doTest() {
+ try {
+ invoke();
+ } catch (Exception ex) {
+ System.out.println(TEST_NAME + " test failed");
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ ex.printStackTrace();
+ }
+ }
+
+ private void invoke() throws Exception {
+
+ String url = "http://" + host + ":" + port + contextRoot
+ + "/myurl";
+ System.out.println("opening connection to " + url);
+ HttpURLConnection conn = (HttpURLConnection)
+ (new URL(url)).openConnection();
+
+ int code = conn.getResponseCode();
+ if (code != 200) {
+ System.out.println("Unexpected return code: " + code);
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ } else {
+ InputStream is = null;
+ BufferedReader input = null;
+ String line = null;
+ try {
+ is = conn.getInputStream();
+ input = new BufferedReader(new InputStreamReader(is));
+ line = input.readLine();
+ System.out.println("line = " + line);
+ } finally {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch(IOException ioe) {
+ // ignore
+ }
+ try {
+ if (input != null) {
+ input.close();
+ }
+ } catch(IOException ioe) {
+ // ignore
+ }
+ }
+ if (EXPECTED_RESPONSE.equals(line)) {
+ stat.addStatus(TEST_NAME, stat.PASS);
+ } else {
+ System.out.println("Wrong response. Expected: " +
+ EXPECTED_RESPONSE + ", received: " + line);
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ }
+ }
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/build.properties
new file mode 100644
index 0000000..bb7bc8d
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/build.properties
@@ -0,0 +1,24 @@
+<!--
+
+ Copyright (c) 2018 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
+
+-->
+
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-servlet-annotation-with-web-inf-lib"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/build.xml
new file mode 100644
index 0000000..3b2d3f1
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/build.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (c) 2010, 2018 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
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+ &commonSetup;
+ &commonBuild;
+ &testproperties;
+ &run;
+
+ <target name="all" depends="build,deploy,run,undeploy"/>
+
+ <target name="clean" depends="init-common">
+ <antcall target="clean-common"/>
+ <delete>
+ <fileset dir="." includes="*.class"/>
+ </delete>
+ <delete file="lib/bean-lib.jar"/>
+ </target>
+
+ <target name="compile" depends="clean">
+ <!-- create WEB-INF/lib/bean-lib.jar -->
+ <mkdir dir="${build.classes.dir}"/>
+ <mkdir dir="${build.classes.dir}/META-INF"/>
+ <javac srcdir="servlet" includes="TestBean.java" destdir="${build.classes.dir}" classpath="${s1astest.classpath}" debug="on" source="1.6"/>
+ <javac srcdir="util" destdir="${build.classes.dir}" classpath="${s1astest.classpath}" debug="on" source="1.6"/>
+ <copy file="descriptor/beans.xml" tofile="${build.classes.dir}/META-INF/beans.xml"/>
+ <delete file="${build.classes.dir}/TestBean.class" /> <!-- This is included in the WAR below -->
+
+ <jar destfile="lib/bean-lib.jar">
+ <fileset dir="${build.classes.dir}"/>
+ </jar>
+ <delete dir="${build.classes.dir}"/>
+
+ <!-- compile test servlet -->
+ <mkdir dir="${build.classes.dir}"/>
+ <echo message="common.xml: Compiling test source files" level="verbose"/>
+ <mkdir dir="servlet"/>
+ <javac srcdir="servlet" destdir="${build.classes.dir}" classpath="${s1astest.classpath}:lib/bean-lib.jar" debug="on" failonerror="true"/>
+ </target>
+
+ <target name="build" depends="compile">
+ <property name="hasWebclient" value="yes"/>
+ <antcall target="webclient-war-common">
+ <param name="hasWebclient" value="yes"/>
+ <param name="webclient.war.classes" value="**/*.class"/>
+ </antcall>
+
+ <javac srcdir="." classpath="${env.APS_HOME}/lib/reportbuilder.jar"
+ includes="WebTest.java"/>
+
+ </target>
+
+ <target name="build-publish-war" depends="build, publish-war-common" />
+
+ <target name="deploy" depends="init-common">
+ <antcall target="deploy-war-common"/>
+ </target>
+
+ <target name="run" depends="init-common">
+ <java classname="WebTest">
+ <arg value="${http.host}"/>
+ <arg value="${http.port}"/>
+ <arg value="${contextroot}"/>
+ <classpath>
+ <pathelement location="${env.APS_HOME}/lib/reportbuilder.jar"/>
+ <pathelement location="."/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="undeploy" depends="init-common">
+ <antcall target="undeploy-war-common"/>
+ </target>
+
+ <target name="usage">
+ <antcall target="usage-common"/>
+ </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/descriptor/beans.xml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/descriptor/beans.xml
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/lib/slf4j-api-1.7.25.jar b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/lib/slf4j-api-1.7.25.jar
new file mode 100644
index 0000000..0143c09
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/lib/slf4j-api-1.7.25.jar
Binary files differ
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/lib/slf4j-simple-1.7.25.jar b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/lib/slf4j-simple-1.7.25.jar
new file mode 100644
index 0000000..a7260f3
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/lib/slf4j-simple-1.7.25.jar
Binary files differ
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/servlet/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/servlet/TestBean.java
new file mode 100644
index 0000000..c696caf
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/servlet/TestBean.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+//Simple TestBean to test CDI.
+public class TestBean
+{
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/servlet/TestLoggerProducer.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/servlet/TestLoggerProducer.java
new file mode 100644
index 0000000..f8e08a7
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/servlet/TestLoggerProducer.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017, 2018 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 javax.enterprise.inject.Produces;
+
+
+public class TestLoggerProducer {
+ @Produces
+ public org.jboss.logging.Logger getLogger(){
+ org.jboss.logging.Logger l = org.jboss.logging.Logger.getLogger(TestLoggerProducer.class);
+ System.out.println("getLogger:: " + l);
+ return l;
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/servlet/TestServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/servlet/TestServlet.java
new file mode 100644
index 0000000..9145274
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/servlet/TestServlet.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2010, 2018 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.IOException;
+import java.io.PrintWriter;
+import java.util.Enumeration;
+import java.util.Set;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebInitParam;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.inject.Inject;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.naming.InitialContext;
+
+@WebServlet(name="mytest",
+ urlPatterns={"/myurl"},
+ initParams={ @WebInitParam(name="n1", value="v1"), @WebInitParam(name="n2", value="v2") } )
+public class TestServlet extends HttpServlet {
+ @Inject TestBean tb;
+ @Inject BeanManager bm;
+ @Inject TestBeanInWebInfLib tbiwil;
+
+ BeanManager bm1;
+
+ @Inject
+ private transient org.jboss.logging.Logger log;
+
+ public void service(HttpServletRequest req, HttpServletResponse res)
+ throws IOException, ServletException {
+
+ PrintWriter writer = res.getWriter();
+ writer.write("Hello from Servlet 3.0. ");
+ String msg = "n1=" + getInitParameter("n1") +
+ ", n2=" + getInitParameter("n2");
+
+ if (tb == null) msg += "Bean injection into Servlet failed";
+ if (tbiwil == null) msg += "Bean injection of a TestBean in WEB-INF/lib into Servlet failed";
+ System.out.println("Test Bean from WEB-INF/lib=" + tbiwil);
+
+ System.out.println("BeanManager is " + bm);
+ System.out.println("BeanManager via lookup is " + bm1);
+ if (bm == null) msg += "BeanManager Injection via @Inject failed";
+ try {
+ bm1 = (BeanManager)((new InitialContext()).lookup("java:comp/BeanManager"));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ msg += "BeanManager Injection via component environment lookup failed";
+ }
+ if (bm1 == null) msg += "BeanManager Injection via component environment lookup failed";
+
+ //Check if Beans in WAR(WEB-INF/classes) and WEB-INF/lib/*.jar are visible
+ //via BeanManager of WAR
+ Set warBeans = bm.getBeans(TestBean.class,new AnnotationLiteral<Any>() {});
+ if (warBeans.size() != 1) msg += "TestBean in WAR is not available via the WAR BeanManager";
+
+ Set webinfLibBeans = bm.getBeans(TestBeanInWebInfLib.class,new AnnotationLiteral<Any>() {});
+ if (webinfLibBeans.size() != 1) msg += "TestBean in WEB-INF/lib is not available via the WAR BeanManager";
+ System.out.println("Test Bean from WEB-INF/lib via BeanManager:" + webinfLibBeans);
+
+ //Test injection into WEB-INF/lib beans
+ msg += tbiwil.testInjection();
+
+ writer.write("initParams: " + msg + "\n");
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/util/TestBeanInWebInfLib.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/util/TestBeanInWebInfLib.java
new file mode 100644
index 0000000..2658910
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/cdi-servlet-3.0-annotation-with-web-inf-lib/util/TestBeanInWebInfLib.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2010, 2018 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.util.Set;
+
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Inject;
+import javax.enterprise.inject.spi.Bean;
+
+public class TestBeanInWebInfLib {
+ @Inject
+ BeanManager bm;
+
+ @Inject
+ TestBean tb;
+
+ public String testInjection() {
+ if (bm == null) {
+ return "Bean Manager not injected into the TestBean in WEB-INF/lib";
+ }
+ System.out.println("BeanManager in WEB-INF/lib bean is " + bm);
+
+ if (tb == null) {
+ return "Injection of WAR's TestBean into the TestBean in WEB-INF/lib failed";
+ }
+
+ Set<Bean<?>> webinfLibBeans = bm.getBeans(TestBeanInWebInfLib.class,
+ new AnnotationLiteral<Any>() {});
+ if (webinfLibBeans.size() != 1){
+ return "TestBean in WEB-INF/lib is not available via the WEB-INF/lib Bean's BeanManager";
+ }
+
+ // success
+ return "";
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/README
new file mode 100644
index 0000000..344a368
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/README
@@ -0,0 +1,10 @@
+- Test support for enabled beans' classes deployed as an embedded RAR
+[test originally from embeddedConnector1.5 test in Connectors developer tests]
+section 12.1. Bean archives of JSR 299 spec:
+
+"Bean classes of enabled beans must be deployed in bean archives.
+• A library jar, EJB jar, application client jar or rar archive is a
+bean archive if it has a file named beans.xml in the META-INF
+directory."
+
+In this test, an embedded RAR has a TestCDIBean Bean class. This is injected into a MDB in another ejb-jar in the EAR.
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/META-INF/application.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/META-INF/application.xml
new file mode 100644
index 0000000..c911361
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/META-INF/application.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN' 'http://java.sun.com/dtd/application_1_3.dtd'>
+<!--
+
+ Copyright (c) 2017, 2018 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
+
+-->
+
+<application>
+ <display-name>GenericMessageDrivenBean</display-name>
+ <description>Application description</description>
+ <module>
+ <connector>generic-ra.rar</connector>
+ </module>
+ <module>
+ <ejb>generic-embedded-ejb.jar</ejb>
+ </module>
+ <module>
+ <java>generic-embedded-client.jar</java>
+ </module>
+</application>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/build.xml
new file mode 100644
index 0000000..8be2ab7
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/build.xml
@@ -0,0 +1,110 @@
+<!--
+
+ Copyright (c) 2002, 2018 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
+
+-->
+
+<!DOCTYPE project [
+ <!ENTITY common SYSTEM "../../../../../config/common.xml">
+ <!ENTITY testcommon SYSTEM "../../../../../config/properties.xml">
+ <!ENTITY database SYSTEM "../../../config/database.xml">
+]>
+
+<project name="connector1.5 MDB" default="all" basedir=".">
+
+ <property name="j2ee.home" value="../../.."/>
+ <property name="earfile" value="generic-embedded.ear"/>
+
+
+ <!-- include common.xml and testcommon.xml -->
+ &database;
+ &common;
+ &testcommon;
+
+ <target name="all" depends="init-common, clean-common">
+ <ant dir="src" inheritAll="false" target="all"/>
+ <antcall target="build-ear"/>
+ <!--
+ <antcall target="ear-common">
+ <param name="appname" value="generic-embedded"/>
+ <param name="application.xml" value="META-INF/application.xml"/>
+ </antcall>
+ -->
+ </target>
+
+ <target name="build-ear">
+
+ <delete file="${assemble.dir}/generic-embeddedApp.ear"/>
+ <mkdir dir="${assemble.dir}"/>
+ <mkdir dir="${build.classes.dir}/META-INF"/>
+ <ear earfile="${assemble.dir}/generic-embeddedApp.ear"
+ appxml="META-INF/application.xml">
+
+ <fileset dir="${assemble.dir}">
+ <include name="*.jar"/>
+ <include name="*.war"/>
+ </fileset>
+ <fileset dir="../ra">
+ <include name="*.rar"/>
+ </fileset>
+ <fileset dir="${env.APS_HOME}/lib">
+ <include name="reporter.jar"/>
+ </fileset>
+ </ear>
+
+ </target>
+
+ <target name="setupJdbc" depends="init-common">
+ <antcall target="create-jdbc-conpool-connector">
+ <param name="db.class" value="org.apache.derby.jdbc.ClientXADataSource"/>
+ <param name="jdbc.conpool.name" value="jdbc-pointbase-pool1"/>
+ <param name="jdbc.resource.type" value="javax.sql.XADataSource"/>
+ </antcall>
+ <antcall target="create-jdbc-resource-common">
+ <param name="jdbc.conpool.name" value="jdbc-pointbase-pool1"/>
+ <param name="jdbc.resource.name" value="jdbc/XAPointbase"/>
+ </antcall>
+
+ <antcall target="execute-sql-connector">
+ <param name="sql.file" value="createdb.sql"/>
+ </antcall>
+ </target>
+
+ <target name="unsetJdbc" depends="init-common">
+ <antcall target="delete-jdbc-resource-common">
+ <param name="jdbc.resource.name" value="jdbc/XAPointbase"/>
+ </antcall>
+ <antcall target="delete-jdbc-connpool-common">
+ <param name="jdbc.conpool.name" value="jdbc-pointbase-pool1"/>
+ </antcall>
+ </target>
+
+ <target name="deploy-ear" depends="init-common">
+ <antcall target="deploy-common">
+ <param name="appname" value="generic-embedded"/>
+ </antcall>
+ </target>
+
+ <target name="undeploy" depends="init-common">
+ <antcall target="undeploy-common">
+ <param name="deployedapp.name" value="generic-embeddedApp"/>
+ <param name="appname" value="generic-embedded"/>
+ </antcall>
+ </target>
+
+ <target name="clean">
+ <antcall target="clean-common"/>
+ </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/createdb.sql b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/createdb.sql
new file mode 100644
index 0000000..7d93610
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/createdb.sql
@@ -0,0 +1,2 @@
+drop table MESSAGES;
+create table MESSAGES (messageId CHAR(50), message varchar(80));
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/META-INF/application-client.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/META-INF/application-client.xml
new file mode 100644
index 0000000..766d51c
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/META-INF/application-client.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE application-client PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application Client 1.3//EN' 'http://java.sun.com/dtd/application-client_1_3.dtd'>
+<!--
+
+ Copyright (c) 2017, 2018 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
+
+-->
+
+<application-client>
+ <display-name>generic-embeddedClient</display-name>
+</application-client>
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/META-INF/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/META-INF/beans.xml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/META-INF/beans.xml
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/META-INF/ejb-jar.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/META-INF/ejb-jar.xml
new file mode 100644
index 0000000..696dd3e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/META-INF/ejb-jar.xml
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (c) 2017, 2018 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
+
+-->
+
+<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
+ version="2.1">
+ <display-name>Ejb1</display-name>
+ <enterprise-beans>
+ <message-driven>
+ <display-name>Generic_Message_Bean</display-name>
+ <ejb-name>GenericMessageBean</ejb-name>
+ <ejb-class>mdb.MyMessageBean</ejb-class>
+ <messaging-type>connector.MyMessageListener</messaging-type>
+ <transaction-type>Container</transaction-type>
+ <activation-config>
+ <activation-config-property>
+ <activation-config-property-name>
+ DestinationType
+ </activation-config-property-name>
+ <activation-config-property-value>
+ java.lang.String
+ </activation-config-property-value>
+ </activation-config-property>
+ <activation-config-property>
+ <activation-config-property-name>
+ TestProp
+ </activation-config-property-name>
+ <activation-config-property-value>
+ WrongValue
+ </activation-config-property-value>
+ </activation-config-property>
+ </activation-config>
+ <resource-ref>
+ <description>description</description>
+ <res-ref-name>MyDB</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ <res-auth>Container</res-auth>
+ <res-sharing-scope>Shareable</res-sharing-scope>
+ </resource-ref>
+ </message-driven>
+ <session>
+ <display-name>MyMessageChecker</display-name>
+ <ejb-name>MyMessageChecker</ejb-name>
+ <home>beans.MessageCheckerHome</home>
+ <remote>beans.MessageChecker</remote>
+ <ejb-class>beans.MessageCheckerEJB</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ <env-entry>
+ <env-entry-name>user</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>PBPUBLIC</env-entry-value>
+ </env-entry>
+ <env-entry>
+ <env-entry-name>password</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>PBPUBLIC</env-entry-value>
+ </env-entry>
+ <resource-ref>
+ <res-ref-name>MyDB</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ <res-auth>Container</res-auth>
+ <res-sharing-scope>Shareable</res-sharing-scope>
+ </resource-ref>
+ <resource-env-ref>
+ <resource-env-ref-name>eis/testAdmin</resource-env-ref-name>
+ <resource-env-ref-type>connector.MyAdminObject</resource-env-ref-type>
+ </resource-env-ref>
+ <security-identity>
+ <use-caller-identity/>
+ </security-identity>
+ </session>
+ </enterprise-beans>
+ <assembly-descriptor>
+ <container-transaction>
+ <method>
+ <ejb-name>GenericMessageBean</ejb-name>
+ <method-name>onMessage</method-name>
+ <method-params>
+ <method-param>java.lang.String</method-param>
+ </method-params>
+ </method>
+ <trans-attribute>Required</trans-attribute>
+ </container-transaction>
+ <container-transaction>
+ <method>
+ <ejb-name>MyMessageChecker</ejb-name>
+ <method-intf>Remote</method-intf>
+ <method-name>getMessageCount</method-name>
+ </method>
+ <trans-attribute>Required</trans-attribute>
+ </container-transaction>
+ </assembly-descriptor>
+</ejb-jar>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/META-INF/sun-application-client.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/META-INF/sun-application-client.xml
new file mode 100644
index 0000000..2b9166a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/META-INF/sun-application-client.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE sun-application-client PUBLIC "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 Application Client 1.3//EN" "http://www.sun.com/software/sunone/appserver/dtds/sun-application-client_1_3-0.dtd">
+<!--
+
+ Copyright (c) 2017, 2018 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
+
+-->
+
+<sun-application-client>
+</sun-application-client>
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/META-INF/sun-ejb-jar.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/META-INF/sun-ejb-jar.xml
new file mode 100644
index 0000000..de701df
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/META-INF/sun-ejb-jar.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 EJB 2.0//EN" "http://www.sun.com/software/sunone/appserver/dtds/sun-ejb-jar_2_0-0.dtd">
+<!--
+
+ Copyright (c) 2017, 2018 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
+
+-->
+
+<sun-ejb-jar>
+ <enterprise-beans>
+ <module-name>ejb.jar</module-name>
+ <unique-id>1</unique-id>
+ <ejb>
+ <ejb-name>GenericMessageBean</ejb-name>
+ <mdb-resource-adapter>
+ <resource-adapter-mid>generic-embeddedApp#generic-ra</resource-adapter-mid>
+ <activation-config>
+ <activation-config-property>
+ <activation-config-property-name>DestinationName</activation-config-property-name>
+ <activation-config-property-value>Foo</activation-config-property-value>
+ </activation-config-property>
+ <activation-config-property>
+ <activation-config-property-name>TestProp</activation-config-property-name>
+ <activation-config-property-value>RightValue</activation-config-property-value>
+ </activation-config-property>
+ </activation-config>
+ </mdb-resource-adapter>
+ <ior-security-config>
+ <transport-config>
+ <integrity>supported</integrity>
+ <confidentiality>supported</confidentiality>
+ <establish-trust-in-target>supported</establish-trust-in-target>
+ <establish-trust-in-client>supported</establish-trust-in-client>
+ </transport-config>
+ <as-context>
+ <auth-method>username_password</auth-method>
+ <realm>default</realm>
+ <required>true</required>
+ </as-context>
+ <sas-context>
+ <caller-propagation>supported</caller-propagation>
+ </sas-context>
+ </ior-security-config>
+ <resource-ref>
+ <res-ref-name>MyDB</res-ref-name>
+ <jndi-name>jdbc/XAPointbase</jndi-name>
+ </resource-ref>
+ <gen-classes />
+ </ejb>
+ <ejb>
+ <ejb-name>MyMessageChecker</ejb-name>
+ <jndi-name>MyMessageChecker</jndi-name>
+ <ior-security-config>
+ <transport-config>
+ <integrity>supported</integrity>
+ <confidentiality>supported</confidentiality>
+ <establish-trust-in-target>supported</establish-trust-in-target>
+ <establish-trust-in-client>supported</establish-trust-in-client>
+ </transport-config>
+ <as-context>
+ <auth-method>username_password</auth-method>
+ <realm>default</realm>
+ <required>false</required>
+ </as-context>
+ <sas-context>
+ <caller-propagation>supported</caller-propagation>
+ </sas-context>
+ </ior-security-config>
+ <resource-ref>
+ <res-ref-name>MyDB</res-ref-name>
+ <jndi-name>jdbc/XAPointbase</jndi-name>
+ </resource-ref>
+ <resource-env-ref>
+ <resource-env-ref-name>eis/testAdmin</resource-env-ref-name>
+ <jndi-name>eis/testAdmin</jndi-name>
+ </resource-env-ref>
+ <gen-classes/>
+ </ejb>
+ </enterprise-beans>
+</sun-ejb-jar>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/beans/MessageChecker.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/beans/MessageChecker.java
new file mode 100644
index 0000000..f582a2a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/beans/MessageChecker.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package beans;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBObject;
+
+public interface MessageChecker extends EJBObject {
+ int getMessageCount() throws RemoteException;
+ boolean done() throws RemoteException;
+ int expectedResults() throws RemoteException;
+ void notifyAndWait() throws RemoteException;
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/beans/MessageCheckerEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/beans/MessageCheckerEJB.java
new file mode 100644
index 0000000..2751b06
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/beans/MessageCheckerEJB.java
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package beans;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+
+import connector.MyAdminObject;
+
+public class MessageCheckerEJB implements SessionBean {
+
+ private int WAIT_TIME = 15;
+ private String user = "j2ee";
+ private String password = "j2ee";
+ private Properties beanProps = null;
+ private SessionContext sessionContext = null;
+ private Connection heldCon = null;
+ private MyAdminObject Controls;
+
+ public MessageCheckerEJB() {}
+
+ public void ejbCreate()
+ throws CreateException {
+ System.out.println("bean removed");
+ heldCon = null;
+ /*
+ if (holdConnection) {
+ try {
+ heldCon = getDBConnection();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw new CreateException("Error in ejbCreate");
+ }
+ }
+ */
+ }
+
+ public boolean done() {
+ return Controls.done();
+ }
+
+ public int expectedResults() {
+ return Controls.expectedResults();
+ }
+
+ public void notifyAndWait() {
+ try {
+ synchronized (Controls.getLockObject()) {
+ //Tell the resource adapter the client is ready to run
+ Controls.getLockObject().notifyAll();
+
+ debug("NOTIFIED... START WAITING");
+ //Wait until being told to read from the database
+ Controls.getLockObject().wait();
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public int getMessageCount() {
+ try {
+ Connection con = getFreshConnection();
+ int count1 = getCount(con);
+ con.close();
+
+ /*
+ synchronized(Controls.getLockObject()) {
+ Controls.getLockObject().notify();
+ }
+ */
+
+ return count1;
+ } catch (Exception e) {
+ e.printStackTrace(System.out);
+ throw new EJBException(e);
+ }
+ }
+
+ private int getCount(Connection con) throws SQLException {
+ Statement stmt = con.createStatement();
+ int count = 0;
+ String messages = "";
+ ResultSet result = stmt.executeQuery(
+ "SELECT messageId, message "+ "FROM messages");
+ while (result.next()) {
+ count++;
+ messages = messages + " - " + result.getString("messageId")+" "+
+ result.getString("message") + "\n";
+ }
+ messages = messages + "count = " + count;
+ System.out.println(messages);
+ stmt.close();
+ return count;
+ }
+
+ public void setSessionContext(SessionContext context) {
+ sessionContext = context;
+ try {
+ Context ic = new InitialContext();
+ user = (String) ic.lookup("java:comp/env/user");
+ password = (String) ic.lookup("java:comp/env/password");
+ Controls = (MyAdminObject) ic.lookup("java:comp/env/eis/testAdmin");
+ System.out.println("CALLING INITILIZE ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]");
+ Controls.initialize();
+ System.out.println("CALLED INITILIZE ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]");
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public void ejbRemove() {
+ System.out.println("bean removed");
+ }
+
+ public void ejbActivate() {
+ System.out.println("bean activated");
+ }
+
+ public void ejbPassivate() {
+ System.out.println("bean passivated");
+ }
+
+ private Connection getFreshConnection() throws Exception {
+ Connection oldHeldCon = heldCon;
+ heldCon = null;
+ Connection result = getDBConnection();
+ heldCon = oldHeldCon;
+ return result;
+ }
+
+ private Connection getDBConnection() throws Exception {
+ if (heldCon != null) return heldCon;
+ Connection con = null;
+ try {
+ Context ic = new InitialContext();
+ DataSource ds = (DataSource) ic.lookup("java:comp/env/MyDB");
+ debug("Looked up Datasource\n");
+ debug("Get JDBC connection, auto sign on");
+ con = ds.getConnection();
+
+ if (con != null) {
+ return con;
+ } else {
+ throw new Exception("Unable to get database connection ");
+ }
+ } catch (SQLException ex1) {
+ //ex1.printStackTrace();
+ throw ex1;
+ }
+ }
+
+ private void closeConnection(Connection con) throws SQLException {
+ if (heldCon != null) {
+ return;
+ } else {
+ con.close();
+ }
+ }
+
+ private void debug(String msg) {
+ System.out.println("[MessageCheckerEJB]:: -> " + msg);
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/beans/MessageCheckerHome.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/beans/MessageCheckerHome.java
new file mode 100644
index 0000000..9b56081
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/beans/MessageCheckerHome.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package beans;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+public interface MessageCheckerHome extends EJBHome {
+ MessageChecker create() throws RemoteException, CreateException;
+ boolean done() throws RemoteException, CreateException;
+ int expectedResults() throws RemoteException, CreateException;
+ void notifyAndWait() throws RemoteException, CreateException;
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/build.properties
new file mode 100644
index 0000000..dad207b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/build.properties
@@ -0,0 +1,21 @@
+<!--
+
+ Copyright (c) 2018 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
+
+-->
+
+
+ejb-jar.xml=META-INF/ejb-jar.xml
+sun-ejb-jar.xml=META-INF/sun-ejb-jar.xml
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/build.xml
new file mode 100644
index 0000000..b58b0c3
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/build.xml
@@ -0,0 +1,68 @@
+<!--
+
+ Copyright (c) 2002, 2018 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
+
+-->
+
+<!DOCTYPE project [
+ <!ENTITY common SYSTEM "../../../../../../config/common.xml">
+ <!ENTITY testcommon SYSTEM "../../../../../../config/properties.xml">
+]>
+
+<project name="connector1.5 MDB" default="all" basedir=".">
+
+ <property name="j2ee.home" value="../../../.."/>
+
+ <!-- include common.xml and testcommon.xml -->
+ &common;
+ &testcommon;
+
+ <target name="all" depends="init-common">
+ <antcall target="compile-common">
+ <param name="src" value="." />
+ <param name="s1astest.classpath" value="${s1astest.classpath}:../../ra/src/classes" />
+ </antcall>
+
+ <antcall target="ejb-jar-common">
+ <param name="ejb-jar.xml" value="META-INF/ejb-jar.xml" />
+ <param name="ejbjar.classes" value="mdb/*.class, beans/*.class, connector/*.class" />
+ <param name="sun-ejb-jar.xml" value="META-INF/sun-ejb-jar.xml" />
+ <param name="beans.xml" value="META-INF/beans.xml" />
+ <param name="appname" value="generic-embedded" />
+ </antcall>
+
+ <antcall target="appclient-jar-common">
+ <param name="appname" value="generic-embedded" />
+ <param name="application-client.xml" value="META-INF/application-client.xml" />
+ <param name="appclientjar.classes" value="mdb/*.class, beans/*.class, connector/*.class, client/Client.class" />
+ <param name="sun-application-client.xml" value="META-INF/sun-application-client.xml" />
+ </antcall>
+<!--
+ <jar jarfile="../ejb.jar" basedir="classes"
+ includes="mdb/*.class, beans/*.class, connector/*.class" >
+ <metainf dir="META-INF">
+ <include name="ejb-jar.xml"/>
+ <include name="sun-ejb-jar.xml"/>
+ </metainf>
+ </jar>
+-->
+ </target>
+
+ <target name="clean">
+ <antcall target="clean-classes-common">
+ <param name="build.classes.dir" value="classes" />
+ </antcall>
+ </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/client/Client.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/client/Client.java
new file mode 100644
index 0000000..676b07b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/client/Client.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package client;
+
+import javax.naming.InitialContext;
+import javax.rmi.PortableRemoteObject;
+
+import beans.MessageChecker;
+import beans.MessageCheckerHome;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+public class Client {
+
+ private static final String TEST_NAME = " Embedded-Connector-1.5 test - ";
+ private static SimpleReporterAdapter stat = new SimpleReporterAdapter(
+ "appserv-tests");
+
+ public Client(String[] args) {
+ // super(args);
+ }
+
+ public static void main(String[] args) {
+ Client client = new Client(args);
+ client.doTest();
+ }
+
+ public String doTest() {
+ stat.addDescription("This is to test connector 1.5 " + "contracts.");
+
+ String res = "NOT RUN";
+ debug("doTest() ENTER...");
+ boolean pass = false;
+ try {
+ res = "ALL TESTS PASSED";
+ int testCount = 1;
+ while (!done()) {
+
+ notifyAndWait();
+ if (!done()) {
+ debug("Running...");
+ pass = checkResults(expectedResults());
+ debug("Got expected results = " + pass);
+
+ // do not continue if one test failed
+ if (!pass) {
+ res = "SOME TESTS FAILED";
+ stat.addStatus(TEST_NAME + testCount, stat.FAIL);
+ break;
+ } else {
+ stat.addStatus(TEST_NAME + testCount, stat.PASS);
+ }
+ } else {
+ break;
+ }
+ testCount++;
+ }
+
+ } catch (Exception ex) {
+ System.out.println("Importing transaction test failed.");
+ ex.printStackTrace();
+ res = "TEST FAILED";
+ }
+
+ stat.printSummary(TEST_NAME);
+
+ debug("EXITING... STATUS = " + res);
+ return res;
+ }
+
+ private boolean checkResults(int num) throws Exception {
+ Object o = (new InitialContext()).lookup("MyMessageChecker");
+ MessageCheckerHome home = (MessageCheckerHome) PortableRemoteObject
+ .narrow(o, MessageCheckerHome.class);
+ MessageChecker checker = home.create();
+ int result = checker.getMessageCount();
+ return result == num;
+ }
+
+ private boolean done() throws Exception {
+ Object o = (new InitialContext()).lookup("MyMessageChecker");
+ MessageCheckerHome home = (MessageCheckerHome) PortableRemoteObject
+ .narrow(o, MessageCheckerHome.class);
+ MessageChecker checker = home.create();
+ return checker.done();
+ }
+
+ private int expectedResults() throws Exception {
+ Object o = (new InitialContext()).lookup("MyMessageChecker");
+ MessageCheckerHome home = (MessageCheckerHome) PortableRemoteObject
+ .narrow(o, MessageCheckerHome.class);
+ MessageChecker checker = home.create();
+ return checker.expectedResults();
+ }
+
+ private void notifyAndWait() throws Exception {
+ Object o = (new InitialContext()).lookup("MyMessageChecker");
+ MessageCheckerHome home = (MessageCheckerHome) PortableRemoteObject
+ .narrow(o, MessageCheckerHome.class);
+ MessageChecker checker = home.create();
+ checker.notifyAndWait();
+ }
+
+ private void debug(String msg) {
+ System.out.println("[CLIENT]:: --> " + msg);
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/client/MANIFEST.MF b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/client/MANIFEST.MF
new file mode 100644
index 0000000..179cd4d
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/client/MANIFEST.MF
@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+Created-By: 1.4.0 (Sun Microsystems Inc.)
+Main-Class: client.Client
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/connector/MyMessageListener.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/connector/MyMessageListener.java
new file mode 100644
index 0000000..a3928d3
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/connector/MyMessageListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+public interface MyMessageListener {
+ public void onMessage (String message);
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/mdb/MyMessageBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/mdb/MyMessageBean.java
new file mode 100644
index 0000000..caf41e9
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/app/src/mdb/MyMessageBean.java
@@ -0,0 +1,230 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package mdb;
+
+import java.sql.Statement;
+
+import javax.ejb.MessageDrivenBean;
+import javax.ejb.MessageDrivenContext;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+
+import connector.MyMessageListener;
+
+/**
+ */
+public class MyMessageBean implements MessageDrivenBean, MyMessageListener {
+
+ private transient MessageDrivenContext mdc = null;
+ private Context context;
+
+ @javax.inject.Inject
+ private connector.TestCDIBean tb;
+
+ /**
+ * Constructor, which is public and takes no arguments.
+ */
+ public MyMessageBean() {
+ }
+
+ /**
+ * setMessageDrivenContext method, declared as public (but not final or
+ * static), with a return type of void, and with one argument of type
+ * javax.ejb.MessageDrivenContext.
+ *
+ * @param mdc
+ * the context to set
+ */
+ public void setMessageDrivenContext(MessageDrivenContext mdc) {
+ this.mdc = mdc;
+ }
+
+ /**
+ * ejbCreate method, declared as public (but not final or static), with a
+ * return type of void, and with no arguments.
+ */
+ public void ejbCreate() {
+ }
+
+ /**
+ * onMessage method, declared as public (but not final or static), with a
+ * return type of void, and with one argument of type javax.jms.Message.
+ *
+ * Casts the incoming Message to a TextMessage and displays the text.
+ *
+ * @param inMessage
+ * the incoming message
+ */
+ public void onMessage(String inMessage) {
+
+ debug("onMessage:: RECEIVED [" + inMessage + "]");
+ debug("TestCDIBean injected:" + tb);
+
+ if (tb == null)
+ throw new RuntimeException("Injection of enabled Bean "
+ + "in RAR into a MDB injection point failed");
+
+ try {
+ if (inMessage.endsWith("WRITE")) {
+ doDbStuff("WRITE", inMessage.substring(0, inMessage
+ .lastIndexOf(":")));
+ } else if (inMessage.endsWith("DELETE")) {
+ doDbStuff("DELETE", inMessage.substring(0, inMessage
+ .lastIndexOf(":")));
+ } else if (inMessage.endsWith("DELETE_ALL")) {
+ doDbStuff("DELETE_ALL", "::");
+ } else {
+ // unsupported op.
+ }
+ } catch (Exception ex) {
+ debug("UH OH...");
+ ex.printStackTrace();
+ }
+
+ }
+
+ /**
+ * ejbRemove method, declared as public (but not final or static), with a
+ * return type of void, and with no arguments.
+ */
+ public void ejbRemove() {
+ }
+
+ private void doDbStuff(String op, String message) throws Exception {
+
+ java.sql.Connection dbConnection = null;
+ String id = message.substring(0, message.indexOf(":"));
+ String body = message.substring(message.indexOf(":") + 1);
+ try {
+ Context ic = new InitialContext();
+
+ if ("READ".equals(op)) {
+
+ debug("Reading row from database...");
+
+ // Creating a database connection
+ /*
+ * DataSource ds = (DataSource) ic.lookup("java:comp/env/MyDB");
+ * debug("Looked up Datasource\n");
+ * debug("Get JDBC connection, auto sign on"); dbConnection =
+ * ds.getConnection();
+ *
+ * Statement stmt = dbConnection.createStatement(); String query
+ * = "SELECT id from messages where id = 'QQ'"; ResultSet
+ * results = stmt.executeQuery(query); results.next();
+ * System.out.println("QQ has balance " +
+ * results.getInt("balance") + " dollars"); results.close();
+ * stmt.close();
+ *
+ * System.out.println("Read one account\n");
+ */
+
+ } else if ("WRITE".equals(op)) {
+
+ debug("Inserting one message in the database\n");
+
+ // Creating a database connection
+ DataSource ds = (DataSource) ic.lookup("java:comp/env/MyDB");
+ // debug("Looked up Datasource\n");
+ // debug("Get JDBC connection, auto sign on");
+ dbConnection = ds.getConnection();
+
+ createRow(id, body, dbConnection);
+ System.out.println("Created one message\n");
+
+ } else if ("DELETE".equals(op)) {
+
+ debug("Deleting one message from the database\n");
+
+ // Creating a database connection
+ DataSource ds = (DataSource) ic.lookup("java:comp/env/MyDB");
+ // debug("Looked up Datasource\n");
+ // debug("Get JDBC connection, auto sign on");
+ dbConnection = ds.getConnection();
+
+ deleteRow(id, dbConnection);
+ System.out.println("Deleted one message\n");
+ } else if ("DELETE_ALL".equals(op)) {
+
+ debug("Deleting all messages from the database\n");
+
+ // Creating a database connection
+ DataSource ds = (DataSource) ic.lookup("java:comp/env/MyDB");
+ // debug("Looked up Datasource\n");
+ // debug("Get JDBC connection, auto sign on");
+ dbConnection = ds.getConnection();
+ deleteAll(dbConnection);
+ System.out.println("Deleted all messages\n");
+ } else {
+ // unsupported op
+ }
+
+ } finally {
+ try {
+ dbConnection.close();
+ } catch (Exception ex) {
+ debug("Exception occured while closing database con nection.");
+ }
+ }
+ }
+
+ private void createRow(String id, String body,
+ java.sql.Connection dbConnection) throws Exception {
+
+ // Create row for this message
+ debug("CreateRow with ID = " + id + ", BODY = " + body);
+ Statement stmt = dbConnection.createStatement();
+ String query = "INSERT INTO messages (messageId, message)"
+ + "VALUES ('" + id + "', '" + body + "')";
+ int resultCount = stmt.executeUpdate(query);
+ if (resultCount != 1) {
+ throw new Exception("ERROR in INSERT !! resultCount = "
+ + resultCount);
+ }
+ stmt.close();
+ }
+
+ private void deleteRow(String id, java.sql.Connection dbConnection)
+ throws Exception {
+
+ // Delete row for this message
+ debug("DeleteRow with ID = " + id);
+ Statement stmt = dbConnection.createStatement();
+ String query = "DELETE FROM messages WHERE messageId = '" + id + "'";
+ int resultCount = stmt.executeUpdate(query);
+ if (resultCount != 1) {
+ throw new Exception("ERROR in INSERT !! resultCount = "
+ + resultCount);
+ }
+ stmt.close();
+ }
+
+ private void deleteAll(java.sql.Connection dbConnection) throws Exception {
+
+ // Delete row for this message
+ Statement stmt = dbConnection.createStatement();
+ String query = "DELETE FROM messages";
+ int resultCount = stmt.executeUpdate(query);
+ debug("Delete all rows from messages... count = " + resultCount);
+ stmt.close();
+ }
+
+ private void debug(String msg) {
+ System.out.println("[MyMessageBean] --> " + msg);
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/build.xml
new file mode 100644
index 0000000..ccd3fa5
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/build.xml
@@ -0,0 +1,75 @@
+<!--
+
+ Copyright (c) 2002, 2018 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
+
+-->
+
+<!DOCTYPE project [
+ <!ENTITY common SYSTEM "../../../../config/common.xml">
+ <!ENTITY testcommon SYSTEM "../../../../config/properties.xml">
+]>
+
+<project name="connector1.5 TEST" default="all" basedir=".">
+<property name="j2ee.home" value="../.."/>
+<property name="client.class" value="client/Client"/>
+
+ <!-- include common.xml and testcommon.xml -->
+ &common;
+ &testcommon;
+
+ <target name="all" depends="init-common, build, setup, runtest, unset"/>
+ <target name="build" depends="init-common">
+ <ant dir="ra" inheritAll="false" target="all"/>
+ <ant dir="app" inheritAll="false" target="all"/>
+ </target>
+
+ <target name="setup">
+ <ant dir="app" inheritAll="false" target="setupJdbc"/>
+ <ant dir="." inheritAll="false" target="deploy"/>
+ </target>
+
+ <target name="deploy">
+ <ant dir="app" inheritAll="false" target="deploy-ear"/>
+ <ant dir="ra" inheritAll="false" target="testAddAdmin"/>
+ <ant dir="." inheritAll="false" target="restart"/>
+ </target>
+
+ <target name="runtest" depends="init-common">
+ <antcall target="runclient-common">
+ <param name="appname" value="generic-embedded" />
+ </antcall>
+ </target>
+
+ <target name="unset">
+ <ant dir="app" inheritAll="false" target="unsetJdbc"/>
+ <ant dir="." inheritAll="false" target="undeploy"/>
+ <ant dir="." inheritAll="false" target="restart"/>
+ </target>
+
+ <target name="undeploy">
+ <ant dir="ra" inheritAll="false" target="testDelAdmin"/>
+ <ant dir="app" inheritAll="false" target="undeploy"/>
+ </target>
+
+ <target name="restart" depends="init-common">
+ <echo message="Not required to restart"/>
+ </target>
+
+ <target name="clean">
+ <ant dir="ra" inheritAll="false" target="clean"/>
+ <ant dir="app" inheritAll="false" target="clean"/>
+ </target>
+
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/createdb.sql b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/createdb.sql
new file mode 100644
index 0000000..19f3324
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/createdb.sql
@@ -0,0 +1,2 @@
+drop table messages;
+create table messages (messageId CHAR(50), message varchar(80));
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/META-INF/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/META-INF/beans.xml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/META-INF/beans.xml
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/META-INF/ra.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/META-INF/ra.xml
new file mode 100644
index 0000000..2ca2ebc
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/META-INF/ra.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (c) 2017, 2018 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
+
+-->
+
+<!--
+<!DOCTYPE connector PUBLIC '-//Sun Microsystems, Inc.//DTD Connector 1.5//EN' 'http://java.sun.com/dtd/connector_1_5.dtd'>
+-->
+<connector xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+ version="1.5">
+ <display-name>Simple Resource Adapter</display-name>
+ <vendor-name>Java Software</vendor-name>
+ <eis-type>Generic Type</eis-type>
+ <resourceadapter-version>1.0Alpha</resourceadapter-version>
+ <resourceadapter>
+ <resourceadapter-class>
+ connector.SimpleResourceAdapterImpl
+ </resourceadapter-class>
+ <config-property>
+ <config-property-name>
+ TestName
+ </config-property-name>
+ <config-property-type>
+ java.lang.String
+ </config-property-type>
+ <config-property-value>
+ ConfigPropertyForRA
+ </config-property-value>
+ </config-property>
+ <inbound-resourceadapter>
+ <messageadapter>
+ <messagelistener>
+ <messagelistener-type>
+ connector.MyMessageListener
+ </messagelistener-type>
+ <activationspec>
+ <activationspec-class>
+ connector.SimpleActivationSpec
+ </activationspec-class>
+ </activationspec>
+ </messagelistener>
+ </messageadapter>
+ </inbound-resourceadapter>
+ <adminobject>
+ <adminobject-interface>connector.MyAdminObject</adminobject-interface>
+ <adminobject-class>connector.MyAdminObject</adminobject-class>
+ <config-property>
+ <config-property-name>ResetControl</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>NORESET</config-property-value>
+ </config-property>
+ <config-property>
+ <config-property-name>ExpectedResult</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>88</config-property-value>
+ </config-property>
+ </adminobject>
+ </resourceadapter>
+</connector>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/build.xml
new file mode 100644
index 0000000..d483e8d
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/build.xml
@@ -0,0 +1,83 @@
+<!--
+
+ Copyright (c) 2002, 2018 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
+
+-->
+
+<!DOCTYPE project [
+ <!ENTITY common SYSTEM "../../../../../config/common.xml">
+ <!ENTITY props SYSTEM "../../../../../config/properties.xml">
+]>
+
+<project name="connector1.5 RA" default="all" basedir=".">
+
+ <property name="j2ee.home" value="../../.."/>
+ <property name="earfile" value="generic-ra.rar"/>
+
+ <!-- include common.xml and testcommon.xml -->
+ &common;
+ &props;
+
+ <target name="all">
+ <ant dir="src" inheritAll="false" target="all"/>
+
+ <jar jarfile="generic-ra.rar" basedir="."
+ includes="generic-ra.jar, META-INF/ra.xml, META-INF/beans.xml" />
+ </target>
+
+ <target name="deploy" depends="init-common">
+ <antcall target="asadmin-common">
+ <param name="admin.command" value="deploy"/>
+ <param name="operand.props" value="generic-ra.rar"/>
+ </antcall>
+ </target>
+
+ <target name="undeploy" depends="init-common">
+ <antcall target="asadmin-common">
+ <param name="admin.command" value="undeploy"/>
+ <param name="operand.props" value="generic-ra"/>
+ </antcall>
+ </target>
+
+ <target name="testAddAdmin" depends="init-common">
+ <antcall target="asadmin-common">
+ <param name="admin.command" value="create-admin-object --target ${appserver.instance.name} --restype connector.MyAdminObject --raname generic-embeddedApp#generic-ra --property ResetControl=BEGINNING"/>
+ <param name="operand.props" value="eis/testAdmin"/>
+ </antcall>
+ </target>
+
+ <target name="testDelAdmin" depends="init-common">
+ <antcall target="asadmin-common">
+ <param name="admin.command" value="delete-admin-object"/>
+ <param name="operand.props" value="--target ${appserver.instance.name} eis/testAdmin"/>
+ </antcall>
+ </target>
+
+ <target name="sendMessage" depends="init-common">
+ <echo message="Class path is ${s1astest.classpath}"/>
+ <java fork="true" classname="connector.Messages" failonerror="true">
+ <arg line="add Foo TestMessage"/>
+ <classpath>
+ <pathelement location="${s1astest.classpath}"/>
+ <pathelement location="generic-ra.jar"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="clean">
+ <ant dir="src" inheritAll="false" target="clean"/>
+ </target>
+
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/build.xml
new file mode 100644
index 0000000..ff8bcc2
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/build.xml
@@ -0,0 +1,49 @@
+<!--
+
+ Copyright (c) 2002, 2018 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
+
+-->
+
+<!DOCTYPE project [
+ <!ENTITY common SYSTEM "../../../../../../config/common.xml">
+ <!ENTITY props SYSTEM "../../../../../../config/properties.xml">
+]>
+
+<project name="connector1.5 RA SRC" default="all" basedir=".">
+
+
+ <!-- include common.xml and testcommon.xml -->
+ &common;
+ &props;
+
+ <target name="all" depends="init-common" >
+ <antcall target="compile-common">
+ <param name="build.classes.dir" value="classes" />
+ <param name="src" value="connector" />
+ </antcall>
+ <jar jarfile="../generic-ra.jar" basedir="classes"
+ includes="connector/*.class" />
+ </target>
+
+
+ <target name="clean">
+ <antcall target="clean-classes-common">
+ <param name="build.classes.dir" value="classes" />
+ </antcall>
+ <delete file="../generic-ra.jar"/>
+ <delete file="../generic-ra.rar"/>
+ </target>
+
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/Controls.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/Controls.java
new file mode 100644
index 0000000..3541235
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/Controls.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+/**
+ *
+ * @author Qingqing Ouyang
+ */
+public class Controls {
+ public static Object readyLock = new Object();
+ public static int expectedResults;
+ public static boolean done = false;
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/DeliveryWork.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/DeliveryWork.java
new file mode 100644
index 0000000..f4599fd
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/DeliveryWork.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+import java.lang.reflect.Method;
+
+import javax.resource.spi.endpoint.MessageEndpoint;
+import javax.resource.spi.work.Work;
+
+/**
+ *
+ * @author Qingqing Ouyang
+ */
+public class DeliveryWork implements Work {
+
+ private MessageEndpoint ep;
+ private int num;
+ private String op;
+ private boolean keepCount;
+ private static int counter = 0;
+
+ public DeliveryWork(MessageEndpoint ep, int numOfMessages, String op) {
+ this.ep = ep;
+ this.num = numOfMessages;
+ this.op = op;
+ this.keepCount = false;
+ }
+
+ public DeliveryWork(MessageEndpoint ep, int numOfMessages, String op,
+ boolean keepCount) {
+ this.ep = ep;
+ this.num = numOfMessages;
+ this.op = op;
+ this.keepCount = keepCount;
+ }
+
+ public void run() {
+
+ debug("ENTER...");
+
+ try {
+ // Method onMessage = getOnMessageMethod();
+ // ep.beforeDelivery(onMessage);
+
+ if (!keepCount) {
+ for (int i = 0; i < num; i++) {
+ String msgId = String.valueOf(i);
+ String msgBody = "This is message " + msgId;
+ String msg = msgId + ":" + msgBody + ":" + op;
+ ((MyMessageListener) ep).onMessage(msg);
+ }
+ } else {
+ for (int i = 0; i < num; i++) {
+ String msgId = String.valueOf(i + counter);
+ String msgBody = "This is message " + msgId;
+ String msg = msgId + ":" + msgBody + ":" + op;
+ ((MyMessageListener) ep).onMessage(msg);
+ }
+ counter = counter + num;
+ }
+
+ // ep.afterDelivery();
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ debug("LEAVE...");
+ }
+
+ public void release() {
+ }
+
+ public String toString() {
+ return op;
+ }
+
+ private Method getOnMessageMethod() {
+
+ Method onMessageMethod = null;
+ try {
+ Class msgListenerClass = connector.MyMessageListener.class;
+ Class[] paramTypes = { java.lang.String.class };
+ onMessageMethod = msgListenerClass.getMethod("onMessage",
+ paramTypes);
+
+ } catch (NoSuchMethodException ex) {
+ ex.printStackTrace();
+ }
+ return onMessageMethod;
+ }
+
+ private void debug(String mesg) {
+ System.out.println("DeliveryWork[" + op + "] --> " + mesg);
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/FakeXAResource.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/FakeXAResource.java
new file mode 100644
index 0000000..52d764a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/FakeXAResource.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+/**
+ * This is class is used for debugging. It prints out trace information on TM
+ * calls to XAResource before directing the call to the actual XAResource object
+ */
+public class FakeXAResource implements XAResource {
+
+ public FakeXAResource() {
+ }
+
+ public void commit(Xid xid, boolean onePhase) throws XAException {
+ print("FakeXAResource.commit: " + xidToString(xid) + "," + onePhase);
+ }
+
+ public void end(Xid xid, int flags) throws XAException {
+ print("FakeXAResource.end: " + xidToString(xid) + ","
+ + flagToString(flags));
+ }
+
+ public void forget(Xid xid) throws XAException {
+ print("FakeXAResource.forget: " + xidToString(xid));
+ }
+
+ public int getTransactionTimeout() throws XAException {
+ return 60 * 1000;
+ }
+
+ public boolean isSameRM(XAResource xares) throws XAException {
+ return false;
+ }
+
+ public int prepare(Xid xid) throws XAException {
+ print("FakeXAResource.prepare: " + xidToString(xid));
+ return XAResource.XA_OK;
+ }
+
+ public Xid[] recover(int flag) throws XAException {
+ print("FakeXAResource.recover: " + flagToString(flag));
+ return null;
+ }
+
+ public void rollback(Xid xid) throws XAException {
+ print("FakeXAResource.rollback: " + xidToString(xid));
+ }
+
+ public boolean setTransactionTimeout(int seconds) throws XAException {
+ return false;
+ }
+
+ public void start(Xid xid, int flags) throws XAException {
+ print("FakeXAResource.start: " + xidToString(xid) + ","
+ + flagToString(flags));
+ throw new XAException();
+ }
+
+ private void print(String s) {
+ System.out.println(s);
+ }
+
+ static public String xidToString(Xid xid) {
+ return String
+ .valueOf((new String(xid.getGlobalTransactionId()) + new String(
+ xid.getBranchQualifier())).hashCode());
+ }
+
+ static public String flagToString(int flag) {
+ switch (flag) {
+ case TMFAIL:
+ return "TMFAIL";
+ case TMJOIN:
+ return "TMJOIN";
+ case TMNOFLAGS:
+ return "TMNOFLAGS";
+ case TMONEPHASE:
+ return "TMONEPHASE";
+ case TMRESUME:
+ return "TMRESUME";
+ case TMSTARTRSCAN:
+ return "TMSTARTRSCAN";
+ case TMENDRSCAN:
+ return "TMENDRSCAN";
+ case TMSUCCESS:
+ return "TMSUCCESS";
+ case TMSUSPEND:
+ return "TMSUSPEND";
+ case XA_RDONLY:
+ return "XA_RDONLY";
+ default:
+ return "" + Integer.toHexString(flag);
+ }
+ }
+
+ public boolean equals(Object obj) {
+ return false;
+ }
+
+ public int hashCode() {
+ return 1;
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/Messages.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/Messages.java
new file mode 100644
index 0000000..597a34b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/Messages.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+
+/**
+ * collection of messages.
+ *
+ * @author Qingqing Ouyang
+ */
+public class Messages {
+
+ private static Hashtable messages = new Hashtable();
+
+ public static void sendMessage(String destName, String message) {
+ if (messages.get(destName) != null) {
+ ((ArrayList) messages.get(destName)).add(message);
+ } else {
+ ArrayList list = new ArrayList();
+ list.add(message);
+ messages.put(destName, list);
+ }
+ System.out.println("sendMessage. message at foo is "
+ + Messages.hasMessages("Foo"));
+ }
+
+ public static boolean hasMessages(String destName) {
+ return messages.get(destName) != null;
+ }
+
+ public static ArrayList getMessages(String destName) {
+ return (ArrayList) messages.get(destName);
+ }
+
+ public static void main(String[] args) {
+ if (args.length != 3) {
+ System.exit(1);
+ }
+
+ String command = args[0];
+ String destName = args[1];
+ String message = args[2];
+
+ if (!"add".equals(command)) {
+ System.exit(1);
+ }
+
+ sendMessage(destName, message);
+ System.out.println("Message : " + message + " sent to " + destName);
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/MyAdminObject.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/MyAdminObject.java
new file mode 100644
index 0000000..57bf91d
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/MyAdminObject.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+public class MyAdminObject implements java.io.Serializable {
+
+ private String resetControl = "NORESET";
+ private Integer expectedResults;
+
+ public void setResetControl(String value) {
+ resetControl = value;
+ }
+
+ public String getResetControl() {
+ return resetControl;
+ }
+
+ public void setExpectedResults(Integer value) {
+ expectedResults = value;
+ }
+
+ public Integer getExpectedResults() {
+ return expectedResults;
+ }
+
+ public void initialize() {
+ System.out
+ .println("[MyAdminObject] Initializing the Controls to false:"
+ + resetControl);
+ if (resetControl.equals("BEGINNING")) {
+ Controls.done = false;
+ System.out
+ .println("[MyAdminObject] Initialized the Controls to false");
+ }
+ }
+
+ public boolean done() {
+ return Controls.done;
+ }
+
+ public int expectedResults() {
+ return Controls.expectedResults;
+ }
+
+ public Object getLockObject() {
+ return Controls.readyLock;
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/MyMessageListener.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/MyMessageListener.java
new file mode 100644
index 0000000..9e58d7e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/MyMessageListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+public interface MyMessageListener {
+ public void onMessage(String message);
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/MyWork.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/MyWork.java
new file mode 100644
index 0000000..7172677
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/MyWork.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+import java.lang.reflect.Method;
+
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkManager;
+
+/**
+ *
+ * @author Qingqing Ouyang
+ */
+public class MyWork implements Work {
+
+ private String name;
+ private boolean stop = false;
+ private MessageEndpointFactory factory;
+ private WorkManager wm;
+
+ public MyWork(String name, MessageEndpointFactory factory, WorkManager wm) {
+ this.factory = factory;
+ this.name = name;
+ this.wm = wm;
+ }
+
+ public void run() {
+
+ debug("ENTER...");
+
+ // try 3 times to create endpoint (in case of failure)
+ for (int i = 0; i < 3; i++) {
+
+ try {
+
+ Method onMessage = getOnMessageMethod();
+ System.out.println("isDeliveryTransacted = "
+ + factory.isDeliveryTransacted(onMessage));
+
+ /*
+ * MessageEndpoint ep = factory.createEndpoint(null);
+ * ep.beforeDelivery(onMessage); ((MyMessageListener)
+ * ep).onMessage(name + ": TEST MSG ONE"); ((MyMessageListener)
+ * ep).onMessage(name + ": TEST MSG TWO"); ((MyMessageListener)
+ * ep).onMessage(name + ": TEST MSG THREE"); ep.afterDelivery();
+ * break;
+ */
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ debug("LEAVE...");
+ }
+
+ public void release() {
+ }
+
+ public void stop() {
+ this.stop = true;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ public Method getOnMessageMethod() {
+
+ Method onMessageMethod = null;
+ try {
+ Class msgListenerClass = connector.MyMessageListener.class;
+ Class[] paramTypes = { java.lang.String.class };
+ onMessageMethod = msgListenerClass.getMethod("onMessage",
+ paramTypes);
+
+ } catch (NoSuchMethodException ex) {
+ ex.printStackTrace();
+ }
+ return onMessageMethod;
+ }
+
+ private void debug(String mesg) {
+ System.out.println("MyWork[" + name + "] --> " + mesg);
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/SimpleActivationSpec.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/SimpleActivationSpec.java
new file mode 100644
index 0000000..4f4840e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/SimpleActivationSpec.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.ResourceAdapter;
+
+/**
+ * This class is supposed to implemented as a JavaBean so that the app server
+ * can instantiate and configure it at the runtime.
+ *
+ * @author Qingqing Ouyang
+ */
+public class SimpleActivationSpec implements ActivationSpec,
+ java.io.Serializable {
+
+ private String destinationName;
+ private String destinationType;
+ private String testProp;
+ private ResourceAdapter resourceadapter;
+
+ /**
+ * Default constructor.
+ */
+ public SimpleActivationSpec() {
+ }
+
+ public String getDestinationName() {
+ return this.destinationName;
+ }
+
+ public void setDestinationName(String name) {
+ debug("setDestinationName() called... name = " + name);
+ this.destinationName = name;
+ }
+
+ public String getDestinationType() {
+ return this.destinationType;
+ }
+
+ public void setDestinationType(String type) {
+ debug("setDestinationType () called... type = " + type);
+ this.destinationType = type;
+ }
+
+ public String getTestProp() {
+ return this.testProp;
+ }
+
+ public void setTestProp(String testProp) {
+ debug("setTestProp () called... testProp = " + testProp);
+ this.testProp = testProp;
+ }
+
+ public ResourceAdapter getResourceAdapter() {
+ debug("getResourceAdapter() called... ");
+ return this.resourceadapter;
+ }
+
+ public void setResourceAdapter(ResourceAdapter ra) {
+ debug("setResourceAdapter() called... ra = " + ra);
+ this.resourceadapter = ra;
+ }
+
+ public void validate() {
+ }
+
+ private void debug(String message) {
+ System.out.println("[SimpleActivationSpec] ==> " + message);
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/SimpleResourceAdapterImpl.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/SimpleResourceAdapterImpl.java
new file mode 100644
index 0000000..11bfe89
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/SimpleResourceAdapterImpl.java
@@ -0,0 +1,224 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+import java.util.Timer;
+
+import javax.resource.NotSupportedException;
+import javax.resource.ResourceException;
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.ResourceAdapter;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.resource.spi.UnavailableException;
+import javax.resource.spi.XATerminator;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.resource.spi.work.ExecutionContext;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkManager;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+/**
+ * This is a sample resource adapter
+ *
+ * @author Qingqing Ouyang
+ */
+public class SimpleResourceAdapterImpl implements ResourceAdapter,
+ java.io.Serializable {
+
+ private BootstrapContext ctx;
+ private WorkManager wm;
+ private String testName;
+
+ private boolean debug = true;
+ private Work work;
+
+ public SimpleResourceAdapterImpl() {
+ debug("constructor...");
+ }
+
+ public void start(BootstrapContext ctx)
+ throws ResourceAdapterInternalException {
+
+ debug("001. Simple RA start...");
+
+ this.ctx = ctx;
+ debug("002. Simple RA start...");
+ this.wm = ctx.getWorkManager();
+ debug("003. Simple RA start...");
+
+ // testing creat timer
+ Timer timer = null;
+ try {
+ timer = ctx.createTimer();
+ } catch (UnavailableException ue) {
+ System.out.println("Error");
+ throw new ResourceAdapterInternalException("Error form bootstrap");
+ }
+ debug("004. Simple RA start...");
+
+ try {
+
+ XATerminator xa = ctx.getXATerminator();
+
+ Xid xid1 = new XID();
+ System.out.println(" XID1 = " + xid1);
+
+ ExecutionContext ec = new ExecutionContext();
+ ec.setXid(xid1);
+ ec.setTransactionTimeout(5 * 1000); // 5 seconds
+ TestWMWork outw = new TestWMWork(1000, false, true, ec);
+ outw.setWorkManager(wm);
+ try {
+ wm.doWork(outw, 1 * 1000, ec, null);
+ xa.commit(xid1, true);
+ } catch (Exception ex) {
+
+ System.out.println(" ex = " + ex.getMessage());
+ xa.rollback(xid1);
+ }
+
+ Xid xid2 = new XID();
+ System.out.println(" XID2 = " + xid2);
+
+ ec = new ExecutionContext();
+ ec.setXid(xid2);
+ ec.setTransactionTimeout(5 * 1000); // 5 seconds
+ TestWMWork anotherw = new TestWMWork(3000, false);
+ anotherw.setWorkManager(wm);
+ try {
+ wm.doWork(anotherw, 1 * 1000, ec, null);
+ xa.commit(xid2, true);
+ } catch (Exception ex) {
+ xa.rollback(xid2);
+ }
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ for (int i = 0; i < 3; i++) {
+ TestWMWork w = new TestWMWork(i, false);
+ try {
+ wm.doWork(w, 1, null, null);
+ } catch (Exception ex) {
+ System.out.println("FAIL: CAUGHT exception : i = " + i);
+ ex.printStackTrace();
+ }
+ }
+
+ for (int i = 3; i < 6; i++) {
+ TestWMWork w = new TestWMWork(i, true);
+ boolean pass = false;
+ try {
+ wm.doWork(w, 1, null, null);
+ } catch (Exception ex) {
+ pass = true;
+ System.out.println("PASS: CAUGHT EXPECTED exception : i = "
+ + i);
+ ex.printStackTrace();
+ } finally {
+ if (!pass) {
+ System.out
+ .println("FAIL: DID NOT GET EXPECTED exception :");
+ }
+ }
+ }
+
+ for (int i = 6; i < 9; i++) {
+ TestWMWork w = new TestWMWork(i, false);
+ try {
+ wm.doWork(w, 1, null, null);
+ } catch (Exception ex) {
+ System.out.println("FAIL: CAUGHT exception : i = " + i);
+ ex.printStackTrace();
+ }
+ }
+
+ for (int i = 9; i < 12; i++) {
+ TestWMWork w = new TestWMWork(i, false);
+ try {
+ wm.startWork(w);
+ } catch (Exception ex) {
+ System.out.println("FAIL: CAUGHT exception : i = " + i);
+ ex.printStackTrace();
+ }
+ }
+
+ for (int i = 12; i < 15; i++) {
+ TestWMWork w = new TestWMWork(i, false);
+ try {
+ wm.scheduleWork(w);
+ } catch (Exception ex) {
+ System.out.println("FAIL: CAUGHT exception : i = " + i);
+ ex.printStackTrace();
+ }
+ }
+
+ debug("005. Simple RA start...");
+ }
+
+ public void stop() {
+ debug("999. Simple RA stop...");
+ if (work != null) {
+ ((WorkDispatcher) work).stop();
+
+ synchronized (Controls.readyLock) {
+ Controls.readyLock.notify();
+ }
+
+ }
+ }
+
+ public void endpointActivation(MessageEndpointFactory factory,
+ ActivationSpec spec) throws NotSupportedException {
+ try {
+ debug("B.000. Create and schedule Dispatcher");
+ work = new WorkDispatcher("DISPATCHER", ctx, factory, spec);
+ wm.scheduleWork(work, 4 * 1000, null, null);
+ debug("B.001. Scheduled Dispatcher");
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public void endpointDeactivation(MessageEndpointFactory endpointFactory,
+ ActivationSpec spec) {
+ debug("endpointDeactivation called...");
+ ((WorkDispatcher) work).stop();
+ }
+
+ public String getTestName() {
+ return testName;
+ }
+
+ public void setTestName(String name) {
+ debug("setTestName called... name = " + name);
+ testName = name;
+ }
+
+ public void debug(String message) {
+ if (debug)
+ System.out.println("[SimpleResourceAdapterImpl] ==> " + message);
+ }
+
+ public XAResource[] getXAResources(ActivationSpec[] specs)
+ throws ResourceException {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/TestCDIBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/TestCDIBean.java
new file mode 100644
index 0000000..c4ec82d
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/TestCDIBean.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+//A test CDI bean that is bundled along with an embedded RAR
+public class TestCDIBean {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/TestWMWork.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/TestWMWork.java
new file mode 100644
index 0000000..9458496
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/TestWMWork.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+import javax.resource.spi.work.ExecutionContext;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkException;
+import javax.resource.spi.work.WorkManager;
+
+/**
+ *
+ * @author Qingqing Ouyang
+ */
+public class TestWMWork implements Work {
+
+ private boolean stop = false;
+ private int id;
+ private boolean isRogue;
+ private boolean doNest;
+ private WorkManager wm;
+ private ExecutionContext ctx;
+
+ public TestWMWork(int id, boolean isRogue) {
+ this(id, isRogue, false, null);
+ }
+
+ public TestWMWork(int id, boolean isRogue, boolean doNest,
+ ExecutionContext ctx) {
+ this.id = id;
+ this.isRogue = isRogue;
+ this.doNest = doNest;
+ this.ctx = ctx;
+ }
+
+ public void setWorkManager(WorkManager wm) {
+ this.wm = wm;
+ }
+
+ public void run() {
+
+ System.out.println("TestWMWork[" + id + "].start running");
+ if (!isRogue) {
+ try {
+ Thread.currentThread().sleep(1000);
+ } catch (Exception ex) {
+ System.out.println("TestWMWork[" + id + "].interrupted = ");
+ ex.printStackTrace();
+ }
+ } else {
+ System.out
+ .println("TestWMWork: Simulating rogue RA's Work: Expected Arithmetic Exception - divide by Zero");
+ int j = 100 / 0;
+ }
+
+ if (doNest && (wm != null)) {
+ Work nestedWork = new TestWMWork(8888, false);
+ try {
+ wm.doWork(nestedWork, 1 * 1000, ctx, null);
+ } catch (WorkException ex) {
+ if (ex.getErrorCode().equals(
+ WorkException.TX_CONCURRENT_WORK_DISALLOWED)) {
+ System.out.println("TestWMWork[" + id + "] "
+ + "PASS: CAUGHT EXPECTED = " + ex.getErrorCode());
+ } else {
+ System.out.println("TestWMWork[" + id + "] "
+ + "FAIL: CAUGHT UNEXPECTED = "
+ + ex.getErrorCode());
+ }
+ }
+
+ nestedWork = new TestWMWork(9999, false);
+ try {
+ ExecutionContext ec = new ExecutionContext();
+ ec.setXid(new XID());
+ ec.setTransactionTimeout(5 * 1000); // 5 seconds
+ wm.doWork(nestedWork, 1 * 1000, ec, null);
+ } catch (Exception ex) {
+ System.out.println("TestWMWork[" + id + "] "
+ + "FAIL: CAUGHT UNEXPECTED = " + ex.getMessage());
+ }
+ }
+
+ System.out.println("TestWMWork[" + id + "].stop running");
+ }
+
+ public void release() {
+ }
+
+ public void stop() {
+ this.stop = true;
+ }
+
+ public String toString() {
+ return String.valueOf(id);
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/WorkDispatcher.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/WorkDispatcher.java
new file mode 100644
index 0000000..febd104
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/WorkDispatcher.java
@@ -0,0 +1,323 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+import java.lang.reflect.Method;
+
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.UnavailableException;
+import javax.resource.spi.XATerminator;
+import javax.resource.spi.endpoint.MessageEndpoint;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.resource.spi.work.ExecutionContext;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkManager;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+/**
+ *
+ * @author Qingqing Ouyang
+ */
+public class WorkDispatcher implements Work {
+
+ private boolean stop = false;
+ private String id;
+ private MessageEndpointFactory factory;
+ private BootstrapContext ctx;
+ private ActivationSpec spec;
+ private WorkManager wm;
+ private XATerminator xa;
+
+ public WorkDispatcher(String id, BootstrapContext ctx,
+ MessageEndpointFactory factory, ActivationSpec spec) {
+ this.id = id;
+ this.ctx = ctx;
+ this.factory = factory;
+ this.spec = spec;
+ this.wm = ctx.getWorkManager();
+ this.xa = ctx.getXATerminator();
+ }
+
+ public void run() {
+
+ debug("ENTER...");
+
+ try {
+ synchronized (Controls.readyLock) {
+ debug("WAIT...");
+ Controls.readyLock.wait();
+
+ if (stop) {
+ return;
+ }
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ debug("Running...");
+
+ // try 3 times to create endpoint (in case of failure)
+ for (int i = 0; i < 3; i++) {
+
+ try {
+
+ Method onMessage = getOnMessageMethod();
+ System.out.println("isDeliveryTransacted = "
+ + factory.isDeliveryTransacted(onMessage));
+
+ if (!factory.isDeliveryTransacted(onMessage)) {
+ // MessageEndpoint ep = factory.createEndpoint(null);
+ // DeliveryWork d = new DeliveryWork("NO_TX", ep);
+ // wm.doWork(d, 0, null, null);
+ } else {
+
+ // MessageEndpoint ep = factory.createEndpoint(null);
+ MessageEndpoint ep = factory
+ .createEndpoint(new FakeXAResource());
+ int numOfMessages = 5;
+
+ // importing transaction
+
+ // write/commit
+ ExecutionContext ec = startTx();
+ debug("Start TX - " + ec.getXid());
+
+ DeliveryWork w = new DeliveryWork(ep, numOfMessages,
+ "WRITE");
+ wm.doWork(w, 0, ec, null);
+ xa.commit(ec.getXid(), true);
+
+ debug("DONE WRITE TO DB");
+ Controls.expectedResults = numOfMessages;
+ notifyAndWait();
+
+ // delete/rollback
+ ec = startTx();
+ debug("Start TX - " + ec.getXid());
+
+ w = new DeliveryWork(ep, numOfMessages, "DELETE");
+ wm.doWork(w, 0, ec, null);
+ xa.rollback(ec.getXid());
+
+ debug("DONE ROLLBACK FROM DB");
+ Controls.expectedResults = numOfMessages;
+ notifyAndWait();
+
+ // delete/commit
+ ec = startTx();
+ debug("Start TX - " + ec.getXid());
+
+ w = new DeliveryWork(ep, numOfMessages, "DELETE");
+ wm.doWork(w, 0, ec, null);
+ xa.commit(ec.getXid(), true);
+
+ debug("DONE DELETE FROM DB");
+ Controls.expectedResults = 0;
+ notifyAndWait();
+
+ // write/commit
+ ec = startTx();
+ debug("Start TX - " + ec.getXid());
+
+ w = new DeliveryWork(ep, numOfMessages, "WRITE");
+ wm.doWork(w, 0, ec, null);
+ xa.commit(ec.getXid(), true);
+
+ debug("DONE WRITE TO DB");
+ Controls.expectedResults = numOfMessages;
+ notifyAndWait();
+
+ // delete/commit
+ ec = startTx();
+ debug("Start TX - " + ec.getXid());
+
+ w = new DeliveryWork(ep, numOfMessages, "DELETE");
+ wm.doWork(w, 0, ec, null);
+ xa.commit(ec.getXid(), true);
+
+ debug("DONE DELETE FROM DB");
+ Controls.expectedResults = 0;
+ notifyAndWait();
+
+ // write multiple times using doWork/commit
+ ec = startTx();
+ debug("Start TX - " + ec.getXid());
+
+ w = new DeliveryWork(ep, 1, "WRITE", true);
+ wm.doWork(w, 0, ec, null);
+ wm.doWork(w, 0, ec, null);
+ wm.doWork(w, 0, ec, null);
+ xa.commit(ec.getXid(), true);
+
+ debug("DONE WRITE TO DB");
+ Controls.expectedResults = 3;
+ notifyAndWait();
+
+ // write multiple times using doWork/rollback
+ ec = startTx();
+ debug("Start TX - " + ec.getXid());
+
+ w = new DeliveryWork(ep, 1, "WRITE", true);
+ wm.doWork(w, 0, ec, null);
+ wm.doWork(w, 0, ec, null);
+ wm.doWork(w, 0, ec, null);
+ xa.rollback(ec.getXid());
+
+ debug("DONE WRITE TO DB");
+ Controls.expectedResults = 3;
+ notifyAndWait();
+
+ ec = startTx();
+ debug("Start TX - " + ec.getXid());
+
+ // write multiple times using doWork/rollback
+ w = new DeliveryWork(ep, 2, "WRITE", true);
+ wm.doWork(w, 0, ec, null);
+ wm.doWork(w, 0, ec, null);
+ wm.doWork(w, 0, ec, null);
+
+ if (XAResource.XA_OK == xa.prepare(ec.getXid())) {
+ xa.commit(ec.getXid(), false);
+ debug("XA PREPARE/COMMIT. DONE WRITE TO DB ");
+ Controls.expectedResults = 9;
+ notifyAndWait();
+ } else {
+ xa.rollback(ec.getXid());
+ debug("XA PREPARE UNSUCCESSFUL. DONE ROLLBACK");
+ Controls.expectedResults = 3;
+ notifyAndWait();
+ }
+
+ // delete all.
+ ec = startTx();
+ debug("Start TX - " + ec.getXid());
+
+ w = new DeliveryWork(ep, 1, "DELETE_ALL");
+ wm.doWork(w, 0, ec, null);
+ xa.commit(ec.getXid(), true);
+
+ debug("DONE DELETE ALL FROM DB");
+ Controls.expectedResults = 0;
+ notifyAndWait();
+
+ done();
+ }
+
+ break;
+ } catch (UnavailableException ex) {
+ // ex.printStackTrace();
+ System.out.println("WorkDispatcher[" + id
+ + "] Endpoint Unavailable");
+ try {
+ Thread.currentThread().sleep(3 * 1000); // 3 seconds
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } catch (XAException ex) {
+ ex.printStackTrace();
+ System.out.println("ERROR CODE = " + ex.errorCode);
+ done();
+ break;
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ done();
+ break;
+ }
+ }
+
+ debug("LEAVE...");
+ }
+
+ public void release() {
+ }
+
+ public void stop() {
+ this.stop = true;
+ }
+
+ public String toString() {
+ return id;
+ }
+
+ public Method getOnMessageMethod() {
+
+ Method onMessageMethod = null;
+ try {
+ Class msgListenerClass = connector.MyMessageListener.class;
+ Class[] paramTypes = { java.lang.String.class };
+ onMessageMethod = msgListenerClass.getMethod("onMessage",
+ paramTypes);
+
+ } catch (NoSuchMethodException ex) {
+ ex.printStackTrace();
+ }
+ return onMessageMethod;
+ }
+
+ private ExecutionContext startTx() {
+ ExecutionContext ec = new ExecutionContext();
+ try {
+ Xid xid = new XID();
+ ec.setXid(xid);
+ ec.setTransactionTimeout(5 * 1000); // 5 seconds
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ return ec;
+ }
+
+ private void notifyAndWait() {
+ try {
+ // Sleep for 5 seconds
+ // Thread.currentThread().sleep(5*1000);
+
+ synchronized (Controls.readyLock) {
+ // Notify the client to check the results
+ Controls.readyLock.notify();
+
+ // Wait until results are verified by the client
+ Controls.readyLock.wait();
+
+ if (stop) {
+ return;
+ }
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ private void done() {
+ try {
+ Controls.done = true;
+ synchronized (Controls.readyLock) {
+ // Notify the client to check the results
+ Controls.readyLock.notify();
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ private void debug(String mesg) {
+ System.out.println("Dispatcher[" + id + "] --> " + mesg);
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/XID.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/XID.java
new file mode 100644
index 0000000..191b904
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/embedded-resource-adapter-as-bean-archive/ra/src/connector/XID.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+import javax.transaction.xa.Xid;
+
+/**
+ * The XID class provides an implementation of the X/Open transaction identifier
+ * it implements the javax.transaction.xa.Xid interface.
+ */
+public class XID implements Xid {
+
+ private static int ID = initializeID();
+
+ private static int initializeID() {
+ return (int) (Math.random() * 100000);
+ }
+
+ public int formatID; // Format identifier
+ // (-1) means that the XID is null
+ public int branchQualifier;
+ public int globalTxID;
+
+ static public final int MAXGTRIDSIZE = 64;
+ static public final int MAXBQUALSIZE = 64;
+
+ public XID() {
+ int foo = ID++;
+ formatID = foo;
+ branchQualifier = foo;
+ globalTxID = foo;
+ }
+
+ public boolean equals(Object o) {
+ XID other; // The "other" XID
+ int L; // Combined gtrid_length + bqual_length
+ int i;
+
+ if (!(o instanceof XID)) // If the other XID isn't an XID
+ {
+ return false; // It can't be equal
+ }
+
+ other = (XID) o; // The other XID, now properly cast
+
+ if (this.formatID == other.formatID
+ && this.branchQualifier == other.branchQualifier
+ && this.globalTxID == other.globalTxID) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Compute the hash code.
+ *
+ * @return the computed hashcode
+ */
+ public int hashCode() {
+ if (formatID == (-1)) {
+ return (-1);
+ }
+
+ return formatID + branchQualifier + globalTxID;
+
+ }
+
+ /*
+ * Convert to String
+ *
+ * <p> This is normally used to display the XID when debugging.
+ */
+
+ /**
+ * Return a string representing this XID.
+ *
+ * @return the string representation of this XID
+ */
+ public String toString() {
+
+ String s = new String("{XID: " + "formatID(" + formatID + "), "
+ + "branchQualifier (" + branchQualifier + "), "
+ + "globalTxID(" + globalTxID + ")}");
+
+ return s;
+ }
+
+ /*
+ * Return branch qualifier
+ */
+
+ /**
+ * Returns the branch qualifier for this XID.
+ *
+ * @return the branch qualifier
+ */
+ public byte[] getBranchQualifier() {
+ String foo = (new Integer(branchQualifier)).toString();
+ return foo.getBytes();
+ }
+
+ public int getFormatId() {
+ return formatID;
+ }
+
+ public byte[] getGlobalTransactionId() {
+ String foo = (new Integer(globalTxID)).toString();
+ return foo.getBytes();
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/README
new file mode 100644
index 0000000..4d99b31
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/README
@@ -0,0 +1,3 @@
+Test
+- Test whether the proxy to a no-interface local EJB is serializable
+Issue 12599
\ No newline at end of file
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/build.properties
new file mode 100644
index 0000000..706d46a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/build.properties
@@ -0,0 +1,25 @@
+<!--
+
+ Copyright (c) 2018 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
+
+-->
+
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-no-interface-local-view-proxy-serializable"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
+<property name="persistence.xml" value="descriptor/persistence.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/build.xml
new file mode 100644
index 0000000..295d086
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/build.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (c) 2010, 2018 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
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+ &commonSetup;
+ &commonBuild;
+ &testproperties;
+ &run;
+
+ <target name="all" depends="build,create-resources,deploy,run,undeploy,delete-resources" />
+
+ <target name="clean" depends="init-common">
+ <antcall target="clean-common" />
+ <delete>
+ <fileset dir="." includes="*.class" />
+ <fileset dir="client/test/client" includes="*.class" />
+ </delete>
+ </target>
+
+ <target name="compile" depends="clean">
+ <antcall target="compile-common">
+ <param name="src" value="servlet" />
+ </antcall>
+ </target>
+
+ <target name="build" depends="compile">
+ <property name="hasWebclient" value="yes" />
+ <antcall target="webclient-war-common">
+ <param name="hasWebclient" value="yes" />
+ <param name="webclient.war.classes" value="**/*.class" />
+ </antcall>
+
+ <javac srcdir="client" classpath="${env.APS_HOME}/lib/reportbuilder.jar" includes="test/client/WebTest.java" />
+
+ </target>
+
+ <target name="build-publish-war" depends="build, publish-war-common" />
+
+ <target name="deploy" depends="init-common">
+ <antcall target="deploy-war-common" />
+ </target>
+
+ <target name="create-resources" depends="init-common">
+ <antcall target="create-jdbc-connpool-common">
+ <param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+ </antcall>
+ <antcall target="create-jdbc-resource-common">
+ <param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+ <param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+ </antcall>
+ </target>
+
+
+ <target name="run" depends="init-common">
+ <java classname="test.client.WebTest">
+ <arg value="${http.host}" />
+ <arg value="${http.port}" />
+ <arg value="${contextroot}" />
+ <classpath>
+ <pathelement location="${env.APS_HOME}/lib/reportbuilder.jar" />
+ <pathelement location="client" />
+ </classpath>
+ </java>
+ </target>
+
+ <target name="undeploy" depends="init-common">
+ <antcall target="undeploy-war-common" />
+ </target>
+
+ <target name="delete-resources" depends="init-common">
+ <antcall target="delete-jdbc-resource-common">
+ <param name="jdbc.resource.name" value="jdbc/jdbc-dev-test-resource" />
+ </antcall>
+
+ <antcall target="delete-jdbc-connpool-common">
+ <param name="jdbc.connpool.name" value="jdbc-dev-test-pool" />
+ </antcall>
+ </target>
+
+ <target name="usage">
+ <antcall target="usage-common" />
+ </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/client/test/client/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/client/test/client/WebTest.java
new file mode 100644
index 0000000..08ed734
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/client/test/client/WebTest.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.client;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+/*
+ * Unit test for @WebServlet
+ */
+@SuppressWarnings("deprecation")
+public class WebTest {
+
+ private static SimpleReporterAdapter stat = new SimpleReporterAdapter(
+ "appserv-tests");
+ private static final String TEST_NAME = "no-interface-local-view-proxy-serializable";
+
+ private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0.";
+
+ private String host;
+ private String port;
+ private String contextRoot;
+
+ public WebTest(String[] args) {
+ host = args[0];
+ port = args[1];
+ contextRoot = args[2];
+ }
+
+ public static void main(String[] args) {
+ stat.addDescription("Unit test for Java EE resource injection");
+ WebTest webTest = new WebTest(args);
+ webTest.doTest();
+ stat.printSummary(TEST_NAME);
+ }
+
+ public void doTest() {
+ try {
+ invoke();
+ } catch (Exception ex) {
+ System.out.println(TEST_NAME + " test failed");
+ stat.addStatus(TEST_NAME, SimpleReporterAdapter.FAIL);
+ ex.printStackTrace();
+ }
+ }
+
+ private void invoke() throws Exception {
+
+ String url = "http://" + host + ":" + port + contextRoot + "/myurl";
+ System.out.println("opening connection to " + url);
+ HttpURLConnection conn = (HttpURLConnection) (new URL(url))
+ .openConnection();
+
+ int code = conn.getResponseCode();
+ if (code != 200) {
+ System.out.println("Unexpected return code: " + code);
+ stat.addStatus(TEST_NAME, SimpleReporterAdapter.FAIL);
+ } else {
+ InputStream is = null;
+ BufferedReader input = null;
+ String line = null;
+ try {
+ is = conn.getInputStream();
+ input = new BufferedReader(new InputStreamReader(is));
+ line = input.readLine();
+ System.out.println("line = " + line);
+ } finally {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch (IOException ioe) {
+ // ignore
+ }
+ try {
+ if (input != null) {
+ input.close();
+ }
+ } catch (IOException ioe) {
+ // ignore
+ }
+ }
+ if (EXPECTED_RESPONSE.equals(line)) {
+ stat.addStatus(TEST_NAME, SimpleReporterAdapter.PASS);
+ } else {
+ System.out.println("Wrong response. Expected: "
+ + EXPECTED_RESPONSE + ", received: " + line);
+ stat.addStatus(TEST_NAME, SimpleReporterAdapter.FAIL);
+ }
+ }
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/descriptor/beans.xml
new file mode 100644
index 0000000..1d355f8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/descriptor/beans.xml
@@ -0,0 +1,25 @@
+<!--
+
+ Copyright (c) 2017, 2018 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
+
+-->
+
+<beans
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+</beans>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/descriptor/persistence.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/descriptor/persistence.xml
new file mode 100644
index 0000000..82f2d7b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/descriptor/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (c) 1997, 2018 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
+
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+ <persistence-unit name="pu1" transaction-type="JTA">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ <jta-data-source>jdbc/__default</jta-data-source>
+ <non-jta-data-source>jdbc/__default</non-jta-data-source>
+ <class>myapp.Department</class>
+ <class>myapp.Employee</class>
+ <properties>
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+ <property name="eclipselink.logging.level" value="INFO"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/servlet/test/beans/TestBeanInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/servlet/test/beans/TestBeanInterface.java
new file mode 100644
index 0000000..47668a4
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/servlet/test/beans/TestBeanInterface.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans;
+
+public interface TestBeanInterface {
+ public void setState(String s);
+ public String getState();
+
+ public void method1();
+}
+
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/servlet/test/beans/nonmock/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/servlet/test/beans/nonmock/TestBean.java
new file mode 100644
index 0000000..5099e36
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/servlet/test/beans/nonmock/TestBean.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans.nonmock;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Inject;
+
+import test.beans.TestBeanInterface;
+import test.ejb.HelloNoInterfaceLocalViewSfulEJB;
+import test.ejb.HelloNoInterfaceLocalViewSlessEJB;
+
+
+@SessionScoped
+public class TestBean implements TestBeanInterface, Serializable{
+ public static boolean testBeanInvoked = false;
+
+ @Inject
+ HelloNoInterfaceLocalViewSfulEJB sfulEJB;
+
+ @Inject
+ HelloNoInterfaceLocalViewSlessEJB slessEJB;
+
+ @Override
+ public void setState(String s) {
+ testBeanInvoked = true;
+ System.out.println("TestBean::m1 called");
+ sfulEJB.setState(s);
+ }
+
+ @Override
+ public String getState() {
+ System.out.println("TestBean::m2 called");
+ return sfulEJB.getState();
+ }
+
+ @Override
+ public String toString(){
+ return "TestBean::ejb=" + sfulEJB;
+ }
+
+ @Override
+ public void method1() {
+ slessEJB.method1("World");
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/servlet/test/ejb/HelloNoInterfaceLocalViewSfulEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/servlet/test/ejb/HelloNoInterfaceLocalViewSfulEJB.java
new file mode 100644
index 0000000..0abcba6
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/servlet/test/ejb/HelloNoInterfaceLocalViewSfulEJB.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.ejb;
+
+import javax.ejb.Stateful;
+
+@Stateful
+public class HelloNoInterfaceLocalViewSfulEJB {
+
+ private String message;
+ public void setState(String msg){
+ this.message = msg;
+
+ }
+ public String getState() {
+ return this.message;
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/servlet/test/ejb/HelloNoInterfaceLocalViewSlessEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/servlet/test/ejb/HelloNoInterfaceLocalViewSlessEJB.java
new file mode 100644
index 0000000..4818e1f
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/servlet/test/ejb/HelloNoInterfaceLocalViewSlessEJB.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.ejb;
+
+import javax.ejb.Stateful;
+
+@Stateful
+public class HelloNoInterfaceLocalViewSlessEJB {
+ public void method1(String msg) {
+ System.out.println("Hello" + msg);
+ }
+
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/servlet/test/servlet/NoInterfaceProxySerializableEJBTestServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/servlet/test/servlet/NoInterfaceProxySerializableEJBTestServlet.java
new file mode 100644
index 0000000..13a603b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/no-interface-local-view-proxy-serializable/servlet/test/servlet/NoInterfaceProxySerializableEJBTestServlet.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.servlet;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.PrintWriter;
+
+import javax.inject.Inject;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import test.beans.TestBeanInterface;
+
+@WebServlet(name = "mytest", urlPatterns = { "/myurl" })
+public class NoInterfaceProxySerializableEJBTestServlet extends HttpServlet {
+
+ @Inject
+ TestBeanInterface tbi;
+
+ protected void doGet(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException,
+ IOException {
+ PrintWriter writer = response.getWriter();
+ writer.write("Hello from Servlet 3.0.");
+ String msg = "";
+
+ // set state
+ tbi.setState("TEST");
+
+ // Test serializability of EJB in TestBean.
+ try {
+ File tmpFile = File.createTempFile("SerializableProxyTest", null);
+ FileOutputStream fout = new FileOutputStream(tmpFile);
+ ObjectOutputStream oos = new ObjectOutputStream(fout);
+ System.out.println("Writing " + tbi + " to file-" + tmpFile);
+ oos.writeObject(tbi);
+ oos.close();
+
+ FileInputStream fin = new FileInputStream(tmpFile);
+ ObjectInputStream ois = new ObjectInputStream(fin);
+ System.out.println("Attempting to read " + tbi + " from file-"
+ + tmpFile);
+
+ TestBeanInterface tb = (TestBeanInterface) ois.readObject();
+ // check if we have access to the same stateful session bean
+ System.out.println(tb.getState().equals("TEST"));
+ if (!tb.getState().equals("TEST"))
+ msg += "Failed to serialize stateful bean";
+ //check if we can invoke stateless EJB
+ tb.method1();
+ ois.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ msg += "Failed to serialize/deserialize proxy to EJB";
+ }
+
+ writer.write(msg + "\n");
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/README
new file mode 100644
index 0000000..b98ee72
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/README
@@ -0,0 +1,3 @@
+A simple field injection of a session scoped Bean into a Servlet that is bundled in an EAR.
+Related GlassFish issue: https://glassfish.dev.java.net/issues/show_bug.cgi?id=14832
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/build.properties
new file mode 100644
index 0000000..e8ca782
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/build.properties
@@ -0,0 +1,28 @@
+<!--
+
+ Copyright (c) 2018 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
+
+-->
+
+
+<property name="module" value="cdi-full-ear"/>
+<property name="appname" value="${module}"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="se.client" value="com.acme.Client"/>
+<property name="app.type" value="application"/>
+<property name="sun-application.xml" value="descriptor/sun-application.xml"/>
+<property name="application.xml" value="descriptor/application.xml"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
+<property name="contextroot" value="${module}"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/build.xml
new file mode 100644
index 0000000..5cb4fe7
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/build.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (c) 2010, 2018 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
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="cdi-full-ear-App" default="usage" basedir=".">
+
+ &commonSetup;
+ &commonBuild;
+ &testproperties;
+
+ <target name="all" depends="clean,build,deploy,run,undeploy"/>
+
+ <target name="clean" depends="init-common">
+ <antcall target="clean-common"/>
+ </target>
+
+ <target name="compile" depends="clean">
+ <antcall target="compile-common">
+ <param name="src" value="war"/>
+ </antcall>
+ <antcall target="webclient-war-common">
+ <param name="hasWebclient" value="true"/>
+ </antcall>
+ <antcall target="compile-common">
+ <param name="src" value="ejb"/>
+ </antcall>
+
+ <javac classpath="${env.S1AS_HOME}/lib/javaee.jar:${env.S1AS_HOME}/modules/gf-client.jar:${build.classes.dir}:${env.APS_HOME}/lib/reporter.jar" srcdir="client" destdir="${build.classes.dir}" debug="on" failonerror="true">
+ <compilerarg line="-endorseddirs ${env.S1AS_HOME}/modules/endorsed"/>
+
+ </javac>
+<!--
+ <antcall target="compile-common">
+ <param name="src" value="client"/>
+ </antcall>
+-->
+ </target>
+
+ <target name="build" depends="compile">
+ <mkdir dir="${assemble.dir}"/>
+ <antcall target="ejb-jar-common">
+ <param name="ejbjar.classes" value="**/Foo.class,**/Hello.class,**/HelloRemote.class,**/Singleton*.class,**/HelloStateless.class,**/HelloSingleton.class,**/FooManagedBean.class,**/BarManagedBean.class, **/FooBarManagedBean.class, **/ManagedSuper.class"/>
+ </antcall>
+ <antcall target="ear-common"/>
+ </target>
+
+ <target name="deploy"
+ depends="init-common">
+ <antcall target="deploy-common"/>
+ </target>
+
+ <target name="run" depends="init-common">
+ <java fork="on"
+ failonerror="true"
+ classpath="${env.S1AS_HOME}/lib/javaee.jar:${env.S1AS_HOME}/modules/gf-client.jar:${build.classes.dir}:${env.APS_HOME}/lib/reporter.jar"
+ classname="${se.client}">
+ <arg line="${contextroot}"/>
+ <arg line="${http.host}"/>
+ <arg line="${http.port}"/>
+ </java>
+ </target>
+
+ <target name="undeploy" depends="init-common">
+ <antcall target="undeploy-common"/>
+ </target>
+
+ <target name="usage">
+ <antcall target="usage-common"/>
+ </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/client/com/acme/Client.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/client/com/acme/Client.java
new file mode 100644
index 0000000..4271f2a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/client/com/acme/Client.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import javax.annotation.Resource;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+public class Client {
+
+ private static final String TEST_NAME = "normal-lookup-in-ear";
+
+ private static SimpleReporterAdapter stat = new SimpleReporterAdapter(
+ "appserv-tests");
+
+ private static String appName;
+ private String host;
+ private String port;
+
+ @Resource(lookup = "java:app/env/value1")
+ private static Integer appLevelViaLookup;
+
+ public static void main(String args[]) {
+ appName = args[0];
+ stat.addDescription(appName);
+ Client client = new Client(args);
+ client.doTest();
+ stat.printSummary(appName + "ID");
+ System.out.println("appLevelViaLookup = '" + appLevelViaLookup + "'");
+ }
+
+ public Client(String[] args) {
+ host = args[1];
+ port = args[2];
+ }
+
+ public void doTest() {
+
+ try {
+
+ String url = "http://" + host + ":" + port + "/" + appName
+ + "/HelloServlet";
+
+ System.out.println("invoking webclient servlet at " + url);
+
+ URL u = new URL(url);
+
+ HttpURLConnection c1 = (HttpURLConnection) u.openConnection();
+ int code = c1.getResponseCode();
+ InputStream is = c1.getInputStream();
+ BufferedReader input = new BufferedReader(new InputStreamReader(
+ is));
+ String line = null;
+ while ((line = input.readLine()) != null) {
+ System.out.println("<response>:" + line);
+ if (line.trim().length() > 0) {
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ return;
+ }
+ }
+ if (code != 200) {
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ return;
+ }
+ stat.addStatus(TEST_NAME, stat.PASS);
+
+ } catch (Exception e) {
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/descriptor/application.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/descriptor/application.xml
new file mode 100644
index 0000000..d9378e7
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/descriptor/application.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (c) 2010, 2018 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
+
+-->
+
+<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="6" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd">
+ <display-name>ejb-ejb30-hello-session3App</display-name>
+ <module>
+ <ejb>cdi-full-ear-ejb.jar</ejb>
+ </module>
+ <module>
+ <web>
+ <web-uri>cdi-full-ear-web.war</web-uri>
+ <context-root>cdi-full-ear</context-root>
+ </web>
+ </module>
+ <env-entry>
+ <env-entry-name>java:app/env/value1</env-entry-name>
+ <env-entry-type>java.lang.Integer</env-entry-type>
+ <env-entry-value>18338</env-entry-value>
+ </env-entry>
+ <env-entry>
+ <env-entry-name>java:app/env/myString</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>myString</env-entry-value>
+ </env-entry>
+</application>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/descriptor/beans.xml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/descriptor/beans.xml
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/ejb/com/acme/Hello.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/ejb/com/acme/Hello.java
new file mode 100644
index 0000000..2ad0681
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/ejb/com/acme/Hello.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme;
+
+
+
+public interface Hello {
+
+ public String hello();
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/ejb/com/acme/HelloSingleton.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/ejb/com/acme/HelloSingleton.java
new file mode 100644
index 0000000..4a9b9bf
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/ejb/com/acme/HelloSingleton.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.SessionContext;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+
+@Singleton
+@Startup
+public class HelloSingleton implements Hello {
+
+ @Resource
+ SessionContext sessionCtx;
+
+ @Resource(name = "java:app/env/myString")
+ protected String myString;
+
+ @EJB(name = "java:app/env/appLevelEjbRef")
+ private Hello hello;
+
+ String appName;
+ String moduleName;
+
+ @PostConstruct
+ private void init() {
+ System.out.println("HelloSingleton::init()");
+
+ System.out.println("myString = '" + myString + "'");
+ if ((myString == null) || !(myString.equals("myString"))) {
+ throw new RuntimeException("Invalid value " + myString
+ + " for myString");
+ }
+
+ appName = (String) sessionCtx.lookup("java:app/AppName");
+ moduleName = (String) sessionCtx.lookup("java:module/ModuleName");
+
+ System.out.println("AppName = " + appName);
+ System.out.println("ModuleName = " + moduleName);
+
+ }
+
+ public String hello() {
+
+ System.out.println("HelloSingleton::hello()");
+
+ return "hello, world!\n";
+ }
+
+ @PreDestroy
+ private void destroy() {
+ System.out.println("HelloSingleton::destroy()");
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/manifest.mf b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/war/com/acme/Hello.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/war/com/acme/Hello.java
new file mode 100644
index 0000000..2ad0681
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/war/com/acme/Hello.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme;
+
+
+
+public interface Hello {
+
+ public String hello();
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/war/com/acme/NormalLookupInEARServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/war/com/acme/NormalLookupInEARServlet.java
new file mode 100644
index 0000000..d0ed24f
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/war/com/acme/NormalLookupInEARServlet.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+import javax.naming.InitialContext;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@SuppressWarnings("serial")
+@WebServlet(urlPatterns = "/HelloServlet", loadOnStartup = 1)
+@EJB(name = "java:module/m1", beanName = "HelloSingleton", beanInterface = Hello.class)
+public class NormalLookupInEARServlet extends HttpServlet {
+
+ @Resource(name = "java:app/env/myString")
+ protected String myString;
+
+ private Hello singleton1;
+
+ @Inject
+ TestBean tw;
+
+ private String msg = "";
+
+ @Override
+ public void init(ServletConfig config) throws ServletException {
+ super.init(config);
+
+ System.out.println("In HelloServlet::init");
+ System.out.println("myString = '" + myString + "'");
+ if ((myString == null) || !(myString.equals("myString"))) {
+ msg += "@Resource lookup of myString failed";
+ throw new RuntimeException("Invalid value " + myString
+ + " for myString");
+ }
+
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ System.out.println("In HelloServlet::doGet");
+ resp.setContentType("text/html");
+
+ PrintWriter out = resp.getWriter();
+ try {
+ InitialContext ic = new InitialContext();
+ String appName = (String) ic.lookup("java:app/AppName");
+ String moduleName = (String) ic.lookup("java:module/ModuleName");
+ checkForNull(appName, "AppName lookup returned null");
+ checkForNull(moduleName, "ModuleName lookup returned null");
+
+ singleton1 = (Hello) ic.lookup("java:module/m1");
+ checkForNull(singleton1,
+ "programmatic lookup of module-level singleton EJB failed");
+
+ System.out.println("My AppName = "
+ + ic.lookup("java:app/AppName"));
+
+ System.out.println("My ModuleName = "
+ + ic.lookup("java:module/ModuleName"));
+
+ } catch (Exception e) {
+ msg += "Exception occurred during test Exception: "
+ + e.getMessage();
+ e.printStackTrace();
+ }
+
+ singleton1.hello();
+
+ checkForNull(tw, "normal lookup of session scoped bean in war failed");
+
+ out.println(msg);
+
+ }
+
+ protected void checkForNull(Object o, String errorMessage) {
+ if (o == null)
+ msg += " " + errorMessage;
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/war/com/acme/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/war/com/acme/TestBean.java
new file mode 100644
index 0000000..f0092d7
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/war/com/acme/TestBean.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme;
+
+public interface TestBean {
+ public void m1();
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/war/com/acme/TestBeanWARImpl.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/war/com/acme/TestBeanWARImpl.java
new file mode 100644
index 0000000..8b45c02
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/war/com/acme/TestBeanWARImpl.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme;
+
+import javax.enterprise.context.SessionScoped;
+
+
+@SessionScoped
+public class TestBeanWARImpl implements TestBean,java.io.Serializable {
+ @Override
+ public void m1() {
+ System.out.println("TestBean::m1");
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/README
new file mode 100644
index 0000000..e3888d0
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/README
@@ -0,0 +1,4 @@
+A variant of the normal-bean-injection-ear testcase that uses programmatic lookup
+
+Related GlassFish issue: https://glassfish.dev.java.net/issues/show_bug.cgi?id=14832
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/build.properties
new file mode 100644
index 0000000..e8ca782
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/build.properties
@@ -0,0 +1,28 @@
+<!--
+
+ Copyright (c) 2018 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
+
+-->
+
+
+<property name="module" value="cdi-full-ear"/>
+<property name="appname" value="${module}"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="se.client" value="com.acme.Client"/>
+<property name="app.type" value="application"/>
+<property name="sun-application.xml" value="descriptor/sun-application.xml"/>
+<property name="application.xml" value="descriptor/application.xml"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
+<property name="contextroot" value="${module}"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/build.xml
new file mode 100644
index 0000000..5cb4fe7
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/build.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (c) 2010, 2018 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
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="cdi-full-ear-App" default="usage" basedir=".">
+
+ &commonSetup;
+ &commonBuild;
+ &testproperties;
+
+ <target name="all" depends="clean,build,deploy,run,undeploy"/>
+
+ <target name="clean" depends="init-common">
+ <antcall target="clean-common"/>
+ </target>
+
+ <target name="compile" depends="clean">
+ <antcall target="compile-common">
+ <param name="src" value="war"/>
+ </antcall>
+ <antcall target="webclient-war-common">
+ <param name="hasWebclient" value="true"/>
+ </antcall>
+ <antcall target="compile-common">
+ <param name="src" value="ejb"/>
+ </antcall>
+
+ <javac classpath="${env.S1AS_HOME}/lib/javaee.jar:${env.S1AS_HOME}/modules/gf-client.jar:${build.classes.dir}:${env.APS_HOME}/lib/reporter.jar" srcdir="client" destdir="${build.classes.dir}" debug="on" failonerror="true">
+ <compilerarg line="-endorseddirs ${env.S1AS_HOME}/modules/endorsed"/>
+
+ </javac>
+<!--
+ <antcall target="compile-common">
+ <param name="src" value="client"/>
+ </antcall>
+-->
+ </target>
+
+ <target name="build" depends="compile">
+ <mkdir dir="${assemble.dir}"/>
+ <antcall target="ejb-jar-common">
+ <param name="ejbjar.classes" value="**/Foo.class,**/Hello.class,**/HelloRemote.class,**/Singleton*.class,**/HelloStateless.class,**/HelloSingleton.class,**/FooManagedBean.class,**/BarManagedBean.class, **/FooBarManagedBean.class, **/ManagedSuper.class"/>
+ </antcall>
+ <antcall target="ear-common"/>
+ </target>
+
+ <target name="deploy"
+ depends="init-common">
+ <antcall target="deploy-common"/>
+ </target>
+
+ <target name="run" depends="init-common">
+ <java fork="on"
+ failonerror="true"
+ classpath="${env.S1AS_HOME}/lib/javaee.jar:${env.S1AS_HOME}/modules/gf-client.jar:${build.classes.dir}:${env.APS_HOME}/lib/reporter.jar"
+ classname="${se.client}">
+ <arg line="${contextroot}"/>
+ <arg line="${http.host}"/>
+ <arg line="${http.port}"/>
+ </java>
+ </target>
+
+ <target name="undeploy" depends="init-common">
+ <antcall target="undeploy-common"/>
+ </target>
+
+ <target name="usage">
+ <antcall target="usage-common"/>
+ </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/client/com/acme/Client.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/client/com/acme/Client.java
new file mode 100644
index 0000000..1cb4a84
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/client/com/acme/Client.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import javax.annotation.Resource;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+public class Client {
+
+ private static final String TEST_NAME = "programmatic-lookup-in-ear";
+
+ private static SimpleReporterAdapter stat = new SimpleReporterAdapter(
+ "appserv-tests");
+
+ private static String appName;
+ private String host;
+ private String port;
+
+ @Resource(lookup = "java:app/env/value1")
+ private static Integer appLevelViaLookup;
+
+ public static void main(String args[]) {
+ appName = args[0];
+ stat.addDescription(appName);
+ Client client = new Client(args);
+ client.doTest();
+ stat.printSummary(appName + "ID");
+ System.out.println("appLevelViaLookup = '" + appLevelViaLookup + "'");
+ }
+
+ public Client(String[] args) {
+ host = args[1];
+ port = args[2];
+ }
+
+ public void doTest() {
+
+ try {
+
+ String url = "http://" + host + ":" + port + "/" + appName
+ + "/HelloServlet";
+
+ System.out.println("invoking webclient servlet at " + url);
+
+ URL u = new URL(url);
+
+ HttpURLConnection c1 = (HttpURLConnection) u.openConnection();
+ int code = c1.getResponseCode();
+ InputStream is = c1.getInputStream();
+ BufferedReader input = new BufferedReader(new InputStreamReader(
+ is));
+ String line = null;
+ while ((line = input.readLine()) != null) {
+ System.out.println("<response>:" + line);
+ if (line.trim().length() > 0) {
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ return;
+ }
+ }
+ if (code != 200) {
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ return;
+ }
+ stat.addStatus(TEST_NAME, stat.PASS);
+
+ } catch (Exception e) {
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/descriptor/application.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/descriptor/application.xml
new file mode 100644
index 0000000..d9378e7
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/descriptor/application.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (c) 2010, 2018 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
+
+-->
+
+<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="6" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd">
+ <display-name>ejb-ejb30-hello-session3App</display-name>
+ <module>
+ <ejb>cdi-full-ear-ejb.jar</ejb>
+ </module>
+ <module>
+ <web>
+ <web-uri>cdi-full-ear-web.war</web-uri>
+ <context-root>cdi-full-ear</context-root>
+ </web>
+ </module>
+ <env-entry>
+ <env-entry-name>java:app/env/value1</env-entry-name>
+ <env-entry-type>java.lang.Integer</env-entry-type>
+ <env-entry-value>18338</env-entry-value>
+ </env-entry>
+ <env-entry>
+ <env-entry-name>java:app/env/myString</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>myString</env-entry-value>
+ </env-entry>
+</application>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/descriptor/beans.xml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/descriptor/beans.xml
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/ejb/com/acme/Hello.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/ejb/com/acme/Hello.java
new file mode 100644
index 0000000..2ad0681
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/ejb/com/acme/Hello.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme;
+
+
+
+public interface Hello {
+
+ public String hello();
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/ejb/com/acme/HelloSingleton.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/ejb/com/acme/HelloSingleton.java
new file mode 100644
index 0000000..4a9b9bf
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/ejb/com/acme/HelloSingleton.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.SessionContext;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+
+@Singleton
+@Startup
+public class HelloSingleton implements Hello {
+
+ @Resource
+ SessionContext sessionCtx;
+
+ @Resource(name = "java:app/env/myString")
+ protected String myString;
+
+ @EJB(name = "java:app/env/appLevelEjbRef")
+ private Hello hello;
+
+ String appName;
+ String moduleName;
+
+ @PostConstruct
+ private void init() {
+ System.out.println("HelloSingleton::init()");
+
+ System.out.println("myString = '" + myString + "'");
+ if ((myString == null) || !(myString.equals("myString"))) {
+ throw new RuntimeException("Invalid value " + myString
+ + " for myString");
+ }
+
+ appName = (String) sessionCtx.lookup("java:app/AppName");
+ moduleName = (String) sessionCtx.lookup("java:module/ModuleName");
+
+ System.out.println("AppName = " + appName);
+ System.out.println("ModuleName = " + moduleName);
+
+ }
+
+ public String hello() {
+
+ System.out.println("HelloSingleton::hello()");
+
+ return "hello, world!\n";
+ }
+
+ @PreDestroy
+ private void destroy() {
+ System.out.println("HelloSingleton::destroy()");
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/manifest.mf b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/war/com/acme/Hello.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/war/com/acme/Hello.java
new file mode 100644
index 0000000..2ad0681
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/war/com/acme/Hello.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme;
+
+
+
+public interface Hello {
+
+ public String hello();
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/war/com/acme/ProgrammaticLookupInEARServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/war/com/acme/ProgrammaticLookupInEARServlet.java
new file mode 100644
index 0000000..ed75d76
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/war/com/acme/ProgrammaticLookupInEARServlet.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+import javax.naming.InitialContext;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@SuppressWarnings("serial")
+@WebServlet(urlPatterns = "/HelloServlet", loadOnStartup = 1)
+@EJB(name = "java:module/m1", beanName = "HelloSingleton", beanInterface = Hello.class)
+public class ProgrammaticLookupInEARServlet extends HttpServlet {
+
+ @Resource(name = "java:app/env/myString")
+ protected String myString;
+
+ private Hello singleton1;
+
+ @Inject
+ Instance<TestBean> programmaticLookup;
+
+ private String msg = "";
+
+ @Override
+ public void init(ServletConfig config) throws ServletException {
+ super.init(config);
+
+ System.out.println("In HelloServlet::init");
+ System.out.println("myString = '" + myString + "'");
+ if ((myString == null) || !(myString.equals("myString"))) {
+ msg += "@Resource lookup of myString failed";
+ throw new RuntimeException("Invalid value " + myString
+ + " for myString");
+ }
+
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ System.out.println("In HelloServlet::doGet");
+ resp.setContentType("text/html");
+
+ PrintWriter out = resp.getWriter();
+ try {
+ InitialContext ic = new InitialContext();
+ String appName = (String) ic.lookup("java:app/AppName");
+ String moduleName = (String) ic.lookup("java:module/ModuleName");
+ checkForNull(appName, "AppName lookup returned null");
+ checkForNull(moduleName, "ModuleName lookup returned null");
+
+ singleton1 = (Hello) ic.lookup("java:module/m1");
+ checkForNull(singleton1,
+ "programmatic lookup of module-level singleton EJB failed");
+
+ System.out.println("My AppName = "
+ + ic.lookup("java:app/AppName"));
+
+ System.out.println("My ModuleName = "
+ + ic.lookup("java:module/ModuleName"));
+
+ } catch (Exception e) {
+ msg += "Exception occurred during test Exception: "
+ + e.getMessage();
+ e.printStackTrace();
+ }
+
+ singleton1.hello();
+
+ checkForNull(programmaticLookup.get(), "programmatic lookup of session scoped bean in war failed");
+
+ out.println(msg);
+
+ }
+
+ protected void checkForNull(Object o, String errorMessage) {
+ if (o == null)
+ msg += " " + errorMessage;
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/war/com/acme/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/war/com/acme/TestBean.java
new file mode 100644
index 0000000..f0092d7
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/war/com/acme/TestBean.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme;
+
+public interface TestBean {
+ public void m1();
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/war/com/acme/TestBeanWARImpl.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/war/com/acme/TestBeanWARImpl.java
new file mode 100644
index 0000000..05f6914
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/programmatic-lookup-ear/war/com/acme/TestBeanWARImpl.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package com.acme;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
+
+
+@SessionScoped
+public class TestBeanWARImpl implements TestBean, Serializable {
+ @Override
+ public void m1() {
+ System.out.println("TestBean::m1");
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/README
new file mode 100644
index 0000000..2be7b7d
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/README
@@ -0,0 +1,5 @@
+Test
+ - Injection of ServletContext into a Servlet. As CDI does not allow injection of ServletContext, a Bridge
+ServletContextListener is used to fire events during the initialization and destruction of ServletContext as suggested in
+http://seamframework.org/Community/InjectServletContextIntoManagedBean#comment111596
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/WebTest.java
new file mode 100644
index 0000000..7f47426
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/WebTest.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2010, 2018 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.net.*;
+import com.sun.ejte.ccl.reporter.*;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+ private static SimpleReporterAdapter stat
+ = new SimpleReporterAdapter("appserv-tests");
+ private static final String TEST_NAME = "servlet-context-injection-in-cdi";
+ private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0. initParams: n1=v1, n2=v2 Servlet context: /cdi-servlet-context-injection";
+
+ private String host;
+ private String port;
+ private String contextRoot;
+
+ public WebTest(String[] args) {
+ host = args[0];
+ port = args[1];
+ contextRoot = args[2];
+ }
+
+ public static void main(String[] args) {
+ stat.addDescription("Unit test for @WebServlet");
+ WebTest webTest = new WebTest(args);
+ webTest.doTest();
+ stat.printSummary(TEST_NAME);
+ }
+
+ public void doTest() {
+ try {
+ invoke();
+ } catch (Exception ex) {
+ System.out.println(TEST_NAME + " test failed");
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ ex.printStackTrace();
+ }
+ }
+
+ private void invoke() throws Exception {
+
+ String url = "http://" + host + ":" + port + contextRoot
+ + "/myurl";
+ System.out.println("opening connection to " + url);
+ HttpURLConnection conn = (HttpURLConnection)
+ (new URL(url)).openConnection();
+
+ int code = conn.getResponseCode();
+ if (code != 200) {
+ System.out.println("Unexpected return code: " + code);
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ } else {
+ InputStream is = null;
+ BufferedReader input = null;
+ String line = null;
+ try {
+ is = conn.getInputStream();
+ input = new BufferedReader(new InputStreamReader(is));
+ line = input.readLine();
+ System.out.println("line = " + line);
+ } finally {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch(IOException ioe) {
+ // ignore
+ }
+ try {
+ if (input != null) {
+ input.close();
+ }
+ } catch(IOException ioe) {
+ // ignore
+ }
+ }
+ if (EXPECTED_RESPONSE.equals(line)) {
+ stat.addStatus(TEST_NAME, stat.PASS);
+ } else {
+ System.out.println("Wrong response. Expected: " +
+ EXPECTED_RESPONSE + ", received: " + line);
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ }
+ }
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/build.properties
new file mode 100644
index 0000000..ca2edae
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/build.properties
@@ -0,0 +1,24 @@
+<!--
+
+ Copyright (c) 2018 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
+
+-->
+
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-servlet-context-injection"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/build.xml
new file mode 100644
index 0000000..83ad666
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/build.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (c) 2010, 2018 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
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+ &commonSetup;
+ &commonBuild;
+ &testproperties;
+ &run;
+
+ <target name="all" depends="build,deploy,run,undeploy"/>
+
+ <target name="clean" depends="init-common">
+ <antcall target="clean-common"/>
+ <delete>
+ <fileset dir="." includes="*.class"/>
+ </delete>
+ </target>
+
+ <target name="compile" depends="clean">
+ <antcall target="compile-common">
+ <param name="src" value="servlet"/>
+ </antcall>
+ </target>
+
+ <target name="build" depends="compile">
+ <property name="hasWebclient" value="yes"/>
+ <antcall target="webclient-war-common">
+ <param name="hasWebclient" value="yes"/>
+ <param name="webclient.war.classes" value="**/*.class"/>
+ </antcall>
+
+ <javac srcdir="." classpath="${env.APS_HOME}/lib/reportbuilder.jar"
+ includes="WebTest.java"/>
+
+ </target>
+
+ <target name="build-publish-war" depends="build, publish-war-common" />
+
+ <target name="deploy" depends="init-common">
+ <antcall target="deploy-war-common"/>
+ </target>
+
+ <target name="run" depends="init-common">
+ <java classname="WebTest">
+ <arg value="${http.host}"/>
+ <arg value="${http.port}"/>
+ <arg value="${contextroot}"/>
+ <classpath>
+ <pathelement location="${env.APS_HOME}/lib/reportbuilder.jar"/>
+ <pathelement location="."/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="undeploy" depends="init-common">
+ <antcall target="undeploy-war-common"/>
+ </target>
+
+ <target name="usage">
+ <antcall target="usage-common"/>
+ </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/descriptor/beans.xml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/descriptor/beans.xml
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/artifacts/Destroyed.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/artifacts/Destroyed.java
new file mode 100644
index 0000000..38d4216
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/artifacts/Destroyed.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package tests.cdi.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({TYPE, METHOD, PARAMETER, FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Destroyed {
+
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/artifacts/Initialized.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/artifacts/Initialized.java
new file mode 100644
index 0000000..59788c2
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/artifacts/Initialized.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package tests.cdi.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({TYPE, METHOD, PARAMETER, FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Initialized {
+
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/artifacts/Preferred.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/artifacts/Preferred.java
new file mode 100644
index 0000000..d10f685
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/artifacts/Preferred.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package tests.cdi.artifacts;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({TYPE, METHOD, PARAMETER, FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Preferred {
+
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/context/ServletContextBridge.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/context/ServletContextBridge.java
new file mode 100644
index 0000000..c978a9b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/context/ServletContextBridge.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package tests.cdi.context;
+
+import java.lang.annotation.Annotation;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Inject;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.annotation.WebListener;
+
+import tests.cdi.artifacts.Destroyed;
+import tests.cdi.artifacts.Initialized;
+
+@WebListener
+public class ServletContextBridge implements ServletContextListener {
+ @Inject
+ private BeanManager beanManager;
+
+ public ServletContextBridge() {
+ }
+
+ /**
+ * Servlet context initialized / destroyed events
+ */
+
+ public void contextDestroyed(final ServletContextEvent e) {
+ fireEvent(e, DESTROYED);
+ }
+
+ public void contextInitialized(final ServletContextEvent e) {
+ fireEvent(e, INITIALIZED);
+ }
+
+ private void fireEvent(final Object payload,
+ final Annotation... qualifiers) {
+ System.out.println("Firing event #0 with qualifiers #1" + payload
+ + qualifiers);
+ beanManager.fireEvent(payload, qualifiers);
+ }
+
+ private static final AnnotationLiteral<Destroyed> DESTROYED = new AnnotationLiteral<Destroyed>() {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+
+ private static final AnnotationLiteral<Initialized> INITIALIZED = new AnnotationLiteral<Initialized>() {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/context/ServletContextProducer.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/context/ServletContextProducer.java
new file mode 100644
index 0000000..964aac0
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/context/ServletContextProducer.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package tests.cdi.context;
+
+//JJS: With cdi 1.1 the ServletContext is produced by Weld (2.0) and so producing one creates an ambiguous dependency.
+//import javax.enterprise.context.ApplicationScoped;
+//import javax.enterprise.event.Observes;
+//import javax.enterprise.inject.Produces;
+//import javax.enterprise.inject.spi.BeanManager;
+//import javax.inject.Inject;
+//import javax.servlet.ServletContext;
+//import javax.servlet.ServletContextEvent;
+//
+//import tests.cdi.artifacts.Destroyed;
+//import tests.cdi.artifacts.Initialized;
+//
+//@ApplicationScoped
+public class ServletContextProducer {
+// private ServletContext servletContext;
+//
+//// @Inject
+//// private BeanManager beanManager;
+//
+// protected void contextInitialized(
+// @Observes @Initialized ServletContextEvent e) {
+// System.out.println("Servlet context initialized with event -" + e);
+// servletContext = e.getServletContext();
+//// servletContext.setAttribute(BeanManager.class.getName(), beanManager);
+// }
+//
+// protected void contextDestroyed(@Observes @Destroyed ServletContextEvent e) {
+// System.out.println("Servlet context destroyed with event #0" + e);
+// servletContext = null;
+// }
+//
+// @Produces
+// @ApplicationScoped
+// public ServletContext getServletContext() {
+// return servletContext;
+// }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/servlet/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/servlet/TestBean.java
new file mode 100644
index 0000000..182be84
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/servlet/TestBean.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017, 2018 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
+ */
+
+package tests.cdi.servlet;
+
+import javax.inject.Inject;
+import javax.servlet.ServletContext;
+
+//Simple TestBean to test CDI.
+public class TestBean
+{
+ @Inject
+ ServletContext sc;
+
+ public String m1(){
+ System.out.println("**********SC = " + sc.getContextPath());
+ return sc.getContextPath();
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/servlet/TestServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/servlet/TestServlet.java
new file mode 100644
index 0000000..8c70b32
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/servlet-context-injection-cdi/servlet/tests/cdi/servlet/TestServlet.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package tests.cdi.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+import javax.naming.InitialContext;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebInitParam;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@WebServlet(name = "mytest", urlPatterns = { "/myurl" }, initParams = {
+ @WebInitParam(name = "n1", value = "v1"),
+ @WebInitParam(name = "n2", value = "v2") })
+public class TestServlet extends HttpServlet {
+ @Inject
+ TestBean tb;
+ @Inject
+ BeanManager bm;
+
+ BeanManager bm1;
+
+ @Inject
+ ServletContext sc;
+
+ public void service(HttpServletRequest req, HttpServletResponse res)
+ throws IOException, ServletException {
+
+ PrintWriter writer = res.getWriter();
+ writer.write("Hello from Servlet 3.0. ");
+ String msg = "n1=" + getInitParameter("n1") + ", n2="
+ + getInitParameter("n2");
+ if (tb == null)
+ msg += "Bean injection into Servlet failed";
+ if (bm == null)
+ msg += "BeanManager Injection via @Inject failed";
+ if (sc == null)
+ msg += "ServletContext Injection via @Inject failed";
+ String servletContext = tb.m1();
+ try {
+ bm1 = (BeanManager) ((new InitialContext())
+ .lookup("java:comp/BeanManager"));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ msg += "BeanManager Injection via component environment lookup failed";
+ }
+ if (bm1 == null)
+ msg += "BeanManager Injection via component environment lookup failed";
+
+ System.out.println("BeanManager is " + bm);
+ System.out.println("BeanManager via lookup is " + bm1);
+
+ msg = "initParams: " + msg + " Servlet context: " + servletContext + "\n";
+ writer.write(msg);
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/README
new file mode 100644
index 0000000..e77c086
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/README
@@ -0,0 +1 @@
+- modification of the simple-managed-bean-interceptor test with non-null package for the managed bean and no no-arg constructor. Though the managed bean spec requires a no-arg constructor, it allows CDI specificaiton and implementations to support ManagedBeans with no no-arg constructor. Deployment would succeed on Weld 1.1 and above.
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/WebTest.java
new file mode 100644
index 0000000..d2c69a6
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/WebTest.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2010, 2018 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.net.*;
+import com.sun.ejte.ccl.reporter.*;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+ private static SimpleReporterAdapter stat
+ = new SimpleReporterAdapter("appserv-tests");
+ private static final String TEST_NAME = "simple-managed-bean-interceptor-non-null-package-noarg-constructor-missing";
+ private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0. initParams: n1=v1, n2=v2";
+
+ private String host;
+ private String port;
+ private String contextRoot;
+
+ public WebTest(String[] args) {
+ host = args[0];
+ port = args[1];
+ contextRoot = args[2];
+ }
+
+ public static void main(String[] args) {
+ stat.addDescription("Unit test for @WebServlet");
+ WebTest webTest = new WebTest(args);
+ webTest.doTest();
+ stat.printSummary(TEST_NAME);
+ }
+
+ public void doTest() {
+ try {
+ invoke();
+ } catch (Exception ex) {
+ System.out.println(TEST_NAME + " test failed");
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ ex.printStackTrace();
+ }
+ }
+
+ private void invoke() throws Exception {
+
+ String url = "http://" + host + ":" + port + contextRoot
+ + "/myurl";
+ System.out.println("opening connection to " + url);
+ HttpURLConnection conn = (HttpURLConnection)
+ (new URL(url)).openConnection();
+
+ int code = conn.getResponseCode();
+ if (code == 404|| code == 500) {
+ stat.addStatus(TEST_NAME, stat.PASS);
+ } else {
+ InputStream is = null;
+ BufferedReader input = null;
+ String line = null;
+ try {
+ is = conn.getInputStream();
+ input = new BufferedReader(new InputStreamReader(is));
+ line = input.readLine();
+ System.out.println("line = " + line);
+ } finally {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch(IOException ioe) {
+ // ignore
+ }
+ try {
+ if (input != null) {
+ input.close();
+ }
+ } catch(IOException ioe) {
+ // ignore
+ }
+ }
+ if (EXPECTED_RESPONSE.equals(line)) {
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ } else {
+ System.out.println("Wrong response. Expected: " +
+ EXPECTED_RESPONSE + ", received: " + line);
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ }
+ }
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/build.properties
new file mode 100644
index 0000000..4809e75
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/build.properties
@@ -0,0 +1,24 @@
+<!--
+
+ Copyright (c) 2018 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
+
+-->
+
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-simple-managed-bean-interceptor"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/build.xml
new file mode 100644
index 0000000..c25e17e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/build.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (c) 2010, 2018 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
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+ &commonSetup;
+ &commonBuild;
+ &testproperties;
+ &run;
+
+ <target name="all" depends="build,deploy,run,undeploy"/>
+
+ <target name="clean" depends="init-common">
+ <antcall target="clean-common"/>
+ <delete>
+ <fileset dir="." includes="WebTest.class"/>
+ </delete>
+ </target>
+
+ <target name="compile" depends="clean">
+ <antcall target="compile-common">
+ <param name="src" value="servlet"/>
+ </antcall>
+ </target>
+
+ <target name="build" depends="compile">
+ <property name="hasWebclient" value="yes"/>
+ <antcall target="webclient-war-common">
+ <param name="hasWebclient" value="yes"/>
+ <param name="webclient.war.classes" value="**/*.class"/>
+ </antcall>
+
+ <javac srcdir="." classpath="${env.APS_HOME}/lib/reportbuilder.jar"
+ includes="WebTest.java"/>
+
+ </target>
+
+ <target name="build-publish-war" depends="build, publish-war-common" />
+
+ <target name="deploy" depends="init-common">
+ <antcall target="deploy-war-common"/>
+ </target>
+
+ <target name="run" depends="init-common">
+ <java classname="WebTest">
+ <arg value="${http.host}"/>
+ <arg value="${http.port}"/>
+ <arg value="${contextroot}"/>
+ <classpath>
+ <pathelement location="${env.APS_HOME}/lib/reportbuilder.jar"/>
+ <pathelement location="."/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="undeploy" depends="init-common">
+ <antcall target="undeploy-war-common"/>
+ </target>
+
+ <target name="usage">
+ <antcall target="usage-common"/>
+ </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/descriptor/beans.xml
new file mode 100644
index 0000000..6264a41
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/descriptor/beans.xml
@@ -0,0 +1,24 @@
+<!--
+
+ Copyright (c) 2017, 2018 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
+
+-->
+
+<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+ <interceptors>
+ <class>test.interceptors.TestAroundInvokeInterceptor</class>
+ </interceptors>
+</beans>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/servlet/test/beans/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/servlet/test/beans/TestBean.java
new file mode 100644
index 0000000..4a7146e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/servlet/test/beans/TestBean.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans;
+
+//Simple Bean to test injection into ManagedBeans
+public class TestBean {
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/servlet/test/beans/TestManagedBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/servlet/test/beans/TestManagedBean.java
new file mode 100644
index 0000000..f631ae8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/servlet/test/beans/TestManagedBean.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans;
+
+//Simple TestBean to test CDI.
+//This bean implements Serializable as it needs to be placed into a Stateful Bean
+@javax.annotation.ManagedBean
+public class TestManagedBean {
+ TestBean tb;
+ boolean postConstructCalled = false;
+
+ //a ManagedBean needs to have a no-arg constructor
+/*
+ public TestManagedBean(){
+ }
+*/
+
+ @javax.inject.Inject //Constructor based Injection
+ public TestManagedBean(TestBean tb){
+ this.tb = tb;
+ }
+
+
+ @javax.annotation.PostConstruct
+ public void init(){
+ System.out.println("In ManagedBean:: PostConstruct");
+ postConstructCalled = true;
+ }
+
+ @Tester
+ public void foo(){
+ System.out.println("foo called");
+ }
+
+ public boolean testPostConstructCalled(){
+ return this.postConstructCalled;
+ }
+
+ public boolean testInjection(){
+ System.out.println("In ManagedBean:: tb=" + tb);
+ postConstructCalled = true;
+ return this.tb != null;
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/servlet/test/beans/Tester.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/servlet/test/beans/Tester.java
new file mode 100644
index 0000000..779d213
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/servlet/test/beans/Tester.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans;
+
+import javax.interceptor.*;
+import java.lang.annotation.*;
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+
+@InterceptorBinding
+@Target({METHOD, TYPE})
+@Retention(RUNTIME)
+public @interface Tester {}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/servlet/test/interceptors/TestAroundInvokeInterceptor.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/servlet/test/interceptors/TestAroundInvokeInterceptor.java
new file mode 100644
index 0000000..700bf69
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/servlet/test/interceptors/TestAroundInvokeInterceptor.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.interceptors;
+
+import javax.interceptor.*;
+
+import test.beans.Tester;
+
+@Tester @Interceptor
+public class TestAroundInvokeInterceptor {
+ public static int aroundInvokeCount = 0;
+
+ public static void reset(){
+ aroundInvokeCount = 0;
+ }
+
+ @AroundInvoke
+ public Object testMethod(InvocationContext ctx) throws Exception {
+ System.out.println("TestAroundInvokeIntercetpr:: aroundInvoke called - target:" + ctx.getTarget() + " , params:"+ ctx.getParameters());
+ aroundInvokeCount ++;
+ ctx.proceed();
+ return null;
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/servlet/test/servlet/TestServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/servlet/test/servlet/TestServlet.java
new file mode 100644
index 0000000..58feb50
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-noargconstructor-missing/servlet/test/servlet/TestServlet.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Enumeration;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebInitParam;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import test.beans.TestManagedBean;
+import test.interceptors.TestAroundInvokeInterceptor;
+
+@WebServlet(name="mytest",
+ urlPatterns={"/myurl"},
+ initParams={ @WebInitParam(name="n1", value="v1"), @WebInitParam(name="n2", value="v2") } )
+public class TestServlet extends HttpServlet {
+ @javax.inject.Inject TestManagedBean tb1;
+ @javax.annotation.Resource TestManagedBean tb;
+
+ public void service(HttpServletRequest req, HttpServletResponse res)
+ throws IOException, ServletException {
+
+ PrintWriter writer = res.getWriter();
+ writer.write("Hello from Servlet 3.0. ");
+ String msg = "n1=" + getInitParameter("n1") +
+ ", n2=" + getInitParameter("n2");
+
+ //ManagedBean testing .. add additional messages in the "msg" string, so that the test will FAIL in the client
+ msg += testManagedBean(tb, " | TestManagedBean injected via @Resource");
+ msg += testManagedBean(tb1, " | TestManagedBean injected via @Inject");
+ msg += testInterceptors();
+
+ writer.write("initParams: " + msg + "\n");
+ }
+
+ private String testManagedBean(TestManagedBean tb, String info) {
+ String msg = "";
+ if (tb == null) msg += info + " is null!";
+ if (tb != null && !tb.testPostConstructCalled()) msg += info + " postConstruct not called";
+ if (tb != null && !tb.testInjection()) msg += info + "Bean Injection into ManagedBean failed";
+ return msg;
+ }
+
+ private String testInterceptors(){
+ System.out.println("calling foo on an @Resource injected Managed Bean");
+ tb.foo();
+ System.out.println("calling foo on an @Inject Managed Bean");
+ tb1.foo(); //TestAroundInvokeInterceptor is not called in this case
+
+ int count = TestAroundInvokeInterceptor.aroundInvokeCount;
+ System.out.println("TestAroundInvokeInterceptor called " + count + " times");
+ TestAroundInvokeInterceptor.reset();
+ if (count == 1) return "";
+ else return "Interceptor invocation count" + count + " invalid";
+ }
+
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/README
new file mode 100644
index 0000000..6f3f094
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/README
@@ -0,0 +1 @@
+- modification of the simple-managed-bean-interceptor test with non-null package for the managed bean
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/WebTest.java
new file mode 100644
index 0000000..cbd3be2
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/WebTest.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2010, 2018 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.net.*;
+import com.sun.ejte.ccl.reporter.*;
+
+/*
+ * Unit test for @WebServlet
+ */
+public class WebTest {
+
+ private static SimpleReporterAdapter stat
+ = new SimpleReporterAdapter("appserv-tests");
+ private static final String TEST_NAME = "simple-managed-bean-interceptor-non-null-package";
+ private static final String EXPECTED_RESPONSE = "Hello from Servlet 3.0. initParams: n1=v1, n2=v2";
+
+ private String host;
+ private String port;
+ private String contextRoot;
+
+ public WebTest(String[] args) {
+ host = args[0];
+ port = args[1];
+ contextRoot = args[2];
+ }
+
+ public static void main(String[] args) {
+ stat.addDescription("Unit test for @WebServlet");
+ WebTest webTest = new WebTest(args);
+ webTest.doTest();
+ stat.printSummary(TEST_NAME);
+ }
+
+ public void doTest() {
+ try {
+ invoke();
+ } catch (Exception ex) {
+ System.out.println(TEST_NAME + " test failed");
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ ex.printStackTrace();
+ }
+ }
+
+ private void invoke() throws Exception {
+
+ String url = "http://" + host + ":" + port + contextRoot
+ + "/myurl";
+ System.out.println("opening connection to " + url);
+ HttpURLConnection conn = (HttpURLConnection)
+ (new URL(url)).openConnection();
+
+ int code = conn.getResponseCode();
+ if (code != 200) {
+ System.out.println("Unexpected return code: " + code);
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ } else {
+ InputStream is = null;
+ BufferedReader input = null;
+ String line = null;
+ try {
+ is = conn.getInputStream();
+ input = new BufferedReader(new InputStreamReader(is));
+ line = input.readLine();
+ System.out.println("line = " + line);
+ } finally {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch(IOException ioe) {
+ // ignore
+ }
+ try {
+ if (input != null) {
+ input.close();
+ }
+ } catch(IOException ioe) {
+ // ignore
+ }
+ }
+ if (EXPECTED_RESPONSE.equals(line)) {
+ stat.addStatus(TEST_NAME, stat.PASS);
+ } else {
+ System.out.println("Wrong response. Expected: " +
+ EXPECTED_RESPONSE + ", received: " + line);
+ stat.addStatus(TEST_NAME, stat.FAIL);
+ }
+ }
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/build.properties
new file mode 100644
index 0000000..4809e75
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/build.properties
@@ -0,0 +1,24 @@
+<!--
+
+ Copyright (c) 2018 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
+
+-->
+
+
+<property name="module" value="cdi"/>
+<property name="appname" value="${module}-simple-managed-bean-interceptor"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="contextroot" value="/${appname}"/>
+<property name="beans.xml" value="descriptor/beans.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/build.xml
new file mode 100644
index 0000000..83ad666
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/build.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (c) 2010, 2018 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
+
+-->
+
+<!DOCTYPE project [
+<!ENTITY commonSetup SYSTEM "./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "./../../../../config/common.xml">
+<!ENTITY run SYSTEM "./../../../../config/run.xml">
+<!ENTITY testproperties SYSTEM "./build.properties">
+]>
+
+<project name="webcontainer_unittest" default="all" basedir=".">
+
+ &commonSetup;
+ &commonBuild;
+ &testproperties;
+ &run;
+
+ <target name="all" depends="build,deploy,run,undeploy"/>
+
+ <target name="clean" depends="init-common">
+ <antcall target="clean-common"/>
+ <delete>
+ <fileset dir="." includes="*.class"/>
+ </delete>
+ </target>
+
+ <target name="compile" depends="clean">
+ <antcall target="compile-common">
+ <param name="src" value="servlet"/>
+ </antcall>
+ </target>
+
+ <target name="build" depends="compile">
+ <property name="hasWebclient" value="yes"/>
+ <antcall target="webclient-war-common">
+ <param name="hasWebclient" value="yes"/>
+ <param name="webclient.war.classes" value="**/*.class"/>
+ </antcall>
+
+ <javac srcdir="." classpath="${env.APS_HOME}/lib/reportbuilder.jar"
+ includes="WebTest.java"/>
+
+ </target>
+
+ <target name="build-publish-war" depends="build, publish-war-common" />
+
+ <target name="deploy" depends="init-common">
+ <antcall target="deploy-war-common"/>
+ </target>
+
+ <target name="run" depends="init-common">
+ <java classname="WebTest">
+ <arg value="${http.host}"/>
+ <arg value="${http.port}"/>
+ <arg value="${contextroot}"/>
+ <classpath>
+ <pathelement location="${env.APS_HOME}/lib/reportbuilder.jar"/>
+ <pathelement location="."/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="undeploy" depends="init-common">
+ <antcall target="undeploy-war-common"/>
+ </target>
+
+ <target name="usage">
+ <antcall target="usage-common"/>
+ </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/descriptor/beans.xml
new file mode 100644
index 0000000..6264a41
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/descriptor/beans.xml
@@ -0,0 +1,24 @@
+<!--
+
+ Copyright (c) 2017, 2018 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
+
+-->
+
+<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+ <interceptors>
+ <class>test.interceptors.TestAroundInvokeInterceptor</class>
+ </interceptors>
+</beans>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/servlet/test/beans/TestBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/servlet/test/beans/TestBean.java
new file mode 100644
index 0000000..4a7146e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/servlet/test/beans/TestBean.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans;
+
+//Simple Bean to test injection into ManagedBeans
+public class TestBean {
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/servlet/test/beans/TestManagedBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/servlet/test/beans/TestManagedBean.java
new file mode 100644
index 0000000..2bc9acc
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/servlet/test/beans/TestManagedBean.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans;
+
+//Simple TestBean to test CDI.
+//This bean implements Serializable as it needs to be placed into a Stateful Bean
+@javax.annotation.ManagedBean
+public class TestManagedBean {
+ TestBean tb;
+ boolean postConstructCalled = false;
+
+ //a ManagedBean needs to have a no-arg constructor
+ public TestManagedBean(){
+ }
+
+ @javax.inject.Inject //Constructor based Injection
+ public TestManagedBean(TestBean tb){
+ this.tb = tb;
+ }
+
+
+ @javax.annotation.PostConstruct
+ public void init(){
+ System.out.println("In ManagedBean:: PostConstruct");
+ postConstructCalled = true;
+ }
+
+ @Tester
+ public void foo(){
+ System.out.println("foo called");
+ }
+
+ public boolean testPostConstructCalled(){
+ return this.postConstructCalled;
+ }
+
+ public boolean testInjection(){
+ System.out.println("In ManagedBean:: tb=" + tb);
+ postConstructCalled = true;
+ return this.tb != null;
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/servlet/test/beans/Tester.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/servlet/test/beans/Tester.java
new file mode 100644
index 0000000..779d213
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/servlet/test/beans/Tester.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.beans;
+
+import javax.interceptor.*;
+import java.lang.annotation.*;
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+
+@InterceptorBinding
+@Target({METHOD, TYPE})
+@Retention(RUNTIME)
+public @interface Tester {}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/servlet/test/interceptors/TestAroundInvokeInterceptor.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/servlet/test/interceptors/TestAroundInvokeInterceptor.java
new file mode 100644
index 0000000..700bf69
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/servlet/test/interceptors/TestAroundInvokeInterceptor.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.interceptors;
+
+import javax.interceptor.*;
+
+import test.beans.Tester;
+
+@Tester @Interceptor
+public class TestAroundInvokeInterceptor {
+ public static int aroundInvokeCount = 0;
+
+ public static void reset(){
+ aroundInvokeCount = 0;
+ }
+
+ @AroundInvoke
+ public Object testMethod(InvocationContext ctx) throws Exception {
+ System.out.println("TestAroundInvokeIntercetpr:: aroundInvoke called - target:" + ctx.getTarget() + " , params:"+ ctx.getParameters());
+ aroundInvokeCount ++;
+ ctx.proceed();
+ return null;
+ }
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/servlet/test/servlet/TestServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/servlet/test/servlet/TestServlet.java
new file mode 100644
index 0000000..917a0fe
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/simple-managed-bean-interceptor-nonnull-package/servlet/test/servlet/TestServlet.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package test.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Enumeration;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebInitParam;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import test.beans.TestManagedBean;
+import test.interceptors.TestAroundInvokeInterceptor;
+
+@WebServlet(name="mytest",
+ urlPatterns={"/myurl"},
+ initParams={ @WebInitParam(name="n1", value="v1"), @WebInitParam(name="n2", value="v2") } )
+public class TestServlet extends HttpServlet {
+ @javax.inject.Inject TestManagedBean tb1;
+ @javax.annotation.Resource TestManagedBean tb;
+
+ public void service(HttpServletRequest req, HttpServletResponse res)
+ throws IOException, ServletException {
+
+ PrintWriter writer = res.getWriter();
+ writer.write("Hello from Servlet 3.0. ");
+ String msg = "n1=" + getInitParameter("n1") +
+ ", n2=" + getInitParameter("n2");
+
+ //ManagedBean testing .. add additional messages in the "msg" string, so that the test will FAIL in the client
+ msg += testManagedBean(tb, " | TestManagedBean injected via @Resource");
+ msg += testManagedBean(tb1, " | TestManagedBean injected via @Inject");
+ msg += testInterceptors();
+
+ writer.write("initParams: " + msg + "\n");
+ }
+
+ private String testManagedBean(TestManagedBean tb, String info) {
+ String msg = "";
+ if (tb == null) msg += info + " is null!";
+ if (tb != null && !tb.testPostConstructCalled()) msg += info + " postConstruct not called";
+ if (tb != null && !tb.testInjection()) msg += info + "Bean Injection into ManagedBean failed";
+ return msg;
+ }
+
+ private String testInterceptors(){
+ System.out.println("calling foo on an @Resource injected Managed Bean");
+ tb.foo();
+ System.out.println("calling foo on an @Inject Managed Bean");
+ tb1.foo(); //TestAroundInvokeInterceptor is not called in this case
+
+ int count = TestAroundInvokeInterceptor.aroundInvokeCount;
+ System.out.println("TestAroundInvokeInterceptor called " + count + " times");
+ TestAroundInvokeInterceptor.reset();
+ if (count == 2) return "";
+ else return "Interceptor invocation count" + count + " invalid";
+ }
+
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/README
new file mode 100644
index 0000000..633f9b5
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/README
@@ -0,0 +1,12 @@
+- Test support for enabled beans' classes deployed as a standalone RAR
+[test originally from connector1.5 test in Connectors developer tests]
+section 12.1. Bean archives of JSR 299 spec:
+
+"Bean classes of enabled beans must be deployed in bean archives.
+• A library jar, EJB jar, application client jar or rar archive is a
+bean archive if it has a file named beans.xml in the META-INF
+directory."
+
+In this test, a standalone RAR has a TestCDIBean Bean class. This is injected into a MDB in another ejb-jar in the EAR.
+
+[Note: This test doesn't seem to work now -- need to investigate]
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/META-INF/application.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/META-INF/application.xml
new file mode 100644
index 0000000..fe9b32e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/META-INF/application.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN' 'http://java.sun.com/dtd/application_1_3.dtd'>
+<!--
+
+ Copyright (c) 2017, 2018 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
+
+-->
+
+<application>
+ <display-name>GenericMessageDrivenBean</display-name>
+ <description>Application description</description>
+ <module>
+ <ejb>simplemdb-ejb.jar</ejb>
+ </module>
+ <module>
+ <java>simplemdb-client.jar</java>
+ </module>
+</application>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/build.xml
new file mode 100644
index 0000000..210abae
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/build.xml
@@ -0,0 +1,85 @@
+<!--
+
+ Copyright (c) 2002, 2018 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
+
+-->
+
+<!DOCTYPE project [
+ <!ENTITY common SYSTEM "../../../../../config/common.xml">
+ <!ENTITY testcommon SYSTEM "../../../../../config/properties.xml">
+ <!ENTITY database SYSTEM "../../../config/database.xml">
+]>
+
+<project name="connector1.5 MDB" default="all" basedir=".">
+
+ <property name="j2ee.home" value="../../.."/>
+ <property name="earfile" value="simplemdb.ear"/>
+
+
+ <!-- include common.xml and testcommon.xml -->
+ &database;
+ &common;
+ &testcommon;
+
+ <target name="all" depends="init-common, clean-common">
+ <ant dir="src" inheritAll="false" target="all"/>
+ <antcall target="ear-common">
+ <param name="appname" value="simplemdb"/>
+ <param name="application.xml" value="META-INF/application.xml"/>
+ </antcall>
+ </target>
+
+ <target name="setupJdbc" depends="init-common">
+ <antcall target="create-jdbc-conpool-connector">
+ <param name="db.class" value="org.apache.derby.jdbc.ClientXADataSource"/>
+ <param name="jdbc.conpool.name" value="jdbc-pointbase-pool1"/>
+ <param name="jdbc.resource.type" value="javax.sql.XADataSource"/>
+ </antcall>
+
+ <antcall target="create-jdbc-resource-common">
+ <param name="jdbc.conpool.name" value="jdbc-pointbase-pool1"/>
+ <param name="jdbc.resource.name" value="jdbc/XAPointbase"/>
+ </antcall>
+
+ <antcall target="execute-sql-connector">
+ <param name="sql.file" value="createdb.sql"/>
+ </antcall>
+ </target>
+
+ <target name="unsetJdbc" depends="init-common">
+ <antcall target="delete-jdbc-resource-common">
+ <param name="jdbc.resource.name" value="jdbc/XAPointbase"/>
+ </antcall>
+ <antcall target="delete-jdbc-connpool-common">
+ <param name="jdbc.conpool.name" value="jdbc-pointbase-pool1"/>
+ </antcall>
+ </target>
+
+ <target name="deploy-ear" depends="init-common">
+ <antcall target="deploy-common">
+ <param name="appname" value="simplemdb"/>
+ </antcall>
+ </target>
+
+ <target name="undeploy" depends="init-common">
+ <antcall target="undeploy-common">
+ <param name="appname" value="simplemdb"/>
+ </antcall>
+ </target>
+
+ <target name="clean">
+ <antcall target="clean-common"/>
+ </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/createdb.sql b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/createdb.sql
new file mode 100644
index 0000000..7d93610
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/createdb.sql
@@ -0,0 +1,2 @@
+drop table MESSAGES;
+create table MESSAGES (messageId CHAR(50), message varchar(80));
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/META-INF/application-client.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/META-INF/application-client.xml
new file mode 100644
index 0000000..75d2e9a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/META-INF/application-client.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE application-client PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application Client 1.3//EN' 'http://java.sun.com/dtd/application-client_1_3.dtd'>
+<!--
+
+ Copyright (c) 2017, 2018 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
+
+-->
+
+<application-client>
+ <display-name>simplemdbClient</display-name>
+</application-client>
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/META-INF/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/META-INF/beans.xml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/META-INF/beans.xml
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/META-INF/ejb-jar.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/META-INF/ejb-jar.xml
new file mode 100644
index 0000000..4bdcc6f
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/META-INF/ejb-jar.xml
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (c) 2017, 2018 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
+
+-->
+
+<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
+ version="2.1">
+ <display-name>Ejb1</display-name>
+ <enterprise-beans>
+ <message-driven>
+ <display-name>Generic_Message_Bean</display-name>
+ <ejb-name>GenericMessageBean</ejb-name>
+ <ejb-class>mdb.MyMessageBean</ejb-class>
+ <messaging-type>connector.MyMessageListener</messaging-type>
+ <transaction-type>Container</transaction-type>
+ <activation-config>
+ <activation-config-property>
+ <activation-config-property-name>
+ DestinationType
+ </activation-config-property-name>
+ <activation-config-property-value>
+ java.lang.String
+ </activation-config-property-value>
+ </activation-config-property>
+ <activation-config-property>
+ <activation-config-property-name>
+ TestProp
+ </activation-config-property-name>
+ <activation-config-property-value>
+ WrongValue
+ </activation-config-property-value>
+ </activation-config-property>
+ <!-- non-String activation spec property -->
+ <activation-config-property>
+ <activation-config-property-name>
+ TestIntegerProp
+ </activation-config-property-name>
+ <activation-config-property-value>
+ 1
+ </activation-config-property-value>
+ </activation-config-property>
+
+ </activation-config>
+ <resource-ref>
+ <description>description</description>
+ <res-ref-name>MyDB</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ <res-auth>Container</res-auth>
+ <res-sharing-scope>Shareable</res-sharing-scope>
+ </resource-ref>
+ </message-driven>
+ <session>
+ <display-name>MyMessageChecker</display-name>
+ <ejb-name>MyMessageChecker</ejb-name>
+ <home>beans.MessageCheckerHome</home>
+ <remote>beans.MessageChecker</remote>
+ <ejb-class>beans.MessageCheckerEJB</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ <env-entry>
+ <env-entry-name>user</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>PBPUBLIC</env-entry-value>
+ </env-entry>
+ <env-entry>
+ <env-entry-name>password</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>PBPUBLIC</env-entry-value>
+ </env-entry>
+ <resource-ref>
+ <res-ref-name>MyDB</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ <res-auth>Container</res-auth>
+ <res-sharing-scope>Shareable</res-sharing-scope>
+ </resource-ref>
+ <resource-env-ref>
+ <resource-env-ref-name>eis/testAdmin</resource-env-ref-name>
+ <resource-env-ref-type>connector.MyAdminObject</resource-env-ref-type>
+ </resource-env-ref>
+ <security-identity>
+ <use-caller-identity/>
+ </security-identity>
+ </session>
+ </enterprise-beans>
+ <assembly-descriptor>
+ <container-transaction>
+ <method>
+ <ejb-name>GenericMessageBean</ejb-name>
+ <method-name>onMessage</method-name>
+ <method-params>
+ <method-param>java.lang.String</method-param>
+ </method-params>
+ </method>
+ <trans-attribute>Required</trans-attribute>
+ </container-transaction>
+ <container-transaction>
+ <method>
+ <ejb-name>MyMessageChecker</ejb-name>
+ <method-intf>Remote</method-intf>
+ <method-name>getMessageCount</method-name>
+ </method>
+ <trans-attribute>Required</trans-attribute>
+ </container-transaction>
+ </assembly-descriptor>
+</ejb-jar>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/META-INF/sun-application-client.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/META-INF/sun-application-client.xml
new file mode 100644
index 0000000..2b9166a
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/META-INF/sun-application-client.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE sun-application-client PUBLIC "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 Application Client 1.3//EN" "http://www.sun.com/software/sunone/appserver/dtds/sun-application-client_1_3-0.dtd">
+<!--
+
+ Copyright (c) 2017, 2018 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
+
+-->
+
+<sun-application-client>
+</sun-application-client>
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/META-INF/sun-ejb-jar.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/META-INF/sun-ejb-jar.xml
new file mode 100644
index 0000000..42cd604
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/META-INF/sun-ejb-jar.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 EJB 2.0//EN" "http://www.sun.com/software/sun
+<!--
+
+ Copyright (c) 2017, 2018 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
+
+-->
+
+one/appserver/dtds/sun-ejb-jar_2_0-0.dtd">
+
+
+<sun-ejb-jar>
+ <enterprise-beans>
+ <module-name>ejb.jar</module-name>
+ <unique-id>1</unique-id>
+ <ejb>
+ <ejb-name>GenericMessageBean</ejb-name>
+ <mdb-resource-adapter>
+ <resource-adapter-mid>generic-ra</resource-adapter-mid>
+ <activation-config>
+ <!-- override prop value -->
+ <activation-config-property>
+ <activation-config-property-name>
+ TestIntegerProp
+ </activation-config-property-name>
+ <activation-config-property-value>
+ 2
+ </activation-config-property-value>
+ </activation-config-property>
+ </activation-config>
+ </mdb-resource-adapter>
+ <ior-security-config>
+ <transport-config>
+ <integrity>supported</integrity>
+ <confidentiality>supported</confidentiality>
+ <establish-trust-in-target>supported</establish-trust-in-target>
+ <establish-trust-in-client>supported</establish-trust-in-client>
+ </transport-config>
+ <as-context>
+ <auth-method>username_password</auth-method>
+ <realm>default</realm>
+ <required>true</required>
+ </as-context>
+ <sas-context>
+ <caller-propagation>supported</caller-propagation>
+ </sas-context>
+ </ior-security-config>
+ <resource-ref>
+ <res-ref-name>MyDB</res-ref-name>
+ <jndi-name>jdbc/XAPointbase</jndi-name>
+ </resource-ref>
+ <gen-classes />
+ </ejb>
+ <ejb>
+ <ejb-name>MyMessageChecker</ejb-name>
+ <jndi-name>MyMessageChecker</jndi-name>
+ <ior-security-config>
+ <transport-config>
+ <integrity>supported</integrity>
+ <confidentiality>supported</confidentiality>
+ <establish-trust-in-target>supported</establish-trust-in-target>
+ <establish-trust-in-client>supported</establish-trust-in-client>
+ </transport-config>
+ <as-context>
+ <auth-method>username_password</auth-method>
+ <realm>default</realm>
+ <required>false</required>
+ </as-context>
+ <sas-context>
+ <caller-propagation>supported</caller-propagation>
+ </sas-context>
+ </ior-security-config>
+ <resource-ref>
+ <res-ref-name>MyDB</res-ref-name>
+ <jndi-name>jdbc/XAPointbase</jndi-name>
+ </resource-ref>
+ <resource-env-ref>
+ <resource-env-ref-name>eis/testAdmin</resource-env-ref-name>
+ <jndi-name>eis/testAdmin</jndi-name>
+ </resource-env-ref>
+ <gen-classes/>
+ </ejb>
+ </enterprise-beans>
+</sun-ejb-jar>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/beans/MessageChecker.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/beans/MessageChecker.java
new file mode 100644
index 0000000..48573f8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/beans/MessageChecker.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package beans;
+
+import javax.ejb.EJBObject;
+import java.rmi.RemoteException;
+import java.sql.SQLException;
+
+public interface MessageChecker extends EJBObject {
+ int getMessageCount() throws RemoteException;
+ boolean done() throws RemoteException;
+ int expectedResults() throws RemoteException;
+ void notifyAndWait() throws RemoteException;
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/beans/MessageCheckerEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/beans/MessageCheckerEJB.java
new file mode 100644
index 0000000..bdc3f62
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/beans/MessageCheckerEJB.java
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package beans;
+
+import connector.MyAdminObject;
+import javax.rmi.PortableRemoteObject;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.ejb.EJBException;
+import javax.ejb.CreateException;
+import java.util.Properties;
+import java.util.Vector;
+import java.sql.*;
+import java.rmi.RemoteException;
+
+import javax.transaction.UserTransaction;
+import javax.naming.*;
+import javax.sql.*;
+
+public class MessageCheckerEJB implements SessionBean {
+
+ private int WAIT_TIME = 15;
+ private String user = "j2ee";
+ private String password = "j2ee";
+ private Properties beanProps = null;
+ private SessionContext sessionContext = null;
+ private Connection heldCon = null;
+ private MyAdminObject Controls;
+
+ public MessageCheckerEJB() {}
+
+ public void ejbCreate()
+ throws CreateException {
+ System.out.println("bean removed");
+ heldCon = null;
+ /*
+ if (holdConnection) {
+ try {
+ heldCon = getDBConnection();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw new CreateException("Error in ejbCreate");
+ }
+ }
+ */
+ }
+
+ public boolean done() {
+ return Controls.done();
+ }
+
+ public int expectedResults() {
+ return Controls.expectedResults();
+ }
+
+ public void notifyAndWait() {
+ try {
+ synchronized (Controls.getLockObject()) {
+ //Tell the resource adapter the client is ready to run
+ Controls.getLockObject().notifyAll();
+
+ debug("NOTIFIED... START WAITING");
+ //Wait until being told to read from the database
+ Controls.getLockObject().wait();
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public int getMessageCount() {
+ try {
+ Connection con = getFreshConnection();
+ int count1 = getCount(con);
+ con.close();
+
+ /*
+ synchronized(Controls.getLockObject()) {
+ Controls.getLockObject().notify();
+ }
+ */
+
+ return count1;
+ } catch (Exception e) {
+ e.printStackTrace(System.out);
+ throw new EJBException(e);
+ }
+ }
+
+ private int getCount(Connection con) throws SQLException {
+ Statement stmt = con.createStatement();
+ int count = 0;
+ String messages = "";
+ ResultSet result = stmt.executeQuery(
+ "SELECT messageId, message "+ "FROM messages");
+ while (result.next()) {
+ count++;
+ messages = messages + " - " + result.getString("messageId")+" "+
+ result.getString("message") + "\n";
+ }
+ messages = messages + "count = " + count;
+ System.out.println(messages);
+ stmt.close();
+ return count;
+ }
+
+ public void setSessionContext(SessionContext context) {
+ sessionContext = context;
+ try {
+ Context ic = new InitialContext();
+ user = (String) ic.lookup("java:comp/env/user");
+ password = (String) ic.lookup("java:comp/env/password");
+ Controls = (MyAdminObject) ic.lookup("java:comp/env/eis/testAdmin");
+ System.out.println("CALLING INITILIZE ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]");
+ Controls.initialize();
+ System.out.println("CALLED INITILIZE ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]");
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public void ejbRemove() {
+ System.out.println("bean removed");
+ }
+
+ public void ejbActivate() {
+ System.out.println("bean activated");
+ }
+
+ public void ejbPassivate() {
+ System.out.println("bean passivated");
+ }
+
+ private Connection getFreshConnection() throws Exception {
+ Connection oldHeldCon = heldCon;
+ heldCon = null;
+ Connection result = getDBConnection();
+ heldCon = oldHeldCon;
+ return result;
+ }
+
+ private Connection getDBConnection() throws Exception {
+ if (heldCon != null) return heldCon;
+ Connection con = null;
+ try {
+ Context ic = new InitialContext();
+ DataSource ds = (DataSource) ic.lookup("java:comp/env/MyDB");
+ debug("Looked up Datasource\n");
+ debug("Get JDBC connection, auto sign on");
+ con = ds.getConnection();
+
+ if (con != null) {
+ return con;
+ } else {
+ throw new Exception("Unable to get database connection ");
+ }
+ } catch (SQLException ex1) {
+ //ex1.printStackTrace();
+ throw ex1;
+ }
+ }
+
+ private void closeConnection(Connection con) throws SQLException {
+ if (heldCon != null) {
+ return;
+ } else {
+ con.close();
+ }
+ }
+
+ private void debug(String msg) {
+ System.out.println("[MessageCheckerEJB]:: -> " + msg);
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/beans/MessageCheckerHome.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/beans/MessageCheckerHome.java
new file mode 100644
index 0000000..4bcc578
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/beans/MessageCheckerHome.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package beans;
+
+import java.rmi.RemoteException;
+import javax.ejb.EJBHome;
+import javax.ejb.CreateException;
+
+public interface MessageCheckerHome extends EJBHome {
+ MessageChecker create() throws RemoteException, CreateException;
+ boolean done() throws RemoteException, CreateException;
+ int expectedResults() throws RemoteException, CreateException;
+ void notifyAndWait() throws RemoteException, CreateException;
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/build.properties
new file mode 100644
index 0000000..dad207b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/build.properties
@@ -0,0 +1,21 @@
+<!--
+
+ Copyright (c) 2018 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
+
+-->
+
+
+ejb-jar.xml=META-INF/ejb-jar.xml
+sun-ejb-jar.xml=META-INF/sun-ejb-jar.xml
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/build.xml
new file mode 100644
index 0000000..24e1832
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/build.xml
@@ -0,0 +1,68 @@
+<!--
+
+ Copyright (c) 2002, 2018 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
+
+-->
+
+<!DOCTYPE project [
+ <!ENTITY common SYSTEM "../../../../../../config/common.xml">
+ <!ENTITY testcommon SYSTEM "../../../../../../config/properties.xml">
+]>
+
+<project name="connector1.5 MDB" default="all" basedir=".">
+
+ <property name="j2ee.home" value="../../../.."/>
+
+ <!-- include common.xml and testcommon.xml -->
+ &common;
+ &testcommon;
+
+ <target name="all" depends="init-common">
+ <antcall target="compile-common">
+ <param name="src" value="." />
+ <param name="s1astest.classpath" value="${s1astest.classpath}:../../ra/src/classes" />
+ </antcall>
+
+ <antcall target="ejb-jar-common">
+ <param name="ejb-jar.xml" value="META-INF/ejb-jar.xml" />
+ <param name="ejbjar.classes" value="mdb/*.class, beans/*.class, connector/*.class" />
+ <param name="beans.xml" value="META-INF/beans.xml" />
+ <param name="sun-ejb-jar.xml" value="META-INF/sun-ejb-jar.xml" />
+ <param name="appname" value="simplemdb" />
+ </antcall>
+
+ <antcall target="appclient-jar-common">
+ <param name="appname" value="simplemdb" />
+ <param name="application-client.xml" value="META-INF/application-client.xml" />
+ <param name="appclientjar.classes" value="mdb/*.class, beans/*.class, connector/*.class, client/Client.class" />
+ <param name="sun-application-client.xml" value="META-INF/sun-application-client.xml" />
+ </antcall>
+<!--
+ <jar jarfile="../ejb.jar" basedir="classes"
+ includes="mdb/*.class, beans/*.class, connector/*.class" >
+ <metainf dir="META-INF">
+ <include name="ejb-jar.xml"/>
+ <include name="sun-ejb-jar.xml"/>
+ </metainf>
+ </jar>
+-->
+ </target>
+
+ <target name="clean">
+ <antcall target="clean-classes-common">
+ <param name="build.classes.dir" value="classes" />
+ </antcall>
+ </target>
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/client/Client.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/client/Client.java
new file mode 100644
index 0000000..f551ce1
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/client/Client.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package client;
+
+import beans.*;
+import connector.*;
+import java.io.*;
+import java.util.*;
+import javax.naming.*;
+import javax.rmi.PortableRemoteObject;
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+public class Client {
+
+ private static SimpleReporterAdapter stat =
+ new SimpleReporterAdapter("appserv-tests");
+
+ public Client (String[] args) {
+ //super(args);
+ }
+
+ public static void main(String[] args) {
+ Client client = new Client(args);
+ client.doTest();
+ }
+
+ public String doTest() {
+ stat.addDescription("This is to test connector 1.5 "+
+ "contracts.");
+
+ String res = "NOT RUN";
+ debug("doTest() ENTER...");
+ boolean pass = false;
+ try {
+ res = "ALL TESTS PASSED";
+ int testCount = 1;
+ while (!done()) {
+
+ notifyAndWait();
+ if (!done()) {
+ debug("Running...");
+ pass = checkResults(expectedResults());
+ debug("Got expected results = " + pass);
+
+ //do not continue if one test failed
+ if (!pass) {
+ res = "SOME TESTS FAILED";
+ stat.addStatus("ID Connector 1.5 test - " + testCount, stat.FAIL);
+ } else {
+ stat.addStatus("ID Connector 1.5 test - " + testCount, stat.PASS);
+ }
+ } else {
+ break;
+ }
+ testCount ++;
+ }
+
+ } catch (Exception ex) {
+ System.out.println("Importing transaction test failed.");
+ ex.printStackTrace();
+ res = "TEST FAILED";
+ }
+ stat.printSummary("connector1.5ID");
+
+
+ debug("EXITING... STATUS = " + res);
+ return res;
+ }
+
+ private boolean checkResults(int num) throws Exception {
+ Object o = (new InitialContext()).lookup("MyMessageChecker");
+ MessageCheckerHome home = (MessageCheckerHome)
+ PortableRemoteObject.narrow(o, MessageCheckerHome.class);
+ MessageChecker checker = home.create();
+ int result = checker.getMessageCount();
+ return result == num;
+ }
+
+ private boolean done() throws Exception {
+ Object o = (new InitialContext()).lookup("MyMessageChecker");
+ MessageCheckerHome home = (MessageCheckerHome)
+ PortableRemoteObject.narrow(o, MessageCheckerHome.class);
+ MessageChecker checker = home.create();
+ return checker.done();
+ }
+
+ private int expectedResults() throws Exception {
+ Object o = (new InitialContext()).lookup("MyMessageChecker");
+ MessageCheckerHome home = (MessageCheckerHome)
+ PortableRemoteObject.narrow(o, MessageCheckerHome.class);
+ MessageChecker checker = home.create();
+ return checker.expectedResults();
+ }
+
+ private void notifyAndWait() throws Exception {
+ Object o = (new InitialContext()).lookup("MyMessageChecker");
+ MessageCheckerHome home = (MessageCheckerHome)
+ PortableRemoteObject.narrow(o, MessageCheckerHome.class);
+ MessageChecker checker = home.create();
+ checker.notifyAndWait();
+ }
+
+
+ private void debug(String msg) {
+ System.out.println("[CLIENT]:: --> " + msg);
+ }
+}
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/client/MANIFEST.MF b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/client/MANIFEST.MF
new file mode 100644
index 0000000..179cd4d
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/client/MANIFEST.MF
@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+Created-By: 1.4.0 (Sun Microsystems Inc.)
+Main-Class: client.Client
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/connector/MyMessageListener.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/connector/MyMessageListener.java
new file mode 100644
index 0000000..a3928d3
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/connector/MyMessageListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+public interface MyMessageListener {
+ public void onMessage (String message);
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/mdb/MyMessageBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/mdb/MyMessageBean.java
new file mode 100644
index 0000000..3af505b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/app/src/mdb/MyMessageBean.java
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package mdb;
+
+import java.sql.Statement;
+
+import javax.ejb.MessageDrivenBean;
+import javax.ejb.MessageDrivenContext;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+
+import connector.MyMessageListener;
+import javax.ejb.*;
+import javax.naming.*;
+import java.io.*;
+import java.rmi.RemoteException;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import java.sql.*;
+import javax.sql.*;
+import javax.jms.*;
+import javax.transaction.*;
+
+
+/**
+ */
+public class MyMessageBean implements MessageDrivenBean,
+ MyMessageListener {
+
+ private transient MessageDrivenContext mdc = null;
+ private Context context;
+
+ @javax.inject.Inject
+ private connector.TestCDIBean tb;
+
+ /**
+ * Constructor, which is public and takes no arguments.
+ */
+ public MyMessageBean() {}
+
+ /**
+ * setMessageDrivenContext method, declared as public (but
+ * not final or static), with a return type of void, and
+ * with one argument of type javax.ejb.MessageDrivenContext.
+ *
+ * @param mdc the context to set
+ */
+ public void setMessageDrivenContext(MessageDrivenContext mdc) {
+ this.mdc = mdc;
+ }
+
+ /**
+ * ejbCreate method, declared as public (but not final or
+ * static), with a return type of void, and with no
+ * arguments.
+ */
+ public void ejbCreate() { }
+
+ /**
+ * onMessage method, declared as public (but not final or
+ * static), with a return type of void, and with one argument
+ * of type javax.jms.Message.
+ *
+ * Casts the incoming Message to a TextMessage and displays
+ * the text.
+ *
+ * @param inMessage the incoming message
+ */
+ public void onMessage(String inMessage) {
+
+ debug("onMessage:: RECEIVED [" + inMessage + "]");
+ debug("TestCDIBean injected:" + tb);
+
+ if (tb == null)
+ throw new RuntimeException("Injection of enabled Bean "
+ + "in RAR into a MDB injection point failed");
+
+ try {
+ if (inMessage.endsWith("WRITE")) {
+ doDbStuff("WRITE",
+ inMessage.substring(0, inMessage.lastIndexOf(":")));
+ } else if (inMessage.endsWith("DELETE")) {
+ doDbStuff("DELETE",
+ inMessage.substring(0, inMessage.lastIndexOf(":")));
+ } else if (inMessage.endsWith("DELETE_ALL")) {
+ doDbStuff("DELETE_ALL", "::");
+ } else {
+ //unsupported op.
+ }
+ } catch (Exception ex) {
+ debug("UH OH...");
+ ex.printStackTrace();
+ }
+
+ }
+
+ /**
+ * ejbRemove method, declared as public (but not final or
+ * static), with a return type of void, and with no
+ * arguments.
+ */
+ public void ejbRemove() {}
+
+
+ private void doDbStuff(String op, String message) throws Exception {
+
+ java.sql.Connection dbConnection = null;
+ String id = message.substring(0, message.indexOf(":"));
+ String body = message.substring(message.indexOf(":")+1);
+ try {
+ Context ic = new InitialContext();
+
+ if ("READ".equals(op)) {
+
+ debug("Reading row from database...");
+
+ // Creating a database connection
+ /*
+ DataSource ds = (DataSource) ic.lookup("java:comp/env/MyDB");
+ debug("Looked up Datasource\n");
+ debug("Get JDBC connection, auto sign on");
+ dbConnection = ds.getConnection();
+
+ Statement stmt = dbConnection.createStatement();
+ String query =
+ "SELECT id from messages where id = 'QQ'";
+ ResultSet results = stmt.executeQuery(query);
+ results.next();
+ System.out.println("QQ has balance " +
+ results.getInt("balance") + " dollars");
+ results.close();
+ stmt.close();
+
+ System.out.println("Read one account\n");
+ */
+
+ } else if ("WRITE".equals(op)) {
+
+ debug("Inserting one message in the database\n");
+
+ // Creating a database connection
+ DataSource ds = (DataSource) ic.lookup("java:comp/env/MyDB");
+ //debug("Looked up Datasource\n");
+ //debug("Get JDBC connection, auto sign on");
+ dbConnection = ds.getConnection();
+
+ createRow(id, body, dbConnection);
+ System.out.println("Created one message\n");
+
+ } else if ("DELETE".equals(op)) {
+
+ debug("Deleting one message from the database\n");
+
+ // Creating a database connection
+ DataSource ds = (DataSource) ic.lookup("java:comp/env/MyDB");
+ //debug("Looked up Datasource\n");
+ //debug("Get JDBC connection, auto sign on");
+ dbConnection = ds.getConnection();
+
+ deleteRow(id, dbConnection);
+ System.out.println("Deleted one message\n");
+ } else if ("DELETE_ALL".equals(op)) {
+
+ debug("Deleting all messages from the database\n");
+
+ // Creating a database connection
+ DataSource ds = (DataSource) ic.lookup("java:comp/env/MyDB");
+ //debug("Looked up Datasource\n");
+ //debug("Get JDBC connection, auto sign on");
+ dbConnection = ds.getConnection();
+ deleteAll(dbConnection);
+ System.out.println("Deleted all messages\n");
+ } else {
+ //unsupported op
+ }
+
+ }finally{
+ try{
+ dbConnection.close();
+ }catch(Exception ex){
+ debug("Exception occured while closing database con nection.");
+ }
+ }
+ }
+
+ private void createRow(String id, String body,
+ java.sql.Connection dbConnection)
+ throws Exception {
+
+ // Create row for this message
+ debug("CreateRow with ID = " + id + ", BODY = " + body);
+ Statement stmt = dbConnection.createStatement();
+ String query = "INSERT INTO messages (messageId, message)" +
+ "VALUES ('" + id + "', '" + body + "')";
+ int resultCount = stmt.executeUpdate(query);
+ if ( resultCount != 1 ) {
+ throw new Exception(
+ "ERROR in INSERT !! resultCount = "+resultCount);
+ }
+ stmt.close();
+ }
+
+ private void deleteRow(String id, java.sql.Connection dbConnection)
+ throws Exception {
+
+ // Delete row for this message
+ debug("DeleteRow with ID = " + id);
+ Statement stmt = dbConnection.createStatement();
+ String query = "DELETE FROM messages WHERE messageId = '" + id + "'";
+ int resultCount = stmt.executeUpdate(query);
+ if ( resultCount != 1 ) {
+ throw new Exception(
+ "ERROR in INSERT !! resultCount = "+resultCount);
+ }
+ stmt.close();
+ }
+
+ private void deleteAll(java.sql.Connection dbConnection)
+ throws Exception {
+
+ // Delete row for this message
+ Statement stmt = dbConnection.createStatement();
+ String query = "DELETE FROM messages";
+ int resultCount = stmt.executeUpdate(query);
+ debug("Delete all rows from messages... count = " + resultCount);
+ stmt.close();
+ }
+
+ private void debug(String msg) {
+ System.out.println("[MyMessageBean] --> " + msg);
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/build.xml
new file mode 100644
index 0000000..645f1c9
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/build.xml
@@ -0,0 +1,98 @@
+<!--
+
+ Copyright (c) 2002, 2018 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
+
+-->
+
+<!DOCTYPE project [
+ <!ENTITY common SYSTEM "../../../../config/common.xml">
+ <!ENTITY testcommon SYSTEM "../../../../config/properties.xml">
+]>
+
+<project name="connector1.5 TEST" default="all" basedir=".">
+<property name="j2ee.home" value="../.."/>
+<property name="client.class" value="client/Client"/>
+
+ <!-- include common.xml and testcommon.xml -->
+ &common;
+ &testcommon;
+
+ <target name="all" depends="init-common, build, setup, runtest, unset"/>
+ <target name="run-dp-test" depends="init-common, build, setup-dp, deploy-dp, runtest, unset-dp, undeploy-dp"/>
+ <target name="build" depends="init-common">
+ <ant dir="ra" inheritAll="false" target="all"/>
+ <ant dir="app" inheritAll="false" target="all"/>
+ </target>
+
+ <target name="setup">
+ <ant dir="app" inheritAll="false" target="setupJdbc"/>
+ <ant dir="." inheritAll="false" target="deploy"/>
+ </target>
+
+ <target name="setup-dp">
+ <ant dir="app" inheritAll="false" target="setupJdbc"/>
+ </target>
+
+ <target name="deploy">
+ <ant dir="ra" inheritAll="false" target="deploy"/>
+ <ant dir="ra" inheritAll="false" target="testAddAdmin"/>
+ <ant dir="app" inheritAll="false" target="deploy-ear"/>
+ <ant dir="." inheritAll="false" target="restart"/>
+ </target>
+
+ <target name="deploy-dp">
+ <ant dir="ra" inheritAll="false" target="testAddAdmin"/>
+ <ant dir="app" inheritAll="false" target="deploy-ear"/>
+ <ant dir="." inheritAll="false" target="restart"/>
+ </target>
+
+ <target name="runtest" depends="init-common">
+ <antcall target="runclient-common">
+ <param name="appname" value="simplemdb" />
+ </antcall>
+ </target>
+
+ <target name="unset">
+ <ant dir="app" inheritAll="false" target="unsetJdbc"/>
+ <ant dir="." inheritAll="false" target="undeploy"/>
+ <ant dir="." inheritAll="false" target="restart"/>
+ </target>
+
+ <target name="unset-dp">
+ <ant dir="app" inheritAll="false" target="unsetJdbc"/>
+ <ant dir="." inheritAll="false" target="restart"/>
+ </target>
+
+ <target name="undeploy">
+ <ant dir="app" inheritAll="false" target="undeploy"/>
+ <ant dir="ra" inheritAll="false" target="testDelAdmin"/>
+ <ant dir="ra" inheritAll="false" target="undeploy"/>
+ </target>
+
+ <target name="undeploy-dp">
+ <ant dir="app" inheritAll="false" target="undeploy"/>
+ <ant dir="ra" inheritAll="false" target="testDelAdmin"/>
+ </target>
+
+ <target name="restart" depends="init-common">
+ <echo message="Not required to restart"/>
+ </target>
+
+ <target name="clean">
+ <ant dir="ra" inheritAll="false" target="clean"/>
+ <ant dir="app" inheritAll="false" target="clean"/>
+ </target>
+
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/createdb.sql b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/createdb.sql
new file mode 100644
index 0000000..19f3324
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/createdb.sql
@@ -0,0 +1,2 @@
+drop table messages;
+create table messages (messageId CHAR(50), message varchar(80));
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/META-INF/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/META-INF/beans.xml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/META-INF/beans.xml
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/META-INF/ra.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/META-INF/ra.xml
new file mode 100644
index 0000000..2ca2ebc
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/META-INF/ra.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (c) 2017, 2018 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
+
+-->
+
+<!--
+<!DOCTYPE connector PUBLIC '-//Sun Microsystems, Inc.//DTD Connector 1.5//EN' 'http://java.sun.com/dtd/connector_1_5.dtd'>
+-->
+<connector xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+ version="1.5">
+ <display-name>Simple Resource Adapter</display-name>
+ <vendor-name>Java Software</vendor-name>
+ <eis-type>Generic Type</eis-type>
+ <resourceadapter-version>1.0Alpha</resourceadapter-version>
+ <resourceadapter>
+ <resourceadapter-class>
+ connector.SimpleResourceAdapterImpl
+ </resourceadapter-class>
+ <config-property>
+ <config-property-name>
+ TestName
+ </config-property-name>
+ <config-property-type>
+ java.lang.String
+ </config-property-type>
+ <config-property-value>
+ ConfigPropertyForRA
+ </config-property-value>
+ </config-property>
+ <inbound-resourceadapter>
+ <messageadapter>
+ <messagelistener>
+ <messagelistener-type>
+ connector.MyMessageListener
+ </messagelistener-type>
+ <activationspec>
+ <activationspec-class>
+ connector.SimpleActivationSpec
+ </activationspec-class>
+ </activationspec>
+ </messagelistener>
+ </messageadapter>
+ </inbound-resourceadapter>
+ <adminobject>
+ <adminobject-interface>connector.MyAdminObject</adminobject-interface>
+ <adminobject-class>connector.MyAdminObject</adminobject-class>
+ <config-property>
+ <config-property-name>ResetControl</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>NORESET</config-property-value>
+ </config-property>
+ <config-property>
+ <config-property-name>ExpectedResult</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>88</config-property-value>
+ </config-property>
+ </adminobject>
+ </resourceadapter>
+</connector>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/build.xml
new file mode 100644
index 0000000..5267dc3
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/build.xml
@@ -0,0 +1,81 @@
+<!--
+
+ Copyright (c) 2002, 2018 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
+
+-->
+
+<!DOCTYPE project [
+ <!ENTITY common SYSTEM "../../../../../config/common.xml">
+ <!ENTITY props SYSTEM "../../../../../config/properties.xml">
+]>
+
+<project name="connector1.5 RA" default="all" basedir=".">
+
+ <property name="j2ee.home" value="../../.."/>
+ <property name="earfile" value="generic-ra.rar"/>
+
+ <!-- include common.xml and testcommon.xml -->
+ &common;
+ &props;
+
+ <target name="all">
+ <ant dir="src" inheritAll="false" target="all"/>
+
+ <jar jarfile="generic-ra.rar" basedir="."
+ includes="generic-ra.jar, META-INF/ra.xml, META-INF/beans.xml" />
+ </target>
+
+ <target name="deploy" depends="init-common">
+ <antcall target="deploy-rar-common">
+ <param name="rarfile" value="generic-ra.rar"/>
+ </antcall>
+ </target>
+
+ <target name="undeploy" depends="init-common">
+ <antcall target="undeploy-rar-common">
+ <param name="undeployrar" value="generic-ra"/>
+ </antcall>
+ </target>
+
+ <target name="testAddAdmin" depends="init-common">
+ <antcall target="asadmin-common">
+ <param name="admin.command" value="create-admin-object --target ${appserver.instance.name} --restype connector.MyAdminObject --raname generic-ra --property ResetControl=BEGINNING"/>
+ <param name="operand.props" value="eis/testAdmin"/>
+ </antcall>
+ </target>
+
+ <target name="testDelAdmin" depends="init-common">
+ <antcall target="asadmin-common">
+ <param name="admin.command" value="delete-admin-object"/>
+ <param name="operand.props" value="--target ${appserver.instance.name} eis/testAdmin"/>
+ </antcall>
+ </target>
+
+ <target name="sendMessage" depends="init-common">
+ <echo message="Class path is ${s1astest.classpath}"/>
+ <java fork="true" classname="connector.Messages" failonerror="true">
+ <arg line="add Foo TestMessage"/>
+ <classpath>
+ <pathelement location="${s1astest.classpath}"/>
+ <pathelement location="generic-ra.jar"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="clean">
+ <ant dir="src" inheritAll="false" target="clean"/>
+ </target>
+
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/build.xml
new file mode 100644
index 0000000..fad2edb
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/build.xml
@@ -0,0 +1,49 @@
+<!--
+
+ Copyright (c) 2002, 2018 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
+
+-->
+
+<!DOCTYPE project [
+ <!ENTITY common SYSTEM "../../../../../../config/common.xml">
+ <!ENTITY props SYSTEM "../../../../../../config/properties.xml">
+]>
+
+<project name="connector1.5 RA SRC" default="all" basedir=".">
+
+
+ <!-- include common.xml and testcommon.xml -->
+ &common;
+ &props;
+
+ <target name="all" depends="init-common" >
+ <antcall target="compile-common">
+ <param name="build.classes.dir" value="classes" />
+ <param name="src" value="connector" />
+ </antcall>
+ <jar jarfile="../generic-ra.jar" basedir="classes"
+ includes="connector/*.class" />
+ </target>
+
+
+ <target name="clean">
+ <antcall target="clean-classes-common">
+ <param name="build.classes.dir" value="classes" />
+ </antcall>
+ <delete file="../generic-ra.jar"/>
+ <delete file="../generic-ra.rar"/>
+ </target>
+
+</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/Controls.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/Controls.java
new file mode 100644
index 0000000..42188a6
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/Controls.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+/**
+ *
+ * @author Qingqing Ouyang
+ */
+public class Controls {
+ public static Object readyLock = new Object();
+ public static int expectedResults;
+ public static boolean done = false;
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/DeliveryWork.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/DeliveryWork.java
new file mode 100644
index 0000000..43377e8
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/DeliveryWork.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+import java.lang.reflect.Method;
+import java.util.Iterator;
+import javax.resource.spi.endpoint.MessageEndpoint;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.resource.spi.UnavailableException;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkManager;
+import javax.resource.spi.work.ExecutionContext;
+
+/**
+ *
+ * @author Qingqing Ouyang
+ */
+public class DeliveryWork implements Work {
+
+ private MessageEndpoint ep;
+ private int num;
+ private String op;
+ private boolean keepCount;
+ private static int counter = 0;
+
+ public DeliveryWork(MessageEndpoint ep, int numOfMessages, String op) {
+ this.ep = ep;
+ this.num = numOfMessages;
+ this.op = op;
+ this.keepCount = false;
+ }
+
+ public DeliveryWork(MessageEndpoint ep, int numOfMessages,
+ String op, boolean keepCount) {
+ this.ep = ep;
+ this.num = numOfMessages;
+ this.op = op;
+ this.keepCount = keepCount;
+ }
+
+ public void run() {
+
+ debug("ENTER...");
+
+ try {
+ //Method onMessage = getOnMessageMethod();
+ //ep.beforeDelivery(onMessage);
+
+ if (!keepCount) {
+ for (int i = 0; i < num; i++) {
+ String msgId = String.valueOf(i);
+ String msgBody = "This is message " + msgId;
+ String msg = msgId + ":" + msgBody + ":" + op;
+ ((MyMessageListener) ep).onMessage(msg);
+ }
+ } else {
+ for (int i = 0; i < num; i++) {
+ String msgId = String.valueOf(i+counter);
+ String msgBody = "This is message " + msgId;
+ String msg = msgId + ":" + msgBody + ":" + op;
+ ((MyMessageListener) ep).onMessage(msg);
+ }
+ counter = counter + num;
+ }
+
+ //ep.afterDelivery();
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ debug("LEAVE...");
+ }
+
+ public void release() {}
+
+ public String toString() {
+ return op;
+ }
+
+ private Method getOnMessageMethod() {
+
+ Method onMessageMethod = null;
+ try {
+ Class msgListenerClass = connector.MyMessageListener.class;
+ Class[] paramTypes = { java.lang.String.class };
+ onMessageMethod =
+ msgListenerClass.getMethod("onMessage", paramTypes);
+
+ } catch (NoSuchMethodException ex) {
+ ex.printStackTrace();
+ }
+ return onMessageMethod;
+ }
+
+ private void debug(String mesg) {
+ System.out.println("DeliveryWork[" + op + "] --> " + mesg);
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/FakeXAResource.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/FakeXAResource.java
new file mode 100644
index 0000000..97ed09e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/FakeXAResource.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+import javax.transaction.xa.*;
+
+/**
+ * This is class is used for debugging. It prints out
+ * trace information on TM calls to XAResource before
+ * directing the call to the actual XAResource object
+ */
+public class FakeXAResource implements XAResource {
+
+ public FakeXAResource() {}
+
+ public void commit(Xid xid, boolean onePhase) throws XAException {
+ print("FakeXAResource.commit: " + xidToString(xid) + "," + onePhase);
+ }
+
+ public void end(Xid xid, int flags) throws XAException {
+ print("FakeXAResource.end: " + xidToString(xid) + "," +
+ flagToString(flags));
+ }
+
+
+ public void forget(Xid xid) throws XAException {
+ print("FakeXAResource.forget: " + xidToString(xid));
+ }
+
+ public int getTransactionTimeout() throws XAException {
+ return 60*1000;
+ }
+
+ public boolean isSameRM(XAResource xares) throws XAException {
+ return false;
+ }
+
+ public int prepare(Xid xid) throws XAException {
+ print("FakeXAResource.prepare: " + xidToString(xid));
+ return XAResource.XA_OK;
+ }
+
+ public Xid[] recover(int flag) throws XAException {
+ print("FakeXAResource.recover: " + flagToString(flag));
+ return null;
+ }
+
+ public void rollback(Xid xid) throws XAException {
+ print("FakeXAResource.rollback: " + xidToString(xid));
+ }
+
+ public boolean setTransactionTimeout(int seconds) throws XAException {
+ return false;
+ }
+
+ public void start(Xid xid, int flags) throws XAException {
+ print("FakeXAResource.start: " + xidToString(xid) + "," +
+ flagToString(flags));
+ throw new XAException();
+ }
+
+ private void print(String s) {
+ System.out.println(s);
+ }
+
+ static public String xidToString(Xid xid) {
+ return String.valueOf((new String(xid.getGlobalTransactionId()) +
+ new String(xid.getBranchQualifier())).hashCode());
+ }
+
+ static public String flagToString(int flag) {
+ switch (flag) {
+ case TMFAIL:
+ return "TMFAIL";
+ case TMJOIN:
+ return "TMJOIN";
+ case TMNOFLAGS:
+ return "TMNOFLAGS";
+ case TMONEPHASE:
+ return "TMONEPHASE";
+ case TMRESUME:
+ return "TMRESUME";
+ case TMSTARTRSCAN:
+ return "TMSTARTRSCAN";
+ case TMENDRSCAN:
+ return "TMENDRSCAN";
+ case TMSUCCESS:
+ return "TMSUCCESS";
+ case TMSUSPEND:
+ return "TMSUSPEND";
+ case XA_RDONLY:
+ return "XA_RDONLY";
+ default:
+ return "" + Integer.toHexString(flag);
+ }
+ }
+
+ public boolean equals(Object obj) {
+ return false;
+ }
+
+ public int hashCode() {
+ return 1;
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/Messages.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/Messages.java
new file mode 100644
index 0000000..84e1c71
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/Messages.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+import java.util.*;
+
+/**
+ * collection of messages.
+ *
+ * @author Qingqing Ouyang
+ */
+public class Messages {
+
+ private static Hashtable messages = new Hashtable();
+
+ public static void sendMessage (String destName, String message) {
+ if (messages.get(destName) != null) {
+ ((ArrayList) messages.get(destName)).add(message);
+ } else {
+ ArrayList list = new ArrayList();
+ list.add(message);
+ messages.put(destName, list);
+ }
+ System.out.println("sendMessage. message at foo is " + Messages.hasMessages("Foo"));
+ }
+
+ public static boolean hasMessages (String destName) {
+ return messages.get(destName) != null;
+ }
+
+ public static ArrayList getMessages (String destName) {
+ return (ArrayList) messages.get(destName);
+ }
+
+ public static void main (String[] args) {
+ if (args.length != 3) {
+ System.exit(1);
+ }
+
+ String command = args[0];
+ String destName = args[1];
+ String message = args[2];
+
+ if (!"add".equals(command)) {
+ System.exit(1);
+ }
+
+ sendMessage(destName, message);
+ System.out.println("Message : " + message + " sent to " + destName);
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/MyAdminObject.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/MyAdminObject.java
new file mode 100644
index 0000000..f33a711
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/MyAdminObject.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+public class MyAdminObject implements java.io.Serializable {
+
+ private String resetControl="NORESET";
+ private Integer expectedResults;
+
+ public void setResetControl (String value) {
+ resetControl = value;
+ }
+
+ public String getResetControl () {
+ return resetControl;
+ }
+
+ public void setExpectedResults (Integer value) {
+ expectedResults = value;
+ }
+
+ public Integer getExpectedResults () {
+ return expectedResults;
+ }
+
+ public void initialize() {
+ System.out.println("[MyAdminObject] Initializing the Controls to false:"+resetControl);
+ if (resetControl.equals("BEGINNING")) {
+ Controls.done=false;
+ System.out.println("[MyAdminObject] Initialized the Controls to false");
+ }
+ }
+
+ public boolean done() {
+ return Controls.done;
+ }
+
+ public int expectedResults(){
+ return Controls.expectedResults;
+ }
+
+ public Object getLockObject(){
+ return Controls.readyLock;
+ }
+
+}
+
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/MyMessageListener.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/MyMessageListener.java
new file mode 100644
index 0000000..a3928d3
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/MyMessageListener.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+public interface MyMessageListener {
+ public void onMessage (String message);
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/MyWork.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/MyWork.java
new file mode 100644
index 0000000..0513628
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/MyWork.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+import java.lang.reflect.Method;
+import java.util.Iterator;
+import javax.resource.spi.endpoint.MessageEndpoint;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.resource.spi.UnavailableException;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkManager;
+import javax.resource.spi.work.ExecutionContext;
+
+/**
+ *
+ * @author Qingqing Ouyang
+ */
+public class MyWork implements Work {
+
+ private String name;
+ private boolean stop = false;
+ private MessageEndpointFactory factory;
+ private WorkManager wm;
+
+ public MyWork(
+ String name, MessageEndpointFactory factory, WorkManager wm) {
+ this.factory = factory;
+ this.name = name;
+ this.wm = wm;
+ }
+
+ public void run() {
+
+ debug("ENTER...");
+
+ //try 3 times to create endpoint (in case of failure)
+ for (int i = 0; i < 3; i++) {
+
+ try {
+
+ Method onMessage = getOnMessageMethod();
+ System.out.println("isDeliveryTransacted = " +
+ factory.isDeliveryTransacted(onMessage));
+
+ /*
+ MessageEndpoint ep = factory.createEndpoint(null);
+ ep.beforeDelivery(onMessage);
+ ((MyMessageListener) ep).onMessage(name + ": TEST MSG ONE");
+ ((MyMessageListener) ep).onMessage(name + ": TEST MSG TWO");
+ ((MyMessageListener) ep).onMessage(name + ": TEST MSG THREE");
+ ep.afterDelivery();
+ break;
+ */
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ debug("LEAVE...");
+ }
+
+ public void release() {}
+
+ public void stop() {
+ this.stop = true;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ public Method getOnMessageMethod() {
+
+ Method onMessageMethod = null;
+ try {
+ Class msgListenerClass = connector.MyMessageListener.class;
+ Class[] paramTypes = { java.lang.String.class };
+ onMessageMethod =
+ msgListenerClass.getMethod("onMessage", paramTypes);
+
+ } catch (NoSuchMethodException ex) {
+ ex.printStackTrace();
+ }
+ return onMessageMethod;
+ }
+
+ private void debug(String mesg) {
+ System.out.println("MyWork[" + name + "] --> " + mesg);
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/SimpleActivationSpec.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/SimpleActivationSpec.java
new file mode 100644
index 0000000..fc14e69
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/SimpleActivationSpec.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.ResourceAdapter;
+
+/**
+ * This class is supposed to implemented as a JavaBean
+ * so that the app server can instantiate and configure
+ * it at the runtime.
+ *
+ * @author Qingqing Ouyang
+ */
+public class SimpleActivationSpec
+ implements ActivationSpec, java.io.Serializable {
+
+ private String destinationName;
+ private String destinationType;
+ private String testProp;
+ private Integer testIntegerProp;
+ private ResourceAdapter resourceadapter;
+
+ /**
+ * Default constructor.
+ */
+ public SimpleActivationSpec () {}
+
+ public String getDestinationName () {
+ return this.destinationName;
+ }
+
+ public void setDestinationName (String name) {
+ debug("setDestinationName() called... name = " + name);
+ this.destinationName = name;
+ }
+
+ public String getDestinationType() {
+ return this.destinationType;
+ }
+
+ public void setDestinationType (String type) {
+ debug("setDestinationType () called... type = " + type);
+ this.destinationType= type;
+ }
+
+ public String getTestProp() {
+ return this.testProp;
+ }
+
+ public void setTestProp (String testProp) {
+ debug("setTestProp () called... testProp = " + testProp);
+ this.testProp = testProp;
+ }
+
+ public Integer getTestIntegerProp() {
+ return this.testIntegerProp;
+ }
+
+ public void setTestIntegerProp (Integer testProp1) {
+ debug("setTestIntegerProp () called... testIntegerProp = " + testProp1);
+ this.testIntegerProp = testProp1;
+ }
+
+ public ResourceAdapter getResourceAdapter () {
+ debug("getResourceAdapter() called... ");
+ return this.resourceadapter;
+ }
+
+ public void setResourceAdapter (ResourceAdapter ra) {
+ debug("setResourceAdapter() called... ra = " + ra);
+ this.resourceadapter = ra;
+ }
+
+ public void validate() {
+ if (this.testIntegerProp.intValue() == 2 && this.testProp.equals("WrongValue")) {
+ //valid
+ } else {
+ throw new RuntimeException("Invalid Configuration testIntegerProp: " + this.testIntegerProp.intValue() + " testProp " + this.testProp);
+
+ }
+
+ }
+
+ private void debug (String message)
+ {
+ System.out.println("[SimpleActivationSpec] ==> " + message);
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/SimpleResourceAdapterImpl.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/SimpleResourceAdapterImpl.java
new file mode 100644
index 0000000..4d4d6c4
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/SimpleResourceAdapterImpl.java
@@ -0,0 +1,235 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Properties;
+import javax.resource.NotSupportedException;
+import javax.resource.ResourceException;
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.ResourceAdapter;
+import javax.resource.spi.XATerminator;
+import javax.resource.spi.endpoint.MessageEndpoint;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.resource.spi.UnavailableException;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.resource.spi.work.ExecutionContext;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkManager;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+/**
+ * This is a sample resource adapter
+ *
+ * @author Qingqing Ouyang
+ */
+public class SimpleResourceAdapterImpl
+implements ResourceAdapter, java.io.Serializable {
+
+ private BootstrapContext ctx;
+ private WorkManager wm;
+ private String testName;
+
+ private boolean debug = true;
+ private Work work;
+
+ public SimpleResourceAdapterImpl () {
+ debug ("constructor...");
+ }
+
+ public void
+ start(BootstrapContext ctx) throws ResourceAdapterInternalException{
+
+ debug("001. Simple RA start...");
+
+ this.ctx = ctx;
+ debug("002. Simple RA start...");
+ this.wm = ctx.getWorkManager();
+ debug("003. Simple RA start...");
+
+ //testing creat timer
+ Timer timer = null;
+ try{
+ timer = ctx.createTimer();
+ } catch(UnavailableException ue) {
+ System.out.println("Error");
+ throw new ResourceAdapterInternalException("Error form bootstrap");
+ }
+ debug("004. Simple RA start...");
+
+ try {
+
+ XATerminator xa = ctx.getXATerminator();
+
+ Xid xid1 = new XID();
+ System.out.println(" XID1 = " + xid1);
+
+ ExecutionContext ec = new ExecutionContext();
+ ec.setXid(xid1);
+ ec.setTransactionTimeout(5*1000); //5 seconds
+ TestWMWork outw = new TestWMWork(1000, false, true, ec);
+ outw.setWorkManager(wm);
+ try {
+ wm.doWork(outw, 1*1000, ec, null);
+ xa.commit(xid1, true);
+ } catch (Exception ex) {
+
+ System.out.println(" ex = " + ex.getMessage());
+ xa.rollback(xid1);
+ }
+
+ Xid xid2 = new XID();
+ System.out.println(" XID2 = " + xid2);
+
+ ec = new ExecutionContext();
+ ec.setXid(xid2);
+ ec.setTransactionTimeout(5*1000); //5 seconds
+ TestWMWork anotherw = new TestWMWork(3000, false);
+ anotherw.setWorkManager(wm);
+ try {
+ wm.doWork(anotherw, 1*1000, ec, null);
+ xa.commit(xid2, true);
+ } catch (Exception ex) {
+ xa.rollback(xid2);
+ }
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+
+ for (int i = 0 ; i < 3; i++) {
+ TestWMWork w = new TestWMWork(i, false);
+ try {
+ wm.doWork(w, 1, null, null);
+ } catch (Exception ex) {
+ System.out.println("FAIL: CAUGHT exception : i = " + i);
+ ex.printStackTrace();
+ }
+ }
+
+ for (int i = 3 ; i < 6; i++) {
+ TestWMWork w = new TestWMWork(i, true);
+ boolean pass = false;
+ try {
+ wm.doWork(w, 1, null, null);
+ } catch (Exception ex) {
+ pass = true;
+ System.out.println("PASS: CAUGHT EXPECTED exception : i = " + i);
+ ex.printStackTrace();
+ } finally {
+ if (!pass) {
+ System.out.println("FAIL: DID NOT GET EXPECTED exception :");
+ }
+ }
+ }
+
+ for (int i = 6 ; i < 9; i++) {
+ TestWMWork w = new TestWMWork(i, false);
+ try {
+ wm.doWork(w, 1, null, null);
+ } catch (Exception ex) {
+ System.out.println("FAIL: CAUGHT exception : i = " + i);
+ ex.printStackTrace();
+ }
+ }
+
+ for (int i = 9 ; i < 12; i++) {
+ TestWMWork w = new TestWMWork(i, false);
+ try {
+ wm.startWork(w);
+ } catch (Exception ex) {
+ System.out.println("FAIL: CAUGHT exception : i = " + i);
+ ex.printStackTrace();
+ }
+ }
+
+ for (int i = 12 ; i < 15; i++) {
+ TestWMWork w = new TestWMWork(i, false);
+ try {
+ wm.scheduleWork(w);
+ } catch (Exception ex) {
+ System.out.println("FAIL: CAUGHT exception : i = " + i);
+ ex.printStackTrace();
+ }
+ }
+
+ debug("005. Simple RA start...");
+ }
+
+ public void
+ stop() {
+ debug("999. Simple RA stop...");
+ if (work != null) {
+ ((WorkDispatcher) work).stop();
+
+ synchronized (Controls.readyLock) {
+ Controls.readyLock.notify();
+ }
+
+ }
+ }
+
+ public void
+ endpointActivation ( MessageEndpointFactory factory, ActivationSpec spec)
+ throws NotSupportedException {
+ try {
+ debug("B.000. Create and schedule Dispatcher");
+ spec.validate();
+ work = new WorkDispatcher("DISPATCHER", ctx, factory, spec);
+ wm.scheduleWork(work, 4*1000, null, null);
+ debug("B.001. Scheduled Dispatcher");
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public void
+ endpointDeactivation (
+ MessageEndpointFactory endpointFactory,
+ ActivationSpec spec) {
+ debug ("endpointDeactivation called...");
+
+ ((WorkDispatcher) work).stop();
+ }
+
+ public String getTestName() {
+ return testName;
+ }
+
+ public void setTestName(String name) {
+ debug("setTestName called... name = " + name);
+ testName = name;
+ }
+
+ public void
+ debug (String message) {
+ if (debug)
+ System.out.println("[SimpleResourceAdapterImpl] ==> " + message);
+ }
+
+ public XAResource[] getXAResources(ActivationSpec[] specs)
+ throws ResourceException {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/TestCDIBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/TestCDIBean.java
new file mode 100644
index 0000000..c4ec82d
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/TestCDIBean.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+//A test CDI bean that is bundled along with an embedded RAR
+public class TestCDIBean {
+
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/TestWMWork.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/TestWMWork.java
new file mode 100644
index 0000000..f132758
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/TestWMWork.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+import java.lang.reflect.Method;
+import java.util.Iterator;
+import javax.resource.spi.endpoint.MessageEndpoint;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.resource.spi.UnavailableException;
+import javax.resource.spi.work.ExecutionContext;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkManager;
+import javax.resource.spi.work.WorkException;
+
+/**
+ *
+ * @author Qingqing Ouyang
+ */
+public class TestWMWork implements Work {
+
+ private boolean stop = false;
+ private int id;
+ private boolean isRogue;
+ private boolean doNest;
+ private WorkManager wm;
+ private ExecutionContext ctx;
+
+ public TestWMWork(int id, boolean isRogue) {
+ this(id, isRogue, false, null);
+ }
+
+ public TestWMWork(int id, boolean isRogue,
+ boolean doNest, ExecutionContext ctx) {
+ this.id = id;
+ this.isRogue = isRogue;
+ this.doNest = doNest;
+ this.ctx = ctx;
+ }
+
+ public void setWorkManager (WorkManager wm) {
+ this.wm = wm;
+ }
+
+ public void run() {
+
+ System.out.println("TestWMWork[" + id + "].start running");
+ if (!isRogue) {
+ try {
+ Thread.currentThread().sleep(1000);
+ } catch (Exception ex) {
+ System.out.println("TestWMWork[" + id + "].interrupted = ");
+ ex.printStackTrace();
+ }
+ } else {
+ System.out.println("TestWMWork: Simulating rogue RA's Work: Expected Arithmetic Exception - divide by Zero");
+ int j = 100/0;
+ }
+
+ if (doNest && (wm != null)) {
+ Work nestedWork = new TestWMWork(8888, false);
+ try {
+ wm.doWork(nestedWork, 1*1000, ctx, null);
+ } catch (WorkException ex) {
+ if (ex.getErrorCode().equals(
+ WorkException.TX_CONCURRENT_WORK_DISALLOWED)) {
+ System.out.println("TestWMWork[" + id + "] " +
+ "PASS: CAUGHT EXPECTED = " + ex.getErrorCode());
+ } else {
+ System.out.println("TestWMWork[" + id + "] " +
+ "FAIL: CAUGHT UNEXPECTED = " + ex.getErrorCode());
+ }
+ }
+
+ nestedWork = new TestWMWork(9999, false);
+ try {
+ ExecutionContext ec = new ExecutionContext();
+ ec.setXid(new XID());
+ ec.setTransactionTimeout(5*1000); //5 seconds
+ wm.doWork(nestedWork, 1*1000, ec, null);
+ } catch (Exception ex) {
+ System.out.println("TestWMWork[" + id + "] " +
+ "FAIL: CAUGHT UNEXPECTED = " + ex.getMessage());
+ }
+ }
+
+ System.out.println("TestWMWork[" + id + "].stop running");
+ }
+
+ public void release() {}
+
+ public void stop() {
+ this.stop = true;
+ }
+
+ public String toString() {
+ return String.valueOf(id);
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/WorkDispatcher.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/WorkDispatcher.java
new file mode 100644
index 0000000..5aa436c
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/WorkDispatcher.java
@@ -0,0 +1,323 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+import java.lang.reflect.Method;
+import java.util.Iterator;
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.XATerminator;
+import javax.resource.spi.endpoint.MessageEndpoint;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.resource.spi.UnavailableException;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkManager;
+import javax.resource.spi.work.ExecutionContext;
+import javax.transaction.xa.Xid;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+
+/**
+ *
+ * @author Qingqing Ouyang
+ */
+public class WorkDispatcher implements Work {
+
+ private boolean stop = false;
+ private String id;
+ private MessageEndpointFactory factory;
+ private BootstrapContext ctx;
+ private ActivationSpec spec;
+ private WorkManager wm;
+ private XATerminator xa;
+
+ public WorkDispatcher(
+ String id,
+ BootstrapContext ctx,
+ MessageEndpointFactory factory,
+ ActivationSpec spec) {
+ this.id = id;
+ this.ctx = ctx;
+ this.factory = factory;
+ this.spec = spec;
+ this.wm = ctx.getWorkManager();
+ this.xa = ctx.getXATerminator();
+ }
+
+ public void run() {
+
+ debug("ENTER...");
+
+ try {
+ synchronized (Controls.readyLock) {
+ debug("WAIT...");
+ Controls.readyLock.wait();
+
+ if (stop) {
+ return;
+ }
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ debug("Running...");
+
+ //try 3 times to create endpoint (in case of failure)
+ for (int i = 0; i < 3; i++) {
+
+ try {
+
+ Method onMessage = getOnMessageMethod();
+ System.out.println("isDeliveryTransacted = " +
+ factory.isDeliveryTransacted(onMessage));
+
+ if (!factory.isDeliveryTransacted(onMessage)) {
+ //MessageEndpoint ep = factory.createEndpoint(null);
+ //DeliveryWork d = new DeliveryWork("NO_TX", ep);
+ //wm.doWork(d, 0, null, null);
+ } else {
+
+ //MessageEndpoint ep = factory.createEndpoint(null);
+ MessageEndpoint ep = factory.createEndpoint(new FakeXAResource());
+ int numOfMessages = 5;
+
+ //importing transaction
+
+ //write/commit
+ ExecutionContext ec = startTx();
+ debug("Start TX - " + ec.getXid());
+
+ DeliveryWork w =
+ new DeliveryWork(ep, numOfMessages, "WRITE");
+ wm.doWork(w, 0, ec, null);
+ xa.commit(ec.getXid(), true);
+
+ debug("DONE WRITE TO DB");
+ Controls.expectedResults = numOfMessages;
+ notifyAndWait();
+
+ //delete/rollback
+ ec = startTx();
+ debug("Start TX - " + ec.getXid());
+
+ w = new DeliveryWork(ep, numOfMessages, "DELETE");
+ wm.doWork(w, 0, ec, null);
+ xa.rollback(ec.getXid());
+
+ debug("DONE ROLLBACK FROM DB");
+ Controls.expectedResults = numOfMessages;
+ notifyAndWait();
+
+ //delete/commit
+ ec = startTx();
+ debug("Start TX - " + ec.getXid());
+
+ w = new DeliveryWork(ep, numOfMessages, "DELETE");
+ wm.doWork(w, 0, ec, null);
+ xa.commit(ec.getXid(), true);
+
+ debug("DONE DELETE FROM DB");
+ Controls.expectedResults = 0;
+ notifyAndWait();
+
+ //write/commit
+ ec = startTx();
+ debug("Start TX - " + ec.getXid());
+
+ w = new DeliveryWork(ep, numOfMessages, "WRITE");
+ wm.doWork(w, 0, ec, null);
+ xa.commit(ec.getXid(), true);
+
+ debug("DONE WRITE TO DB");
+ Controls.expectedResults = numOfMessages;
+ notifyAndWait();
+
+ //delete/commit
+ ec = startTx();
+ debug("Start TX - " + ec.getXid());
+
+ w = new DeliveryWork(ep, numOfMessages, "DELETE");
+ wm.doWork(w, 0, ec, null);
+ xa.commit(ec.getXid(), true);
+
+ debug("DONE DELETE FROM DB");
+ Controls.expectedResults = 0;
+ notifyAndWait();
+
+ //write multiple times using doWork/commit
+ ec = startTx();
+ debug("Start TX - " + ec.getXid());
+
+ w = new DeliveryWork(ep, 1, "WRITE", true);
+ wm.doWork(w, 0, ec, null);
+ wm.doWork(w, 0, ec, null);
+ wm.doWork(w, 0, ec, null);
+ xa.commit(ec.getXid(), true);
+
+ debug("DONE WRITE TO DB");
+ Controls.expectedResults = 3;
+ notifyAndWait();
+
+ //write multiple times using doWork/rollback
+ ec = startTx();
+ debug("Start TX - " + ec.getXid());
+
+ w = new DeliveryWork(ep, 1, "WRITE", true);
+ wm.doWork(w, 0, ec, null);
+ wm.doWork(w, 0, ec, null);
+ wm.doWork(w, 0, ec, null);
+ xa.rollback(ec.getXid());
+
+ debug("DONE WRITE TO DB");
+ Controls.expectedResults = 3;
+ notifyAndWait();
+
+ ec = startTx();
+ debug("Start TX - " + ec.getXid());
+
+ //write multiple times using doWork/rollback
+ w = new DeliveryWork(ep, 2, "WRITE", true);
+ wm.doWork(w, 0, ec, null);
+ wm.doWork(w, 0, ec, null);
+ wm.doWork(w, 0, ec, null);
+
+ if (XAResource.XA_OK == xa.prepare(ec.getXid())) {
+ xa.commit(ec.getXid(), false);
+ debug("XA PREPARE/COMMIT. DONE WRITE TO DB ");
+ Controls.expectedResults = 9;
+ notifyAndWait();
+ } else {
+ xa.rollback(ec.getXid());
+ debug("XA PREPARE UNSUCCESSFUL. DONE ROLLBACK");
+ Controls.expectedResults = 3;
+ notifyAndWait();
+ }
+
+ //delete all.
+ ec = startTx();
+ debug("Start TX - " + ec.getXid());
+
+ w = new DeliveryWork(ep, 1, "DELETE_ALL");
+ wm.doWork(w, 0, ec, null);
+ xa.commit(ec.getXid(), true);
+
+ debug("DONE DELETE ALL FROM DB");
+ Controls.expectedResults = 0;
+ notifyAndWait();
+
+ done();
+ }
+
+ break;
+ } catch (UnavailableException ex) {
+ //ex.printStackTrace();
+ System.out.println("WorkDispatcher["+id+"] Endpoint Unavailable");
+ try {
+ Thread.currentThread().sleep(3*1000); //3 seconds
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } catch (XAException ex) {
+ ex.printStackTrace();
+ System.out.println("ERROR CODE = " + ex.errorCode);
+ done();
+ break;
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ done();
+ break;
+ }
+ }
+
+ debug("LEAVE...");
+ }
+
+ public void release() {}
+
+ public void stop() {
+ this.stop = true;
+ }
+
+ public String toString() {
+ return id;
+ }
+
+ public Method getOnMessageMethod() {
+
+ Method onMessageMethod = null;
+ try {
+ Class msgListenerClass = connector.MyMessageListener.class;
+ Class[] paramTypes = { java.lang.String.class };
+ onMessageMethod =
+ msgListenerClass.getMethod("onMessage", paramTypes);
+
+ } catch (NoSuchMethodException ex) {
+ ex.printStackTrace();
+ }
+ return onMessageMethod;
+ }
+
+ private ExecutionContext startTx() {
+ ExecutionContext ec = new ExecutionContext();
+ try {
+ Xid xid = new XID();
+ ec.setXid(xid);
+ ec.setTransactionTimeout(5*1000); //5 seconds
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ return ec;
+ }
+
+ private void notifyAndWait() {
+ try {
+ //Sleep for 5 seconds
+ //Thread.currentThread().sleep(5*1000);
+
+ synchronized(Controls.readyLock) {
+ //Notify the client to check the results
+ Controls.readyLock.notify();
+
+ //Wait until results are verified by the client
+ Controls.readyLock.wait();
+
+ if (stop) {
+ return;
+ }
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ private void done() {
+ try {
+ Controls.done = true;
+ synchronized(Controls.readyLock) {
+ //Notify the client to check the results
+ Controls.readyLock.notify();
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ private void debug(String mesg) {
+ System.out.println("Dispatcher[" + id + "] --> " + mesg);
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/XID.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/XID.java
new file mode 100644
index 0000000..138e91b
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/standalone-resource-adapter-as-bean-archive/ra/src/connector/XID.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2010, 2018 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
+ */
+
+package connector;
+
+import javax.transaction.xa.Xid;
+
+/**
+ * The XID class provides an implementation of the X/Open
+ * transaction identifier it implements the javax.transaction.xa.Xid interface.
+ */
+public class XID implements Xid {
+
+
+ private static int ID = initializeID();
+
+ private static int initializeID() {
+ return (int)(Math.random()*100000);
+ }
+
+ public int formatID; // Format identifier
+ // (-1) means that the XID is null
+ public int branchQualifier;
+ public int globalTxID;
+
+ static public final int MAXGTRIDSIZE= 64;
+ static public final int MAXBQUALSIZE= 64;
+
+ public XID() {
+ int foo = ID++;
+ formatID = foo;
+ branchQualifier = foo;
+ globalTxID = foo;
+ }
+
+ public boolean equals(Object o) {
+ XID other; // The "other" XID
+ int L; // Combined gtrid_length + bqual_length
+ int i;
+
+ if (!(o instanceof XID)) // If the other XID isn't an XID
+ {
+ return false; // It can't be equal
+ }
+
+ other = (XID)o; // The other XID, now properly cast
+
+ if (this.formatID == other.formatID
+ && this.branchQualifier == other.branchQualifier
+ && this.globalTxID == other.globalTxID) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Compute the hash code.
+ *
+ * @return the computed hashcode
+ */
+ public int hashCode() {
+ if (formatID == (-1)) {
+ return (-1);
+ }
+
+ return formatID + branchQualifier + globalTxID;
+
+ }
+
+ /*
+ * Convert to String
+ *
+ * <p> This is normally used to display the XID when debugging.
+ */
+
+ /**
+ * Return a string representing this XID.
+ *
+ * @return the string representation of this XID
+ */
+ public String toString() {
+
+ String s = new String("{XID: " +
+ "formatID(" + formatID + "), " +
+ "branchQualifier (" + branchQualifier + "), " +
+ "globalTxID(" + globalTxID + ")}");
+
+ return s;
+ }
+
+ /*
+ * Return branch qualifier
+ */
+
+ /**
+ * Returns the branch qualifier for this XID.
+ *
+ * @return the branch qualifier
+ */
+ public byte[] getBranchQualifier() {
+ String foo = (new Integer(branchQualifier)).toString();
+ return foo.getBytes();
+ }
+
+ public int getFormatId() {
+ return formatID;
+ }
+
+ public byte[] getGlobalTransactionId() {
+ String foo = (new Integer(globalTxID)).toString();
+ return foo.getBytes();
+ }
+}