Initial Contribution Signed-off-by: Vinay Vishal <vinay.vishal@oracle.com>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/README b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/README new file mode 100644 index 0000000..098e4ae --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/README
@@ -0,0 +1,5 @@ +Test +- Injection of a no-interface bean in a request-scoped model via @Inject +and @EJB and invocation of methods defined in the EJB class and +in a super-class of the EJB +- glassfish issue 13040
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/build.properties b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/build.properties new file mode 100644 index 0000000..5b8ba11 --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/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}-no-interface-ejb"/> +<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-component-resources/no-interface-ejb/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/build.xml new file mode 100644 index 0000000..a0e6a9d --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/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" /> + <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="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="usage"> + <antcall target="usage-common" /> + </target> +</project>
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/client/test/client/WebTest.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/client/test/client/WebTest.java new file mode 100644 index 0000000..e775694 --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/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 = "injection-of-no-interface-bean-view-and-EJB-with-local-view"; + + 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, 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-component-resources/no-interface-ejb/descriptor/beans.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/descriptor/beans.xml new file mode 100644 index 0000000..1d355f8 --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/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-component-resources/no-interface-ejb/descriptor/persistence.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/descriptor/persistence.xml new file mode 100644 index 0000000..82f2d7b --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/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-component-resources/no-interface-ejb/servlet/test/beans/TestBeanInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/TestBeanInterface.java new file mode 100644 index 0000000..cf49083 --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/TestBeanInterface.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; + +public interface TestBeanInterface { + public String runTests(); +}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/InjectViaAtEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/InjectViaAtEJB.java new file mode 100644 index 0000000..594448d --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/InjectViaAtEJB.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 InjectViaAtEJB { + +}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/InjectViaAtInject.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/InjectViaAtInject.java new file mode 100644 index 0000000..8e11c88 --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/InjectViaAtInject.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 InjectViaAtInject { + +}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/LocalEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/LocalEJB.java new file mode 100644 index 0000000..04bb97c --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/LocalEJB.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 LocalEJB { +} +
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/NoInterfaceBeanView.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/NoInterfaceBeanView.java new file mode 100644 index 0000000..6e95330 --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/artifacts/NoInterfaceBeanView.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 NoInterfaceBeanView { + +}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/local/TestBeanSuper.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/local/TestBeanSuper.java new file mode 100644 index 0000000..a95c06e --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/local/TestBeanSuper.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 test.beans.nonmock.local; + +import test.beans.TestBeanInterface; +import test.ejb.local.TestInterface; +import test.ejb.local.TestLocalEJB; + +abstract class TestBeanSuper implements TestBeanInterface { + + abstract TestInterface getTestEJB(); + + @Override + public String runTests() { + String s = ""; + if (!getTestEJB().m1DefinedInInterface()) + s += "Cannot call method defined in the local EJB's interface"; + return s; + + } + +}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/local/TestEJBInjectionViaAtEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/local/TestEJBInjectionViaAtEJB.java new file mode 100644 index 0000000..edadb04 --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/local/TestEJBInjectionViaAtEJB.java
@@ -0,0 +1,41 @@ +/* + * 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.local; + +import javax.ejb.EJB; +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +import test.beans.artifacts.InjectViaAtEJB; +import test.beans.artifacts.LocalEJB; +import test.ejb.local.TestInterface; + + + +@RequestScoped +@InjectViaAtEJB +@LocalEJB + +public class TestEJBInjectionViaAtEJB extends TestBeanSuper{ + @EJB TestInterface tnie; + + @Override + TestInterface getTestEJB() { + return tnie; + } + +}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/local/TestEJBInjectionViaInject.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/local/TestEJBInjectionViaInject.java new file mode 100644 index 0000000..c4dec72 --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/local/TestEJBInjectionViaInject.java
@@ -0,0 +1,41 @@ +/* + * 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.local; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.inject.Named; + +import test.beans.artifacts.InjectViaAtInject; +import test.beans.artifacts.LocalEJB; +import test.ejb.local.TestInterface; + + +@RequestScoped +@InjectViaAtInject +@LocalEJB + +public class TestEJBInjectionViaInject extends TestBeanSuper { + @Inject TestInterface tnie; + + @Override + TestInterface getTestEJB() { + return tnie; + } + + +}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/nointerfacebeanview/TestBeanSuper.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/nointerfacebeanview/TestBeanSuper.java new file mode 100644 index 0000000..5a38f90 --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/nointerfacebeanview/TestBeanSuper.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 test.beans.nonmock.nointerfacebeanview; + +import test.beans.TestBeanInterface; +import test.ejb.nointerfacebeanview.TestNoInterfaceEJB; + +abstract class TestBeanSuper implements TestBeanInterface { + + abstract TestNoInterfaceEJB getTestEJB(); + + @Override + public String runTests() { + String s = ""; + if (!getTestEJB().m2DefinedInSuperClass()) + s += "Cannot call method defined in super class"; + if (!getTestEJB().m3DefinedInEJB()) + s += "Cannot call method defined in EJB"; + return s; + } + +}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/nointerfacebeanview/TestEJBInjectionViaAtEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/nointerfacebeanview/TestEJBInjectionViaAtEJB.java new file mode 100644 index 0000000..a6eaacd --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/nointerfacebeanview/TestEJBInjectionViaAtEJB.java
@@ -0,0 +1,43 @@ +/* + * 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.nointerfacebeanview; + +import javax.ejb.EJB; +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +import test.beans.artifacts.InjectViaAtEJB; +import test.beans.artifacts.NoInterfaceBeanView; +import test.ejb.nointerfacebeanview.TestNoInterfaceEJB; + + +@RequestScoped +@InjectViaAtEJB +@NoInterfaceBeanView + +public class TestEJBInjectionViaAtEJB extends TestBeanSuper{ + @EJB TestNoInterfaceEJB tnie; + + public TestEJBInjectionViaAtEJB() { + new Throwable().printStackTrace(); + } + @Override + TestNoInterfaceEJB getTestEJB() { + return tnie; + } + +}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/nointerfacebeanview/TestEJBInjectionViaInject.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/nointerfacebeanview/TestEJBInjectionViaInject.java new file mode 100644 index 0000000..62b1b11 --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/beans/nonmock/nointerfacebeanview/TestEJBInjectionViaInject.java
@@ -0,0 +1,41 @@ +/* + * 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.nointerfacebeanview; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.inject.Named; + +import test.beans.artifacts.InjectViaAtInject; +import test.beans.artifacts.NoInterfaceBeanView; +import test.ejb.nointerfacebeanview.TestNoInterfaceEJB; + + +@RequestScoped +@InjectViaAtInject +@NoInterfaceBeanView + +public class TestEJBInjectionViaInject extends TestBeanSuper { + @Inject TestNoInterfaceEJB tnie; + + @Override + TestNoInterfaceEJB getTestEJB() { + return tnie; + } + + +}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/local/TestInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/local/TestInterface.java new file mode 100644 index 0000000..fefb9ad --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/local/TestInterface.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.ejb.local; + +public interface TestInterface { + public boolean m1DefinedInInterface(); +}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/local/TestLocalEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/local/TestLocalEJB.java new file mode 100644 index 0000000..18054b1 --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/local/TestLocalEJB.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.ejb.local; + +import javax.ejb.Local; +import javax.ejb.Stateless; + +@Stateless +@Local(TestInterface.class) +public class TestLocalEJB extends TestSuperClass implements TestInterface { + public boolean m3DefinedInEJB(){ + System.out.println("local ejb: m3"); + return true; + } +}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/local/TestSuperClass.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/local/TestSuperClass.java new file mode 100644 index 0000000..53ad721 --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/local/TestSuperClass.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.ejb.local; + +import javax.enterprise.inject.Alternative; + + +//marked as Alternative, otherwise there would +//an ambiguous definition for TestLocalInterface between this +//super class and the TestLocalEJB +public @Alternative class TestSuperClass implements TestInterface{ + + @Override + public boolean m1DefinedInInterface() { + System.out.println("local bean: m1"); + return true; + } + + public boolean m2DefinedInSuperClass(){ + System.out.println("local: m2"); + return true; + } + +}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/nointerfacebeanview/TestInterface.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/nointerfacebeanview/TestInterface.java new file mode 100644 index 0000000..dcb7186 --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/nointerfacebeanview/TestInterface.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.ejb.nointerfacebeanview; + +public interface TestInterface { + public boolean m1DefinedInInterface(); +}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/nointerfacebeanview/TestNoInterfaceEJB.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/nointerfacebeanview/TestNoInterfaceEJB.java new file mode 100644 index 0000000..ec60e4d --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/nointerfacebeanview/TestNoInterfaceEJB.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.ejb.nointerfacebeanview; + +import javax.ejb.Stateless; + + +@Stateless +public class TestNoInterfaceEJB { + public boolean m1DefinedInInterface() { + System.out.println("no interface bean: m1"); + return true; + } + + public boolean m2DefinedInSuperClass(){ + System.out.println("no interface bean: m2"); + return true; + } + public boolean m3DefinedInEJB() { + System.out.println("no interface ejb: m3"); + return true; + } + +}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/nointerfacebeanview/TestSuperClass.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/nointerfacebeanview/TestSuperClass.java new file mode 100644 index 0000000..b4fbe8e --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/ejb/nointerfacebeanview/TestSuperClass.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.ejb.nointerfacebeanview; + +import javax.enterprise.inject.Alternative; + + +public class TestSuperClass implements TestInterface{ + + @Override + public boolean m1DefinedInInterface() { + System.out.println("no interface bean: m1"); + return true; + } + + public boolean m2DefinedInSuperClass(){ + System.out.println("no interface bean: m2"); + return true; + } + +}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/servlet/FooBean.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/servlet/FooBean.java new file mode 100644 index 0000000..1e102af --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/servlet/FooBean.java
@@ -0,0 +1,36 @@ +/* + * 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.servlet; + +import javax.inject.Inject; + +import test.beans.TestBeanInterface; +import test.beans.artifacts.InjectViaAtEJB; +import test.beans.artifacts.NoInterfaceBeanView; + +public class FooBean { + + @Inject + @InjectViaAtEJB + @NoInterfaceBeanView + TestBeanInterface testBeanEJB; + + public TestBeanInterface getBean(){ + return testBeanEJB; + } + +}
diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/servlet/NoInterfaceEJBTestServlet.java b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/servlet/NoInterfaceEJBTestServlet.java new file mode 100644 index 0000000..d878ef3 --- /dev/null +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-component-resources/no-interface-ejb/servlet/test/servlet/NoInterfaceEJBTestServlet.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 + */ + +package test.servlet; + +import java.io.IOException; +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; +import test.beans.artifacts.InjectViaAtEJB; +import test.beans.artifacts.InjectViaAtInject; +import test.beans.artifacts.LocalEJB; +import test.beans.artifacts.NoInterfaceBeanView; +import test.ejb.nointerfacebeanview.TestInterface; +import test.ejb.nointerfacebeanview.TestSuperClass; + +@WebServlet(name = "mytest", urlPatterns = { "/myurl" }) +public class NoInterfaceEJBTestServlet extends HttpServlet { + +// @Inject +// @InjectViaAtInject +// @NoInterfaceBeanView +// TestBeanInterface testBeanInject; + + + @Inject + FooBean fb; +// @Inject +// @InjectViaAtInject +// @LocalEJB +// TestBeanInterface testLocalBeanInject; + +// @Inject +// @InjectViaAtEJB +// @LocalEJB +// TestBeanInterface testLocalBeanEJB; + + @Inject + TestInterface ti; + + @Inject + TestSuperClass ti1; + + protected void doGet(HttpServletRequest request, + HttpServletResponse response) throws ServletException, + IOException { + PrintWriter writer = response.getWriter(); + writer.write("Hello from Servlet 3.0."); + + String msg = ""; + //test EJB injection via @EJB + String m = fb.getBean().runTests(); + if (!m.equals("")) + msg += "Invocation on no-interface EJB -- obtained through @EJB -- failed. Failed tests" + m; + + //test EJB injection via @Inject +// m = testBeanInject.runTests(); +// if (!m.equals("")) +// msg += "Invocation on no-interface EJB -- obtained through @Inject -- failed. Failed tests" + m; + + //test No-Interface EJB injection via @Inject of an interface the + //no-interface bean is implementing + if (ti != null && !(ti.m1DefinedInInterface())) + msg += "Invocation on no-interface EJB -- obtained through @Inject -- (method defined in super interface) failed"; + + //test No-Interface EJB injection via @Inject of an interface the + //no-interface bean is implementing + if (ti1 != null && !(ti1.m2DefinedInSuperClass())) + msg += "Invocation on no-interface EJB -- obtained through @Inject -- (method defined in super class) failed"; + + //test local EJB injection via @EJB +// m = testLocalBeanEJB.runTests(); +// if (!m.equals("")) +// msg += "Invocation on local EJB -- obtained through @EJB -- failed. Failed tests" + m; + + //test EJB injection via @Inject +// m = testLocalBeanInject.runTests(); +// if (!m.equals("")) +// msg += "Invocation on local EJB -- obtained through @Inject -- failed. Failed tests" + m; + + writer.write(msg + "\n"); + + } +}