jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nirodha Pramod <niro...@wso2.com>
Subject How to invoke a java method
Date Thu, 23 Feb 2012 23:37:33 GMT
Hi,

I want to test a session enabled axis2 service with Jmeter. There's an
special java client have written to test this. I want invoke that class
within jmeter.I tried with BShell sampler. But I get an error when the test
starts.

ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval In
file: inline evaluation of: ``import java.text.SimpleDateFormat; import
java.util.Calendar; import java.util.H . . . '' Encountered "," at line
116, column 23.

Is there any other sampler I can use for this?

Thanks,
Nirodha



Ps:  Following is what is inside my beanshell

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;

import javax.xml.namespace.QName;

import net.permanente.p2api.service.bean.xsd.LoginResponse;
import net.permanente.p2api.service.caaps.cappslogin.DoLogin;
import net.permanente.p2api.service.caaps.cappslogin.Login;
import net.permanente.p2api.service.caaps.cappslogin.LoginResponseE;
import net.permanente.p2api.service.caaps.cappslogin.Logout;
import net.permanente.p2api.service.capps.AppointmentPurposeRuleStub;
import net.permanente.p2api.service.capps.AppointmentScheduleStub;
import net.permanente.p2api.service.capps.appointment.AppointmentStub;
import net.permanente.p2api.service.capps.caapslogin.CAAPSLoginStub;
import net.permanente.p2api.service.exception.xsd.ServiceException;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.databinding.ADBException;

import
net.permanente.p2api.service.capps.AppointmentPurposeRuleStub.NextResponse;
import net.permanente.p2api.service.capps.AppointmentPurposeRuleStub.Query;
import
net.permanente.p2api.service.capps.AppointmentPurposeRuleStub.QueryResponse;
import
net.permanente.p2api.service.capps.AppointmentPurposeRuleStub.ApptPurposeRuleData;

