diff --git a/Chapter9-2-1/consumer/pom.xml b/Chapter9-2-1/consumer/pom.xml index 3d6fea0..7b35a9d 100644 --- a/Chapter9-2-1/consumer/pom.xml +++ b/Chapter9-2-1/consumer/pom.xml @@ -29,11 +29,6 @@ spring-boot-starter - - org.springframework.boot - spring-boot-starter-web - - org.springframework.boot spring-boot-starter-test diff --git a/Chapter9-2-1/consumer/src/main/java/com/didispace/web/ComputeController.java b/Chapter9-2-1/consumer/src/main/java/com/didispace/web/ComputeController.java deleted file mode 100644 index 3d8f5ca..0000000 --- a/Chapter9-2-1/consumer/src/main/java/com/didispace/web/ComputeController.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.didispace.web; - -import com.didispace.service.ComputeService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * Created by zhaiyc on 2016/7/14. - */ -@RestController -public class ComputeController { - - @Autowired - private ComputeService computeService; - - @RequestMapping(value = "/add", method = RequestMethod.GET) - public String add(@RequestParam Integer a, @RequestParam Integer b) { - return String.valueOf(a + b); - } - -} diff --git a/Chapter9-2-1/consumer/src/test/java/com/didispace/ApplicationTests.java b/Chapter9-2-1/consumer/src/test/java/com/didispace/ApplicationTests.java index 244658f..7b9c59e 100644 --- a/Chapter9-2-1/consumer/src/test/java/com/didispace/ApplicationTests.java +++ b/Chapter9-2-1/consumer/src/test/java/com/didispace/ApplicationTests.java @@ -1,24 +1,24 @@ package com.didispace; -import org.junit.Before; +import com.didispace.service.ComputeService; +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.SpringApplicationConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.web.WebAppConfiguration; @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = Application.class) -@WebAppConfiguration public class ApplicationTests { - @Before - public void setUp() throws Exception { - } + @Autowired + ComputeService computeService; @Test - public void getHello() throws Exception { + public void testAdd() throws Exception { + Assert.assertEquals("compute-service:add", new Integer(3), computeService.add(1, 2)); } }