blob: e1fcf92552308f76d9f284ee442094d975806375 [file] [log] [blame]
/*
* Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package com.sun.s1asdev.ejb.sfsb.stress.client;
import java.util.ArrayList;
import javax.naming.*;
import jakarta.jms.*;
import jakarta.ejb.*;
import javax.rmi.PortableRemoteObject;
import com.sun.s1asdev.ejb.sfsb.stress.ejb.StressSFSBHome;
import com.sun.s1asdev.ejb.sfsb.stress.ejb.StressSFSB;
import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
public class Client {
// consts
public static String kTestNotRun = "TEST NOT RUN";
public static String kTestPassed = "TEST PASSED";
public static String kTestFailed = "TEST FAILED";
private static SimpleReporterAdapter stat =
new SimpleReporterAdapter("appserv-tests");
private static final int MAX_SFSBS = 40;
private ArrayList sfsbList = new ArrayList();
public static void main (String[] args) {
stat.addDescription("stress");
Client client = new Client(args);
System.out.println("[stressClient] doTest()...");
client.doTest();
System.out.println("[stressClient] DONE doTest()...");
stat.printSummary("stress");
}
public Client (String[] args) {
}
public void doTest() {
initSFSBList(); //create SFSBs
accessSFSB(); //access the SFBS
}
private void initSFSBList() {
System.out.println("[stressClient] Inside init....");
try {
Context ic = new InitialContext();
Object objref = ic.lookup("java:comp/env/ejb/StressSFSBHome");
StressSFSBHome home = (StressSFSBHome)PortableRemoteObject.narrow
(objref, StressSFSBHome.class);
for (int i=0; i < MAX_SFSBS; i++) {
//Creating these many SFSBs will cause passivation
StressSFSB sfsb = (StressSFSB) home.create("SFSB_"+i);
sfsbList.add(sfsb);
}
System.out.println("[stress] Initalization done");
stat.addStatus("ejbclient initSFSBList", stat.PASS);
} catch(Exception e) {
e.printStackTrace();
//stat.addStatus("ejbclient localEntityGetEJBObject(-)" , stat.PASS);
System.out.println("[stressClient] Exception in init....");
e.printStackTrace();
stat.addStatus("ejbclient initSFSBList", stat.FAIL);
}
}
public void accessSFSB() {
try {
boolean passed = true;
for (int i=0; i < MAX_SFSBS; i++) {
StressSFSB sfsb = (StressSFSB) sfsbList.get(i);
String sfsbName = "SFSB_"+i;
passed = sfsb.doWork((long) 2000);
System.out.println("Bean #: " + i + " ==> " + passed);
if (! passed) {
break;
}
}
if (passed) {
stat.addStatus("ejbclient accessSFSB", stat.PASS);
} else {
stat.addStatus("ejbclient accessSFSB", stat.FAIL);
}
} catch (Exception ex) {
stat.addStatus("ejbclient accessSFSB", stat.FAIL);
}
}
} //Client{}