File tree 2 files changed +39
-0
lines changed 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2019 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ // [START functions_helloworld_get]
18
+ import java .io .IOException ;
19
+ import java .io .PrintWriter ;
20
+ import javax .servlet .http .HttpServletRequest ;
21
+ import javax .servlet .http .HttpServletResponse ;
22
+
23
+ public class HelloWorld {
24
+ // Simple function to return "Hello World"
25
+ public void helloGet (HttpServletRequest request , HttpServletResponse response )
26
+ throws IOException {
27
+ PrintWriter writer = response .getWriter ();
28
+ writer .write ("Hello World!" );
29
+ }
30
+ }
31
+
32
+ // [END functions_helloworld_get]
Original file line number Diff line number Diff line change @@ -69,6 +69,13 @@ public void afterTest() {
69
69
System .setOut (null );
70
70
}
71
71
72
+ @ Test
73
+ public void helloWorldTest () throws IOException {
74
+ new HelloWorld ().helloGet (request , response );
75
+
76
+ assertThat (responseOut .toString (), containsString ("Hello World!" ));
77
+ }
78
+
72
79
@ Test
73
80
public void logHelloWorldTest () throws IOException {
74
81
new LogHelloWorld ().logHelloWorld (request , response );
You can’t perform that action at this time.
0 commit comments