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 com.sun.s1asdev.jdbc.customval.client; |
| 18 | |
| 19 | import javax.naming.*; |
| 20 | import java.rmi.*; |
| 21 | import java.util.*; |
| 22 | |
| 23 | import com.sun.s1asdev.jdbc.customval.ejb.SimpleBMPHome; |
| 24 | import com.sun.s1asdev.jdbc.customval.ejb.SimpleBMP; |
| 25 | import com.sun.ejte.ccl.reporter.SimpleReporterAdapter; |
| 26 | |
| 27 | public class Client { |
| 28 | |
| 29 | public static void main(String[] args) |
| 30 | throws Exception { |
| 31 | |
| 32 | SimpleReporterAdapter stat = new |
| 33 | SimpleReporterAdapter(); |
| 34 | String testSuite = "CustomValidation-1 "; |
| 35 | InitialContext ic = new InitialContext(); |
| 36 | Object objRef = ic.lookup("java:comp/env/ejb/SimpleBMPHome"); |
| 37 | SimpleBMPHome convalBMPHome = (SimpleBMPHome) |
| 38 | javax.rmi.PortableRemoteObject.narrow(objRef, SimpleBMPHome.class); |
| 39 | |
| 40 | SimpleBMP convalBMP = convalBMPHome.create(); |
David Matějček | f4dc06a | 2021-05-17 12:10:57 +0200 | [diff] [blame^] | 41 | stat.addDescription("Custom Validation Test using a custom validator "); |
Vinay Vishal | 5717147 | 2018-09-18 20:22:00 +0530 | [diff] [blame] | 42 | |
| 43 | if (args != null && args.length > 0) { |
| 44 | String param = args[0]; |
| 45 | |
| 46 | switch (Integer.parseInt(param)) { |
| 47 | case 1: { |
| 48 | if (convalBMP.test1()) { |
| 49 | stat.addStatus(testSuite + "test-1 ", stat.PASS); |
| 50 | } else { |
| 51 | stat.addStatus(testSuite + "test-1 ", stat.FAIL); |
| 52 | } |
| 53 | break; |
| 54 | } |
| 55 | case 3: { |
| 56 | if (convalBMP.test1()) { |
| 57 | stat.addStatus(testSuite + "test-3 ", stat.PASS); |
| 58 | System.out.println("test-3 returned true as validation is enabled "); |
| 59 | } else { |
| 60 | stat.addStatus(testSuite + "test-3 ", stat.FAIL); |
| 61 | } |
| 62 | break; |
| 63 | } |
| 64 | case 4: { |
| 65 | if (convalBMP.test1()) { |
| 66 | stat.addStatus(testSuite + "test-4 ", stat.PASS); |
| 67 | System.out.println("test-4 returned true as validation is enabled "); |
| 68 | } else { |
| 69 | stat.addStatus(testSuite + "test-4 ", stat.FAIL); |
| 70 | } |
| 71 | break; |
| 72 | } |
| 73 | |
| 74 | case 2: { |
| 75 | try { |
| 76 | if(convalBMP.test1()){ |
| 77 | stat.addStatus(testSuite + "test-2 ", stat.FAIL); |
| 78 | }else{ |
| 79 | stat.addStatus(testSuite + "test-2 ", stat.PASS); |
| 80 | System.out.println("test-2 returned false as validation is not enabled "); |
| 81 | } |
| 82 | } |
| 83 | catch (Exception e) { |
| 84 | stat.addStatus(testSuite + "test1 ", stat.PASS); |
| 85 | } |
| 86 | break; |
| 87 | } |
| 88 | } |
| 89 | stat.printSummary(); |
| 90 | } |
| 91 | } |
| 92 | } |