Vinay Vishal | 5717147 | 2018-09-18 20:22:00 +0530 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package servlet; |
| 18 | |
| 19 | import javax.servlet.http.HttpServlet; |
| 20 | import javax.servlet.http.HttpServletRequest; |
| 21 | import javax.servlet.http.HttpServletResponse; |
| 22 | import javax.servlet.ServletException; |
| 23 | import javax.naming.InitialContext; |
| 24 | import javax.naming.NamingException; |
Gaurav Gupta | ed5e731 | 2020-05-01 07:54:26 +0530 | [diff] [blame^] | 25 | import jakarta.ejb.CreateException; |
Vinay Vishal | 5717147 | 2018-09-18 20:22:00 +0530 | [diff] [blame] | 26 | import java.io.IOException; |
| 27 | import java.io.PrintWriter; |
| 28 | |
| 29 | import com.sun.s1asdev.jdbc.resenabledisable.ejb.SimpleBMPHome; |
| 30 | import com.sun.s1asdev.jdbc.resenabledisable.ejb.SimpleBMP; |
| 31 | |
| 32 | public 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 | } |