Vinay Vishal | 5717147 | 2018-09-18 20:22:00 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2006, 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 com.sun.s1asdev.security.timerStandalone.client; |
| 18 | |
Gaurav Gupta | ed5e731 | 2020-05-01 07:54:26 +0530 | [diff] [blame] | 19 | import jakarta.ejb.EJB; |
Vinay Vishal | 5717147 | 2018-09-18 20:22:00 +0530 | [diff] [blame] | 20 | import com.sun.s1asdev.security.timerStandalone.*; |
| 21 | import com.sun.ejte.ccl.reporter.SimpleReporterAdapter; |
| 22 | |
| 23 | public class Client { |
| 24 | |
David Matějček | f4dc06a | 2021-05-17 12:10:57 +0200 | [diff] [blame^] | 25 | private static SimpleReporterAdapter stat = |
Vinay Vishal | 5717147 | 2018-09-18 20:22:00 +0530 | [diff] [blame] | 26 | new SimpleReporterAdapter("appserv-tests"); |
| 27 | |
| 28 | public static void main (String[] args) { |
| 29 | |
| 30 | stat.addDescription("security-timerStandalone"); |
| 31 | Client client = new Client(args); |
| 32 | client.doTest(); |
| 33 | stat.printSummary("security-timerStandalone"); |
David Matějček | f4dc06a | 2021-05-17 12:10:57 +0200 | [diff] [blame^] | 34 | } |
| 35 | |
Vinay Vishal | 5717147 | 2018-09-18 20:22:00 +0530 | [diff] [blame] | 36 | public Client (String[] args) { |
| 37 | } |
| 38 | |
| 39 | @EJB |
| 40 | private static Sful sful; |
| 41 | |
| 42 | @EJB |
| 43 | private static Sless sless; |
| 44 | |
| 45 | public void doTest() { |
| 46 | |
| 47 | try { |
| 48 | |
| 49 | System.out.println("invoking stateful"); |
| 50 | sful.hello(); |
| 51 | |
| 52 | System.out.println("invoking stateless"); |
| 53 | sless.hello(); |
| 54 | |
| 55 | System.out.println("Sleeping to wait for timeout to happen..."); |
| 56 | // wait a bit for timeout to happen |
| 57 | Thread.sleep(12000); |
| 58 | |
| 59 | System.out.println("Woke up. Now checking for timeout"); |
| 60 | |
| 61 | boolean timeoutCalled = sless.timeoutCalled(); |
| 62 | |
| 63 | if( timeoutCalled ) { |
| 64 | System.out.println("verified that timeout was called"); |
| 65 | } else { |
| 66 | throw new Exception("timeout not called"); |
| 67 | } |
| 68 | |
| 69 | System.out.println("test complete"); |
| 70 | |
| 71 | stat.addStatus("local main", stat.PASS); |
| 72 | |
| 73 | } catch(Exception e) { |
| 74 | e.printStackTrace(); |
| 75 | stat.addStatus("local main" , stat.FAIL); |
| 76 | } |
David Matějček | f4dc06a | 2021-05-17 12:10:57 +0200 | [diff] [blame^] | 77 | |
| 78 | return; |
Vinay Vishal | 5717147 | 2018-09-18 20:22:00 +0530 | [diff] [blame] | 79 | } |
| 80 | } |