重庆网站建设哪家做的好网站建设主流语言

diannao/2026/1/24 4:23:04/文章来源:
重庆网站建设哪家做的好,网站建设主流语言,十大黄金软件免费下载,设计上海网站建设这是Project Student的一部分。 其他职位包括带有Jersey的 Web服务 客户端#xff0c;带有Jersey的 Web服务服务器 #xff0c; 业务层和带有Spring Data的持久性 。 到目前为止#xff0c;所有集成测试都使用了内存嵌入式数据库#xff0c;该数据库无法一次又一次地保留信… 这是Project Student的一部分。 其他职位包括带有Jersey的 Web服务 客户端带有Jersey的 Web服务服务器 业务层和带有Spring Data的持久性 。 到目前为止所有集成测试都使用了内存嵌入式数据库该数据库无法一次又一次地保留信息。 当我们将REST服务器与“真实”数据库服务器完全集成时这种情况会发生变化-剩余的测试数据将污染我们的开发或测试数据库。 一旦我们进行了运行集成测试代码的连续集成这将是一个非常头疼的事情。 一种解决方案是以一种允许我们的测试使用共享开发数据库而不污染它或其他测试的方式“分片”我们的集成测试数据。 最简单的方法是将TestRun字段添加到所有对象。 “测试”数据将具有指示特定测试运行的值“实时”数据将具有空值。 确切的时间表是 创建并持久保存一个TestRun对象 创建具有适当TestRun值的测试对象 执行集成测试 删除测试对象 删除TestRun对象 TestRun表中的​​任何条目将是1主动集成测试或2引发未处理异常的集成测试失败当然这取决于事务管理器。 重要的是要注意即使事务管理器执行了回滚我们也可以在引发意外异常后捕获数据库状态-这是对junit测试运行程序的简单扩展。 时间戳记和用户字段使您可以轻松地根据其年龄例如超过7天的任何测试或运行测试的人员删除陈旧的测试数据。 TestablePersistentObject抽象基类 此更改从持久性级别开始因此我们应该从持久性级别开始并逐步进行扩展。 我们首先用测试运行值扩展PersistentObject抽象基类。 MappedSuperclass public abstract class TestablePersistentObject extends PersistentObject {private static final long serialVersionUID 1L;private TestRun testRun;/*** Fetch testRun object. We use lazy fetching since we rarely care about the* contents of this object - we just want to ensure referential integrity to* an existing testRun object when persisting a TPO.* * return*/ManyToOne(fetch FetchType.LAZY, optional true)public TestRun getTestRun() {return testRun;}public void setTestRun(TestRun testRun) {this.testRun testRun;}Transientpublic boolean isTestData() {return testRun ! null;} }TestRun类 TestRun类包含有关单个集成测试运行的标识信息。 它包含一个名称默认情况下该集成测试为classnamemethodname 测试的日期和时间以及运行该测试的用户的名称。 捕获其他信息将很容易。 测试对象列表为我们带来了两个重大胜利。 首先如果需要例如在意外的异常之后可以轻松捕获数据库的状态。 其次级联删除使删除所有测试对象变得容易。 XmlRootElement Entity Table(name test_run) AttributeOverride(name id, column Column(name test_run_pkey)) public class TestRun extends PersistentObject {private static final long serialVersionUID 1L;private String name;private Date testDate;private String user;private ListTestablePersistentObject objects Collections.emptyList();Column(length 80, unique false, updatable true)public String getName() {return name;}public void setName(String name) {this.name name;}Column(name test_date, nullable false, updatable false)Temporal(TemporalType.TIMESTAMP)public Date getTestDate() {return testDate;}public void setTestDate(Date testDate) {this.testDate testDate;}Column(length 40, unique false, updatable false)public String getUser() {return user;}public void setUser(String user) {this.user user;}OneToMany(cascade CascadeType.ALL)public ListTestablePersistentObject getObjects() {return objects;}public void setObjects(ListTestablePersistentObject objects) {this.objects objects;}/*** This is similar to standard prepersist method but we also set default* values for everything else.*/PrePersistpublic void prepersist() {if (getCreationDate() null) {setCreationDate(new Date());}if (getTestDate() null) {setTestDate(new Date());}if (getUuid() null) {setUuid(UUID.randomUUID().toString());}if (getUser() null) {setUser(System.getProperty(user.name));}if (name null) {setName(test run getUuid());}} } TestRun类扩展了PersistentObject而不是TestablePersistentObject因为我们的其他集成测试将充分利用它。 Spring数据仓库 我们必须向每个存储库添加一种其他方法。 Repository public interface CourseRepository extends JpaRepository {ListCourse findCoursesByTestRun(TestRun testRun);.... }服务介面 同样我们必须为每个服务添加两个其他方法。 public interface CourseService {ListCourse findAllCourses();Course findCourseById(Integer id);Course findCourseByUuid(String uuid);Course createCourse(String name);Course updateCourse(Course course, String name);void deleteCourse(String uuid);// new method for testingCourse createCourseForTesting(String name, TestRun testRun);// new method for testingListCourse findAllCoursesForTestRun(TestRun testRun); } 我不会显示TestRunRepositoryTestRunService接口或TestRunService实现因为它们与我在前几篇博客文章中所描述的相同。 服务实施 我们必须对现有Service实施进行一次小的更改并添加两种新方法。 Service public class CourseServiceImpl implements CourseService {Resourceprivate TestRunService testRunService;/*** see com.invariantproperties.sandbox.student.business.CourseService#* findAllCourses()*/Transactional(readOnly true)Overridepublic ListCourse findAllCourses() {ListCourse courses null;try {courses courseRepository.findCoursesByTestRun(null);} catch (DataAccessException e) {if (!(e instanceof UnitTestException)) {log.info(error loading list of courses: e.getMessage(), e);}throw new PersistenceException(unable to get list of courses., e);}return courses;}/*** see com.invariantproperties.sandbox.student.business.CourseService#* findAllCoursesForTestRun(com.invariantproperties.sandbox.student.common.TestRun)*/Transactional(readOnly true)Overridepublic ListCourse findAllCoursesForTestRun(TestRun testRun) {ListCourse courses null;try {courses courseRepository.findCoursesByTestRun(testRun);} catch (DataAccessException e) {if (!(e instanceof UnitTestException)) {log.info(error loading list of courses: e.getMessage(), e);}throw new PersistenceException(unable to get list of courses., e);}return courses;}/*** see com.invariantproperties.sandbox.student.business.CourseService#* createCourseForTesting(java.lang.String,* com.invariantproperties.sandbox.student.common.TestRun)*/TransactionalOverridepublic Course createCourseForTesting(String name, TestRun testRun) {final Course course new Course();course.setName(name);course.setTestUuid(testRun.getTestUuid());Course actual null;try {actual courseRepository.saveAndFlush(course);} catch (DataAccessException e) {if (!(e instanceof UnitTestException)) {log.info(internal error retrieving course: name, e);}throw new PersistenceException(unable to create course, e);}return actual;} }CourseServiceIntegrationTest 我们对集成测试进行了一些更改。 我们只需更改一种测试方法因为它是唯一实际创建测试对象的方法。 其余方法是不需要测试数据的查询。 请注意我们更改名称值以确保其唯一性。 这是解决唯一性约束例如电子邮件地址的一种方法。 RunWith(SpringJUnit4ClassRunner.class) ContextConfiguration(classes { BusinessApplicationContext.class, TestBusinessApplicationContext.class,TestPersistenceJpaConfig.class }) Transactional TransactionConfiguration(defaultRollback true) public class CourseServiceIntegrationTest {Resourceprivate CourseService dao;Resourceprivate TestRunService testService;Testpublic void testCourseLifecycle() throws Exception {final TestRun testRun testService.createTestRun();final String name Calculus 101 : testRun.getUuid();final Course expected new Course();expected.setName(name);assertNull(expected.getId());// create courseCourse actual dao.createCourseForTesting(name, testRun);expected.setId(actual.getId());expected.setUuid(actual.getUuid());expected.setCreationDate(actual.getCreationDate());assertThat(expected, equalTo(actual));assertNotNull(actual.getUuid());assertNotNull(actual.getCreationDate());// get course by idactual dao.findCourseById(expected.getId());assertThat(expected, equalTo(actual));// get course by uuidactual dao.findCourseByUuid(expected.getUuid());assertThat(expected, equalTo(actual));// get all coursesfinal ListCourse courses dao.findCoursesByTestRun(testRun);assertTrue(courses.contains(actual));// update courseexpected.setName(Calculus 102 : testRun.getUuid());actual dao.updateCourse(actual, expected.getName());assertThat(expected, equalTo(actual));// verify testRun.getObjectsfinal ListTestablePersistentObject objects testRun.getObjects();assertTrue(objects.contains(actual));// delete Coursedao.deleteCourse(expected.getUuid());try {dao.findCourseByUuid(expected.getUuid());fail(exception expected);} catch (ObjectNotFoundException e) {// expected}testService.deleteTestRun(testRun.getUuid());}.... } 我们可以使用Before和After透明地包装所有测试方法但是许多测试不需要测试数据而许多需要测试数据的测试则需要唯一的测试数据例如电子邮件地址。 在后一种情况下我们按照上述方法折叠测试UUID。 REST Web服务服务器 REST Web服务需要在请求类中添加测试uuid并在创建对象时添加一些逻辑以正确处理它。 REST Web服务不支持获取所有测试对象的列表。 “正确”的方法将是创建TestRun服务并响应/ get / {id}查询提供关联的对象。 XmlRootElement public class Name {private String name;private String testUuid;public String getName() {return name;}public void setName(String name) {this.name name;}public String getTestUuid() {return testUuid;}public void setTestUuid(String testUuid) {this.testUuid testUuid;} } 现在我们可以检查可选的testUuid字段并调用适当的create方法。 Service Path(/course) public class CourseResource extends AbstractResource {Resourceprivate CourseService service;Resourceprivate TestRunService testRunService;/*** Create a Course.* * param req* return*/POSTConsumes({ MediaType.APPLICATION_JSON, MediaType.TEXT_XML })Produces({ MediaType.APPLICATION_JSON, MediaType.TEXT_XML })public Response createCourse(Name req) {log.debug(CourseResource: createCourse());final String name req.getName();if ((name null) || name.isEmpty()) {return Response.status(Status.BAD_REQUEST).entity(name is required).build();}Response response null;try {Course course null;if (req.getTestUuid() ! null) {TestRun testRun testRunService.findTestRunByUuid(req.getTestUuid());if (testRun ! null) {course service.createCourseForTesting(name, testRun);} else {response Response.status(Status.BAD_REQUEST).entity(unknown test UUID).build();}} else {course service.createCourse(name);}if (course null) {response Response.status(Status.INTERNAL_SERVER_ERROR).build();} else {response Response.created(URI.create(course.getUuid())).entity(scrubCourse(course)).build();}} catch (Exception e) {if (!(e instanceof UnitTestException)) {log.info(unhandled exception, e);}response Response.status(Status.INTERNAL_SERVER_ERROR).build();}return response;}.... }REST Web服务客户端 最后REST服务器必须添加一种其他方法。 客户端尚不支持获取所有测试对象的列表。 public interface CourseRestClient {/*** Create specific course for testing.* * param name* param testRun*/Course createCourseForTesting(String name, TestRun testRun);.... } 和 public class CourseRestClientImpl extends AbstractRestClientImpl implements CourseRestClient {/*** Create JSON string.* * param name* return*/String createJson(final String name, final TestRun testRun) {return String.format({ \name\: \%s\, \testUuid\: \%s\ }, name, testRun.getTestUuid());}/*** see com.invariantproperties.sandbox.student.webservice.client.CourseRestClient#createCourse(java.lang.String)*/Overridepublic Course createCourseForTesting(final String name, final TestRun testRun) {if (name null || name.isEmpty()) {throw new IllegalArgumentException(name is required);}if (testRun null || testRun.getTestUuid() null || testRun.getTestUuid().isEmpty()) {throw new IllegalArgumentException(testRun is required);}return createObject(createJson(name, testRun));}.... }源代码 可从http://code.google.com/p/invariant-properties-blog/source/browse/student获取源代码。 澄清度 我认为在TestRun中不可能有OneToMany到TestablePersistentObject但是使用H2的集成测试成功了。 不幸的是当我使用PostgreSQL数据库启动完全集成的Web服务时这会引起问题。 我将代码留在上面因为即使我们没有通用集合也总是可以有一个教室列表一个课程列表等。 但是代码已从源代码控制的版本中删除。 更正 接口方法应该是findCourseByTestRun_Uuid 而不是findCourseByTestRun 。 另一种方法是使用JPA标准查询–请参阅“ 项目学生JPA标准查询” 。 参考 项目学生来自Invariant Properties博客的JCG合作伙伴 Bear Giles提供的分片集成测试数据 。 翻译自: https://www.javacodegeeks.com/2014/01/project-student-sharding-integration-test-data.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/88767.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

