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
4dfdce5a
Commit
4dfdce5a
authored
Oct 02, 2016
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7081 from izeye:polish-20161002
* pr/7081: Polish
parents
8feef456
503d735f
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
26 additions
and
59 deletions
+26
-59
ConditionMessage.java
...mework/boot/autoconfigure/condition/ConditionMessage.java
+6
-6
ConditionMessageTests.java
...k/boot/autoconfigure/condition/ConditionMessageTests.java
+2
-2
OnInitializedRestarterCondition.java
...oot/devtools/restart/OnInitializedRestarterCondition.java
+2
-2
howto.adoc
spring-boot-docs/src/main/asciidoc/howto.adoc
+4
-4
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+1
-1
SpringBootTestContextBootstrapperIntegrationTests.java
...ap/SpringBootTestContextBootstrapperIntegrationTests.java
+0
-6
DefinitionsParserTests.java
...mework/boot/test/mock/mockito/DefinitionsParserTests.java
+2
-0
MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java
...estFieldForExistingBeanWithQualifierIntegrationTests.java
+3
-0
CustomQualifier.java
...ework/boot/test/mock/mockito/example/CustomQualifier.java
+5
-0
MyMockBean.java
...gframework/boot/test/mock/mockito/example/MyMockBean.java
+0
-37
JsonObjectDeserializer.java
.../springframework/boot/jackson/JsonObjectDeserializer.java
+1
-1
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java
View file @
4dfdce5a
...
@@ -141,7 +141,7 @@ public final class ConditionMessage {
...
@@ -141,7 +141,7 @@ public final class ConditionMessage {
/**
/**
* Factory method to create a new {@link ConditionMessage} with a specific message.
* Factory method to create a new {@link ConditionMessage} with a specific message.
* @param message the source message (may be a format string if {@code args} are
* @param message the source message (may be a format string if {@code args} are
* specified
* specified
)
* @param args format arguments for the message
* @param args format arguments for the message
* @return a new {@link ConditionMessage} instance
* @return a new {@link ConditionMessage} instance
*/
*/
...
@@ -155,7 +155,7 @@ public final class ConditionMessage {
...
@@ -155,7 +155,7 @@ public final class ConditionMessage {
/**
/**
* Factory method to create a new {@link ConditionMessage} comprised of the specified
* Factory method to create a new {@link ConditionMessage} comprised of the specified
* messages.
* messages.
* @param messages the source messages (may be {@code null}
* @param messages the source messages (may be {@code null}
)
* @return a new {@link ConditionMessage} instance
* @return a new {@link ConditionMessage} instance
*/
*/
public
static
ConditionMessage
of
(
Collection
<?
extends
ConditionMessage
>
messages
)
{
public
static
ConditionMessage
of
(
Collection
<?
extends
ConditionMessage
>
messages
)
{
...
@@ -283,7 +283,7 @@ public final class ConditionMessage {
...
@@ -283,7 +283,7 @@ public final class ConditionMessage {
/**
/**
* Indicates something is not available. For example {@code notAvailable("time")}
* Indicates something is not available. For example {@code notAvailable("time")}
* results in the message "time i
n
not available".
* results in the message "time i
s
not available".
* @param item the item that is not available
* @param item the item that is not available
* @return a built {@link ConditionMessage}
* @return a built {@link ConditionMessage}
*/
*/
...
@@ -374,9 +374,9 @@ public final class ConditionMessage {
...
@@ -374,9 +374,9 @@ public final class ConditionMessage {
}
}
/**
/**
* Indicate the items. For example
* Indicate the items
with a {@link Style}
. For example
* {@code didNotFind("bean", "beans").items(Collections.singleton("x")} results in
* {@code didNotFind("bean", "beans").items(
Style.QUOTE,
Collections.singleton("x")} results in
* the message "did not find bean
x
".
* the message "did not find bean
'x'
".
* @param style the render style
* @param style the render style
* @param items the source of the items (may be {@code null})
* @param items the source of the items (may be {@code null})
* @return a built {@link ConditionMessage}
* @return a built {@link ConditionMessage}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionMessageTests.java
View file @
4dfdce5a
...
@@ -132,7 +132,7 @@ public class ConditionMessageTests {
...
@@ -132,7 +132,7 @@ public class ConditionMessageTests {
}
}
@Test
@Test
public
void
foundWhenSingleElementShouldUs
ing
Singular
()
throws
Exception
{
public
void
foundWhenSingleElementShouldUs
e
Singular
()
throws
Exception
{
ConditionMessage
message
=
ConditionMessage
.
forCondition
(
Test
.
class
)
ConditionMessage
message
=
ConditionMessage
.
forCondition
(
Test
.
class
)
.
found
(
"bean"
,
"beans"
).
items
(
"a"
);
.
found
(
"bean"
,
"beans"
).
items
(
"a"
);
assertThat
(
message
.
toString
()).
isEqualTo
(
"@Test found bean a"
);
assertThat
(
message
.
toString
()).
isEqualTo
(
"@Test found bean a"
);
...
@@ -160,7 +160,7 @@ public class ConditionMessageTests {
...
@@ -160,7 +160,7 @@ public class ConditionMessageTests {
}
}
@Test
@Test
public
void
didNotFindWhenSingleElementShouldUs
ing
Singular
()
throws
Exception
{
public
void
didNotFindWhenSingleElementShouldUs
e
Singular
()
throws
Exception
{
ConditionMessage
message
=
ConditionMessage
.
forCondition
(
Test
.
class
)
ConditionMessage
message
=
ConditionMessage
.
forCondition
(
Test
.
class
)
.
didNotFind
(
"class"
,
"classes"
).
items
(
"a"
);
.
didNotFind
(
"class"
,
"classes"
).
items
(
"a"
);
assertThat
(
message
.
toString
()).
isEqualTo
(
"@Test did not find class a"
);
assertThat
(
message
.
toString
()).
isEqualTo
(
"@Test did not find class a"
);
...
...
spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/OnInitializedRestarterCondition.java
View file @
4dfdce5a
...
@@ -24,7 +24,7 @@ import org.springframework.context.annotation.ConditionContext;
...
@@ -24,7 +24,7 @@ import org.springframework.context.annotation.ConditionContext;
import
org.springframework.core.type.AnnotatedTypeMetadata
;
import
org.springframework.core.type.AnnotatedTypeMetadata
;
/**
/**
* {@link Condition} that checks that a {@link Restarter} is available an initialized.
* {@link Condition} that checks that a {@link Restarter} is available an
d
initialized.
*
*
* @author Phillip Webb
* @author Phillip Webb
* @see ConditionalOnInitializedRestarter
* @see ConditionalOnInitializedRestarter
...
@@ -35,7 +35,7 @@ class OnInitializedRestarterCondition extends SpringBootCondition {
...
@@ -35,7 +35,7 @@ class OnInitializedRestarterCondition extends SpringBootCondition {
public
ConditionOutcome
getMatchOutcome
(
ConditionContext
context
,
public
ConditionOutcome
getMatchOutcome
(
ConditionContext
context
,
AnnotatedTypeMetadata
metadata
)
{
AnnotatedTypeMetadata
metadata
)
{
ConditionMessage
.
Builder
message
=
ConditionMessage
ConditionMessage
.
Builder
message
=
ConditionMessage
.
forCondition
(
"Initialize
r
Restarter Condition"
);
.
forCondition
(
"Initialize
d
Restarter Condition"
);
Restarter
restarter
=
getRestarter
();
Restarter
restarter
=
getRestarter
();
if
(
restarter
==
null
)
{
if
(
restarter
==
null
)
{
return
ConditionOutcome
.
noMatch
(
message
.
because
(
"unavailable"
));
return
ConditionOutcome
.
noMatch
(
message
.
because
(
"unavailable"
));
...
...
spring-boot-docs/src/main/asciidoc/howto.adoc
View file @
4dfdce5a
...
@@ -24,9 +24,9 @@ can send us a {github-code}[pull request].
...
@@ -24,9 +24,9 @@ can send us a {github-code}[pull request].
[[howto-failure-analyzer]]
[[howto-failure-analyzer]]
=== Create your own FailureAnalyzer
=== Create your own FailureAnalyzer
{dc-spring-boot}/diagnostics/FailureAnalyzer.{dc-ext}[
[
`FailureAnalyzer`] is a great way
{dc-spring-boot}/diagnostics/FailureAnalyzer.{dc-ext}[`FailureAnalyzer`] is a great way
to intercept an exception on startup and turn it into a human-readable message, wrapped
to intercept an exception on startup and turn it into a human-readable message, wrapped
into a {dc-spring-boot}/diagnostics/FailureAnalysis.{dc-ext}[
[
`FailureAnalysis`]. Spring
into a {dc-spring-boot}/diagnostics/FailureAnalysis.{dc-ext}[`FailureAnalysis`]. Spring
Boot provides such analyzer for application context related exceptions, JSR-303
Boot provides such analyzer for application context related exceptions, JSR-303
validations and more. It is actually very easy to create your own.
validations and more. It is actually very easy to create your own.
...
@@ -34,7 +34,7 @@ validations and more. It is actually very easy to create your own.
...
@@ -34,7 +34,7 @@ validations and more. It is actually very easy to create your own.
presence of a specified exception type in the exception to handle. You can extend from
presence of a specified exception type in the exception to handle. You can extend from
that so that your implementation gets a chance to handle the exception only when it is
that so that your implementation gets a chance to handle the exception only when it is
actually present. If for whatever reason you can't handle the exception, return `null`
actually present. If for whatever reason you can't handle the exception, return `null`
to
let
another implementation a chance to handle the exception.
to
give
another implementation a chance to handle the exception.
`FailureAnalyzer` implementations are to be registered in a `META-INF/spring.factories`:
`FailureAnalyzer` implementations are to be registered in a `META-INF/spring.factories`:
the following registers `ProjectConstraintViolationFailureAnalyzer`:
the following registers `ProjectConstraintViolationFailureAnalyzer`:
...
@@ -2652,7 +2652,7 @@ then be depended upon by your application and other projects.
...
@@ -2652,7 +2652,7 @@ then be depended upon by your application and other projects.
If you cannot rearrange your code as recommended above, Spring Boot's Maven and Gradle
If you cannot rearrange your code as recommended above, Spring Boot's Maven and Gradle
plugins must be configured to produce a separate artifact that is suitable for use as a
plugins must be configured to produce a separate artifact that is suitable for use as a
dependency. The executable archive cannot be used as a dependency as the
dependency. The executable archive cannot be used as a dependency as the
<<appendix-executable-jar-format.adoc#executable-jar-jar-file-structure,exec
tu
able jar
<<appendix-executable-jar-format.adoc#executable-jar-jar-file-structure,exec
ut
able jar
format>> packages application classes in `BOOT-INF/classes`. This means
format>> packages application classes in `BOOT-INF/classes`. This means
that they cannot be found when the executable jar is used as a dependency.
that they cannot be found when the executable jar is used as a dependency.
...
...
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
4dfdce5a
...
@@ -5266,7 +5266,7 @@ Data JPA tests may also inject a
...
@@ -5266,7 +5266,7 @@ Data JPA tests may also inject a
bean which provides an alternative to the standard JPA `EntityManager` specifically
bean which provides an alternative to the standard JPA `EntityManager` specifically
designed for tests. If you want to use `TestEntityManager` outside of `@DataJpaTests` you
designed for tests. If you want to use `TestEntityManager` outside of `@DataJpaTests` you
can also use the `@AutoConfigureTestEntityManager` annotation. A `JdbcTemplate` is also
can also use the `@AutoConfigureTestEntityManager` annotation. A `JdbcTemplate` is also
available
should
you need that.
available
if
you need that.
[source,java,indent=0]
[source,java,indent=0]
----
----
...
...
spring-boot-test/src/test/java/org/springframework/boot/test/context/bootstrap/SpringBootTestContextBootstrapperIntegrationTests.java
View file @
4dfdce5a
...
@@ -24,7 +24,6 @@ import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
...
@@ -24,7 +24,6 @@ import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
import
org.springframework.boot.test.context.TestConfiguration
;
import
org.springframework.boot.test.context.TestConfiguration
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.stereotype.Component
;
import
org.springframework.test.context.BootstrapWith
;
import
org.springframework.test.context.BootstrapWith
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.context.junit4.SpringRunner
;
...
@@ -83,9 +82,4 @@ public class SpringBootTestContextBootstrapperIntegrationTests {
...
@@ -83,9 +82,4 @@ public class SpringBootTestContextBootstrapperIntegrationTests {
}
}
@Component
static
class
ExampleTestComponent
{
}
}
}
spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/DefinitionsParserTests.java
View file @
4dfdce5a
...
@@ -169,6 +169,8 @@ public class DefinitionsParserTests {
...
@@ -169,6 +169,8 @@ public class DefinitionsParserTests {
QualifierDefinition
qualifier
=
QualifierDefinition
.
forElement
(
QualifierDefinition
qualifier
=
QualifierDefinition
.
forElement
(
ReflectionUtils
.
findField
(
SpyBeanOnClassAndField
.
class
,
"caller"
));
ReflectionUtils
.
findField
(
SpyBeanOnClassAndField
.
class
,
"caller"
));
assertThat
(
fieldDefinition
.
getQualifier
()).
isNotNull
().
isEqualTo
(
qualifier
);
assertThat
(
fieldDefinition
.
getQualifier
()).
isNotNull
().
isEqualTo
(
qualifier
);
assertThat
(
fieldDefinition
.
getTypeToSpy
().
resolve
())
.
isEqualTo
(
ExampleServiceCaller
.
class
);
}
}
@Test
@Test
...
...
spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests.java
View file @
4dfdce5a
...
@@ -36,6 +36,9 @@ import static org.mockito.Mockito.verify;
...
@@ -36,6 +36,9 @@ import static org.mockito.Mockito.verify;
/**
/**
* Test {@link MockBean} on a test class field can be used to replace existing bean while
* Test {@link MockBean} on a test class field can be used to replace existing bean while
* preserving qualifiers.
* preserving qualifiers.
*
* @author Stephane Nicoll
* @author Phillip Webb
*/
*/
@RunWith
(
SpringRunner
.
class
)
@RunWith
(
SpringRunner
.
class
)
public
class
MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests
{
public
class
MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests
{
...
...
spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/example/CustomQualifier.java
View file @
4dfdce5a
...
@@ -21,6 +21,11 @@ import java.lang.annotation.RetentionPolicy;
...
@@ -21,6 +21,11 @@ import java.lang.annotation.RetentionPolicy;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Qualifier
;
/**
* Custom qualifier for testing.
*
* @author Stephane Nicoll
*/
@Qualifier
@Qualifier
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
CustomQualifier
{
public
@interface
CustomQualifier
{
...
...
spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/example/MyMockBean.java
deleted
100644 → 0
View file @
8feef456
/*
* Copyright 2012-2016 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
*
* http://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
.
test
.
mock
.
mockito
.
example
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
org.springframework.boot.test.mock.mockito.MockBean
;
import
org.springframework.core.annotation.AliasFor
;
@Target
({
ElementType
.
TYPE
,
ElementType
.
FIELD
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@MockBean
public
@interface
MyMockBean
{
@AliasFor
(
annotation
=
MockBean
.
class
,
attribute
=
"value"
)
Class
<?>
value
();
}
spring-boot/src/main/java/org/springframework/boot/jackson/JsonObjectDeserializer.java
View file @
4dfdce5a
...
@@ -78,7 +78,7 @@ public abstract class JsonObjectDeserializer<T>
...
@@ -78,7 +78,7 @@ public abstract class JsonObjectDeserializer<T>
/**
/**
* Helper method to extract a value from the given {@code jsonNode} or return
* Helper method to extract a value from the given {@code jsonNode} or return
* {@code null} when the node itself is {@code null}.
* {@code null} when the node itself is {@code null}.
* @param jsonNode the source node (may be {@code null}
* @param jsonNode the source node (may be {@code null}
)
* @param type the data type. May be {@link String}, {@link Boolean}, {@link Long},
* @param type the data type. May be {@link String}, {@link Boolean}, {@link Long},
* {@link Integer}, {@link Short}, {@link Double}, {@link Float}, {@link BigDecimal}
* {@link Integer}, {@link Short}, {@link Double}, {@link Float}, {@link BigDecimal}
* or {@link BigInteger}.
* or {@link BigInteger}.
...
...
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