From 7b5e72ab342d485baf7db018ccd86dda90abf494 Mon Sep 17 00:00:00 2001 From: Xiong Neng Date: Fri, 14 Sep 2018 15:11:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90springboot-hibernate=E5=8D=87?= =?UTF-8?q?=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- springboot-cxf/README.md | 4 ++++ .../com/xncoding/webservice/ApplicationTests.java | 14 ++------------ springboot-echarts/README.md | 7 ++++++- springboot-echarts/pom.xml | 2 -- .../com/xncoding/{echarts => }/Application.java | 2 +- .../pos/dao/repository/impl/ArticleDAO.java | 5 +++-- .../src/main/resources/application.yml | 4 ++-- .../java/com/xncoding/pos/ApplicationTests.java | 2 ++ 8 files changed, 20 insertions(+), 20 deletions(-) rename springboot-echarts/src/main/java/com/xncoding/{echarts => }/Application.java (90%) diff --git a/springboot-cxf/README.md b/springboot-cxf/README.md index 900d01e..0617a2a 100644 --- a/springboot-cxf/README.md +++ b/springboot-cxf/README.md @@ -46,6 +46,10 @@ com.xncoding.webservice.client.User user = c.getCommonServiceImplPort().getUser( assertThat(user.getName(), is("Tom")); ``` +## 测试步骤 + +先启动springboot项目,然后执行`com.xncoding.webservice.ApplicationTests`单元测试类。 + ## 许可证 Copyright (c) 2018 Xiong Neng diff --git a/springboot-cxf/src/test/java/com/xncoding/webservice/ApplicationTests.java b/springboot-cxf/src/test/java/com/xncoding/webservice/ApplicationTests.java index 0b6def4..20a4bfe 100644 --- a/springboot-cxf/src/test/java/com/xncoding/webservice/ApplicationTests.java +++ b/springboot-cxf/src/test/java/com/xncoding/webservice/ApplicationTests.java @@ -1,6 +1,5 @@ package com.xncoding.webservice; -import com.xncoding.webservice.client.CommonService_Service; import com.xncoding.webservice.model.User; import com.xncoding.webservice.service.ICommonService; import org.apache.cxf.endpoint.Client; @@ -8,18 +7,9 @@ import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.test.context.junit4.SpringRunner; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class ApplicationTests { - @LocalServerPort + private Integer port; /** * 接口地址 @@ -28,7 +18,7 @@ public class ApplicationTests { @Before public void prepare() { - wsdlAddress = "http://localhost:" + port + "/services/CommonService?wsdl"; + wsdlAddress = "http://localhost:8092/services/CommonService?wsdl"; } /** diff --git a/springboot-echarts/README.md b/springboot-echarts/README.md index f836fa3..90d5c40 100644 --- a/springboot-echarts/README.md +++ b/springboot-echarts/README.md @@ -19,12 +19,17 @@ 尝试采用页面js轮询方式,1秒轮询一次,有数据的时候就导出图片。结果导出图片太大了,不知道怎么回事,另外轮询方案始终不是很好。 -最后还是老老实实使用websocket方案,自己手动打开这个网页吧。 +最后还是老老实实使用websocket方案 ## JMH性能测试 在包`com.xncoding.benchmark`中,有几个基准测试,并且可将测试结果利用echarts图片导出到图片。 +## 测试步骤 + +1. 启动应用后,用浏览器打开首页: +2. 然后再执行图片生成测试方法`com.xncoding.echarts.common.util.ApplicationTests.testOption()` + ## 许可证 Copyright (c) 2018 Xiong Neng diff --git a/springboot-echarts/pom.xml b/springboot-echarts/pom.xml index ee0d778..ff3d30c 100644 --- a/springboot-echarts/pom.xml +++ b/springboot-echarts/pom.xml @@ -23,8 +23,6 @@ UTF-8 1.8 4.1.19.Final - 3.0.7.RELEASE - 2.2.2 1.20 diff --git a/springboot-echarts/src/main/java/com/xncoding/echarts/Application.java b/springboot-echarts/src/main/java/com/xncoding/Application.java similarity index 90% rename from springboot-echarts/src/main/java/com/xncoding/echarts/Application.java rename to springboot-echarts/src/main/java/com/xncoding/Application.java index f0e9961..89207e6 100644 --- a/springboot-echarts/src/main/java/com/xncoding/echarts/Application.java +++ b/springboot-echarts/src/main/java/com/xncoding/Application.java @@ -1,4 +1,4 @@ -package com.xncoding.echarts; +package com.xncoding; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/springboot-hibernate/src/main/java/com/xncoding/pos/dao/repository/impl/ArticleDAO.java b/springboot-hibernate/src/main/java/com/xncoding/pos/dao/repository/impl/ArticleDAO.java index c8b9ad0..2410cc9 100644 --- a/springboot-hibernate/src/main/java/com/xncoding/pos/dao/repository/impl/ArticleDAO.java +++ b/springboot-hibernate/src/main/java/com/xncoding/pos/dao/repository/impl/ArticleDAO.java @@ -53,8 +53,9 @@ public class ArticleDAO implements IArticleDAO { @Override public boolean articleExists(String title, String category) { String hql = "FROM Article as atcl WHERE atcl.title = ? and atcl.category = ?"; - int count = entityManager.createQuery(hql).setParameter(1, title) - .setParameter(2, category).getResultList().size(); + int count = entityManager.createQuery(hql) + .setParameter(0, title) + .setParameter(1, category).getResultList().size(); return count > 0; } } diff --git a/springboot-hibernate/src/main/resources/application.yml b/springboot-hibernate/src/main/resources/application.yml index 74c44ec..c388d93 100644 --- a/springboot-hibernate/src/main/resources/application.yml +++ b/springboot-hibernate/src/main/resources/application.yml @@ -26,7 +26,7 @@ logging: spring: profiles: dev datasource: - url: jdbc:mysql://127.0.0.1:3306/pos?useSSL=false&autoReconnect=true&tinyInt1isBit=false&useUnicode=true&characterEncoding=utf8 + url: jdbc:mysql://127.0.0.1:3306/pos?serverTimezone=UTC&useSSL=false&autoReconnect=true&tinyInt1isBit=false&useUnicode=true&characterEncoding=utf8 username: root password: 123456 @@ -46,7 +46,7 @@ logging: spring: profiles: test datasource: - url: jdbc:mysql://127.0.0.1:3306/pos?useSSL=false&autoReconnect=true&tinyInt1isBit=false&useUnicode=true&characterEncoding=utf8 + url: jdbc:mysql://127.0.0.1:3306/pos?serverTimezone=UTC&useSSL=false&autoReconnect=true&tinyInt1isBit=false&useUnicode=true&characterEncoding=utf8 username: root password: 123456 diff --git a/springboot-hibernate/src/test/java/com/xncoding/pos/ApplicationTests.java b/springboot-hibernate/src/test/java/com/xncoding/pos/ApplicationTests.java index 1a5408b..8288135 100644 --- a/springboot-hibernate/src/test/java/com/xncoding/pos/ApplicationTests.java +++ b/springboot-hibernate/src/test/java/com/xncoding/pos/ApplicationTests.java @@ -8,6 +8,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; @@ -23,6 +24,7 @@ import static org.hamcrest.Matchers.nullValue; */ @RunWith(SpringRunner.class) @SpringBootTest +@Transactional public class ApplicationTests { private static final Logger log = LoggerFactory.getLogger(ApplicationTests.class);