游戏的网站seo推广软件

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼6、free()函数问:下面的程序会在用户输入’freeze’的时候出问题,而’zebra’则不会,为什么?#include int main(int argc, char *argv[]) {char *ptr (char*)malloc(10);if(NULL ptr){printf(…

媒体网站开发字体设计在线生成

链接:https://pan.baidu.com/s/1-tCCFwZ0RggXtbWYBVyhFg?pwdmcgv 提取码:mcgv 华为MageBookD14原厂WIN11系统自带所有驱动、出厂状态主题壁纸、Office办公软件、华为电脑管家、华为应用市场等预装软件程序 文件格式:esd/wim/swm 安装方式…

购物网站设计需要哪些模块优秀英文企业网站

广搜练手题 题目链接 思路 打印每个数与其最近的 1 1 1的曼哈顿距离&#xff0c;显然广搜&#xff0c;存储每一个 1 1 1&#xff0c;针对每一个 1 1 1开始广搜&#xff0c;逐层更新&#xff0c;每轮后更新的为两轮之中的最小曼哈顿距离 ACcode #include<bits/stdc.h>…

有专门做辩论的网站吗如何推广自己的网址

&#xff08;笔记&#xff0c;只为获取流量券&#xff09; MySQL中&#xff0c;UPDATE 操作涉及到行级锁和表级锁的概念&#xff0c;具体取决于事务隔离级别和被更新的条件, 无索引的情况下&#xff1a; 当表没有索引的情况下&#xff0c;UPDATE 操作通常会涉及到表级锁。这是…

