Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
67c81100
Commit
67c81100
authored
Apr 09, 2021
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.4.x'
Closes gh-25991
parents
734abc81
2b9ba962
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
48 additions
and
30 deletions
+48
-30
build.gradle
...t-integration-tests/spring-boot-server-tests/build.gradle
+0
-2
ExampleAutoConfiguration.java
...rc/test/java/com/autoconfig/ExampleAutoConfiguration.java
+28
-11
ResourceHandlingApplication.java
...rc/test/java/com/example/ResourceHandlingApplication.java
+10
-2
AbstractApplicationLauncher.java
...rk/boot/context/embedded/AbstractApplicationLauncher.java
+1
-0
ApplicationBuilder.java
...ngframework/boot/context/embedded/ApplicationBuilder.java
+1
-3
EmbeddedServletContainerJarPackagingIntegrationTests.java
...EmbeddedServletContainerJarPackagingIntegrationTests.java
+2
-2
EmbeddedServletContainerWarPackagingIntegrationTests.java
...EmbeddedServletContainerWarPackagingIntegrationTests.java
+4
-3
application.yml
...ring-boot-server-tests/src/test/resources/application.yml
+0
-1
pom-template.xml
...ing-boot-server-tests/src/test/resources/pom-template.xml
+2
-6
No files found.
spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/build.gradle
View file @
67c81100
...
...
@@ -11,7 +11,6 @@ configurations {
dependencies
{
testImplementation
(
project
(
":spring-boot-project:spring-boot-starters:spring-boot-starter-test"
))
testImplementation
(
project
(
":spring-boot-project:spring-boot-actuator-autoconfigure"
))
testImplementation
(
project
(
":spring-boot-project:spring-boot-tools:spring-boot-test-support"
))
testImplementation
(
"com.samskivert:jmustache"
)
testImplementation
(
"jakarta.servlet:jakarta.servlet-api"
)
...
...
@@ -26,7 +25,6 @@ dependencies {
testRepository
(
project
(
path:
":spring-boot-project:spring-boot-dependencies"
,
configuration:
"mavenRepository"
))
testRepository
(
project
(
path:
":spring-boot-project:spring-boot-tools:spring-boot-maven-plugin"
,
configuration:
"mavenRepository"
))
testRepository
(
project
(
path:
":spring-boot-project:spring-boot-starters:spring-boot-starter"
,
configuration:
"mavenRepository"
))
testRepository
(
project
(
path:
":spring-boot-project:spring-boot-starters:spring-boot-starter-actuator"
,
configuration:
"mavenRepository"
))
testRepository
(
project
(
path:
":spring-boot-project:spring-boot-starters:spring-boot-starter-jetty"
,
configuration:
"mavenRepository"
))
testRepository
(
project
(
path:
":spring-boot-project:spring-boot-starters:spring-boot-starter-json"
,
configuration:
"mavenRepository"
))
testRepository
(
project
(
path:
":spring-boot-project:spring-boot-starters:spring-boot-starter-parent"
,
configuration:
"mavenRepository"
))
...
...
spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/com/autoconfig/ExampleAutoConfiguration.java
View file @
67c81100
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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.
...
...
@@ -16,27 +16,44 @@
package
com
.
autoconfig
;
import
org.springframework.boot.actuate.endpoint.annotation.Endpoint
;
import
org.springframework.boot.actuate.endpoint.annotation.ReadOperation
;
import
java.io.IOException
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWarDeployment
;
import
org.springframework.boot.web.servlet.ServletRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.MediaType
;
@ConditionalOnWarDeployment
@Configuration
public
class
ExampleAutoConfiguration
{
@Bean
public
TestEndpoint
testEndpoint
()
{
return
new
TestEndpoint
();
@ConditionalOnWarDeployment
public
ServletRegistrationBean
<
TestServlet
>
onWarTestServlet
()
{
ServletRegistrationBean
<
TestServlet
>
registration
=
new
ServletRegistrationBean
<>(
new
TestServlet
());
registration
.
addUrlMappings
(
"/conditionalOnWar"
);
return
registration
;
}
@Bean
public
ServletRegistrationBean
<
TestServlet
>
testServlet
()
{
ServletRegistrationBean
<
TestServlet
>
registration
=
new
ServletRegistrationBean
<>(
new
TestServlet
());
registration
.
addUrlMappings
(
"/always"
);
return
registration
;
}
@Endpoint
(
id
=
"war"
)
static
class
TestEndpoint
{
static
class
TestServlet
extends
HttpServlet
{
@ReadOperation
String
hello
()
{
return
"{\"hello\":\"world\"}"
;
@Override
protected
void
doGet
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
resp
.
setContentType
(
MediaType
.
APPLICATION_JSON_VALUE
);
resp
.
getWriter
().
println
(
"{\"hello\":\"world\"}"
);
resp
.
flushBuffer
();
}
}
...
...
spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/com/example/ResourceHandlingApplication.java
View file @
67c81100
...
...
@@ -56,8 +56,16 @@ public class ResourceHandlingApplication {
}
public
static
void
main
(
String
[]
args
)
{
new
SpringApplicationBuilder
(
ResourceHandlingApplication
.
class
).
properties
(
"server.port:0"
)
.
listeners
(
new
WebServerPortFileWriter
(
args
[
0
])).
run
(
args
);
try
{
Class
.
forName
(
"org.springframework.web.servlet.DispatcherServlet"
);
System
.
err
.
println
(
"Spring MVC must not be present, otherwise its static resource handling "
+
"will be used rather than the embedded containers'"
);
System
.
exit
(
1
);
}
catch
(
Throwable
ex
)
{
new
SpringApplicationBuilder
(
ResourceHandlingApplication
.
class
).
properties
(
"server.port:0"
)
.
listeners
(
new
WebServerPortFileWriter
(
args
[
0
])).
run
(
args
);
}
}
private
static
final
class
GetResourcePathsServlet
extends
HttpServlet
{
...
...
spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/AbstractApplicationLauncher.java
View file @
67c81100
...
...
@@ -91,6 +91,7 @@ abstract class AbstractApplicationLauncher implements BeforeEachCallback {
List
<
String
>
arguments
=
new
ArrayList
<>();
arguments
.
add
(
System
.
getProperty
(
"java.home"
)
+
"/bin/java"
);
arguments
.
addAll
(
getArguments
(
archive
,
serverPortFile
));
arguments
.
add
(
"--server.servlet.register-default-servlet=true"
);
ProcessBuilder
processBuilder
=
new
ProcessBuilder
(
StringUtils
.
toStringArray
(
arguments
));
if
(
workingDirectory
!=
null
)
{
processBuilder
.
directory
(
workingDirectory
);
...
...
spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/ApplicationBuilder.java
View file @
67c81100
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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.
...
...
@@ -161,8 +161,6 @@ class ApplicationBuilder {
metaInf
.
mkdirs
();
FileCopyUtils
.
copy
(
new
File
(
"src/test/resources/META-INF/spring.factories"
),
new
File
(
metaInf
,
"spring.factories"
));
FileCopyUtils
.
copy
(
new
File
(
"src/test/resources/application.yml"
),
new
File
(
srcMainResources
,
"application.yml"
));
}
private
void
packageApplication
(
File
appDirectory
,
File
settingsXml
)
throws
MavenInvocationException
{
...
...
spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/EmbeddedServletContainerJarPackagingIntegrationTests.java
View file @
67c81100
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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.
...
...
@@ -81,7 +81,7 @@ class EmbeddedServletContainerJarPackagingIntegrationTests {
@TestTemplate
void
conditionalOnWarDeploymentBeanIsNotAvailableForEmbeddedServer
(
RestTemplate
rest
)
{
ResponseEntity
<
String
>
entity
=
rest
.
getForEntity
(
"/
actuator/
war"
,
String
.
class
);
ResponseEntity
<
String
>
entity
=
rest
.
getForEntity
(
"/war"
,
String
.
class
);
assertThat
(
entity
.
getStatusCode
()).
isEqualTo
(
HttpStatus
.
NOT_FOUND
);
}
...
...
spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/EmbeddedServletContainerWarPackagingIntegrationTests.java
View file @
67c81100
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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.
...
...
@@ -104,8 +104,9 @@ class EmbeddedServletContainerWarPackagingIntegrationTests {
@TestTemplate
void
conditionalOnWarDeploymentBeanIsNotAvailableForEmbeddedServer
(
RestTemplate
rest
)
{
ResponseEntity
<
String
>
entity
=
rest
.
getForEntity
(
"/actuator/war"
,
String
.
class
);
assertThat
(
entity
.
getStatusCode
()).
isEqualTo
(
HttpStatus
.
NOT_FOUND
);
assertThat
(
rest
.
getForEntity
(
"/always"
,
String
.
class
).
getStatusCode
()).
isEqualTo
(
HttpStatus
.
OK
);
assertThat
(
rest
.
getForEntity
(
"/conditionalOnWar"
,
String
.
class
).
getStatusCode
())
.
isEqualTo
(
HttpStatus
.
NOT_FOUND
);
}
private
List
<
String
>
readLines
(
String
input
)
{
...
...
spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/resources/application.yml
deleted
100644 → 0
View file @
734abc81
management.endpoints.web.exposure.include
:
'
*'
spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/resources/pom-template.xml
View file @
67c81100
...
...
@@ -18,11 +18,7 @@
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-json
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
<artifactId>
spring-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
...
...
@@ -30,7 +26,7 @@
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-web
mvc
</artifactId>
<artifactId>
spring-web
</artifactId>
</dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment