Move intro inside main src (#1037)
* Initial commit * Initial commit * deleted old files * classNotFoundException-contextLoaderListener * Spring Boot Application * delete ClassNotFoundException * Add intro package inside main source tree
This commit is contained in:
parent
673faede4c
commit
e4bc0a44ce
13
spring-boot/src/main/java/com/baeldung/intro/App.java
Normal file
13
spring-boot/src/main/java/com/baeldung/intro/App.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package com.baeldung.intro;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class App
|
||||||
|
{
|
||||||
|
public static void main( String[] args )
|
||||||
|
{
|
||||||
|
SpringApplication.run(App.class, args);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.baeldung.intro.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class HomeController {
|
||||||
|
|
||||||
|
@RequestMapping("/")
|
||||||
|
public String root(){
|
||||||
|
return "Index Page";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/local")
|
||||||
|
public String local(){
|
||||||
|
return "/local";
|
||||||
|
}
|
||||||
|
}
|
8
spring-boot/src/main/resources/public/error/404.html
Normal file
8
spring-boot/src/main/resources/public/error/404.html
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>RESOURCE NOT FOUND</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>404 RESOURCE NOT FOUND</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
39
spring-boot/src/test/java/com/baeldung/intro/AppTest.java
Normal file
39
spring-boot/src/test/java/com/baeldung/intro/AppTest.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package com.baeldung.intro;
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
@AutoConfigureMockMvc
|
||||||
|
public class AppTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MockMvc mvc;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getIndex() throws Exception {
|
||||||
|
mvc.perform(MockMvcRequestBuilders.get("/").accept(MediaType.APPLICATION_JSON))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(content().string(equalTo("Index Page")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getLocal() throws Exception {
|
||||||
|
mvc.perform(MockMvcRequestBuilders.get("/local").accept(MediaType.APPLICATION_JSON))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(content().string(equalTo("/local")));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user