辽宁城建设计院有限公司网站公司网站建设费用会计科目

说明&#xff1a;基于filebeat采集日志 概述&#xff1a; 在Kubernetes环境中&#xff0c;Filebeat不需要和业务服务部署在同一个容器中。通常的做法是将Filebeat作为一个DaemonSet部署在集群中&#xff0c;这样它可以在每个节点上运行一个实例&#xff0c;并从所有容器中收集…

网站开发文档包括广州番禺区核酸检测点

什么是守护进程&#xff1f;答&#xff1a;守护进程是后台运行的、系统启动是就存在的、不予任何终端关联的&#xff0c;用于处理一些系统级别任务的特殊进程。实现思路&#xff1a;实现一个守护进程&#xff0c;其实就是将普通进程按照上述特性改造为守护进程的过程。需要注意…

网络营销推广优化网站推广优化淄博公司

我在python上编写了一个小脚本,该脚本从控制台调用命令行以使linux机器休眠(或在更改一个单词的情况下将其自身关闭),然后在一段时间后唤醒.通过watch命令一次又一次地调用该命令.import osimport timeos.system("watch -n 20 sudo rtcwake -u -s 10 -m mem")因此,在…

网站导航一定要一样吗网站设计模版免费下载

NB-IoT模组的应用场景一般具备低频次、小数据量、上行为主、工作时间短&#xff08;激活态时间短&#xff09;等特点。因此&#xff0c;休眠态的功耗是NB-IoT模组产品综合耗电的重点考量参数之一。中移物联OneMO超低功耗NB-IoT模组MN316&#xff0c;凭借其紧凑的尺寸、极低的休…

