controller接口单元测试
diff --git a/src/main/java/com/supwisdom/dlpay/framework/util/TradeDict.java b/src/main/java/com/supwisdom/dlpay/framework/util/TradeDict.java
index 5596b24..65e525a 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/util/TradeDict.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/util/TradeDict.java
@@ -10,6 +10,7 @@
public static final String STATUS_NORMAL = "normal";
public static final String STATUS_CLOSED = "closed";
public static final String STATUS_LOCKED = "locked";
+ public static final String SUBJNO_SHOP = "locked";
/**
* 流水状态
diff --git a/src/main/kotlin/com/supwisdom/dlpay/DlpayApplication.kt b/src/main/kotlin/com/supwisdom/dlpay/DlpayApplication.kt
index a9cea45..0a4f46a 100644
--- a/src/main/kotlin/com/supwisdom/dlpay/DlpayApplication.kt
+++ b/src/main/kotlin/com/supwisdom/dlpay/DlpayApplication.kt
@@ -8,7 +8,6 @@
@ComponentScan("com.supwisdom.dlpay")
@SpringBootApplication
-@PropertySource("file:\${catalina.home}/conf/dlpay_config.properties")
class DlpayApplication
fun main(args: Array<String>) {
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index e69de29..c151216 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -0,0 +1,17 @@
+#######################################springboot配置 start#################################
+# 单库数据库配置
+spring.datasource.url=jdbc:oracle:thin:@172.28.201.101:47922:orcl
+spring.datasource.username=dlpay
+spring.datasource.password=kingstar
+spring.datasource.driver.class=oracle.jdbc.driver.OracleDriver
+spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
+spring.jpa.show-sql=true
+spring.datasource.hikari.connection-timeout=60000
+spring.datasource.hikari.maximum-pool-size=5
+spring.jpa.hibernate.ddl-auto=update
+# logging
+logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n
+logging.level.org.hibernate.SQL=debug
+#################### JSP PAGE ####################
+spring.mvc.view.prefix=/pages/
+spring.mvc.view.suffix=.jsp
\ No newline at end of file
diff --git a/src/test/kotlin/com/supwisdom/dlpay/DlpayApplicationTests.kt b/src/test/kotlin/com/supwisdom/dlpay/DlpayApplicationTests.kt
index 625cdbd..c8b875f 100644
--- a/src/test/kotlin/com/supwisdom/dlpay/DlpayApplicationTests.kt
+++ b/src/test/kotlin/com/supwisdom/dlpay/DlpayApplicationTests.kt
@@ -1,16 +1,11 @@
package com.supwisdom.dlpay
-import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringRunner
@RunWith(SpringRunner::class)
@SpringBootTest
-class DlpayApplicationTests {
-
- @Test
- fun contextLoads() {
- }
+abstract class DlpayApplicationTests{
}
diff --git a/src/test/kotlin/com/supwisdom/dlpay/ShopControllerTest.kt b/src/test/kotlin/com/supwisdom/dlpay/ShopControllerTest.kt
new file mode 100644
index 0000000..4ff1714
--- /dev/null
+++ b/src/test/kotlin/com/supwisdom/dlpay/ShopControllerTest.kt
@@ -0,0 +1,89 @@
+package com.supwisdom.dlpay
+
+import com.google.gson.Gson
+import com.supwisdom.dlpay.framework.domain.TShop
+import com.supwisdom.dlpay.shop.bean.ShopParam
+import org.junit.Assert
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.http.MediaType
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import org.springframework.test.web.servlet.MockMvc
+
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post
+import org.springframework.test.web.servlet.result.MockMvcResultHandlers.print
+import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
+
+/**
+ * Created by shuwei on 2019/4/15.
+ */
+@RunWith(SpringRunner::class)
+@SpringBootTest
+@AutoConfigureMockMvc
+class ShopControllerTest {
+ @Autowired
+ private lateinit var mvc: MockMvc
+
+ class RetBean {
+ var shopid: Int = 0
+ var retcode: Int = 0
+ lateinit var shop: TShop
+ }
+
+ @Test
+ fun open() {
+ val shopParam = ShopParam()
+ shopParam.uniqueId = ""//random req
+ shopParam.shopname = "测试名称"
+ val gson = Gson()
+ val ret = mvc.perform(post("/shop/open").content(gson.toJson(shopParam))
+ .contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk)
+ .andDo(print())
+ .andReturn()
+ val res = ret.response.contentAsString
+ Assert.assertNotNull(res)
+ val retBean = gson.fromJson(res, RetBean::class.java)
+ Assert.assertNotNull(retBean)
+ Assert.assertEquals(0, retBean.retcode)
+ Assert.assertNotNull(retBean.shopid)
+ Assert.assertNotEquals(0, retBean.shopid)
+ }
+
+ @Test
+ fun get() {
+ val shopParam = ShopParam()
+ shopParam.uniqueId = "testuniqueId"//测试用
+ shopParam.shopname = "测试名称:testuniqueId"
+ val gson = Gson()
+ val ret = mvc.perform(post("/shop/open").content(gson.toJson(shopParam))
+ .contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk)
+ .andDo(print())
+ .andReturn()
+ val resOpen = ret.response.contentAsString
+ Assert.assertNotNull(resOpen)
+ val retBeanOpen = gson.fromJson(resOpen, RetBean::class.java)
+ Assert.assertNotNull(retBeanOpen)
+ Assert.assertNotNull(retBeanOpen.shopid)
+ shopParam.shopid = retBeanOpen.shopid
+
+ val retGet = mvc.perform(get("/shop/get").content(gson.toJson(shopParam))
+ .contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk)
+ .andDo(print())
+ .andReturn()
+ val res = retGet.response.contentAsString
+ Assert.assertNotNull(res)
+ val retBean = gson.fromJson(res, RetBean::class.java)
+ Assert.assertNotNull(retBean)
+ Assert.assertEquals(0, retBean.retcode)
+ Assert.assertNotNull(retBean.shop)
+ Assert.assertEquals(retBeanOpen.shopid, retBean.shop.shopid)
+ }
+}
\ No newline at end of file