blob: b5cd08effa6ec12a819ad15df37ecf01d3705193 [file] [log] [blame]
Vinay Vishal57171472018-09-18 20:22:00 +05301/*
2 * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v. 2.0, which is available at
6 * http://www.eclipse.org/legal/epl-2.0.
7 *
8 * This Source Code may also be made available under the following Secondary
9 * Licenses when the conditions for such availability set forth in the
10 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11 * version 2 with the GNU Classpath Exception, which is available at
12 * https://www.gnu.org/software/classpath/license.html.
13 *
14 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15 */
16
17package servlet;
18
19import javax.servlet.http.HttpServlet;
20import javax.servlet.http.HttpServletRequest;
21import javax.servlet.http.HttpServletResponse;
22import javax.servlet.ServletException;
23import javax.naming.InitialContext;
24import javax.naming.NamingException;
Gaurav Guptaed5e7312020-05-01 07:54:26 +053025import jakarta.ejb.CreateException;
Vinay Vishal57171472018-09-18 20:22:00 +053026import java.io.IOException;
27import java.io.PrintWriter;
28
29import com.sun.s1asdev.jdbc.resenabledisable.ejb.SimpleBMPHome;
30import com.sun.s1asdev.jdbc.resenabledisable.ejb.SimpleBMP;
31
32public class SimpleServlet extends HttpServlet {
33
34
35 public void doGet (HttpServletRequest request, HttpServletResponse response)
36 throws ServletException, IOException {
37 doPost(request, response);
38 }
39
40 /** handles the HTTP POST operation **/
41 public void doPost (HttpServletRequest request,HttpServletResponse response)
42 throws ServletException, IOException {
43 doTest(request, response);
44 }
45
46 public void doTest(HttpServletRequest request, HttpServletResponse response) throws IOException{
47 PrintWriter out = response.getWriter();
48
49 try{
50 System.out.println("JDBC Resource Enable/Disable test");
51
52 InitialContext ic = new InitialContext();
53 SimpleBMPHome simpleBMPHome = (SimpleBMPHome) ic.lookup("java:comp/env/ejb/SimpleBMPEJB");
54 out.println("Running resource enable disable test ");
55
56 //stat.addDescription("Running serializable connector test ");
57 SimpleBMP bean = simpleBMPHome.create();
58
59 for(int i=0; i<3; i++){
60 if(!bean.test1()){
61 out.println("TEST:FAIL");
62 break;
63 }
64 }
65 out.println("TEST:PASS");
66 } catch(NamingException ne) {
67 ne.printStackTrace();
68 } catch(CreateException e) {
69 e.printStackTrace();
70 } finally {
71 out.println("END_OF_TEST");
72 out.flush();
73 }
74 }
75}