|
|
@@ -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); |
|
|
|
} |
|
|
|
} |