1517874642 пре 4 година
родитељ
комит
408dfd3319
2 измењених фајлова са 22 додато и 37 уклоњено
  1. +15
    -9
      user-service/pom.xml
  2. +7
    -28
      user-service/src/test/java/test/ControllerTest.java

+ 15
- 9
user-service/pom.xml Прегледај датотеку

@@ -66,16 +66,22 @@
<artifactId>mybatis-typehandlers-jsr310</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-web</artifactId>-->
<!-- <version>2.1.3.RELEASE</version>-->
<!-- </dependency>-->


<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.3.1.RELEASE</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

</dependencies>
<!-- <build>-->


+ 7
- 28
user-service/src/test/java/test/ControllerTest.java Прегледај датотеку

@@ -2,48 +2,27 @@ package test;

import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
import com.hp.user.client.entity.AreaVO;
import com.hp.user.client.service.AreaService;
import com.hp.user.service.controller.AreaController;

import org.junit.Before;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.junit.Test;

import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.List;

@MapperScan("com.hp.user.service.dao") //扫描的mapper
@SpringBootApplication
@NacosPropertySource(dataId = "userdatasource", autoRefreshed = true)

//@RunWith(SpringRunner.class)
//@SpringBootTest
@RunWith(SpringRunner.class)
@SpringBootTest
public class ControllerTest {
@Resource
private AreaService areaService;

@Before
public void init() {
try {
String[] args = new String[]{};
SpringApplication.run(ControllerTest.class, args);

}catch(Exception e) {
e.printStackTrace();
}

}
private AreaController areaController;


@Test
public void testQueryAllArea() {
List<AreaVO> areas = areaService.getAllArea();
// List<AreaVO> users = areaController.queryAllArea();
areas.forEach(System.out::println);
List<AreaVO> users = areaController.queryAllArea();
users.forEach(System.out::println);
}
}

Loading…
Откажи
Сачувај