当前位置: 首页 > news >正文

政务网站建设目的 意义如何推广短剧

政务网站建设目的 意义,如何推广短剧,丛台专业做网站,app开发网站建设包含项目一. 引言 随着公司项目整体架构由原来的多渠道各自为战#xff0c;向着建立统一的服务端应用#xff0c;从而为各渠道提供服务调用的转变#xff0c;服务端应用接口测试成了我们日常工作中的重要任务之一。经过半年的摸索和项目实战#xff0c;我们已经掌握了一套接口测试的…一. 引言 随着公司项目整体架构由原来的多渠道各自为战向着建立统一的服务端应用从而为各渠道提供服务调用的转变服务端应用接口测试成了我们日常工作中的重要任务之一。经过半年的摸索和项目实战我们已经掌握了一套接口测试的流程。这里对我们的接口测试流程进行下梳理一来是对之前的工作进行总结二来可以发现其中的不足和需要改进之处。 接口测试客户端的搭建主要可以分为以下几个步骤 1. 客户端项目搭建 2. 服务端地址配置 3. 接口请求封装 4. 测试用例编写 二. 正文 1. 客户端项目搭建 a.新建项目 首先在eclipse中创建一个简单的maven项目目录结构可以为默认的这里我们用不到test/resources这个路径可以把它给去了。jdk版本可以根据服务端应用的版本来选择这里我们选的是1.6的。 b.导入jar包 接着编写pom.xml文件引入相应的jar包。相关的jar可以分为三类框架/工具类、服务端应用接口包、测试用例框架包。框架一般会用到spring配置服务端地址、hibernate连接数据库工具类的有commons-langjacksonlog4j等等服务端应用相关的包例如我们的服务调用用的是dubbo协议则需要引入dubbo相关的jar以及服务提供的相应接口api包, 如果我们想用cxf-jaxws来调用服务则需要引入cxf相关的jar包测试用例框架包这里我们用的是junit另外如果还想要对接口进行性能测试的话就需要引入对应测试工具相关的jar包如ApacheJMeter-core/ApacheJMeter-java。以下是一个简单的pom配置 project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersiongroupIdcom.lglan/groupIdartifactIdInterfaceTestDemo/artifactIdversion0.0.1-SNAPSHOT/versionpropertiesproject.build.sourceEncodingUTF-8/project.build.sourceEncodingproject.reporting.outputEncodingUTF-8/project.reporting.outputEncodingspring.version3.1.2.RELEASE/spring.versionjunit.version4.9/junit.versiondubbo.version2.5.3/dubbo.versionzkclient.version0.1/zkclient.versionzookeeper.version3.4.5/zookeeper.version/propertiesdependenciesdependencygroupIdjunit/groupIdartifactIdjunit/artifactIdversion${junit.version}/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-context/artifactIdversion${spring.version}/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-core/artifactIdversion${spring.version}/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-beans/artifactIdversion${spring.version}/version/dependencydependencygroupIdlog4j/groupIdartifactIdlog4j/artifactIdversion1.2.14/version/dependencydependencygroupIdcom.alibaba/groupIdartifactIddubbo/artifactIdversion${dubbo.version}/versionexclusionsexclusiongroupIdorg.springframework/groupIdartifactIdspring/artifactId/exclusion/exclusions/dependencydependencygroupIdcom.github.sgroschupf/groupIdartifactIdzkclient/artifactIdversion${zkclient.version}/version/dependencydependencygroupIdorg.apache.zookeeper/groupIdartifactIdzookeeper/artifactIdversion${zookeeper.version}/versionexclusionsexclusionartifactIdjmxtools/artifactIdgroupIdcom.sun.jdmk/groupId/exclusionexclusionartifactIdjmxri/artifactIdgroupIdcom.sun.jmx/groupId/exclusionexclusionartifactIdjms/artifactIdgroupIdjavax.jms/groupId/exclusion/exclusions/dependencydependencygroupIdorg.apache.cxf/groupIdartifactIdcxf-rt-frontend-simple/artifactIdversion2.6.1/version/dependencydependencygroupIdorg.apache.cxf/groupIdartifactIdcxf-rt-transports-http/artifactIdversion2.6.1/version/dependencydependencygroupIdorg.apache.cxf/groupIdartifactIdcxf-rt-frontend-jaxws/artifactIdversion2.6.1/versionexclusionsexclusiongroupIdorg.apache.cxf/groupIdartifactIdcxf-rt-ws-addr/artifactId/exclusion/exclusions/dependency/dependenciesbuildpluginsplugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-surefire-plugin/artifactId version2.16/version configuration skipTeststrue/skipTests /configuration /plugin /plugins/build /project C. src/main/java目录下新建包 接下来我们在src/main/java源码目录下新建相关的包路径根据包中类的功能大致可以三类 1. 工具辅组类例如常量类以及常用工具类的封装类 2. 请求参数封装类 3.服务端接口封装及调用类 2.服务端地址配置 首先在resources目录下新建xml配置文件采用spring的IOC来管理各服务提供的接口地址。 例一dubbo协议的服务地址配置文件 ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:dubbohttp://code.alibabatech.com/schema/dubboxmlns:contexthttp://www.springframework.org/schema/contextxmlns:txhttp://www.springframework.org/schema/txxsi:schemaLocationhttp://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsdcontext:annotation-config/context:component-scan base-packagecom.*/ !-- 消费方应用名用于计算依赖关系不是匹配条件不要与提供方一样 --dubbo:application nameapp_opentravel /!-- 使用zookeeper注册中心暴露服务地址 --!-- dubbo:registry addressredis://172.0.0.1:6380 / --!-- 生成远程服务代理可以像使用本地bean一样使用demoService --dubbo:reference idiOneService interfacecom.lglan.demo.service.IOneService timeout5000 urldubbo://172.0.0.1:20880/ dubbo:reference idiTwoService interfacecom.lglan.demo.service.ITwoService timeout5000 urldubbo://172.0.0.1:20880/ /beans 例二jaxws形式的远程调用接口地址配置 ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:contexthttp://www.springframework.org/schema/contextxmlns:txhttp://www.springframework.org/schema/txxmlns:jaxwshttp://cxf.apache.org/jaxwsxsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsdhttp://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsdcontext:annotation-config/context:component-scan base-packagecom.ceair.travel.handlers/jaxws:client idOneService serviceClasscom.lglan.demo.service.IOneService addresshttp://172.0.0.1/lglan/services/IOneService?wsdl//beans 配置完接口地址后接下来我们在com.lglan.services路径下新建一个抽象类AbstractBaseService.java 用来默认加载配置文件并且定义一个抽象方法其它的service类可以通过继承该抽象类并实现抽象方法来获取特定的服务接口 package com.lglan.services;import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.support.ClassPathXmlApplicationContext;public abstract class AbstractBaseService implements ApplicationContextAware{private ApplicationContext applicationContext;Overridepublic void setApplicationContext(ApplicationContext applicationContext)throws BeansException {this.applicationContext applicationContext;}public ApplicationContext getApplicationContext(){if (null this.applicationContext) {return new ClassPathXmlApplicationContext(new String[]{classpath:dubboService.xml,classpath:wsdlService.xml} );}else {return this.applicationContext;}}public abstract Object getRemoteService();} 例如OneService.java类可以用来获得OneService服务 package com.lglan.services;public class OneService extends AbstractBaseService{Overridepublic OneService getRemoteService() {OneService iOneService (OneService) getApplicationContext().getBean(iOneService);return iOneService;}} 这样如果在测试用例中要调用OneService接口则直接创建一个OneService类就可以调用其具体的服务了。 3.接口请求封装 服务端提供的接口请求类其结构根据业务需要往往是比较复杂的一个请求包含几十个类几百个字段都是很正常的事。所以在测试用例中不可能把请求中的所有字段都填上通常只是输入一些跟具体业务逻辑和常见相关的参数其它字段要么不填要么写死如果是必填的话。为了测试用例代码的简洁我们要对请求先进行封装只暴露几个和业务相关的必填参数这样测试类中只要通过输入几个不同的参数组合就可以得到不同的测试用例来测试不同的业务逻辑和场景了。 例如一个机票预定的请求其数据结构如下图如果每个测试用例都要去手动填写如下这些参数的话那肯定得疯了。所以通过请求封装后我们只暴露了出发到达城市和日期以及乘机人数每个测试用例只要填写以上几个简单的参数就可以执行了。这也更符合实际的业务场景对于用户来说也只是需要输入这么几个参数就可以预定机票了。   4.测试用例编写 通过以上几个步骤的工作我们的接口测试客户端就基本上算是搭建完成了。最后就是测试用例的设计和编写。一般我们采用junit框架来编写测试用例在src/test/java下面按接口名新建一个包并在包下面创建测试用例类如 package com.lglan.oneservice.testcase;import static org.junit.Assert.*;import org.junit.After; import org.junit.Before; import org.junit.Test;import com.lglan.services.OneService;public class OneServiceTest {OneService oneService;Beforepublic void setUp() throws Exception {oneService new OneService();}Testpublic void testOneService() {String agr1 请求参数1;String agr2 请求参数2;OneServiceRQ oneServiceRQ OneServiceRQUtil.assembleRQ(arg1,arg2); OneServiceRS oneServiceRS oneServiceRQ.getResponse(oneServiceRQ);System.out.println(oneServiceRS);}Afterpublic void tearDown() throws Exception {} } 三.总结 1.新建项目引入相关jar包 2.配置接口地址的xml文件 3.用一个抽象类来读取配置文件服务类继承该抽象类来获得相应的接口实例化对象工厂模式 4.对请求参数进行封装 5.编写测试用例组装请求并通过服务类进行服务调用打印响应结果   全文完…转载于:https://www.cnblogs.com/beetle-shu/p/4199755.html
http://www.zqtcl.cn/news/800101/

