parent
8feef4560b
commit
503d735fdd
|
@ -141,7 +141,7 @@ public final class ConditionMessage {
|
|||
/**
|
||||
* 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
|
||||
* specified
|
||||
* specified)
|
||||
* @param args format arguments for the message
|
||||
* @return a new {@link ConditionMessage} instance
|
||||
*/
|
||||
|
@ -155,7 +155,7 @@ public final class ConditionMessage {
|
|||
/**
|
||||
* Factory method to create a new {@link ConditionMessage} comprised of the specified
|
||||
* 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
|
||||
*/
|
||||
public static ConditionMessage of(Collection<? extends ConditionMessage> messages) {
|
||||
|
@ -283,7 +283,7 @@ public final class ConditionMessage {
|
|||
|
||||
/**
|
||||
* Indicates something is not available. For example {@code notAvailable("time")}
|
||||
* results in the message "time in not available".
|
||||
* results in the message "time is not available".
|
||||
* @param item the item that is not available
|
||||
* @return a built {@link ConditionMessage}
|
||||
*/
|
||||
|
@ -374,9 +374,9 @@ public final class ConditionMessage {
|
|||
}
|
||||
|
||||
/**
|
||||
* Indicate the items. For example
|
||||
* {@code didNotFind("bean", "beans").items(Collections.singleton("x")} results in
|
||||
* the message "did not find bean x".
|
||||
* Indicate the items with a {@link Style}. For example
|
||||
* {@code didNotFind("bean", "beans").items(Style.QUOTE, Collections.singleton("x")} results in
|
||||
* the message "did not find bean 'x'".
|
||||
* @param style the render style
|
||||
* @param items the source of the items (may be {@code null})
|
||||
* @return a built {@link ConditionMessage}
|
||||
|
|
|
@ -132,7 +132,7 @@ public class ConditionMessageTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void foundWhenSingleElementShouldUsingSingular() throws Exception {
|
||||
public void foundWhenSingleElementShouldUseSingular() throws Exception {
|
||||
ConditionMessage message = ConditionMessage.forCondition(Test.class)
|
||||
.found("bean", "beans").items("a");
|
||||
assertThat(message.toString()).isEqualTo("@Test found bean a");
|
||||
|
@ -160,7 +160,7 @@ public class ConditionMessageTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void didNotFindWhenSingleElementShouldUsingSingular() throws Exception {
|
||||
public void didNotFindWhenSingleElementShouldUseSingular() throws Exception {
|
||||
ConditionMessage message = ConditionMessage.forCondition(Test.class)
|
||||
.didNotFind("class", "classes").items("a");
|
||||
assertThat(message.toString()).isEqualTo("@Test did not find class a");
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.springframework.context.annotation.ConditionContext;
|
|||
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 and initialized.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @see ConditionalOnInitializedRestarter
|
||||
|
@ -35,7 +35,7 @@ class OnInitializedRestarterCondition extends SpringBootCondition {
|
|||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
ConditionMessage.Builder message = ConditionMessage
|
||||
.forCondition("Initializer Restarter Condition");
|
||||
.forCondition("Initialized Restarter Condition");
|
||||
Restarter restarter = getRestarter();
|
||||
if (restarter == null) {
|
||||
return ConditionOutcome.noMatch(message.because("unavailable"));
|
||||
|
|
|
@ -24,9 +24,9 @@ can send us a {github-code}[pull request].
|
|||
|
||||
[[howto-failure-analyzer]]
|
||||
=== 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
|
||||
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
|
||||
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
|
||||
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`
|
||||
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`:
|
||||
the following registers `ProjectConstraintViolationFailureAnalyzer`:
|
||||
|
@ -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
|
||||
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
|
||||
<<appendix-executable-jar-format.adoc#executable-jar-jar-file-structure,exectuable jar
|
||||
<<appendix-executable-jar-format.adoc#executable-jar-jar-file-structure,executable jar
|
||||
format>> packages application classes in `BOOT-INF/classes`. This means
|
||||
that they cannot be found when the executable jar is used as a dependency.
|
||||
|
||||
|
|
|
@ -5266,7 +5266,7 @@ Data JPA tests may also inject a
|
|||
bean which provides an alternative to the standard JPA `EntityManager` specifically
|
||||
designed for tests. If you want to use `TestEntityManager` outside of `@DataJpaTests` you
|
||||
can also use the `@AutoConfigureTestEntityManager` annotation. A `JdbcTemplate` is also
|
||||
available should you need that.
|
||||
available if you need that.
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
|
|||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.test.context.BootstrapWith;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
|
@ -83,9 +82,4 @@ public class SpringBootTestContextBootstrapperIntegrationTests {
|
|||
|
||||
}
|
||||
|
||||
@Component
|
||||
static class ExampleTestComponent {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -169,6 +169,8 @@ public class DefinitionsParserTests {
|
|||
QualifierDefinition qualifier = QualifierDefinition.forElement(
|
||||
ReflectionUtils.findField(SpyBeanOnClassAndField.class, "caller"));
|
||||
assertThat(fieldDefinition.getQualifier()).isNotNull().isEqualTo(qualifier);
|
||||
assertThat(fieldDefinition.getTypeToSpy().resolve())
|
||||
.isEqualTo(ExampleServiceCaller.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -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
|
||||
* preserving qualifiers.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
public class MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests {
|
||||
|
|
|
@ -21,6 +21,11 @@ import java.lang.annotation.RetentionPolicy;
|
|||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
||||
/**
|
||||
* Custom qualifier for testing.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Qualifier
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface CustomQualifier {
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* 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();
|
||||
|
||||
}
|
|
@ -78,7 +78,7 @@ public abstract class JsonObjectDeserializer<T>
|
|||
/**
|
||||
* Helper method to extract a value from the given {@code jsonNode} or return
|
||||
* {@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},
|
||||
* {@link Integer}, {@link Short}, {@link Double}, {@link Float}, {@link BigDecimal}
|
||||
* or {@link BigInteger}.
|
||||
|
|
Loading…
Reference in New Issue