zoukankan      html  css  js  c++  java
  • 性能测试二十九:Dubbo框架测试脚本编写

    测试脚本编写

    新建一个folder命名为lib,用于存放依赖包

     

    把以下jar全部拷进lib下,并build path

     

    找开发要 真正要测试的以jar包形式存在的代码的类,

     

    打开看一下

    放到lib并build

    所以说,要测试Dubbo框架下的接口,lib下要导入Dubbo框架的jar,还有需要测试的接口的jar包

    导入配置文件

     

    修改配置项,ip,接口

     到这,准备工作就做好了,开始写代码访问

     

    package cn.test.dubbo;

    import org.springframework.context.support.ClassPathXmlApplicationContext;

    import com.li.domain.Product;
    import com.li.service.ProductService;

    public class MyDubboTest {

    public static void main(String[] args) {
    //1、首先启动Dubbo框架,并且加载applicationContext.xml配置文件
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");

    //2、直接获取远程接口的对象(由框架自动完成)
    //后面那个productService为配置文件中zookeeper获取的远程接口对象的实例(id=“···”)
    ProductService productService = (ProductService) context.getBean("productService");

    //3、调用接口对象的方法
    Product product = productService.getProductByPid(1);
    if (product == null){
    System.out.println("事物失败");
    }else{
    System.out.println("事物成功");
    System.out.println(product);
    }
    }
    }

  • 相关阅读:
    bloom filter
    【转】单实例
    Log Structured Merge Trees(LSM) 原理
    【转】南网成立始末
    变电站综合自动化系统
    bsp tree
    Private Bytes,Working Set,Virtual Size的区别
    kdtree
    asp.net下载文件几种方式
    C# FTP操作
  • 原文地址:https://www.cnblogs.com/zhongyehai/p/10279967.html
Copyright © 2011-2022 走看看