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
2038fac8
Commit
2038fac8
authored
Jul 17, 2019
by
dreis2211
Committed by
Stephane Nicoll
Jul 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove testsupport.assertj package
See gh-17557
parent
3bf5cf11
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
14 additions
and
174 deletions
+14
-174
ConditionEvaluationReportTests.java
...toconfigure/condition/ConditionEvaluationReportTests.java
+8
-21
ResourcePropertiesTests.java
...ework/boot/autoconfigure/web/ResourcePropertiesTests.java
+1
-3
GroovyGrabDependencyResolverTests.java
...li/command/install/GroovyGrabDependencyResolverTests.java
+4
-7
pom.xml
...roject/spring-boot-tools/spring-boot-test-support/pom.xml
+0
-4
Matched.java
...org/springframework/boot/testsupport/assertj/Matched.java
+0
-61
package-info.java
...pringframework/boot/testsupport/assertj/package-info.java
+0
-20
MatchedTests.java
...pringframework/boot/testsupport/assertj/MatchedTests.java
+0
-56
ConcurrentReferenceCachingMetadataReaderFactoryTests.java
...ConcurrentReferenceCachingMetadataReaderFactoryTests.java
+1
-2
No files found.
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReportTests.java
View file @
2038fac8
...
...
@@ -34,7 +34,6 @@ import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportM
import
org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration
;
import
org.springframework.boot.test.util.TestPropertyValues
;
import
org.springframework.boot.testsupport.assertj.Matched
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Condition
;
...
...
@@ -47,8 +46,6 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
import
org.springframework.util.ClassUtils
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
import
static
org
.
hamcrest
.
Matchers
.
nullValue
;
/**
* Tests for {@link ConditionEvaluationReport}.
...
...
@@ -86,7 +83,7 @@ class ConditionEvaluationReportTests {
@Test
void
get
()
{
assertThat
(
this
.
report
).
isNot
EqualTo
(
nullValue
()
);
assertThat
(
this
.
report
).
isNot
Null
(
);
assertThat
(
this
.
report
).
isSameAs
(
ConditionEvaluationReport
.
get
(
this
.
beanFactory
));
}
...
...
@@ -95,8 +92,8 @@ class ConditionEvaluationReportTests {
this
.
beanFactory
.
setParentBeanFactory
(
new
DefaultListableBeanFactory
());
ConditionEvaluationReport
.
get
((
ConfigurableListableBeanFactory
)
this
.
beanFactory
.
getParentBeanFactory
());
assertThat
(
this
.
report
).
isSameAs
(
ConditionEvaluationReport
.
get
(
this
.
beanFactory
));
assertThat
(
this
.
report
).
isNot
EqualTo
(
nullValue
()
);
assertThat
(
this
.
report
.
getParent
()).
isNot
EqualTo
(
nullValue
()
);
assertThat
(
this
.
report
).
isNot
Null
(
);
assertThat
(
this
.
report
.
getParent
()).
isNot
Null
(
);
ConditionEvaluationReport
.
get
((
ConfigurableListableBeanFactory
)
this
.
beanFactory
.
getParentBeanFactory
());
assertThat
(
this
.
report
).
isSameAs
(
ConditionEvaluationReport
.
get
(
this
.
beanFactory
));
assertThat
(
this
.
report
.
getParent
()).
isSameAs
(
ConditionEvaluationReport
...
...
@@ -184,7 +181,7 @@ class ConditionEvaluationReportTests {
outcomes
.
add
(
this
.
condition1
,
new
ConditionOutcome
(
true
,
"Message 1"
));
outcomes
.
add
(
this
.
condition2
,
new
ConditionOutcome
(
true
,
"Message 2"
));
outcomes
.
add
(
this
.
condition3
,
new
ConditionOutcome
(
true
,
"Message 2"
));
assertThat
(
getNumberOfOutcomes
(
outcomes
)).
isEqualTo
(
2
);
assertThat
(
outcomes
).
hasSize
(
2
);
}
@Test
...
...
@@ -193,15 +190,15 @@ class ConditionEvaluationReportTests {
ConditionEvaluationReport
report
=
ConditionEvaluationReport
.
get
(
context
.
getBeanFactory
());
String
autoconfigKey
=
MultipartAutoConfiguration
.
class
.
getName
();
ConditionAndOutcomes
outcomes
=
report
.
getConditionAndOutcomesBySource
().
get
(
autoconfigKey
);
assertThat
(
outcomes
).
isNot
EqualTo
(
nullValue
()
);
assertThat
(
getNumberOfOutcomes
(
outcomes
)).
isEqualTo
(
2
);
assertThat
(
outcomes
).
isNot
Null
(
);
assertThat
(
outcomes
).
hasSize
(
2
);
List
<
String
>
messages
=
new
ArrayList
<>();
for
(
ConditionAndOutcome
outcome
:
outcomes
)
{
messages
.
add
(
outcome
.
getOutcome
().
getMessage
());
}
assertThat
(
messages
).
a
reAtLeastOne
(
Matched
.
by
(
containsString
(
"@ConditionalOnClass found required classes "
assertThat
(
messages
).
a
nyMatch
((
message
)
->
message
.
contains
(
"@ConditionalOnClass found required classes "
+
"'javax.servlet.Servlet', 'org.springframework.web.multipart."
+
"support.StandardServletMultipartResolver', 'javax.servlet.MultipartConfigElement'"
))
)
;
+
"support.StandardServletMultipartResolver', 'javax.servlet.MultipartConfigElement'"
));
context
.
close
();
}
...
...
@@ -252,16 +249,6 @@ class ConditionEvaluationReportTests {
context
.
close
();
}
private
int
getNumberOfOutcomes
(
ConditionAndOutcomes
outcomes
)
{
Iterator
<
ConditionAndOutcome
>
iterator
=
outcomes
.
iterator
();
int
numberOfOutcomesAdded
=
0
;
while
(
iterator
.
hasNext
())
{
numberOfOutcomesAdded
++;
iterator
.
next
();
}
return
numberOfOutcomesAdded
;
}
@Configuration
(
proxyBeanMethods
=
false
)
@Import
(
WebMvcAutoConfiguration
.
class
)
static
class
Config
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTests.java
View file @
2038fac8
...
...
@@ -21,11 +21,9 @@ import java.time.Duration;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.autoconfigure.web.ResourceProperties.Cache
;
import
org.springframework.boot.testsupport.assertj.Matched
;
import
org.springframework.http.CacheControl
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
endsWith
;
/**
* Tests for {@link ResourceProperties}.
...
...
@@ -62,7 +60,7 @@ class ResourcePropertiesTests {
@Test
void
defaultStaticLocationsAllEndWithTrailingSlash
()
{
assertThat
(
this
.
properties
.
getStaticLocations
()).
a
re
(
Matched
.
by
(
endsWith
(
"/"
)
));
assertThat
(
this
.
properties
.
getStaticLocations
()).
a
llMatch
((
location
)
->
location
.
endsWith
(
"/"
));
}
@Test
...
...
spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/install/GroovyGrabDependencyResolverTests.java
View file @
2038fac8
...
...
@@ -23,7 +23,6 @@ import java.util.HashSet;
import
java.util.List
;
import
java.util.Set
;
import
org.assertj.core.api.Condition
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
...
...
@@ -31,11 +30,8 @@ import org.springframework.boot.cli.compiler.GroovyCompilerConfiguration;
import
org.springframework.boot.cli.compiler.GroovyCompilerScope
;
import
org.springframework.boot.cli.compiler.RepositoryConfigurationFactory
;
import
org.springframework.boot.cli.compiler.grape.RepositoryConfiguration
;
import
org.springframework.boot.testsupport.assertj.Matched
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
hasItems
;
import
static
org
.
hamcrest
.
Matchers
.
startsWith
;
/**
* Tests for {@link GroovyGrabDependencyResolver}.
...
...
@@ -104,12 +100,13 @@ class GroovyGrabDependencyResolverTests {
}
@Test
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
void
resolveShorthandArtifactWithDependencies
()
throws
Exception
{
List
<
File
>
resolved
=
this
.
resolver
.
resolve
(
Arrays
.
asList
(
"spring-beans"
));
assertThat
(
resolved
).
hasSize
(
3
);
assertThat
(
getNames
(
resolved
)).
has
((
Condition
)
Matched
.
by
(
hasItems
(
startsWith
(
"spring-core-"
),
startsWith
(
"spring-beans-"
),
startsWith
(
"spring-jcl-"
))));
Set
<
String
>
names
=
getNames
(
resolved
);
assertThat
(
names
).
anyMatch
((
name
)
->
name
.
startsWith
(
"spring-core-"
));
assertThat
(
names
).
anyMatch
((
name
)
->
name
.
startsWith
(
"spring-beans-"
));
assertThat
(
names
).
anyMatch
((
name
)
->
name
.
startsWith
(
"spring-jcl-"
));
}
@Test
...
...
spring-boot-project/spring-boot-tools/spring-boot-test-support/pom.xml
View file @
2038fac8
...
...
@@ -47,10 +47,6 @@
<groupId>
org.springframework
</groupId>
<artifactId>
spring-core
</artifactId>
</dependency>
<dependency>
<groupId>
org.hamcrest
</groupId>
<artifactId>
hamcrest
</artifactId>
</dependency>
<dependency>
<groupId>
org.assertj
</groupId>
<artifactId>
assertj-core
</artifactId>
...
...
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/assertj/Matched.java
deleted
100644 → 0
View file @
3bf5cf11
/*
* Copyright 2012-2017 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
.
assertj
;
import
org.assertj.core.api.Condition
;
import
org.hamcrest.Matcher
;
import
org.hamcrest.StringDescription
;
import
org.springframework.util.Assert
;
/**
* Adapter class allowing a Hamcrest {@link Matcher} to be used as an AssertJ
* {@link Condition}.
*
* @param <T> the type of object that the condition accepts
* @author Phillip Webb
* @since 2.0.0
*/
public
final
class
Matched
<
T
>
extends
Condition
<
T
>
{
private
final
Matcher
<?
extends
T
>
matcher
;
private
Matched
(
Matcher
<?
extends
T
>
matcher
)
{
Assert
.
notNull
(
matcher
,
"Matcher must not be null"
);
this
.
matcher
=
matcher
;
}
@Override
public
boolean
matches
(
T
value
)
{
if
(
this
.
matcher
.
matches
(
value
))
{
return
true
;
}
StringDescription
description
=
new
StringDescription
();
this
.
matcher
.
describeTo
(
description
);
describedAs
(
description
.
toString
());
return
false
;
}
public
static
<
T
>
Condition
<
T
>
when
(
Matcher
<?
extends
T
>
matcher
)
{
return
by
(
matcher
);
}
public
static
<
T
>
Condition
<
T
>
by
(
Matcher
<?
extends
T
>
matcher
)
{
return
new
Matched
<>(
matcher
);
}
}
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/assertj/package-info.java
deleted
100644 → 0
View file @
3bf5cf11
/*
* Copyright 2012-2017 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.
*/
/**
* Utilities and helpers for AssertJ.
*/
package
org
.
springframework
.
boot
.
testsupport
.
assertj
;
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/test/java/org/springframework/boot/testsupport/assertj/MatchedTests.java
deleted
100644 → 0
View file @
3bf5cf11
/*
* 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
.
assertj
;
import
org.junit.jupiter.api.Test
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatExceptionOfType
;
import
static
org
.
hamcrest
.
Matchers
.
startsWith
;
/**
* Tests for {@link Matched}.
*
* @author Phillip Webb
*/
class
MatchedTests
{
@Test
void
byMatcherMatches
()
{
assertThat
(
"1234"
).
is
(
Matched
.
by
(
startsWith
(
"12"
)));
}
@Test
void
byMatcherDoesNotMatch
()
{
assertThatExceptionOfType
(
AssertionError
.
class
)
.
isThrownBy
(()
->
assertThat
(
"1234"
).
is
(
Matched
.
by
(
startsWith
(
"23"
))))
.
withMessageContaining
(
"a string starting with \"23\""
);
}
@Test
void
whenMatcherMatches
()
{
assertThat
(
"1234"
).
is
(
Matched
.
when
(
startsWith
(
"12"
)));
}
@Test
void
whenMatcherDoesNotMatch
()
{
assertThatExceptionOfType
(
AssertionError
.
class
)
.
isThrownBy
(()
->
assertThat
(
"1234"
).
is
(
Matched
.
when
(
startsWith
(
"23"
))))
.
withMessageContaining
(
"a string starting with \"23\""
);
}
}
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/type/classreading/ConcurrentReferenceCachingMetadataReaderFactoryTests.java
View file @
2038fac8
...
...
@@ -22,7 +22,6 @@ import org.springframework.core.io.Resource;
import
org.springframework.core.type.classreading.MetadataReader
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
sameInstance
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
spy
;
...
...
@@ -53,7 +52,7 @@ class ConcurrentReferenceCachingMetadataReaderFactoryTests {
MetadataReader
metadataReader1
=
factory
.
getMetadataReader
(
getClass
().
getName
());
factory
.
clearCache
();
MetadataReader
metadataReader2
=
factory
.
getMetadataReader
(
getClass
().
getName
());
assertThat
(
metadataReader1
).
isNot
EqualTo
(
sameInstance
(
metadataReader2
)
);
assertThat
(
metadataReader1
).
isNot
SameAs
(
metadataReader2
);
verify
(
factory
,
times
(
2
)).
createMetadataReader
(
any
(
Resource
.
class
));
}
...
...
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