安安互联怎么上传网站科研实验室网站建设

2024年6月24日&#xff0c;JumpServer开源堡垒机正式发布v3.10.11 LTS版本。JumpServer开源项目组将对v3.10 LTS版本提供长期的支持和优化&#xff0c;并定期迭代发布小版本。欢迎广大社区用户升级至v3.10 LTS最新版本&#xff0c;以获得更佳的使用体验。 在JumpServer v3.10.…

dede分类信息网站网站首页设计一般包括那三个

目录 一、下载nltk_data-gh-pages.zip数据文件 二、将nltk_data文件夹移到对应的目录 三、测试 四、成功调用punkt库 问题&#xff1a; 解决方案&#xff1a; 在使用自然语言处理库nltk时&#xff0c;许多初学者会遇到“nltk.download(punkt)”无法正常下载的问题。本…

asp网站设计代做深圳高端网站建设多少钱

对于Python初学者来说&#xff0c;舍得强烈推荐从《HeadFirst Python》开始读起&#xff0c;这本书当真做到了深入浅出&#xff0c;HeadFirst系列&#xff0c;本身亦是品质的保证。这本书舍得已在《Python起步&#xff1a;写给零编程基础的童鞋》一文中提供了下载。为了方便大家…

网站开发都需要什么工作百安居装修报价清单

