zoukankan      html  css  js  c++  java
  • LR中测试dubbo接口的脚本

    import lrapi.lr;
    import com.alibaba.dubbo.config.ApplicationConfig;
    import com.alibaba.dubbo.config.ReferenceConfig;
    import com.unj.dubbotest.provider.DemoService;

    public class Actions
    {
    private final String ID = "ID";

    //dubbo服务地址
    private final String URL = "dubbo://ip:20880";

    //版本号
    private final String VERSION = "1.0.0";

    //服务名
    private final String SERVICE_NAME = "com.unj.dubbotest.provider.DemoService";

    private Object object;

    public int init() throws Throwable {
    // 当前应用配置
    ApplicationConfig application = new ApplicationConfig();
    application.setName("hehe_consumer");

    // 引用远程服务
    ReferenceConfig reference = new ReferenceConfig();
    reference.setApplication(application);
    reference.setId(ID);
    reference.setVersion(VERSION);

    // dubbo服务名
    reference.setInterface(SERVICE_NAME);

    // dubboip地址
    reference.setUrl(URL);

    // 和本地bean一样使用xxxService
    object = reference.get();
    return 0;
    }


    public int action() throws Throwable {
    DemoService demoService = (DemoService)object;
    String hello = demoService.sayHello("dubboTest");
    System.out.println(hello);
    return 0;
    }


    public int end() throws Throwable {
    return 0;
    }
    }

  • 相关阅读:
    springboot 之JPA
    Oracle数据库安装
    Pytho之Django
    springboot之docker化
    opencv之dlib库人脸识别
    opencv之调用摄像头
    springboot之多模块化项目打包
    python学习笔记2--list
    ETL测试
    Mockserver -MOCO的使用
  • 原文地址:https://www.cnblogs.com/NiceTime/p/8561142.html
Copyright © 2011-2022 走看看