Commit 383640d5 authored by Phillip Webb's avatar Phillip Webb

Merge branch '1.5.x'

parents 757be57d b2ae6b5f
......@@ -108,7 +108,8 @@ public class HealthMvcEndpointAutoConfigurationTests {
public void endpointConditionalOnMissingBean() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(TestConfiguration.class, TestHealthMvcEndpointConfiguration.class);
this.context.register(TestConfiguration.class,
TestHealthMvcEndpointConfiguration.class);
this.context.refresh();
MockHttpServletRequest request = new MockHttpServletRequest();
Health health = (Health) this.context.getBean(HealthMvcEndpoint.class)
......@@ -141,6 +142,7 @@ public class HealthMvcEndpointAutoConfigurationTests {
public HealthMvcEndpoint endpoint(HealthEndpoint endpoint) {
return new TestHealthMvcEndpoint(endpoint);
}
}
static class TestHealthMvcEndpoint extends HealthMvcEndpoint {
......@@ -150,9 +152,11 @@ public class HealthMvcEndpointAutoConfigurationTests {
}
@Override
protected boolean exposeHealthDetails(HttpServletRequest request, Principal principal) {
protected boolean exposeHealthDetails(HttpServletRequest request,
Principal principal) {
return true;
}
}
static class TestHealthIndicator extends AbstractHealthIndicator {
......
......@@ -20,7 +20,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.springframework.boot.autoconfigure.template.AbstractTemplateAvailabilityProvider;
import org.springframework.boot.autoconfigure.template.PathBasedTemplateAvailabilityProvider;
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
/**
......@@ -31,7 +31,7 @@ import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvi
* @since 1.1.0
*/
public class FreeMarkerTemplateAvailabilityProvider
extends AbstractTemplateAvailabilityProvider {
extends PathBasedTemplateAvailabilityProvider {
public FreeMarkerTemplateAvailabilityProvider() {
super("freemarker.template.Configuration",
......
......@@ -20,7 +20,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.springframework.boot.autoconfigure.template.AbstractTemplateAvailabilityProvider;
import org.springframework.boot.autoconfigure.template.PathBasedTemplateAvailabilityProvider;
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
/**
......@@ -31,7 +31,7 @@ import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvi
* @since 1.1.0
*/
public class GroovyTemplateAvailabilityProvider
extends AbstractTemplateAvailabilityProvider {
extends PathBasedTemplateAvailabilityProvider {
public GroovyTemplateAvailabilityProvider() {
super("groovy.text.TemplateEngine", GroovyTemplateAvailabilityProperties.class,
......
......@@ -27,13 +27,14 @@ import org.springframework.core.io.ResourceLoader;
import org.springframework.util.ClassUtils;
/**
* Abstract base class for {@link TemplateAvailabilityProvider} implementations.
* Abstract base class for {@link TemplateAvailabilityProvider} implementations that find
* templates from paths.
*
* @author Andy Wilkinson
* @author Phillip Webb
* @since 1.4.6
*/
public abstract class AbstractTemplateAvailabilityProvider
public abstract class PathBasedTemplateAvailabilityProvider
implements TemplateAvailabilityProvider {
private final String className;
......@@ -42,7 +43,7 @@ public abstract class AbstractTemplateAvailabilityProvider
private final String propertyPrefix;
public AbstractTemplateAvailabilityProvider(String className,
public PathBasedTemplateAvailabilityProvider(String className,
Class<? extends TemplateAvailabilityProperties> propertiesClass,
String propertyPrefix) {
this.className = className;
......
......@@ -32,6 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* Integration tests for {@link JsonTest}.
*
* @author Phillip Webb
* @author Madhura Bhave
*/
@RunWith(SpringRunner.class)
@JsonTest
......@@ -82,9 +83,9 @@ public class JsonTestIntegrationTests {
ExampleJsonObjectWithView object = new ExampleJsonObjectWithView();
object.setValue("spring");
JsonContent<ExampleJsonObjectWithView> content = this.jacksonWithViewJson
.forView(ExampleJsonObjectWithView.TestView.class)
.write(object);
.forView(ExampleJsonObjectWithView.TestView.class).write(object);
assertThat(content).doesNotHaveJsonPathValue("id");
assertThat(content).isEqualToJson("example.json");
}
}
......@@ -113,6 +113,10 @@ public abstract class AbstractJsonMarshalTester<T> {
return this.type;
}
/**
* Return class used to load relative resources.
* @return the resource load class
*/
protected final Class<?> getResourceLoadClass() {
return this.resourceLoadClass;
}
......
......@@ -152,13 +152,14 @@ public class JacksonTester<T> extends AbstractJsonMarshalTester<T> {
}
/**
* Returns a new instance of {@link JacksonTester} with the view
* that should be used for json serialization/deserialization.
* Returns a new instance of {@link JacksonTester} with the view that should be used
* for json serialization/deserialization.
* @param view the view class
* @return the new instance
*/
public JacksonTester<T> forView(Class<?> view) {
return new JacksonTester<T>(this.getResourceLoadClass(), this.getType(), this.objectMapper, view);
return new JacksonTester<T>(this.getResourceLoadClass(), this.getType(),
this.objectMapper, view);
}
/**
......
......@@ -35,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* Integration tests for {@link JacksonTester}. Shows typical usage.
*
* @author Phillip Webb
* @author Madhura Bhave
*/
public class JacksonTesterIntegrationTests {
......@@ -56,6 +57,13 @@ public class JacksonTesterIntegrationTests {
JacksonTester.initFields(this, this.objectMapper);
}
@Test
public void typicalTest() throws Exception {
String example = JSON;
assertThat(this.simpleJson.parse(example).getObject().getName())
.isEqualTo("Spring");
}
@Test
public void typicalListTest() throws Exception {
String example = "[" + JSON + "]";
......@@ -79,10 +87,9 @@ public class JacksonTesterIntegrationTests {
ExampleObjectWithView object = new ExampleObjectWithView();
object.setName("Spring");
object.setAge(123);
JsonContent<ExampleObjectWithView> content = this.jsonWithView.forView(
ExampleObjectWithView.TestView.class).write(object);
assertThat(content).extractingJsonPathStringValue("@.name")
.isEqualTo("Spring");
JsonContent<ExampleObjectWithView> content = this.jsonWithView
.forView(ExampleObjectWithView.TestView.class).write(object);
assertThat(content).extractingJsonPathStringValue("@.name").isEqualTo("Spring");
assertThat(content).doesNotHaveJsonPathValue("age");
}
......@@ -90,10 +97,9 @@ public class JacksonTesterIntegrationTests {
public void readWithResourceAndView() throws Exception {
this.objectMapper.disable(MapperFeature.DEFAULT_VIEW_INCLUSION);
ByteArrayResource resource = new ByteArrayResource(JSON.getBytes());
ObjectContent<ExampleObjectWithView> content = this.jsonWithView.forView(
ExampleObjectWithView.TestView.class).read(resource);
assertThat(content.getObject().getName())
.isEqualTo("Spring");
ObjectContent<ExampleObjectWithView> content = this.jsonWithView
.forView(ExampleObjectWithView.TestView.class).read(resource);
assertThat(content.getObject().getName()).isEqualTo("Spring");
assertThat(content.getObject().getAge()).isEqualTo(0);
}
......@@ -101,10 +107,9 @@ public class JacksonTesterIntegrationTests {
public void readWithReaderAndView() throws Exception {
this.objectMapper.disable(MapperFeature.DEFAULT_VIEW_INCLUSION);
Reader reader = new StringReader(JSON);
ObjectContent<ExampleObjectWithView> content = this.jsonWithView.forView(
ExampleObjectWithView.TestView.class).read(reader);
assertThat(content.getObject().getName())
.isEqualTo("Spring");
ObjectContent<ExampleObjectWithView> content = this.jsonWithView
.forView(ExampleObjectWithView.TestView.class).read(reader);
assertThat(content.getObject().getName()).isEqualTo("Spring");
assertThat(content.getObject().getAge()).isEqualTo(0);
}
......
......@@ -33,9 +33,9 @@ public interface SpringApplicationAdminMXBean {
boolean isReady();
/**
* Specify if the application runs in an embedded web container. Return
* {@code false} on a web application that hasn't fully started yet, so it is
* preferable to wait for the application to be {@link #isReady() ready}.
* Specify if the application runs in an embedded web container. Return {@code false}
* on a web application that hasn't fully started yet, so it is preferable to wait for
* the application to be {@link #isReady() ready}.
* @return {@code true} if the application runs in an embedded web container
* @see #isReady()
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment