Rename samples to smoke tests
Closes gh-17197
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package smoketest.devtools;
|
||||
|
||||
public final class Message {
|
||||
|
||||
/**
|
||||
* Sample message.
|
||||
*/
|
||||
public static String MESSAGE = "Message";
|
||||
|
||||
private Message() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package smoketest.devtools;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
@Controller
|
||||
public class MyController {
|
||||
|
||||
@PostConstruct
|
||||
public void slowRestart() throws InterruptedException {
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public ModelAndView get(HttpSession session) {
|
||||
Object sessionVar = session.getAttribute("var");
|
||||
if (sessionVar == null) {
|
||||
sessionVar = new Date();
|
||||
session.setAttribute("var", sessionVar);
|
||||
}
|
||||
ModelMap model = new ModelMap("message", Message.MESSAGE).addAttribute("sessionVar", sessionVar);
|
||||
return new ModelAndView("hello", model);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package smoketest.devtools;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SampleDevToolsApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SampleDevToolsApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# Enable remote support, for local development you don't need this line
|
||||
spring.devtools.remote.secret=secret
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
public file
|
||||
@@ -0,0 +1,9 @@
|
||||
h1 {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.content {
|
||||
font-family: sans-serif;
|
||||
border-top: 3px solid red;
|
||||
padding-top: 30px;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="https://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>Hello</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1 th:text="${message}">Header</h1>
|
||||
<div class="content">
|
||||
<h2 th:text="${sessionVar}">Session Var</h2>
|
||||
Lorem ipsum dolor sit amet,
|
||||
consectetur adipiscing elit. Cras ut fringilla augue, quis dictum
|
||||
turpis. Sed tincidunt mi vel euismod viverra. Nulla facilisi.
|
||||
Suspendisse mauris dolor, egestas ac leo at, porttitor ullamcorper
|
||||
leo. Suspendisse consequat, justo ut rutrum interdum, nibh massa
|
||||
semper dui, id sagittis tellus lectus at nibh. Etiam at scelerisque
|
||||
nisi. Quisque vel eros tempor, fermentum sapien sed, gravida neque.
|
||||
Fusce interdum sed dolor a semper. Morbi porta mauris a velit laoreet
|
||||
viverra. Praesent et tellus vehicula, sagittis mi quis, faucibus urna.
|
||||
Ut diam tortor, vehicula eget aliquam eget, elementum a odio. Fusce at
|
||||
nisl sapien. Suspendisse potenti.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package smoketest.devtools;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link SampleDevToolsApplication}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
class SampleDevToolsApplicationIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
||||
@Test
|
||||
void testStaticResource() {
|
||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/css/application.css", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("color: green;");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPublicResource() {
|
||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/public.txt", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("public file");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassResource() {
|
||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application.properties", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user