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
cb7c3774
Commit
cb7c3774
authored
May 24, 2021
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.4.x'
Closes gh-26646
parents
363b5087
94269175
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
42 additions
and
334 deletions
+42
-334
build.gradle
...-boot-project/spring-boot-test-autoconfigure/build.gradle
+2
-1
ImportsContextCustomizerFactoryWithAutoConfigurationTests.java
...tsContextCustomizerFactoryWithAutoConfigurationTests.java
+11
-11
WebMvcTestPrintDefaultIntegrationTests.java
...rvlet/mockmvc/WebMvcTestPrintDefaultIntegrationTests.java
+10
-10
build.gradle
...t/spring-boot-tools/spring-boot-test-support/build.gradle
+1
-0
ModifiedClassPathExtension.java
...oot/testsupport/classpath/ModifiedClassPathExtension.java
+18
-13
Launcher.java
...ngframework/boot/testsupport/junit/platform/Launcher.java
+0
-52
LauncherDiscoveryRequest.java
.../testsupport/junit/platform/LauncherDiscoveryRequest.java
+0
-34
LauncherDiscoveryRequestBuilder.java
...pport/junit/platform/LauncherDiscoveryRequestBuilder.java
+0
-54
ReflectiveWrapper.java
...rk/boot/testsupport/junit/platform/ReflectiveWrapper.java
+0
-50
SummaryGeneratingListener.java
...testsupport/junit/platform/SummaryGeneratingListener.java
+0
-38
TestExecutionSummary.java
...boot/testsupport/junit/platform/TestExecutionSummary.java
+0
-50
package-info.java
...amework/boot/testsupport/junit/platform/package-info.java
+0
-21
No files found.
spring-boot-project/spring-boot-test-autoconfigure/build.gradle
View file @
cb7c3774
...
@@ -72,8 +72,9 @@ dependencies {
...
@@ -72,8 +72,9 @@ dependencies {
testImplementation
(
"org.hibernate.validator:hibernate-validator"
)
testImplementation
(
"org.hibernate.validator:hibernate-validator"
)
testImplementation
(
"org.hsqldb:hsqldb"
)
testImplementation
(
"org.hsqldb:hsqldb"
)
testImplementation
(
"org.jooq:jooq"
)
testImplementation
(
"org.jooq:jooq"
)
testImplementation
(
"org.junit.platform:junit-platform-engine"
)
testImplementation
(
"org.junit.jupiter:junit-jupiter"
)
testImplementation
(
"org.junit.jupiter:junit-jupiter"
)
testImplementation
(
"org.junit.platform:junit-platform-engine"
)
testImplementation
(
"org.junit.platform:junit-platform-launcher"
)
testImplementation
(
"org.mockito:mockito-core"
)
testImplementation
(
"org.mockito:mockito-core"
)
testImplementation
(
"org.mockito:mockito-junit-jupiter"
)
testImplementation
(
"org.mockito:mockito-junit-jupiter"
)
testImplementation
(
"org.skyscreamer:jsonassert"
)
testImplementation
(
"org.skyscreamer:jsonassert"
)
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/cache/ImportsContextCustomizerFactoryWithAutoConfigurationTests.java
View file @
cb7c3774
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
21
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -21,6 +21,10 @@ import java.lang.annotation.RetentionPolicy;
...
@@ -21,6 +21,10 @@ import java.lang.annotation.RetentionPolicy;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.junit.platform.engine.discovery.DiscoverySelectors
;
import
org.junit.platform.engine.discovery.DiscoverySelectors
;
import
org.junit.platform.launcher.Launcher
;
import
org.junit.platform.launcher.LauncherDiscoveryRequest
;
import
org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder
;
import
org.junit.platform.launcher.core.LauncherFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.AutoConfigurationPackage
;
import
org.springframework.boot.autoconfigure.AutoConfigurationPackage
;
...
@@ -28,9 +32,6 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
...
@@ -28,9 +32,6 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import
org.springframework.boot.autoconfigure.domain.EntityScan
;
import
org.springframework.boot.autoconfigure.domain.EntityScan
;
import
org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
;
import
org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
;
import
org.springframework.boot.test.autoconfigure.orm.jpa.ExampleEntity
;
import
org.springframework.boot.test.autoconfigure.orm.jpa.ExampleEntity
;
import
org.springframework.boot.testsupport.junit.platform.Launcher
;
import
org.springframework.boot.testsupport.junit.platform.LauncherDiscoveryRequest
;
import
org.springframework.boot.testsupport.junit.platform.LauncherDiscoveryRequestBuilder
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.ContextConfiguration
;
...
@@ -49,7 +50,7 @@ class ImportsContextCustomizerFactoryWithAutoConfigurationTests {
...
@@ -49,7 +50,7 @@ class ImportsContextCustomizerFactoryWithAutoConfigurationTests {
static
ApplicationContext
contextFromTest
;
static
ApplicationContext
contextFromTest
;
@Test
@Test
void
testClassesThatHaveSameAnnotationsShareAContext
()
throws
Throwable
{
void
testClassesThatHaveSameAnnotationsShareAContext
()
{
executeTests
(
DataJpaTest1
.
class
);
executeTests
(
DataJpaTest1
.
class
);
ApplicationContext
test1Context
=
contextFromTest
;
ApplicationContext
test1Context
=
contextFromTest
;
executeTests
(
DataJpaTest3
.
class
);
executeTests
(
DataJpaTest3
.
class
);
...
@@ -58,7 +59,7 @@ class ImportsContextCustomizerFactoryWithAutoConfigurationTests {
...
@@ -58,7 +59,7 @@ class ImportsContextCustomizerFactoryWithAutoConfigurationTests {
}
}
@Test
@Test
void
testClassesThatOnlyHaveDifferingUnrelatedAnnotationsShareAContext
()
throws
Throwable
{
void
testClassesThatOnlyHaveDifferingUnrelatedAnnotationsShareAContext
()
{
executeTests
(
DataJpaTest1
.
class
);
executeTests
(
DataJpaTest1
.
class
);
ApplicationContext
test1Context
=
contextFromTest
;
ApplicationContext
test1Context
=
contextFromTest
;
executeTests
(
DataJpaTest2
.
class
);
executeTests
(
DataJpaTest2
.
class
);
...
@@ -67,7 +68,7 @@ class ImportsContextCustomizerFactoryWithAutoConfigurationTests {
...
@@ -67,7 +68,7 @@ class ImportsContextCustomizerFactoryWithAutoConfigurationTests {
}
}
@Test
@Test
void
testClassesThatOnlyHaveDifferingPropertyMappedAnnotationAttributesDoNotShareAContext
()
throws
Throwable
{
void
testClassesThatOnlyHaveDifferingPropertyMappedAnnotationAttributesDoNotShareAContext
()
{
executeTests
(
DataJpaTest1
.
class
);
executeTests
(
DataJpaTest1
.
class
);
ApplicationContext
test1Context
=
contextFromTest
;
ApplicationContext
test1Context
=
contextFromTest
;
executeTests
(
DataJpaTest4
.
class
);
executeTests
(
DataJpaTest4
.
class
);
...
@@ -75,11 +76,10 @@ class ImportsContextCustomizerFactoryWithAutoConfigurationTests {
...
@@ -75,11 +76,10 @@ class ImportsContextCustomizerFactoryWithAutoConfigurationTests {
assertThat
(
test1Context
).
isNotSameAs
(
test2Context
);
assertThat
(
test1Context
).
isNotSameAs
(
test2Context
);
}
}
private
void
executeTests
(
Class
<?>
testClass
)
throws
Throwable
{
private
void
executeTests
(
Class
<?>
testClass
)
{
ClassLoader
classLoader
=
testClass
.
getClassLoader
();
LauncherDiscoveryRequest
request
=
LauncherDiscoveryRequestBuilder
.
request
()
LauncherDiscoveryRequest
request
=
new
LauncherDiscoveryRequestBuilder
(
classLoader
)
.
selectors
(
DiscoverySelectors
.
selectClass
(
testClass
)).
build
();
.
selectors
(
DiscoverySelectors
.
selectClass
(
testClass
)).
build
();
Launcher
launcher
=
new
Launcher
(
testClass
.
getClassLoader
()
);
Launcher
launcher
=
LauncherFactory
.
create
(
);
launcher
.
execute
(
request
);
launcher
.
execute
(
request
);
}
}
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintDefaultIntegrationTests.java
View file @
cb7c3774
/*
/*
* 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");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -21,15 +21,16 @@ import org.junit.jupiter.api.Test;
...
@@ -21,15 +21,16 @@ import org.junit.jupiter.api.Test;
import
org.junit.jupiter.api.TestMethodOrder
;
import
org.junit.jupiter.api.TestMethodOrder
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.junit.platform.engine.discovery.DiscoverySelectors
;
import
org.junit.platform.engine.discovery.DiscoverySelectors
;
import
org.junit.platform.launcher.Launcher
;
import
org.junit.platform.launcher.LauncherDiscoveryRequest
;
import
org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder
;
import
org.junit.platform.launcher.core.LauncherFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
;
import
org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
;
import
org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
;
import
org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
;
import
org.springframework.boot.test.system.CapturedOutput
;
import
org.springframework.boot.test.system.CapturedOutput
;
import
org.springframework.boot.test.system.OutputCaptureExtension
;
import
org.springframework.boot.test.system.OutputCaptureExtension
;
import
org.springframework.boot.testsupport.junit.platform.Launcher
;
import
org.springframework.boot.testsupport.junit.platform.LauncherDiscoveryRequest
;
import
org.springframework.boot.testsupport.junit.platform.LauncherDiscoveryRequestBuilder
;
import
org.springframework.security.test.context.support.WithMockUser
;
import
org.springframework.security.test.context.support.WithMockUser
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.MockMvc
;
...
@@ -49,22 +50,21 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
...
@@ -49,22 +50,21 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
class
WebMvcTestPrintDefaultIntegrationTests
{
class
WebMvcTestPrintDefaultIntegrationTests
{
@Test
@Test
void
shouldNotPrint
(
CapturedOutput
output
)
throws
Throwable
{
void
shouldNotPrint
(
CapturedOutput
output
)
{
executeTests
(
ShouldNotPrint
.
class
);
executeTests
(
ShouldNotPrint
.
class
);
assertThat
(
output
).
doesNotContain
(
"HTTP Method"
);
assertThat
(
output
).
doesNotContain
(
"HTTP Method"
);
}
}
@Test
@Test
void
shouldPrint
(
CapturedOutput
output
)
throws
Throwable
{
void
shouldPrint
(
CapturedOutput
output
)
{
executeTests
(
ShouldPrint
.
class
);
executeTests
(
ShouldPrint
.
class
);
assertThat
(
output
).
containsOnlyOnce
(
"HTTP Method"
);
assertThat
(
output
).
containsOnlyOnce
(
"HTTP Method"
);
}
}
private
void
executeTests
(
Class
<?>
testClass
)
throws
Throwable
{
private
void
executeTests
(
Class
<?>
testClass
)
{
ClassLoader
classLoader
=
testClass
.
getClassLoader
();
LauncherDiscoveryRequest
request
=
LauncherDiscoveryRequestBuilder
.
request
()
LauncherDiscoveryRequest
request
=
new
LauncherDiscoveryRequestBuilder
(
classLoader
)
.
selectors
(
DiscoverySelectors
.
selectClass
(
testClass
)).
build
();
.
selectors
(
DiscoverySelectors
.
selectClass
(
testClass
)).
build
();
Launcher
launcher
=
new
Launcher
(
testClass
.
getClassLoader
()
);
Launcher
launcher
=
LauncherFactory
.
create
(
);
launcher
.
execute
(
request
);
launcher
.
execute
(
request
);
}
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-test-support/build.gradle
View file @
cb7c3774
...
@@ -14,6 +14,7 @@ dependencies {
...
@@ -14,6 +14,7 @@ dependencies {
compileOnly
(
"org.elasticsearch:elasticsearch"
)
compileOnly
(
"org.elasticsearch:elasticsearch"
)
compileOnly
(
"org.junit.jupiter:junit-jupiter"
)
compileOnly
(
"org.junit.jupiter:junit-jupiter"
)
compileOnly
(
"org.junit.platform:junit-platform-engine"
)
compileOnly
(
"org.junit.platform:junit-platform-engine"
)
compileOnly
(
"org.junit.platform:junit-platform-launcher"
)
compileOnly
(
"org.mockito:mockito-core"
)
compileOnly
(
"org.mockito:mockito-core"
)
compileOnly
(
"org.springframework:spring-context"
)
compileOnly
(
"org.springframework:spring-context"
)
compileOnly
(
"org.springframework.data:spring-data-redis"
)
compileOnly
(
"org.springframework.data:spring-data-redis"
)
...
...
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtension.java
View file @
cb7c3774
/*
/*
* 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");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -24,12 +24,16 @@ import org.junit.jupiter.api.extension.ExtensionContext;
...
@@ -24,12 +24,16 @@ import org.junit.jupiter.api.extension.ExtensionContext;
import
org.junit.jupiter.api.extension.InvocationInterceptor
;
import
org.junit.jupiter.api.extension.InvocationInterceptor
;
import
org.junit.jupiter.api.extension.ReflectiveInvocationContext
;
import
org.junit.jupiter.api.extension.ReflectiveInvocationContext
;
import
org.junit.platform.engine.discovery.DiscoverySelectors
;
import
org.junit.platform.engine.discovery.DiscoverySelectors
;
import
org.junit.platform.launcher.Launcher
;
import
org.junit.platform.launcher.LauncherDiscoveryRequest
;
import
org.junit.platform.launcher.TestPlan
;
import
org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder
;
import
org.junit.platform.launcher.core.LauncherFactory
;
import
org.junit.platform.launcher.listeners.SummaryGeneratingListener
;
import
org.junit.platform.launcher.listeners.TestExecutionSummary
;
import
org.springframework.boot.testsupport.junit.platform.Launcher
;
import
org.springframework.boot.testsupport.junit.platform.LauncherDiscoveryRequest
;
import
org.springframework.boot.testsupport.junit.platform.LauncherDiscoveryRequestBuilder
;
import
org.springframework.boot.testsupport.junit.platform.SummaryGeneratingListener
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.util.ReflectionUtils
;
/**
/**
...
@@ -95,17 +99,18 @@ class ModifiedClassPathExtension implements InvocationInterceptor {
...
@@ -95,17 +99,18 @@ class ModifiedClassPathExtension implements InvocationInterceptor {
}
}
private
void
runTest
(
ClassLoader
classLoader
,
String
testClassName
,
String
testMethodName
)
throws
Throwable
{
private
void
runTest
(
ClassLoader
classLoader
,
String
testClassName
,
String
testMethodName
)
throws
Throwable
{
Class
<?>
testClass
=
Class
.
forName
(
testClassName
,
false
,
classLoader
);
Class
<?>
testClass
=
classLoader
.
loadClass
(
testClassName
);
Method
testMethod
=
findMethod
(
testClass
,
testMethodName
);
Method
testMethod
=
findMethod
(
testClass
,
testMethodName
);
LauncherDiscoveryRequest
request
=
new
LauncherDiscoveryRequestBuilder
(
classLoader
)
LauncherDiscoveryRequest
request
=
LauncherDiscoveryRequestBuilder
.
request
(
)
.
selectors
(
DiscoverySelectors
.
selectMethod
(
testClass
,
testMethod
)).
build
();
.
selectors
(
DiscoverySelectors
.
selectMethod
(
testClass
,
testMethod
)).
build
();
Launcher
launcher
=
new
Launcher
(
classLoader
);
Launcher
launcher
=
LauncherFactory
.
create
();
SummaryGeneratingListener
listener
=
new
SummaryGeneratingListener
(
classLoader
);
TestPlan
testPlan
=
launcher
.
discover
(
request
);
SummaryGeneratingListener
listener
=
new
SummaryGeneratingListener
();
launcher
.
registerTestExecutionListeners
(
listener
);
launcher
.
registerTestExecutionListeners
(
listener
);
launcher
.
execute
(
request
);
launcher
.
execute
(
testPlan
);
T
hrowable
failure
=
listener
.
getSummary
().
getFailure
();
T
estExecutionSummary
summary
=
listener
.
getSummary
();
if
(
failure
!=
null
)
{
if
(
!
CollectionUtils
.
isEmpty
(
summary
.
getFailures
())
)
{
throw
failure
;
throw
summary
.
getFailures
().
get
(
0
).
getException
()
;
}
}
}
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/Launcher.java
deleted
100644 → 0
View file @
363b5087
/*
* 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
org
.
springframework
.
boot
.
testsupport
.
junit
.
platform
;
import
java.lang.reflect.Array
;
/**
* Reflective mirror of JUnit 5's {@code Launcher}.
*
* @author Phillip Webb
* @since 2.2.0
*/
public
class
Launcher
extends
ReflectiveWrapper
{
private
final
Class
<?>
testExecutionListenerType
;
private
final
Object
instance
;
public
Launcher
(
ClassLoader
classLoader
)
throws
Throwable
{
super
(
classLoader
,
"org.junit.platform.launcher.Launcher"
);
this
.
testExecutionListenerType
=
loadClass
(
"org.junit.platform.launcher.TestExecutionListener"
);
Class
<?>
factoryClass
=
loadClass
(
"org.junit.platform.launcher.core.LauncherFactory"
);
this
.
instance
=
factoryClass
.
getMethod
(
"create"
).
invoke
(
null
);
}
public
void
registerTestExecutionListeners
(
SummaryGeneratingListener
listener
)
throws
Throwable
{
Object
listeners
=
Array
.
newInstance
(
this
.
testExecutionListenerType
,
1
);
Array
.
set
(
listeners
,
0
,
listener
.
instance
);
this
.
type
.
getMethod
(
"registerTestExecutionListeners"
,
listeners
.
getClass
()).
invoke
(
this
.
instance
,
listeners
);
}
public
void
execute
(
LauncherDiscoveryRequest
request
)
throws
Throwable
{
Object
listeners
=
Array
.
newInstance
(
this
.
testExecutionListenerType
,
0
);
this
.
type
.
getMethod
(
"execute"
,
request
.
type
,
listeners
.
getClass
()).
invoke
(
this
.
instance
,
request
.
instance
,
listeners
);
}
}
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/LauncherDiscoveryRequest.java
deleted
100644 → 0
View file @
363b5087
/*
* 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
org
.
springframework
.
boot
.
testsupport
.
junit
.
platform
;
/**
* Reflective mirror of JUnit 5's {@code LauncherDiscoveryRequest}.
*
* @author Phillip Webb
* @since 2.2.0
*/
public
class
LauncherDiscoveryRequest
extends
ReflectiveWrapper
{
final
Object
instance
;
LauncherDiscoveryRequest
(
ClassLoader
classLoader
,
Object
instance
)
throws
Throwable
{
super
(
classLoader
,
"org.junit.platform.launcher.LauncherDiscoveryRequest"
);
this
.
instance
=
instance
;
}
}
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/LauncherDiscoveryRequestBuilder.java
deleted
100644 → 0
View file @
363b5087
/*
* 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
org
.
springframework
.
boot
.
testsupport
.
junit
.
platform
;
import
java.lang.reflect.Method
;
import
org.junit.platform.engine.DiscoverySelector
;
/**
* Reflective mirror of JUnit 5's {@code LauncherDiscoveryRequestBuilder}.
*
* @author Phillip Webb
* @since 2.2.0
*/
public
class
LauncherDiscoveryRequestBuilder
extends
ReflectiveWrapper
{
final
Object
instance
;
public
LauncherDiscoveryRequestBuilder
(
ClassLoader
classLoader
)
throws
Throwable
{
super
(
classLoader
,
"org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder"
);
this
.
instance
=
this
.
type
.
getMethod
(
"request"
).
invoke
(
null
);
}
LauncherDiscoveryRequestBuilder
(
ClassLoader
classLoader
,
Class
<?>
type
,
Object
instance
)
throws
Throwable
{
super
(
classLoader
,
type
);
this
.
instance
=
instance
;
}
public
LauncherDiscoveryRequestBuilder
selectors
(
DiscoverySelector
...
selectors
)
throws
Throwable
{
Class
<?>[]
parameterTypes
=
{
DiscoverySelector
[].
class
};
Method
method
=
this
.
type
.
getMethod
(
"selectors"
,
parameterTypes
);
return
new
LauncherDiscoveryRequestBuilder
(
getClassLoader
(),
this
.
type
,
method
.
invoke
(
this
.
instance
,
new
Object
[]
{
selectors
}));
}
public
LauncherDiscoveryRequest
build
()
throws
Throwable
{
return
new
LauncherDiscoveryRequest
(
getClassLoader
(),
this
.
type
.
getMethod
(
"build"
).
invoke
(
this
.
instance
));
}
}
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/ReflectiveWrapper.java
deleted
100644 → 0
View file @
363b5087
/*
* 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
org
.
springframework
.
boot
.
testsupport
.
junit
.
platform
;
import
org.springframework.util.ClassUtils
;
/**
* Base class for all reflective wrappers.
*
* @author Phillip Webb
*/
class
ReflectiveWrapper
{
final
ClassLoader
classLoader
;
final
Class
<?>
type
;
ReflectiveWrapper
(
ClassLoader
classLoader
,
String
type
)
throws
Throwable
{
this
.
classLoader
=
classLoader
;
this
.
type
=
loadClass
(
type
);
}
protected
ReflectiveWrapper
(
ClassLoader
classLoader
,
Class
<?>
type
)
throws
Throwable
{
this
.
classLoader
=
classLoader
;
this
.
type
=
type
;
}
protected
final
ClassLoader
getClassLoader
()
{
return
this
.
classLoader
;
}
protected
final
Class
<?>
loadClass
(
String
type
)
throws
ClassNotFoundException
,
LinkageError
{
return
ClassUtils
.
forName
(
type
,
this
.
classLoader
);
}
}
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/SummaryGeneratingListener.java
deleted
100644 → 0
View file @
363b5087
/*
* Copyright 2012-2020 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
org
.
springframework
.
boot
.
testsupport
.
junit
.
platform
;
/**
* Reflective mirror of JUnit 5's {@code SummaryGeneratingListener}.
*
* @author Phillip Webb
* @since 2.2.0
*/
public
class
SummaryGeneratingListener
extends
ReflectiveWrapper
{
final
Object
instance
;
public
SummaryGeneratingListener
(
ClassLoader
classLoader
)
throws
Throwable
{
super
(
classLoader
,
"org.junit.platform.launcher.listeners.SummaryGeneratingListener"
);
this
.
instance
=
this
.
type
.
getDeclaredConstructor
().
newInstance
();
}
public
TestExecutionSummary
getSummary
()
throws
Throwable
{
return
new
TestExecutionSummary
(
getClassLoader
(),
this
.
type
.
getMethod
(
"getSummary"
).
invoke
(
this
.
instance
));
}
}
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/TestExecutionSummary.java
deleted
100644 → 0
View file @
363b5087
/*
* 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
org
.
springframework
.
boot
.
testsupport
.
junit
.
platform
;
import
java.util.List
;
import
org.springframework.util.CollectionUtils
;
/**
* Reflective mirror of JUnit 5's {@code TestExecutionSummary}.
*
* @author Phillip Webb
* @since 2.2.0
*/
public
class
TestExecutionSummary
extends
ReflectiveWrapper
{
private
final
Class
<?>
failureType
;
private
final
Object
instance
;
TestExecutionSummary
(
ClassLoader
classLoader
,
Object
instance
)
throws
Throwable
{
super
(
classLoader
,
"org.junit.platform.launcher.listeners.TestExecutionSummary"
);
this
.
failureType
=
loadClass
(
"org.junit.platform.launcher.listeners.TestExecutionSummary$Failure"
);
this
.
instance
=
instance
;
}
public
Throwable
getFailure
()
throws
Throwable
{
List
<?>
failures
=
(
List
<?>)
this
.
type
.
getMethod
(
"getFailures"
).
invoke
(
this
.
instance
);
if
(!
CollectionUtils
.
isEmpty
(
failures
))
{
Object
failure
=
failures
.
get
(
0
);
return
(
Throwable
)
this
.
failureType
.
getMethod
(
"getException"
).
invoke
(
failure
);
}
return
null
;
}
}
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/package-info.java
deleted
100644 → 0
View file @
363b5087
/*
* 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.
*/
/**
* Reflective mirror of JUnit 5 classes required to workaround surefire bug
* {@code SUREFIRE-1679}.
*/
package
org
.
springframework
.
boot
.
testsupport
.
junit
.
platform
;
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