Bläddra i källkod

Introduce test for CI

 - See ./test/run.sh
 - See https://drone.io/github.com/springframework-meta/gs-rest-service
Chris Beams 13 år sedan
förälder
incheckning
3c52c4297f
6 ändrade filer med 40 tillägg och 39 borttagningar
  1. 3
    1
      README.md
  2. 8
    23
      complete/pom.xml
  3. 6
    5
      complete/src/main/java/hello/HelloWorldController.java
  4. 2
    10
      initial/pom.xml
  5. 1
    0
      test/expected.json
  6. 20
    0
      test/run.sh

+ 3
- 1
README.md Visa fil

@@ -1,5 +1,7 @@
1 1
 # Getting Started Building a RESTful Web Service
2 2
 
3
+[![Build Status](https://drone.io/github.com/springframework-meta/gs-rest-service/status.png)](https://drone.io/github.com/springframework-meta/gs-rest-service/latest)
4
+
3 5
 Introduction
4 6
 ------------
5 7
 
@@ -201,7 +203,7 @@ public class HelloWorldController {
201 203
 
202 204
     @RequestMapping(method=RequestMethod.GET)
203 205
     public @ResponseBody Greeting sayHello(
204
-            @RequestParam(value="name", required=false, defaultValue="Stranger") String name) {
206
+            @RequestParam(value="name", required=false, defaultValue="World") String name) {
205 207
         return new Greeting(counter.incrementAndGet(), String.format(template, name));
206 208
     }
207 209
 }

+ 8
- 23
complete/pom.xml Visa fil

@@ -5,7 +5,7 @@
5 5
 
6 6
 	<groupId>org.springframework</groupId>
7 7
 	<artifactId>gs-rest-service-complete</artifactId>
8
-	<version>0.0.1-SNAPSHOT</version>
8
+	<version>1.0-SNAPSHOT</version>
9 9
 
10 10
 	<parent>
11 11
 		<groupId>org.springframework.bootstrap</groupId>
@@ -13,6 +13,10 @@
13 13
 		<version>0.5.0.BUILD-SNAPSHOT</version>
14 14
 	</parent>
15 15
 
16
+	<properties>
17
+		<start-class>hello.HelloWorldConfiguration</start-class>
18
+	</properties>
19
+
16 20
 	<dependencies>
17 21
 		<dependency>
18 22
 			<groupId>org.springframework.bootstrap</groupId>
@@ -24,10 +28,6 @@
24 28
 		</dependency>
25 29
 	</dependencies>
26 30
 
27
-	<properties>
28
-		<start-class>hello.HelloWorldConfiguration</start-class>
29
-	</properties>
30
-
31 31
 	<build>
32 32
 		<plugins>
33 33
 			<plugin>
@@ -40,30 +40,15 @@
40 40
 	<repositories>
41 41
 		<repository>
42 42
 			<id>spring-snapshots</id>
43
-			<name>Spring Snapshots</name>
44 43
 			<url>http://repo.springsource.org/snapshot</url>
45
-			<snapshots>
46
-				<enabled>true</enabled>
47
-			</snapshots>
48
-		</repository>
49
-		<repository>
50
-			<id>spring-milestones</id>
51
-			<name>Spring Milestones</name>
52
-			<url>http://repo.springsource.org/milestone</url>
53
-			<snapshots>
54
-				<enabled>false</enabled>
55
-			</snapshots>
44
+			<snapshots><enabled>true</enabled></snapshots>
56 45
 		</repository>
57 46
 	</repositories>
58 47
 	<pluginRepositories>
59 48
 		<pluginRepository>
60 49
 			<id>spring-snapshots</id>
61
-			<name>Spring Snapshots</name>
62 50
 			<url>http://repo.springsource.org/snapshot</url>
63
-			<snapshots>
64
-				<enabled>true</enabled>
65
-			</snapshots>
51
+			<snapshots><enabled>true</enabled></snapshots>
66 52
 		</pluginRepository>
67 53
 	</pluginRepositories>
68
-
69
-</project>
54
+</project>

+ 6
- 5
complete/src/main/java/hello/HelloWorldController.java Visa fil

@@ -15,9 +15,10 @@ public class HelloWorldController {
15 15
 	private static final String template = "Hello, %s!";
16 16
 	private final AtomicLong counter = new AtomicLong();
17 17
 	
18
-	@RequestMapping(method=RequestMethod.GET)
19
-	public @ResponseBody Greeting sayHello(@RequestParam(value="name", required=false, defaultValue="Stranger") String name) {
20
-		return new Greeting(counter.incrementAndGet(), String.format(template, name));
21
-	}
22
-	
18
+    @RequestMapping(method=RequestMethod.GET)
19
+    public @ResponseBody Greeting sayHello(
20
+            @RequestParam(value="name", required=false, defaultValue="World") String name) {
21
+        return new Greeting(counter.incrementAndGet(), String.format(template, name));
22
+    }
23
+
23 24
 }

+ 2
- 10
initial/pom.xml Visa fil

@@ -24,26 +24,18 @@
24 24
 		</dependency>
25 25
 	</dependencies>
26 26
 
27
-	<!-- TODO: remove once bootstrap goes GA -->
28 27
 	<repositories>
29 28
 		<repository>
30 29
 			<id>spring-snapshots</id>
31
-			<name>Spring Snapshots</name>
32 30
 			<url>http://repo.springsource.org/snapshot</url>
33
-			<snapshots>
34
-				<enabled>true</enabled>
35
-			</snapshots>
31
+			<snapshots><enabled>true</enabled></snapshots>
36 32
 		</repository>
37 33
 	</repositories>
38 34
 	<pluginRepositories>
39 35
 		<pluginRepository>
40 36
 			<id>spring-snapshots</id>
41
-			<name>Spring Snapshots</name>
42 37
 			<url>http://repo.springsource.org/snapshot</url>
43
-			<snapshots>
44
-				<enabled>true</enabled>
45
-			</snapshots>
38
+			<snapshots><enabled>true</enabled></snapshots>
46 39
 		</pluginRepository>
47 40
 	</pluginRepositories>
48
-
49 41
 </project>

+ 1
- 0
test/expected.json Visa fil

@@ -0,0 +1 @@
1
+{"id":1,"content":"Hello, World!"}

+ 20
- 0
test/run.sh Visa fil

@@ -0,0 +1,20 @@
1
+cd $(dirname $0)
2
+cd ../complete
3
+mvn package
4
+java -jar target/gs-rest-service-complete-1.0-SNAPSHOT.jar &
5
+PID=$!
6
+sleep 3
7
+curl -s http://localhost:8080/hello-world > target/actual.json
8
+kill -9 $PID
9
+
10
+if diff -w ../test/expected.json target/actual.json
11
+	then
12
+		echo SUCCESS
13
+		let ret=0
14
+	else
15
+		echo FAIL
16
+		let ret=255
17
+fi
18
+
19
+rm -rf target
20
+exit $ret