相关文章:

  • 东莞模板网站做一个电子商务网站在哪里做
  • 给别人网站做跳转株洲专业网站排名优化
  • 国外网站空间租用费用网站前端设计图
  • 宜州做网站点点网 xml转wordpress
  • 太原建站方法erp系统好上手吗
  • 网站建设如何实现检索功能河南城乡建设网站
  • 江苏做电缆桥架的公司网站购物网站答辩ppt怎么做
  • 惠州网站建设系统公司公司网站建设公司
  • 做酒类直供网站行吗石家庄桥西网站制作公司
  • 电子商务门户网站的研究与实现漳州做网站多少钱
  • 咖啡网站源码呼和浩特网站建设价位
  • 邯郸哪儿能做网站广州冼村房价多少钱
  • 网站建设开发成本设计素材库
  • wordpress获取站点链接wordpress 滑动验证
  • 怎么把网站上的通栏手机公司网站建设
  • 微山县建设局官方网站wordpress 内容换行
  • 网站选择空间ps个人主页设计
  • 河北网站seo外包网站嵌入百度地图
  • 公司怎么开网站WordPress有哪些工具
  • 一流专业建设网站原平新闻头条最新消息
  • 网站开发文档模板 开源北京保障房建设项目网站
  • 营销型网站分类网站关键词如何快速上首页
  • 帝国和WordPress比较wordpress文章页标题优化
  • 宁晋网站建设温岭新站seo
  • 大学科研项目做网站成都免费建站模板
  • 兰州网站开发企业在微信公众号发布wordpress
  • 网站信息化建设总体情况网站建设介绍ppt模板下载
  • 广州 建网站asp.net.网站开发
  • 装修网站模板国家正规现货交易平台
  • 福州高端网站制作网站建设项目单子来源