简介&#xff1a; 从团队的角度来看&#xff0c;写好代码是一件非常有必要的事情。如何写出干净优雅的代码是个很困难的课题&#xff0c;我没有找到万能的 solution&#xff0c;更多的是一些 trade off&#xff0c;可以稍微讨论一下。 写了多年的代码&#xff0c;始终觉得如何写…

二级域名网站查询全国工商网注册查询网

创建型模式 1、FACTORY —追MM少不了请吃饭了&#xff0c;麦当劳的鸡翅和肯德基的鸡翅都是MM爱吃的东西&#xff0c;虽然口味有所不同&#xff0c;但不管你带MM去麦当劳或肯德基&#xff0c;只管向服务员说“来四个鸡翅”就行了。麦当劳和肯德基就是生产鸡翅的Factory 工厂模式…

揭阳有哪家网站制作公司内蒙古住房与建设官方网站

1、模式标准 模式名称&#xff1a;组合模式 模式分类&#xff1a;结构型 模式意图&#xff1a;将对象组合成树型结构以表示“部分-整体”的层次结构。Composite 使得用户对单个对象和组合对象的使用具有一致性。 结构图&#xff1a; 适用于&#xff1a; 1、想表示对象的部分…

网站设计制作怎样可以快速天津建设工程信息网吧

一、题目 输入一个数n&#xff0c;计算123……n的和 二、代码截图【带注释】 三、源代码【带注释】 #include int main() { int num0; printf("请输入要运算的数:"); scanf("%d",&num); sumResult(num);//相加结果函数 } //计算打印…

网站页面设计论文网站流量的做

在MySQL中&#xff0c;update是原地更新数据&#xff0c;原地更新数据&#xff0c;原地更新数据。重要的事情说3遍。这是不同于PGSQL的。 update的具体过程是&#xff1a; (1)、先对该条record对应的索引加X锁 (2)、将修改后的数据写入到redo.log中 (3)、将修改之前的数据备…

西安市住宅和城乡建设局网站wordpress允许爬取

针对 ant-design-vue 版本 3.2.6 中 组件使用 mode“combobox” 时模式不生效的问题&#xff0c;我们可以基于现有信息和社区反馈来探讨可能的原因及解决方案。 警告与弃用通知 根据最新的资料&#xff0c;ant-design-vue 已经发出警告&#xff1a;[antdv: Select] The combob…

网站icp备案证明文件芜湖seo外包公司

本文来源&#xff1a; V3学院 尤老师的培训班笔记【高速收发器】xilinx高速收发器学习记录Xilinx-7Series-FPGA高速收发器使用学习—概述与参考时钟GT Transceiver的总体架构梳理 文章目录 一、概述&#xff1a;二、高速收发器结构&#xff1a;2.1 QUAD2.1.1 时钟2.1.2 CHANNEL…

对话弹窗在网站上浮动个人做外贸怎么做

给定一个字符串数组 strs &#xff0c;将 变位词 组合在一起。 可以按任意顺序返回结果列表。 注意&#xff1a;若两个字符串中每个字符出现的次数都相同&#xff0c;则称它们互为变位词。 示例 1: 输入: strs [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”] 输出…

188旅游网站管理系统源码网站服务类型怎么选

1.控制坐标轴长度比率和数据单位长度 您可以控制 x 轴、y 轴和 z 轴的相对长度&#xff08;图框纵横比&#xff09;&#xff0c;也可以控制一个数据单位沿每个轴的相对长度&#xff08;数据纵横比&#xff09;。 1.1图框纵横比 图框纵横比是 x 轴、y 轴和 z 轴的相对长度。默认…