From b5a19c78cf57c153b18ee8a254ac4b0a646bdb26 Mon Sep 17 00:00:00 2001 From: huangsimin Date: Thu, 15 Aug 2019 17:42:04 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E4=BF=AE=E6=94=B9Pom=20Assembly?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE,=20=20=E5=AE=8C=E7=BE=8E=E6=89=93=E5=8C=85sc?= =?UTF-8?q?ripts.=20fix:=20test=E7=9A=84=E8=AE=BE=E7=BD=AE,=20=20=E4=BD=BF?= =?UTF-8?q?unittest=E5=8F=AF=E4=BB=A5=E6=A0=B9=E6=8D=AE=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=8F=98=E9=87=8F=E5=90=AF=E5=8A=A8=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 10 ++-- usergw-service/pom.xml | 57 +++++++++++++------ usergw-service/src/main/assembly/assembly.xml | 45 +++++++++++++++ .../src/main/assembly/scripts/run.bat | 10 ++++ .../src/main/assembly/scripts/run.sh | 8 +++ .../java => main}/resources/test-gateway.yaml | 0 .../service/usergw/TestHttp2DubboConfig.java | 2 +- .../service/usergw/TestHttp2DubboConfig2.java | 4 +- .../service/usergw/TestHttp2DubboConfig3.java | 4 +- .../service/usergw/TestHttp2DubboConfig4.java | 2 +- .../{test.properties => test1.properties} | 0 .../test2.properties} | 2 +- .../test3.properties} | 2 +- .../test4.properties} | 2 +- 14 files changed, 116 insertions(+), 32 deletions(-) create mode 100644 usergw-service/src/main/assembly/assembly.xml create mode 100644 usergw-service/src/main/assembly/scripts/run.bat create mode 100644 usergw-service/src/main/assembly/scripts/run.sh rename usergw-service/src/{test/java => main}/resources/test-gateway.yaml (100%) rename usergw-service/src/test/java/resources/{test.properties => test1.properties} (100%) rename usergw-service/src/test/java/{cn/ecpark/service/usergw/application2.properties => resources/test2.properties} (91%) rename usergw-service/src/test/java/{cn/ecpark/service/usergw/application3.properties => resources/test3.properties} (91%) rename usergw-service/src/test/java/{cn/ecpark/service/usergw/application4.properties => resources/test4.properties} (92%) diff --git a/pom.xml b/pom.xml index 9f89c20..e60075d 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.1.6.RELEASE + 2.1.7.RELEASE @@ -22,7 +22,7 @@ UTF-8 UTF-8 Greenwich.SR2 - 2.7.2 + 2.7.3 @@ -47,19 +47,19 @@ org.apache.dubbo dubbo-spring-boot-starter - 2.7.1 + ${dubbo.version} org.apache.dubbo dubbo - 2.7.2 + ${dubbo.version} org.apache.dubbo dubbo-dependencies-zookeeper - 2.7.1 + ${dubbo.version} pom diff --git a/usergw-service/pom.xml b/usergw-service/pom.xml index 44ae320..9a657ba 100644 --- a/usergw-service/pom.xml +++ b/usergw-service/pom.xml @@ -17,9 +17,11 @@ 1.8 + false - + + cn.ecpark.service usergw-api @@ -56,7 +58,7 @@ org.yaml snakeyaml - 1.21 + 1.24 @@ -64,12 +66,6 @@ fastjson 1.2.58 - - - cn.ecpark.service - usergw-api - ${project.parent.version} - com.ctrip.framework.apollo @@ -91,17 +87,42 @@ org.springframework.boot spring-boot-maven-plugin + + cn.ecpark.service.usergw.App + - + + maven-compiler-plugin + maven-resources-plugin + maven-source-plugin + - maven-compiler-plugin - - - maven-resources-plugin - - - maven-source-plugin - + maven-assembly-plugin + 3.1.1 + + + make-assembly + package + + single + + + + + + + + true + + src/main/assembly/assembly.xml + + + + + + org.jacoco @@ -129,4 +150,4 @@ - \ No newline at end of file + diff --git a/usergw-service/src/main/assembly/assembly.xml b/usergw-service/src/main/assembly/assembly.xml new file mode 100644 index 0000000..c913986 --- /dev/null +++ b/usergw-service/src/main/assembly/assembly.xml @@ -0,0 +1,45 @@ + + assembly + + dir + zip + + false + + + src/main/assembly/scripts + bin + 0755 + true + + + + src/main/resources + config + + *.properties + gateway.yaml + + + + + ${project.build.directory} + / + + *.jar + + + + + + + + \ No newline at end of file diff --git a/usergw-service/src/main/assembly/scripts/run.bat b/usergw-service/src/main/assembly/scripts/run.bat new file mode 100644 index 0000000..9e69887 --- /dev/null +++ b/usergw-service/src/main/assembly/scripts/run.bat @@ -0,0 +1,10 @@ +@echo off & setlocal enabledelayedexpansion +set BIN_DIR=%~dp0 + +::run +cd %BIN_DIR%\.. + set APP_JAR="" + for %%f in (*-*-*.jar) do set APP_JAR=%%f + java -Dloader.path=config -Dfile.encoding=UTF-8 -Xms256m -Xmx512m -jar %APP_JAR% +cd %BIN_DIR% + diff --git a/usergw-service/src/main/assembly/scripts/run.sh b/usergw-service/src/main/assembly/scripts/run.sh new file mode 100644 index 0000000..caf978d --- /dev/null +++ b/usergw-service/src/main/assembly/scripts/run.sh @@ -0,0 +1,8 @@ +#!/bin/sh +##cnf +APP_PMS="-Xms256m -Xmx512m" +APP_JAR=`echo *-*-*.jar` +##run +cur=$(dirname $(readlink -f "$0")) && cd $cur/.. + +exec java -Dloader.path=config -Dfile.encoding=UTF-8 ${APP_PMS} -jar ${APP_JAR} diff --git a/usergw-service/src/test/java/resources/test-gateway.yaml b/usergw-service/src/main/resources/test-gateway.yaml similarity index 100% rename from usergw-service/src/test/java/resources/test-gateway.yaml rename to usergw-service/src/main/resources/test-gateway.yaml diff --git a/usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig.java b/usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig.java index ba0b099..1877ac6 100644 --- a/usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig.java +++ b/usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig.java @@ -18,7 +18,7 @@ import reactor.netty.http.client.HttpClientResponse; @SpringBootTest(classes= App.class, webEnvironment = WebEnvironment.RANDOM_PORT) @RunWith(SpringRunner.class) -@TestPropertySource(locations = "classpath:/resources/test.properties", properties = {"apollo.meta=", "app.id="}) +@TestPropertySource(locations = "classpath:/resources/test1.properties", properties = {"apollo.meta=", "app.id="}) public class TestHttp2DubboConfig { @LocalServerPort diff --git a/usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig2.java b/usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig2.java index 5c3e37c..967eaa0 100644 --- a/usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig2.java +++ b/usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig2.java @@ -13,10 +13,10 @@ import reactor.netty.http.client.HttpClient; import reactor.netty.http.client.HttpClient.ResponseReceiver; import reactor.netty.http.client.HttpClientResponse; -// TODO: 添加附加Dubbo Service for Test启动进程 + @SpringBootTest(classes = App.class, webEnvironment = WebEnvironment.RANDOM_PORT) @RunWith(SpringRunner.class) -@TestPropertySource(locations = { "application2.properties" }) +@TestPropertySource(locations = "classpath:/resources/test2.properties", properties = {"apollo.meta=", "app.id="}) public class TestHttp2DubboConfig2 { @LocalServerPort diff --git a/usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig3.java b/usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig3.java index 9e9335d..787d1a1 100644 --- a/usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig3.java +++ b/usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig3.java @@ -17,10 +17,10 @@ import reactor.netty.http.client.HttpClient; import reactor.netty.http.client.HttpClient.ResponseReceiver; import reactor.netty.http.client.HttpClientResponse; -// TODO: 添加附加Dubbo Service for Test启动进程 + @SpringBootTest(classes = App.class, webEnvironment = WebEnvironment.DEFINED_PORT) @RunWith(SpringRunner.class) -@TestPropertySource(locations = { "application3.properties" }) +@TestPropertySource(locations = "classpath:/resources/test3.properties", properties = {"apollo.meta=", "app.id="}) public class TestHttp2DubboConfig3 { @LocalServerPort diff --git a/usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig4.java b/usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig4.java index 37c79ac..9d2786e 100644 --- a/usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig4.java +++ b/usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig4.java @@ -16,7 +16,7 @@ import reactor.netty.http.client.HttpClientResponse; // TODO: 添加附加Dubbo Service for Test启动进程 @SpringBootTest(classes = App.class, webEnvironment = WebEnvironment.RANDOM_PORT) @RunWith(SpringRunner.class) -@TestPropertySource(locations = { "application4.properties" }) +@TestPropertySource(locations = "classpath:/resources/test4.properties", properties = {"apollo.meta=", "app.id="}) public class TestHttp2DubboConfig4 { @LocalServerPort diff --git a/usergw-service/src/test/java/resources/test.properties b/usergw-service/src/test/java/resources/test1.properties similarity index 100% rename from usergw-service/src/test/java/resources/test.properties rename to usergw-service/src/test/java/resources/test1.properties diff --git a/usergw-service/src/test/java/cn/ecpark/service/usergw/application2.properties b/usergw-service/src/test/java/resources/test2.properties similarity index 91% rename from usergw-service/src/test/java/cn/ecpark/service/usergw/application2.properties rename to usergw-service/src/test/java/resources/test2.properties index 592aa8c..7152322 100644 --- a/usergw-service/src/test/java/cn/ecpark/service/usergw/application2.properties +++ b/usergw-service/src/test/java/resources/test2.properties @@ -11,5 +11,5 @@ server.port=8888 # logging.level.org.springframework.cloud.gateway=debug logging.file=logs/log -yame.config=test-gateway2.yaml +yame.gateway.config=test-gateway2.yaml diff --git a/usergw-service/src/test/java/cn/ecpark/service/usergw/application3.properties b/usergw-service/src/test/java/resources/test3.properties similarity index 91% rename from usergw-service/src/test/java/cn/ecpark/service/usergw/application3.properties rename to usergw-service/src/test/java/resources/test3.properties index 1dcad2f..27ac3b7 100644 --- a/usergw-service/src/test/java/cn/ecpark/service/usergw/application3.properties +++ b/usergw-service/src/test/java/resources/test3.properties @@ -11,5 +11,5 @@ server.port=8888 # logging.level.org.springframework.cloud.gateway=debug logging.file=logs/log -yame.config=test-gateway3.yaml +yame.gateway.config=test-gateway3.yaml diff --git a/usergw-service/src/test/java/cn/ecpark/service/usergw/application4.properties b/usergw-service/src/test/java/resources/test4.properties similarity index 92% rename from usergw-service/src/test/java/cn/ecpark/service/usergw/application4.properties rename to usergw-service/src/test/java/resources/test4.properties index fa63143..de36ee3 100644 --- a/usergw-service/src/test/java/cn/ecpark/service/usergw/application4.properties +++ b/usergw-service/src/test/java/resources/test4.properties @@ -17,5 +17,5 @@ server.port=8888 # logging.level.org.springframework.cloud.gateway=debug logging.file=logs/log -yame.config=test-gateway4.yaml +yame.gateway.config=test-gateway4.yaml