import java.text.ParseException;


    public static String local_END_POINT = new String("
http://localhost:9763/services/");
    public static String PROD1_END_POINT = new String("
http://pp-app-esb-1.tpmg.net:48008/services/");
    public static String PESB1_END_POINT = new String("
http://pr-app-esb-1.tpmg.net:48008/services/");
    public static String PROD_ESB_POINT = new String("
http://172.25.125.8:48008/services/");
    public static String PpROD_ESB_POINT = new String("
http://172.25.125.22:48008/services/");
    public static String PROD2_END_POINT = new String("
http://pp-app-esb-2.tpmg.net:48008/services/");
    public static String PESB2_END_POINT = new String("
http://pr-app-esb-1.tpmg.net:48008/services/");
    public static String TRN_END_POINT = new String("
http://10.237.114.141:39762/services/");
    public static String TRN_ESB_POINT = new String("
http://10.237.114.141:8008/services/");
    public static String DEV_WSAS_POINT = new String("
http://10.237.119.47:39762/services/");
    public static String DEV_ESB_POINT = new String("
http://10.237.119.46:39763/services/");
    public static String TTG_PR_WSAS_POINT = new String("
http://10.237.114.100:39762/services/");
    public static String TTG_PR_ESB_HAR_1 = new String("
http://ttg-pr-esb-1:48008/services/");
    public static String TTG_PR_ESB_HAR_2 = new String("
http://ttg-pr-esb-2:48008/services/");
    public static String TTG_QA_ESB_2 = new String("
http://10.237.119.107:8008/services/");
    public static String TTG_QA_WSAS_2 = new String("
http://10.237.119.107:39762/services/");
    public static String TTG_DEV_ESB_2 = new String("
http://10.237.119.47:8008/services/");
    public static String ES412_END_POINT = new String("
http://ttg-pr-esb-5:8280/esb/services");
    public static String AS412_END_POINT = new String("
http://ttg-pr-esb-8:19443/services/");
    public static String AS4129_END_POINT = new String("
http://ttg-pr-esb-9:19443/as/services/");
    //public static String AS412_END_POINT = new String("
http://localhost:80/as/services/");
    public static String TCPMON_POINT = new String("
http://localhost:19443/as/services/");
    public static String END_POINT = AS412_END_POINT;
    public static String MRN = new String("0092128000");//0092128000,
0092140400 88020503  07460003 09991901
    public static String MRN_PREFIX = new String("11");
    public static String RACF = "ks01577"; //KS01577 ks01234
    public static String PASSWORD = "kaiser1@";// KAISER1@ richard1
    public static String USER_FACILITY = "STR";
    public static String MEDIA_CODE = "WWW";
    public static String CLIENT_APP = "MDO";
    public static String FACILITY_ID = "OAK"; // SRO for online booking and
STR for partner booking and OAK for cisco/mills

    // public static String MRN = new String("09982345");
    public static String PORTAL_SESSION_ID = new
String("WBBC528-558C1B1E31965A42D97074CCB0E80215");
    public static String PORTAL_SESSION_ID1 = new
String("87D533EDE89420D434178048829EE4CG");
    public static String PORTAL_SESSION_ID2 = new
String("87D533EDE89420D434178048829EE4CH");






        try {
// C:\\WorkSpace\\wso2\\session-example\\client\\repo\\conf\\axis2.xml
// C:\\WorkSpace\\wso2\\migrationTesting\\repository\\axis2_client.xml
            String repoPath = "C:\\KP\\Apps\\wso2as-4.1.2\\repository";
            String axis2xmlPath =
"C:\\KP\\Apps\\wso2as-4.1.2\\repository\\conf\\axis2-client.xml";
            ConfigurationContext configCtx = ConfigurationContextFactory
                    .createConfigurationContextFromFileSystem(repoPath,
                            null);


            Calendar calendar = Calendar.getInstance();

calendar.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
            calendar.clear();

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd
HH:mm:ss");
            SimpleDateFormat usdf = new SimpleDateFormat("yyyy-MM-dd");
            calendar.setTime(sdf.parse("2012-01-25 12:10:00"));

// The Operations and their querry Parameters...
            DoLogin iLogin = new DoLogin();
            Logout iLogout = new Logout();
            iLogin.setClientAppId(CLIENT_APP);
            iLogin.setClientTimeStamp(calendar);
            iLogin.setMediaCode(MEDIA_CODE);

            iLogin.setMrnPrefix(MRN_PREFIX);
            iLogin.setPassword(PASSWORD);
            iLogin.setUserFacility(USER_FACILITY);
            iLogin.setUserId(RACF);
            iLogin.setClientCorrelationId("123");

            iLogout.setMrnPrefix(MRN_PREFIX);
            String[] mrnArray = {"12978764",
"007459997"};//"12978764","007459997","0092128000","0092129300","0092130300","0092131600",
// "0092133100","0092134700","0092137100","0092137300",
// "0092138100","0092139200","0092139400","0092140400",
// "0092141700","0092145100","00865038"};
            Map<String, String> contextMap = new HashMap<String, String>();
            print("ServiceEndpoint is [" + END_POINT + "]");
            for (int j = 0; j < 2; j++) {

                print("**** Starting Iteration [" + j + "] ****");
                for (int i = 0; i < mrnArray.length; i++) {
                    CAAPSLoginStub cstub = new CAAPSLoginStub(configCtx,
END_POINT + "CAAPSLogin");
                    AppointmentPurposeRuleStub astub = new
AppointmentPurposeRuleStub(configCtx, AS4129_END_POINT +
"AppointmentPurposeRule");
                    AppointmentStub aptStub = new
AppointmentStub(configCtx, END_POINT + "Appointment");
                    AppointmentScheduleStub aptSchStub = new
AppointmentScheduleStub(configCtx, END_POINT + "AppointmentSchedule");
                    print("Created stubs");
                    Thread.sleep(2000);

                    ServiceClient sc = cstub._getServiceClient();
                    //sc.engageModule("addressing");
                    sc.engageModule("addressing");

                    Options opts = sc.getOptions();
                    opts.setManageSession(true);

                    sc.setOptions(opts);



/*cstub._getServiceClient().getOptions().setManageSession(true);

 cstub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.REUSE_HTTP_CLIENT,true);

 cstub._getServiceClient().engageModule("addressing");*/


aptStub._getServiceClient().getOptions().setManageSession(true);

aptStub._getServiceClient().engageModule(org.apache.axis2.Constants.MODULE_ADDRESSING);

aptStub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.REUSE_HTTP_CLIENT,
true);


aptSchStub._getServiceClient().getOptions().setManageSession(true);

aptSchStub._getServiceClient().engageModule(org.apache.axis2.Constants.MODULE_ADDRESSING);

aptSchStub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.REUSE_HTTP_CLIENT,
true);

                    print("Set stub parameters");
                    //Thread.sleep(2000);
                    iLogin.setMrn(mrnArray[i]);
                    print("Calling the Login Method [" + mrnArray[i] + "]");

                    LoginResponse lResponse =
cstub.doLogin(iLogin).get_return();
                    print(cstub._getServiceClient()
                            .getTargetEPR());

                    OMElement serviceGroupID = cstub._getServiceClient()
                            .getTargetEPR()
                            .getAllReferenceParameters()
                            .get(new QName("
http://ws.apache.org/namespaces/axis2", "ServiceGroupId"));
                    OMElement loginResp =
lResponse.getOMElement(LoginResponseE.MY_QNAME,
OMAbstractFactory.getOMFactory());

                    if (lResponse != null) {
                        print("Login method return value is [" +
loginResp.toString() + "]");
                        contextMap.put(mrnArray[i],
lResponse.getContextId());
                    } else {
                        print("Failed to call the api");
                    }

                    print("ServiceGroup is [" + serviceGroupID.toString() +
"]");

astub._getServiceClient().getOptions().getTo().addReferenceParameter(serviceGroupID.cloneOMElement());

astub._getServiceClient().getOptions().setManageSession(true);

                    ///Thread.sleep(10000);
                    Query qAptRuleTxt = new Query();
                    qAptRuleTxt.setFacilityId(FACILITY_ID);
                    qAptRuleTxt.setMrn(mrnArray[i]);
                    qAptRuleTxt.setMrnPrefix(MRN_PREFIX);
                    qAptRuleTxt.setContextId(lResponse.getContextId());
                    print("Calling getApptPurposeRuleText");
                    ApptPurposeRuleData ruleData =
astub.query(qAptRuleTxt).get_return();
                    print("got ruleData= " + ruleData);
// serviceGroupID = (OMElement) astub._getServiceClient()
// .getTargetEPR()
// .getAllReferenceParameters()
// .get(new QName("http://ws.apache.org/namespaces/axis2
","ServiceGroupId"));

                    OMElement ruleResp =
ruleData.getOMElement(QueryResponse.MY_QNAME,
OMAbstractFactory.getOMFactory());
                    if (ruleData != null) {
                        print("Received rules [" + ruleResp.toString() +
"]");
                    }
                    Thread.sleep(2000);
                    print("Calling getNextApptPurposeRuleText");

net.permanente.p2api.service.capps.AppointmentPurposeRuleStub.Next
qNApptRule = new
net.permanente.p2api.service.capps.AppointmentPurposeRuleStub.Next();
                    qNApptRule.setMrn(mrnArray[i]);
                    qNApptRule.setMrnPrefix(MRN_PREFIX);
                    qNApptRule.setContextId(lResponse.getContextId());
// qNApptRule.setPreviousScriptId("40000001"); // online booking
// qNApptRule.setPreviousResponseCode("01");
                    qNApptRule.setPreviousScriptId("50000001"); // partner
booking 00000704
                    qNApptRule.setPreviousResponseCode("02"); // 01 for
partner booking and 02 for mills
// print("request is [" +
qNApptRule.getOMElement(net.permanente.p2api.service.capps.AppointmentPurposeRuleStub.Next.MY_QNAME,
OMAbstractFactory.getOMFactory()));

                    ruleData = astub.next(qNApptRule).get_return();
// serviceGroupID = (OMElement) astub._getServiceClient()
// .getTargetEPR()
// .getAllReferenceParameters()
// .get(new QName("http://ws.apache.org/namespaces/axis2
","ServiceGroupId"));
//
                    ruleResp = ruleData.getOMElement(NextResponse.MY_QNAME,
OMAbstractFactory.getOMFactory());

                    if (ruleData != null) {
                        print("Received rules [" + ruleResp.toString() +
"]");
                        Thread.sleep(2000);

net.permanente.p2api.service.caaps.apptschedule.Query qAptSchedule = new
net.permanente.p2api.service.caaps.apptschedule.Query();
                        print("Processing first rule");

net.permanente.p2api.service.capps.AppointmentPurposeRuleStub.AppointmentRule[]
apptRule = ruleData.getApptPurposeRule();
                        print("Number of rules received are [" +
apptRule.length + "]");

net.permanente.p2api.service.capps.AppointmentPurposeRuleStub.AppointmentRule
aRule = new
net.permanente.p2api.service.capps.AppointmentPurposeRuleStub.AppointmentRule();
                        aRule = apptRule[0];


qAptSchedule.setBookingGuidelineId(aRule.getBookingGuidelineId());
                        qAptSchedule.setContextId(lResponse.getContextId());
                        qAptSchedule.setFacilityId(FACILITY_ID);
                        qAptSchedule.setMrn(mrnArray[i]);
                        qAptSchedule.setMrnPrefix(MRN_PREFIX);
                        Calendar ecalendar = Calendar.getInstance();
                        ecalendar.clear();
                        ecalendar.setTime(sdf.parse(sdf.format(new
java.util.Date())));
// ecalendar.setTime(sdf.parse("2009-03-01 00:00:00"));
                        ecalendar.add(java.util.Calendar.DATE, 0);
// this is new code
                        qAptSchedule.setSearchEarliestDate(ecalendar);
                        qAptSchedule.setSearchEarliestTime(ecalendar);
// qAptSchedule.setSearchEarliestDateTwo(ecalendar);
// qAptSchedule.setSearchEarliestDateTwo(null);
// This is old code
// qAptSchedule.setSearchEarliestDateOne(ecalendar);
// qAptSchedule.setSearchEarliestDateTwo(ecalendar);
// qAptSchedule.setSearchEarliestTimeOne(ecalendar);
// qAptSchedule.setSearchEarliestTimeTwo(ecalendar);

                        qAptSchedule.setApptInterval(1);
                        qAptSchedule.setNameFormatCode("D");
                        qAptSchedule.setNoOfApptsToBeReturned(4);

                        Calendar lcalendar = Calendar.getInstance();
                        lcalendar.clear();

lcalendar.setTime(sdf.parse(sdf.format(ecalendar.getTime())));
                        lcalendar.add(java.util.Calendar.DATE, 10);
                        qAptSchedule.setSearchLatestDate(lcalendar);
                        qAptSchedule.setSearchLatestDate(null);

// qAptSchedule.setSearchLatestDateOne(lcalendar);
// qAptSchedule.setSearchLatestDateTwo(lcalendar);
// qAptSchedule.setSearchLatestTimeOne(lcalendar);
// qAptSchedule.setSearchLatestTimeTwo(lcalendar);

                        qAptSchedule.setSearchMondayFlag(false);
                        qAptSchedule.setSearchSatFlag(true);
                        qAptSchedule.setSearchSundayFlag(false);
                        qAptSchedule.setSearchThursFlag(false);
                        qAptSchedule.setSearchTuesdayFlag(false);
                        qAptSchedule.setSearchWedFlag(false);
                        qAptSchedule.setSearchFriFlag(false);


aptSchStub._getServiceClient().getOptions().getTo().addReferenceParameter(serviceGroupID.cloneOMElement());

                        print("Appointment schedule query is [" +
qAptSchedule.getOMElement(net.permanente.p2api.service.caaps.apptschedule.Query.MY_QNAME,
OMAbstractFactory.getOMFactory()));

// ApptScheduleSlot slot = aptSchStub.query(qAptSchedule).get_return();
// serviceGroupID = (OMElement) aptSchStub._getServiceClient()
// .getTargetEPR()
// .getAllReferenceParameters()
// .get(new QName("http://ws.apache.org/namespaces/axis2
","ServiceGroupId"));
// AppointmentSlot[] aSlots = slot.getApptList();
// if (aSlots != null && aSlots.length > 0) {
// OMElement slotResp =
slot.getOMElement(net.permanente.p2api.service.caaps.apptschedule.QueryResponse.MY_QNAME,
OMAbstractFactory.getOMFactory());
//
// print("Received First lot appointments [\n" + slotResp.toString() +
"\n]");
// print("**** Appointment times *****");
// for (int k = 0; k < aSlots.length ; k++) {
// print("begin time  " +
sdf.format(aSlots[k].getAppointmentBeginTime().getTime()));
// print("appt Time " +
sdf.format(aSlots[k].getAppointmentTime().getTime()));
// }
// Thread.sleep(2000);
// if (slot.getMoreAppointment()) {
// net.permanente.p2api.service.caaps.apptschedule.Next nAptSchedule = new
net.permanente.p2api.service.caaps.apptschedule.Next();
// nAptSchedule.setContextId(lResponse.getContextId());
// nAptSchedule.setMrn(mrnArray[i]);
// nAptSchedule.setMrnPrefix(MRN_PREFIX);
// ApptScheduleSlot nSlot = aptSchStub.next(nAptSchedule).get_return();
// OMElement nslotResp =
nSlot.getOMElement(net.permanente.p2api.service.caaps.apptschedule.NextResponse.MY_QNAME,
OMAbstractFactory.getOMFactory());
// print("Received Second lot appointments [\n" + nslotResp.toString() +
"\n]");
// int k = 0;
// while (nSlot.getMoreAppointment()) {
// nSlot = aptSchStub.next(nAptSchedule).get_return();
// nslotResp =
nSlot.getOMElement(net.permanente.p2api.service.caaps.apptschedule.NextResponse.MY_QNAME,
OMAbstractFactory.getOMFactory());
// print("Received " + ++k + " lot appointments [\n" + nslotResp.toString()
+ "\n]");
// }
// }
// AppointmentSlot aptSlot = aSlots[0];
// net.permanente.p2api.service.caaps.appointment.Insert aptInsert = new
net.permanente.p2api.service.caaps.appointment.Insert();
// aptInsert.setActivityCode(aptSlot.getActivityCode());
// Calendar cal = Calendar.getInstance();
//
cal.setTime(sdf.parse(sdf.format(aptSlot.getAppointmentTime().getTime())));
// aptInsert.setAppointmentBeginTime(cal);
// aptInsert.setAppointmentBeginTime(cal.getTime());
// aptInsert.setAvailabilityCode(null);
// aptInsert.setBookingReasonNote(aptSlot.getInstructionText());
// aptInsert.setChartRequestCode(aptSlot.getChartRequestCode());
// aptInsert.setClinicId(aptSlot.getClinicId());
// aptInsert.setConfirmationSwitch(aptSlot.getConfirmationSwitch().equalsIgnoreCase("Y")
? true : false);
// aptInsert.setContextId(lResponse.getContextId());
// aptInsert.setFacilityId(aptSlot.getFacilityId());
// aptInsert.setInterpreterLanguageCode(null);
// aptInsert.setInterpreterRequiredSwitch(false);
//
aptInsert.setMedicalRecordRequestCode(aptSlot.getMedicalRecordRequestCode());
// aptInsert.setMrn(mrnArray[i]);
// aptInsert.setMrnPrefix(MRN_PREFIX);
// aptInsert.setXrayRequestCode(aptSlot.getXrayRequestCode());
// aptInsert.setReminderCode(aptSlot.getReminderCode());
// aptInsert.setResourceId(aptSlot.getResourceId());
//
aptStub._getServiceClient().getOptions().getTo().addReferenceParameter(serviceGroupID.cloneOMElement());

// Response iResp = aptStub.insert(aptInsert).get_return();
// OMElement insertResp =
iResp.getOMElement(net.permanente.p2api.service.caaps.appointment.InsertResponse.MY_QNAME,
OMAbstractFactory.getOMFactory());
// print("Parrs Insert response [" + insertResp.toString() + "]");
// }

net.permanente.p2api.service.caaps.apptschedule.Terminate tAptSchedule =
new net.permanente.p2api.service.caaps.apptschedule.Terminate();
                        tAptSchedule.setContextId(lResponse.getContextId());
                        tAptSchedule.setMrn(mrnArray[i]);
                        tAptSchedule.setMrnPrefix(MRN_PREFIX);
                        Thread.sleep(2000);
                        aptSchStub.terminate(tAptSchedule);
// serviceGroupID = (OMElement) aptSchStub._getServiceClient()
// .getTargetEPR()
// .getAllReferenceParameters()
// .get(new QName("http://ws.apache.org/namespaces/axis2
","ServiceGroupId"));
                        print("terminated search");

                    }
                    print("calling the logout method");
                    iLogout.setMrn(mrnArray[i]);
                    iLogout.setMrnPrefix(MRN_PREFIX);
                    iLogout.setContextId(contextMap.get(mrnArray[i]));

cstub._getServiceClient().getOptions().getTo().addReferenceParameter(serviceGroupID.cloneOMElement());

                    cstub.logout(iLogout);
                    cstub.cleanup();
                    aptSchStub.cleanup();
                    aptStub.cleanup();
                    astub.cleanup();
                }

                print("**** Completed Iteration [" + j + "] ****");
                Thread.sleep(1000);
            }
// }
// for (int j = 0; j < mrnArray.length; j++){
// print("calling the logout method");
// iLogout.setMrn(mrnArray[j]);
// iLogout.setMrnPrefix(MRN_PREFIX);
// iLogout.setContextId(contextMap.get(mrnArray[j]));
////
cstub._getServiceClient().getOptions().getTo().addReferenceParameter(serviceGroupID);
// cstub.logout(iLogout);
// }

        } catch (AxisFault axisFault) {
            axisFault.printStackTrace();  //To change body of catch
statement use File | Settings | File Templates.
        } catch (java.rmi.RemoteException e) {
            e.printStackTrace();  //To change body of catch statement use
File | Settings | File Templates.
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
        } catch (ADBException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RuntimeException e) {
            e.printStackTrace();
        } catch (Throwable th) {
            th.printStackTrace();
        }



*
*
*
*
*Nirodha Gallage*
*
*Software Engineer, QA.
WSO2 Inc.: http://wso2.com/
Email: nirodha@wso2.com   Mobile: +94716429078

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message