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.initsql.client; |
| 18 | |
| 19 | import javax.naming.*; |
| 20 | import java.rmi.*; |
| 21 | import java.util.*; |
| 22 | import javax.sql.DataSource; |
| 23 | import com.sun.s1asdev.jdbc.initsql.ejb.SimpleSessionHome; |
| 24 | import com.sun.s1asdev.jdbc.initsql.ejb.SimpleSession; |
| 25 | import com.sun.ejte.ccl.reporter.SimpleReporterAdapter; |
| 26 | |
| 27 | public class Client { |
| 28 | |
| 29 | private static SimpleReporterAdapter stat = new SimpleReporterAdapter(); |
| 30 | private static String testSuite = "initsql-test"; |
| 31 | |
| 32 | private static InitialContext ic; |
| 33 | public static void main(String[] args) |
| 34 | throws Exception { |
| 35 | |
| 36 | try { |
| 37 | ic = new InitialContext(); |
| 38 | } catch(NamingException ex) { |
| 39 | ex.printStackTrace(); |
| 40 | } |
| 41 | |
| 42 | Object objRef = ic.lookup("java:comp/env/ejb/SimpleSessionHome"); |
| 43 | SimpleSessionHome simpleSessionHome = (SimpleSessionHome) |
| 44 | javax.rmi.PortableRemoteObject.narrow(objRef, SimpleSessionHome.class); |
| 45 | stat.addDescription("Running initsql testSuite "); |
| 46 | SimpleSession simpleSession = simpleSessionHome.create(); |
| 47 | |
| 48 | if (args != null && args.length > 0) { |
| 49 | String param = args[0]; |
| 50 | |
| 51 | switch (Integer.parseInt(param)) { |
| 52 | case 1: { |
| 53 | if (simpleSession.test1(false)) { //Case sensitive test |
| 54 | stat.addStatus(testSuite + "test-1 ", stat.PASS); |
| 55 | } else { |
| 56 | stat.addStatus(testSuite + "test-1 ", stat.FAIL); |
| 57 | } |
| 58 | break; |
| 59 | } |
| 60 | case 2: { |
| 61 | if (simpleSession.test1(true)) { //Case insensitivity test |
| 62 | stat.addStatus(testSuite + "test-2 ", stat.PASS); |
| 63 | } else { |
| 64 | stat.addStatus(testSuite + "test-2 ", stat.FAIL); |
| 65 | } |
| 66 | break; |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | stat.printSummary(); |
| 72 | } |
| 73 | } |