Polish
This commit is contained in:
parent
fffc6f5dd2
commit
2f16a01dd5
|
|
@ -97,13 +97,17 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
|
|||
EnvironmentEndpoint report = getEndpointBean();
|
||||
Map<String, Object> env = report.invoke();
|
||||
assertEquals("******",
|
||||
((Map<String, Object>) env.get("systemProperties")).get("my.services.amqp-free.credentials.uri"));
|
||||
((Map<String, Object>) env.get("systemProperties"))
|
||||
.get("my.services.amqp-free.credentials.uri"));
|
||||
assertEquals("******",
|
||||
((Map<String, Object>) env.get("systemProperties")).get("credentials.http_api_uri"));
|
||||
((Map<String, Object>) env.get("systemProperties"))
|
||||
.get("credentials.http_api_uri"));
|
||||
assertEquals("******",
|
||||
((Map<String, Object>) env.get("systemProperties")).get("my.services.cleardb-free.credentials"));
|
||||
((Map<String, Object>) env.get("systemProperties"))
|
||||
.get("my.services.cleardb-free.credentials"));
|
||||
assertEquals("******",
|
||||
((Map<String, Object>) env.get("systemProperties")).get("foo.mycredentials.uri"));
|
||||
((Map<String, Object>) env.get("systemProperties"))
|
||||
.get("foo.mycredentials.uri"));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,10 +22,7 @@ import java.util.Collections;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.mongodb.DB;
|
||||
import com.mongodb.Mongo;
|
||||
import com.mongodb.MongoClient;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
|
|
@ -62,6 +59,10 @@ import org.springframework.util.Assert;
|
|||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.mongodb.DB;
|
||||
import com.mongodb.Mongo;
|
||||
import com.mongodb.MongoClient;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Spring Data's mongo support.
|
||||
* <p>
|
||||
|
|
@ -137,20 +138,10 @@ public class MongoDataAutoConfiguration implements BeanClassLoaderAware {
|
|||
throws ClassNotFoundException {
|
||||
MongoMappingContext context = new MongoMappingContext();
|
||||
context.setInitialEntitySet(getInitialEntitySet(beanFactory));
|
||||
Class<? extends FieldNamingStrategy> fieldNamingStrategyClass = this.properties.
|
||||
getFieldNamingStrategy();
|
||||
if (fieldNamingStrategyClass != null) {
|
||||
try {
|
||||
context.setFieldNamingStrategy(fieldNamingStrategyClass.newInstance());
|
||||
}
|
||||
catch (InstantiationException e) {
|
||||
throw new IllegalArgumentException("Invalid custom FieldNamingStrategy " +
|
||||
"(is it abstract?) '" + fieldNamingStrategyClass.getName() + "'", e);
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
throw new IllegalArgumentException("Invalid custom FieldNamingStrategy " +
|
||||
"(is the constructor accessible?)'" + fieldNamingStrategyClass.getName() + "'", e);
|
||||
}
|
||||
Class<? extends FieldNamingStrategy> strategyClass = this.properties
|
||||
.getFieldNamingStrategy();
|
||||
if (strategyClass != null) {
|
||||
context.setFieldNamingStrategy(BeanUtils.instantiate(strategyClass));
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,7 +133,8 @@ public class MongoProperties {
|
|||
return this.fieldNamingStrategy;
|
||||
}
|
||||
|
||||
public void setFieldNamingStrategy(Class<? extends FieldNamingStrategy> fieldNamingStrategy) {
|
||||
public void setFieldNamingStrategy(
|
||||
Class<? extends FieldNamingStrategy> fieldNamingStrategy) {
|
||||
this.fieldNamingStrategy = fieldNamingStrategy;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,23 +35,21 @@ public class JspTemplateAvailabilityProvider implements TemplateAvailabilityProv
|
|||
public boolean isTemplateAvailable(String view, Environment environment,
|
||||
ClassLoader classLoader, ResourceLoader resourceLoader) {
|
||||
if (ClassUtils.isPresent("org.apache.jasper.compiler.JspConfig", classLoader)) {
|
||||
String prefix = getProperty(environment, "spring.mvc.view.prefix", "spring.view.prefix",
|
||||
WebMvcAutoConfiguration.DEFAULT_PREFIX);
|
||||
String suffix = getProperty(environment, "spring.mvc.view.suffix", "spring.view.suffix",
|
||||
WebMvcAutoConfiguration.DEFAULT_SUFFIX);
|
||||
String prefix = getProperty(environment, "spring.mvc.view.prefix",
|
||||
"spring.view.prefix", WebMvcAutoConfiguration.DEFAULT_PREFIX);
|
||||
String suffix = getProperty(environment, "spring.mvc.view.suffix",
|
||||
"spring.view.suffix", WebMvcAutoConfiguration.DEFAULT_SUFFIX);
|
||||
return resourceLoader.getResource(prefix + view + suffix).exists();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String getProperty(Environment environment, String key, String deprecatedKey, String defaultValue) {
|
||||
private String getProperty(Environment environment, String key, String deprecatedKey,
|
||||
String defaultValue) {
|
||||
if (environment.containsProperty(key)) {
|
||||
return environment.getProperty(key);
|
||||
}
|
||||
if (environment.containsProperty(deprecatedKey)) {
|
||||
return environment.getProperty(deprecatedKey);
|
||||
}
|
||||
return defaultValue;
|
||||
return environment.getProperty(deprecatedKey, defaultValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ public class WebMvcProperties {
|
|||
private String suffix;
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
return this.prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
|
|
@ -139,11 +139,13 @@ public class WebMvcProperties {
|
|||
}
|
||||
|
||||
public String getSuffix() {
|
||||
return suffix;
|
||||
return this.suffix;
|
||||
}
|
||||
|
||||
public void setSuffix(String suffix) {
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import org.hamcrest.Matchers;
|
|||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.mongo.city.City;
|
||||
|
|
@ -41,7 +42,6 @@ import org.springframework.data.mongodb.gridfs.GridFsTemplate;
|
|||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.mongodb.Mongo;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -124,11 +124,12 @@ public class MongoDataAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void interfaceFieldNamingStrategy() {
|
||||
thrown.expectMessage("Invalid custom FieldNamingStrategy");
|
||||
this.thrown.expectMessage("Invalid custom FieldNamingStrategy");
|
||||
testFieldNamingStrategy(FieldNamingStrategy.class.getName(), null);
|
||||
}
|
||||
|
||||
public void testFieldNamingStrategy(String strategy, Class<? extends FieldNamingStrategy> expectedType) {
|
||||
public void testFieldNamingStrategy(String strategy,
|
||||
Class<? extends FieldNamingStrategy> expectedType) {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
if (strategy != null) {
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
|
|
@ -137,9 +138,10 @@ public class MongoDataAutoConfigurationTests {
|
|||
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
MongoMappingContext mappingContext = this.context.getBean(MongoMappingContext.class);
|
||||
FieldNamingStrategy fieldNamingStrategy =
|
||||
(FieldNamingStrategy) ReflectionTestUtils.getField(mappingContext, "fieldNamingStrategy");
|
||||
MongoMappingContext mappingContext = this.context
|
||||
.getBean(MongoMappingContext.class);
|
||||
FieldNamingStrategy fieldNamingStrategy = (FieldNamingStrategy) ReflectionTestUtils
|
||||
.getField(mappingContext, "fieldNamingStrategy");
|
||||
assertEquals(expectedType, fieldNamingStrategy.getClass());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ import org.apache.maven.plugins.annotations.Parameter;
|
|||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.shared.artifact.filter.collection.AbstractArtifactFeatureFilter;
|
||||
import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts;
|
||||
|
||||
import org.springframework.boot.loader.tools.FileUtils;
|
||||
import org.springframework.boot.loader.tools.MainClassFinder;
|
||||
|
||||
|
|
@ -349,7 +348,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
|
|||
|
||||
private void addDependencies(List<URL> urls) throws MalformedURLException,
|
||||
MojoExecutionException {
|
||||
FilterArtifacts filters = this.useTestClasspath ? getFilters() : getFilters(new TestArtifactFilter());
|
||||
FilterArtifacts filters = this.useTestClasspath ? getFilters()
|
||||
: getFilters(new TestArtifactFilter());
|
||||
Set<Artifact> artifacts = filterDependencies(this.project.getArtifacts(), filters);
|
||||
for (Artifact artifact : artifacts) {
|
||||
if (artifact.getFile() != null) {
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ mvn spring-boot:run
|
|||
in such a way that any dependency that is excluded in the plugin's configuration gets excluded
|
||||
from the classpath as well. See {{{./examples/exclude-dependency.html}Exclude a dependency}} for
|
||||
more details.
|
||||
|
||||
|
||||
Sometimes it is useful to include test dependencies when running the application. For example,
|
||||
if you want to run your application in a test mode that uses stub classes. If you wish to do this,
|
||||
you can set the <<<useTestClasspath>>> parameter to true. Note that this is only applied when you
|
||||
|
|
|
|||
Loading…
Reference in New Issue