Skip to content

Commit 84c108c

Browse files
author
Anand Rajneesh
committed
[#18] Added HelloWorld example
1 parent 9747776 commit 84c108c

File tree

3 files changed

+63
-1
lines changed

3 files changed

+63
-1
lines changed

pom.xml

+11-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<groupId>org.gluecoders.guides</groupId>
88
<artifactId>springboot-guide</artifactId>
99
<version>1.0-SNAPSHOT</version>
10-
10+
<packaging>jar</packaging>
1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1313
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
@@ -23,6 +23,16 @@
2323
<version>${spring.version}</version>
2424
<type>pom</type>
2525
</dependency>
26+
<dependency>
27+
<groupId>org.springframework.boot</groupId>
28+
<artifactId>spring-boot-starter-web</artifactId>
29+
<version>${spring.version}</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.springframework.boot</groupId>
33+
<artifactId>spring-boot-starter-test</artifactId>
34+
<version>${spring.version}</version>
35+
</dependency>
2636
</dependencies>
2737

2838
<build>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.gluecoders.library;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.web.bind.annotation.GetMapping;
6+
import org.springframework.web.bind.annotation.RequestMapping;
7+
import org.springframework.web.bind.annotation.RestController;
8+
9+
/**
10+
* Created by Anand_Rajneesh on 6/10/2017.
11+
*/
12+
@SpringBootApplication
13+
@RestController
14+
public class Application {
15+
16+
public static void main(String[] args) {
17+
SpringApplication.run(Application.class, args);
18+
}
19+
20+
@RequestMapping("/")
21+
@GetMapping
22+
public String hello(){
23+
return "Hi ! Welcome to Spring Boot Guide";
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.gluecoders.library;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
7+
import org.springframework.test.context.junit4.SpringRunner;
8+
import org.springframework.test.web.servlet.MockMvc;
9+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
10+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
11+
/**
12+
* Created by Anand_Rajneesh on 6/10/2017.
13+
*/
14+
@RunWith(SpringRunner.class)
15+
@WebMvcTest(Application.class)
16+
public class ApplicationTest {
17+
18+
@Autowired
19+
private MockMvc mvc;
20+
21+
@Test
22+
public void testHello() throws Exception {
23+
mvc.perform(get("/"))
24+
.andExpect(status().isOk())
25+
.andExpect(content().string("Hi ! Welcome to Spring Boot Guide"));
26+
}
27+
}

0 commit comments

Comments
 (0)