Initial Contribution
Signed-off-by: Vinay Vishal <vinay.vishal@oracle.com>
diff --git a/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/build.properties b/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/build.properties
new file mode 100644
index 0000000..2e64961
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/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="msgctxt"/>
+<property name="appname" value="${module}"/>
+<property name="assemble" value="${build.classes.dir}/archive"/>
+<property name="web.xml" value="./web.xml"/>
+<property name="sun-web.xml" value="./sun-web.xml"/>
+<property name="webservices.xml" value="./webservices.xml"/>
diff --git a/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/build.xml b/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/build.xml
new file mode 100644
index 0000000..9ef15ab
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/build.xml
@@ -0,0 +1,144 @@
+<?xml version="1.0"?>
+<!--
+
+ 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 project [
+<!ENTITY commonSetup SYSTEM "file:./../../../../config/properties.xml">
+<!ENTITY commonBuild SYSTEM "file:./../../../../config/common.xml">
+<!ENTITY commonRun SYSTEM "file:./../../../../config/run.xml">
+<!ENTITY jaxwsTools SYSTEM "file:./../jaxwstools.xml">
+<!ENTITY testproperties SYSTEM "file:./build.properties">
+]>
+
+<project name="Hello2" default="core" basedir=".">
+
+ &commonSetup;
+ &commonBuild;
+ &commonRun;
+ &testproperties;
+ &jaxwsTools;
+
+ <property name="src-name" value="endpoint/Hello.java"/>
+ <property name="client-src-name" value="client/Client.java"/>
+
+ <target name="compile" depends="init-common">
+ <antcall target="compile-common">
+ <param name="src" value="endpoint"/>
+ </antcall>
+ </target>
+
+ <target name="deploy-app">
+ <antcall target="deploy-war-common">
+ <param name="contextroot" value="${appname}"/>
+ </antcall>
+ </target>
+
+ <target name="undeploy" depends="init-common">
+ <antcall target="undeploy-war-common"/>
+ <antcall target="undeploy-client"/>
+ </target>
+
+
+
+ <target name="all" depends="clean, setup, runtest1, undeploy"/>
+ <target name="runtest1" depends="init-common">
+ <mkdir dir="${build.classes.dir}/client"/>
+ <javac srcdir="." destdir="${build.classes.dir}/client"
+ classpath="${env.APS_HOME}/lib/reporter.jar"
+ includes="client/**"/>
+ <unjar src="${env.APS_HOME}/lib/reporter.jar" dest="${build.classes.dir}/client"/>
+ <java classname="client.TestClient">
+ <classpath>
+ <pathelement path="${build.classes.dir}/client"/>
+ </classpath>
+ <arg value="http://${http.host}:${http.port}/wsclient/RequestProcessor"/>
+ </java>
+
+<!--restore the tokens back in file-->
+ <replace file="webclient/Client.java" token="${http.host}" value="HTTP_HOST"/>
+ <replace file="webclient/Client.java" token="${http.port}" value="HTTP_PORT"/>
+ </target>
+
+
+ <target name="setup" depends="assemble-web, deploy-app, assemble-client,deploy-client"/>
+ <target name="assemble-web" depends="init-common, compile">
+ <antcall target="pkg-war">
+ <param name="war.classes" value="${build.classes.dir}"/>
+ <param name="war.file" value="${assemble.dir}/${appname}-web.war"/>
+ </antcall>
+ </target>
+
+ <target name="clean" depends="init-common">
+ <antcall target="clean-common"/>
+ </target>
+
+ <target name="assemble-client" depends="init-common">
+ <mkdir dir="${build.classes.dir}/webclient/WEB-INF/classes"/>
+ <antcall target="wsimport">
+ <param name="wsimport.args"
+ value="-p client -Xendorsed -keep -d ${build.classes.dir}/webclient/WEB-INF/classes http://${http.host}:${http.port}/msgctxt/HelloService?wsdl"/>
+ </antcall>
+ <replace file="webclient/Client.java" value="${http.host}" token="HTTP_HOST"/>
+ <replace file="webclient/Client.java" value="${http.port}" token="HTTP_PORT"/>
+ <javac srcdir="." destdir="${build.classes.dir}/webclient/WEB-INF/classes"
+ includes="webclient/**">
+ <classpath refid="classpath"/>
+ <compilerarg value="-Djava.endorsed.dirs=${env.S1AS_HOME}/modules/endorsed"/>
+
+ </javac>
+ <copy file="client-web.xml" tofile="${build.classes.dir}/webclient/WEB-INF/web.xml"/>
+ <copy file="client-sun-web.xml" tofile="${build.classes.dir}/webclient/WEB-INF/sun-web.xml"/>
+ <jar destfile="${assemble.dir}/wsclient.war" basedir="${build.classes.dir}/webclient" includes="**"/>
+ </target>
+
+
+ <target name="undeploy-client" depends="init-common">
+ <exec executable="${ASADMIN}">
+ <arg line="undeploy"/>
+ <arg line="--user ${admin.user}"/>
+ <arg line="--passwordfile ${admin.password.file}"/>
+ <arg line="--host ${admin.host}"/>
+ <arg line="--port ${admin.port}"/>
+ <arg line="wsclient"/>
+ </exec>
+ </target>
+
+ <target name="deploy-client" depends="init-common">
+ <property name="client.war" value="${assemble.dir}/wsclient.war"/> <echo message="Deploying ${wsdl.war} from ${basedir}." level="verbose"/>
+ <exec executable="${ASADMIN}">
+ <arg line="deploy"/>
+ <arg line="--user ${admin.user}"/>
+ <arg line="--passwordfile ${admin.password.file}"/>
+ <arg line="--host ${admin.host}"/>
+ <arg line="--port ${admin.port}"/>
+ <arg line="${client.war}"/>
+ </exec>
+ </target>
+
+
+
+ <target name="report-success">
+ <echo message="Test PASSED"/>
+ </target>
+
+ <target name="report-failure">
+ <echo message="Test FAILED"/>
+ </target>
+
+ </project>
+
diff --git a/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/client-sun-web.xml b/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/client-sun-web.xml
new file mode 100644
index 0000000..397457e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/client-sun-web.xml
@@ -0,0 +1,23 @@
+<?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 sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server
+9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
+<sun-web-app>
+</sun-web-app>
diff --git a/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/client-web.xml b/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/client-web.xml
new file mode 100644
index 0000000..027dfce
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/client-web.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ 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
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:j2ee="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <description>A test application</description>
+ <display-name>WebTier</display-name>
+ <servlet>
+ <display-name>centralServlet</display-name>
+ <servlet-name>RequestProcessor</servlet-name>
+ <servlet-class>client.Client</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>RequestProcessor</servlet-name>
+ <url-pattern>/RequestProcessor</url-pattern>
+ </servlet-mapping>
+
+ <session-config>
+ <session-timeout>54</session-timeout>
+ </session-config>
+</web-app>
+
diff --git a/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/client/TestClient.java b/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/client/TestClient.java
new file mode 100644
index 0000000..d903e9e
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/client/TestClient.java
@@ -0,0 +1,99 @@
+/*
+ * 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 client;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
+
+public class TestClient {
+
+ private static SimpleReporterAdapter stat =
+ new SimpleReporterAdapter("appserv-tests");
+
+ public boolean found1 = false;
+ public boolean found2 = false;
+
+ public static void main (String[] args) {
+ stat.addDescription("msgctxt");
+ TestClient client = new TestClient();
+ client.doTest(args);
+ stat.printSummary("msgctxt");
+ }
+
+ public void doTest(String[] args) {
+
+ String url = args[0];
+ try {
+ int code = invokeServlet(url);
+ report(code);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ private int invokeServlet(String url) throws Exception {
+ log("Invoking url = " + 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) {
+ log(line);
+ if(line.indexOf("So the RESULT OF HELLO SERVICE IS") != -1)
+ found1 = true;
+ if(line.indexOf("WebSvcTest-Hello All") != -1)
+ found2 = true;
+ }
+ return code;
+ }
+
+ private void report(int code) {
+ if(code != 200) {
+ log("Incorrect return code: " + code);
+ fail();
+ }
+ if(!found1) {
+ fail();
+ }
+ if(!found2) {
+ fail();
+ }
+ pass();
+ }
+
+ private void log(String message) {
+ System.out.println("[client.TestClient]:: " + message);
+ }
+
+ private void pass() {
+ stat.addStatus("msgctxt", stat.PASS);
+ }
+
+ private void fail() {
+ stat.addStatus("msgctxt", stat.FAIL);
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/endpoint/Hello.java b/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/endpoint/Hello.java
new file mode 100644
index 0000000..9821bf0
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/endpoint/Hello.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 endpoint;
+
+import javax.jws.WebService;
+import javax.annotation.Resource;
+import javax.xml.ws.WebServiceContext;
+
+@WebService
+public class Hello {
+
+ @Resource WebServiceContext wsc;
+
+ public String sayHello(String param) {
+ javax.xml.ws.handler.MessageContext m = wsc.getMessageContext();
+ if(m == null)
+ return "WebService Context injection failed";
+ if(wsc != null)
+ return "WebSvcTest-Hello " + param;
+ return "WebService Context injection failed";
+ }
+}
diff --git a/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/web.xml b/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/web.xml
new file mode 100644
index 0000000..d4ee4b5
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/web.xml
@@ -0,0 +1,47 @@
+<?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
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:j2ee="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <description>WebTier for the Hello Service</description>
+ <display-name>HelloWAR</display-name>
+
+ <servlet>
+ <description>Endpoint for Hello Web Service</description>
+ <display-name>HelloWebService</display-name>
+ <servlet-name>Hello</servlet-name>
+ <servlet-class>endpoint.Hello</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Hello</servlet-name>
+ <url-pattern>/HelloService</url-pattern>
+ </servlet-mapping>
+
+ <session-config>
+ <session-timeout>54</session-timeout>
+ </session-config>
+
+</web-app>
+
diff --git a/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/webclient/Client.java b/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/webclient/Client.java
new file mode 100644
index 0000000..5ea3624
--- /dev/null
+++ b/appserver/tests/appserv-tests/devtests/webservice/annotations/msgctxt/webclient/Client.java
@@ -0,0 +1,69 @@
+/*
+ * 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 client;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.xml.ws.*;
+import javax.xml.ws.soap.*;
+
+public class Client extends HttpServlet {
+
+
+ @WebServiceRef(wsdlLocation="http://HTTP_HOST:HTTP_PORT/msgctxt/HelloService?WSDL")
+ HelloService service;
+
+ public void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws javax.servlet.ServletException {
+ doPost(req, resp);
+ }
+
+ public void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws javax.servlet.ServletException {
+
+ try {
+
+ Hello port = service.getHelloPort();
+
+ String ret = port.sayHello("All");
+
+
+ PrintWriter out = resp.getWriter();
+ resp.setContentType("text/html");
+ out.println("<html>");
+ out.println("<head>");
+ out.println("<title>TestServlet</title>");
+ out.println("</head>");
+ out.println("<body>");
+ out.println("<p>");
+ out.println("So the RESULT OF HELLO SERVICE IS :");
+ out.println("</p>");
+ out.println("[" + ret + "]");
+ out.println("</body>");
+ out.println("</html>");
+ out.flush();
+ out.close();
+ } catch(Exception e) {
+ e.printStackTrace();
+
+ }
+ }
+}
+