Merge branch '1.4.x' into 1.5.x

pull/7075/merge
Stephane Nicoll 8 years ago
commit e643fc5bd1

@ -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 {
/** /**
* 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 {
/** /**
* 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 in not available". * results in the message "time is 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 {
} }
/** /**
* 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}

@ -132,7 +132,7 @@ public class ConditionMessageTests {
} }
@Test @Test
public void foundWhenSingleElementShouldUsingSingular() throws Exception { public void foundWhenSingleElementShouldUseSingular() 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 {
} }
@Test @Test
public void didNotFindWhenSingleElementShouldUsingSingular() throws Exception { public void didNotFindWhenSingleElementShouldUseSingular() 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");

@ -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 and initialized.
* *
* @author Phillip Webb * @author Phillip Webb
* @see ConditionalOnInitializedRestarter * @see ConditionalOnInitializedRestarter
@ -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("Initializer Restarter Condition"); .forCondition("Initialized 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"));

@ -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.
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`:
@ -2614,7 +2614,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,exectuable jar <<appendix-executable-jar-format.adoc#executable-jar-jar-file-structure,executable 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.

@ -5210,7 +5210,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]
---- ----

@ -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 {
} }
@Component
static class ExampleTestComponent {
}
} }

@ -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

@ -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 {

@ -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 {

@ -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 * 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}.

Loading…
Cancel
Save