Apply source cleanup and formatting

pull/236/head
Phillip Webb 11 years ago
parent 80f2336f17
commit ed9735361e

@ -22,9 +22,9 @@ import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.endpoint.AutoConfigurationReportEndpoint.Report;
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport.ConditionAndOutcome;
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport.ConditionAndOutcomes;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Condition;
import org.springframework.util.ClassUtils;

@ -31,7 +31,8 @@ public class MetricCopyExporterTests {
private final InMemoryMetricRepository writer = new InMemoryMetricRepository();
private final InMemoryMetricRepository reader = new InMemoryMetricRepository();
private final MetricCopyExporter exporter = new MetricCopyExporter(this.reader, this.writer);
private final MetricCopyExporter exporter = new MetricCopyExporter(this.reader,
this.writer);
@Test
public void export() {

@ -31,7 +31,8 @@ public class RichGaugeExporterTests {
private final InMemoryRichGaugeRepository reader = new InMemoryRichGaugeRepository();
private final InMemoryMetricRepository writer = new InMemoryMetricRepository();
private final RichGaugeExporter exporter = new RichGaugeExporter(this.reader, this.writer);
private final RichGaugeExporter exporter = new RichGaugeExporter(this.reader,
this.writer);
@Test
public void prefixedMetricsCopied() {

@ -30,7 +30,8 @@ public class DefaultCounterServiceTests {
private final MetricWriter repository = mock(MetricWriter.class);
private final DefaultCounterService service = new DefaultCounterService(this.repository);
private final DefaultCounterService service = new DefaultCounterService(
this.repository);
@Test
public void incrementPrependsCounter() {

@ -21,7 +21,7 @@ import java.util.List;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
@ -65,7 +65,7 @@ public abstract class AutoConfigurationPackages {
beanDefinition.setBeanClass(BasePackage.class);
beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(0,
packageName);
beanDefinition.setRole(AbstractBeanDefinition.ROLE_INFRASTRUCTURE);
beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
registry.registerBeanDefinition(BEAN, beanDefinition);
}

@ -76,8 +76,8 @@ public abstract class SpringBootCondition implements Condition {
return message;
}
private void recordEvaluation(ConditionContext context,
String classOrMethodName, ConditionOutcome outcome) {
private void recordEvaluation(ConditionContext context, String classOrMethodName,
ConditionOutcome outcome) {
if (context.getBeanFactory() != null) {
ConditionEvaluationReport.get(context.getBeanFactory())
.recordConditionEvaluation(classOrMethodName, this, outcome);

@ -29,8 +29,6 @@ import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport.ConditionAndOutcome;
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport.ConditionAndOutcomes;
import org.springframework.boot.autoconfigure.web.MultipartAutoConfiguration;

@ -32,7 +32,6 @@ import org.mockito.stubbing.Answer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport;
import org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer;
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.event.ApplicationFailedEvent;

@ -16,7 +16,6 @@
package org.springframework.boot.cli.command;
/**
* Exception used to indicate that no arguemnts were specified.
*

@ -31,8 +31,6 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import org.springframework.boot.cli.command.OptionParsingCommand;
import joptsimple.BuiltinHelpFormatter;
import joptsimple.HelpFormatter;
import joptsimple.OptionDescriptor;
@ -40,6 +38,8 @@ import joptsimple.OptionParser;
import joptsimple.OptionSet;
import joptsimple.OptionSpecBuilder;
import org.springframework.boot.cli.command.OptionParsingCommand;
/**
* Delegate used by {@link OptionParsingCommand} to parse options and run the command.
*

@ -18,7 +18,6 @@ package org.springframework.boot.cli.command;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.boot.cli.command.CommandRunner;
import org.springframework.boot.cli.command.run.RunCommand;
import org.springframework.boot.cli.util.OutputCapture;

@ -42,7 +42,6 @@ import org.codehaus.groovy.control.io.ReaderSource;
import org.codehaus.groovy.transform.ASTTransformation;
import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.cli.compiler.ResolveDependencyCoordinatesTransformation;
import org.springframework.boot.cli.compiler.dependencies.ArtifactCoordinatesResolver;
import static org.junit.Assert.assertEquals;

@ -18,7 +18,6 @@ package org.springframework.boot.cli.compiler.dependencies;
import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.cli.compiler.dependencies.ManagedDependenciesArtifactCoordinatesResolver;
import org.springframework.boot.dependency.tools.Dependency;
import org.springframework.boot.dependency.tools.ManagedDependencies;

@ -16,8 +16,6 @@
package sample.data.mongo;
import static org.junit.Assert.assertTrue;
import java.net.ConnectException;
import org.junit.Rule;
@ -25,6 +23,8 @@ import org.junit.Test;
import org.springframework.boot.test.OutputCapture;
import org.springframework.core.NestedCheckedException;
import static org.junit.Assert.assertTrue;
/**
* Tests for {@link SampleMongoApplication}.
*

@ -16,8 +16,6 @@
package sample.secure;
import static org.junit.Assert.assertEquals;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -37,6 +35,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import sample.secure.SampleSecureApplicationTests.TestConfiguration;
import static org.junit.Assert.assertEquals;
/**
* Basic integration tests for demo application.
*
@ -57,9 +57,10 @@ public class SampleSecureApplicationTests {
@Before
public void init() {
AuthenticationManager authenticationManager = context.getBean(AuthenticationManager.class);
authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(
"user", "password"));
AuthenticationManager authenticationManager = context
.getBean(AuthenticationManager.class);
authentication = authenticationManager
.authenticate(new UsernamePasswordAuthenticationToken("user", "password"));
}
@After

@ -38,7 +38,6 @@ import org.springframework.http.client.ClientHttpResponse;
import org.springframework.web.client.DefaultResponseErrorHandler;
import org.springframework.web.client.RestTemplate;
import sample.ui.secure.SampleSecureApplication;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

@ -29,7 +29,7 @@ import org.springframework.boot.gradle.task.RunApp;
/**
* Gradle 'Spring Boot' {@link Plugin}.
*
*
* @author Phillip Webb
* @author Dave Syer
*/
@ -59,7 +59,8 @@ public class SpringBootPlugin implements Plugin<Project> {
private void applyRun(Project project) {
addRunAppTask(project);
// register BootRepackage so that we can use task foo(type: BootRepackage) {}
project.getExtensions().getExtraProperties().set("BootRepackage", Repackage.class);
project.getExtensions().getExtraProperties()
.set("BootRepackage", Repackage.class);
}
private void applyResolutionStrategy(Project project) {
@ -80,14 +81,16 @@ public class SpringBootPlugin implements Plugin<Project> {
+ "archives so that they can be executed from the command "
+ "line using 'java -jar'");
packageTask.setGroup(BasePlugin.BUILD_GROUP);
packageTask.dependsOn(project.getConfigurations().getByName(
Dependency.ARCHIVES_CONFIGURATION).getAllArtifacts().getBuildDependencies());
packageTask.dependsOn(project.getConfigurations()
.getByName(Dependency.ARCHIVES_CONFIGURATION).getAllArtifacts()
.getBuildDependencies());
return packageTask;
}
private void addRunAppTask(Project project) {
RunApp runJarTask = project.getTasks().create(RUN_APP_TASK_NAME, RunApp.class);
runJarTask.setDescription("Run the project with support for auto-detecting main class and reloading static resources");
runJarTask.setDescription("Run the project with support for "
+ "auto-detecting main class and reloading static resources");
runJarTask.setGroup("Execution");
runJarTask.dependsOn("assemble");
}

@ -1,4 +1,3 @@
package org.springframework.boot.gradle;
import org.gradle.api.Action;
@ -11,7 +10,7 @@ import org.springframework.boot.dependency.tools.ManagedDependencies;
/**
* A resolution strategy to resolve missing version numbers using the
* 'spring-boot-dependencies' POM.
*
*
* @author Phillip Webb
*/
public class SpringBootResolutionStrategy {

@ -64,16 +64,18 @@ class ProjectLibraries implements Libraries {
@Override
public void doWithLibraries(LibraryCallback callback) throws IOException {
FileCollection custom = this.customConfigurationName != null ? this.project.getConfigurations().findByName(
this.customConfigurationName)
: null;
FileCollection custom = this.customConfigurationName != null ? this.project
.getConfigurations().findByName(this.customConfigurationName) : null;
if (custom != null) {
libraries(LibraryScope.CUSTOM, custom, callback);
} else {
FileCollection compile = this.project.getConfigurations().getByName("compile");
}
else {
FileCollection compile = this.project.getConfigurations()
.getByName("compile");
FileCollection runtime = this.project.getConfigurations().getByName("runtime");
FileCollection runtime = this.project.getConfigurations()
.getByName("runtime");
runtime = runtime.minus(compile);
FileCollection provided = this.project.getConfigurations().findByName(
@ -98,4 +100,5 @@ class ProjectLibraries implements Libraries {
}
}
}
}

@ -60,7 +60,8 @@ public class Repackage extends DefaultTask {
}
if (this.customConfiguration != null) {
libraries.setCustomConfigurationName(this.customConfiguration);
} else if (extension.getCustomConfiguration() != null) {
}
else if (extension.getCustomConfiguration() != null) {
libraries.setCustomConfigurationName(extension.getCustomConfiguration());
}
project.getTasks().withType(Jar.class, new Action<Jar>() {
@ -85,12 +86,14 @@ public class Repackage extends DefaultTask {
long startTime = System.currentTimeMillis();
try {
return super.findMainMethod(source);
} finally {
}
finally {
long duration = System.currentTimeMillis()
- startTime;
if (duration > FIND_WARNING_TIMEOUT) {
getLogger().warn(
"Searching for the main-class is taking some time, "
getLogger()
.warn("Searching for the "
+ "main-class is taking some time, "
+ "consider using setting 'springBoot.mainClass'");
}
}
@ -103,7 +106,8 @@ public class Repackage extends DefaultTask {
repackager.setBackupSource(extension.isBackupSource());
try {
repackager.repackage(libraries);
} catch (IOException ex) {
}
catch (IOException ex) {
throw new IllegalStateException(ex.getMessage(), ex);
}
}
@ -111,4 +115,5 @@ public class Repackage extends DefaultTask {
}
});
}
}

@ -36,7 +36,7 @@ import org.springframework.boot.loader.tools.MainClassFinder;
/**
* Run the project from Gradle.
*
*
* @author Dave Syer
*/
public class RunApp extends DefaultTask {
@ -54,15 +54,15 @@ public class RunApp extends DefaultTask {
@Override
public void execute(SourceSet set) {
if (SourceSet.MAIN_SOURCE_SET_NAME.equals(set.getName())) {
main = set;
RunApp.this.main = set;
}
};
});
final Set<File> allResources = new LinkedHashSet<File>();
if (main != null) {
SourceDirectorySet resources = main.getResources();
if (this.main != null) {
SourceDirectorySet resources = this.main.getResources();
allResources.addAll(resources.getSrcDirs());
}
@ -70,13 +70,13 @@ public class RunApp extends DefaultTask {
@Override
public void execute(JavaExec exec) {
ArrayList<File> files = new ArrayList<File>(
exec.getClasspath().getFiles());
ArrayList<File> files = new ArrayList<File>(exec.getClasspath()
.getFiles());
files.addAll(0, allResources);
getLogger().info("Adding classpath: " + allResources);
exec.setClasspath(new SimpleFileCollection(files));
if (exec.getMain() == null) {
final String mainClass = findMainClass(main);
final String mainClass = findMainClass(RunApp.this.main);
exec.setMain(mainClass);
exec.getConventionMapping().map("main", new Callable<String>() {
@ -84,6 +84,7 @@ public class RunApp extends DefaultTask {
public String call() throws Exception {
return mainClass;
}
});
getLogger().info("Found main: " + mainClass);
}
@ -100,7 +101,8 @@ public class RunApp extends DefaultTask {
getLogger().info("Looking for main in: " + main.getOutput().getClassesDir());
try {
return MainClassFinder.findMainClass(main.getOutput().getClassesDir());
} catch (IOException ex) {
}
catch (IOException ex) {
throw new IllegalStateException("Cannot find main class", ex);
}
}

@ -24,9 +24,9 @@ import java.util.Set;
import org.springframework.boot.yaml.DefaultProfileDocumentMatcher;
import org.springframework.boot.yaml.SpringProfileDocumentMatcher;
import org.springframework.boot.yaml.YamlPropertiesFactoryBean;
import org.springframework.boot.yaml.YamlProcessor.DocumentMatcher;
import org.springframework.boot.yaml.YamlProcessor.MatchStatus;
import org.springframework.boot.yaml.YamlPropertiesFactoryBean;
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.Resource;
import org.springframework.util.StringUtils;

@ -18,7 +18,6 @@ package org.springframework.boot.cloudfoundry;
import org.junit.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.cloudfoundry.VcapApplicationListener;
import org.springframework.boot.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.context.ConfigurableApplicationContext;

@ -24,9 +24,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.config.ConfigFileApplicationListener;
import org.springframework.boot.config.PropertySourceLoader;
import org.springframework.boot.config.PropertySourceLoadersFactory;
import org.springframework.boot.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.context.ConfigurableApplicationContext;

@ -17,7 +17,6 @@
package org.springframework.boot.context;
import org.junit.Test;
import org.springframework.boot.context.ContextIdApplicationContextInitializer;
import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

@ -19,7 +19,6 @@ package org.springframework.boot.context;
import org.junit.Assume;
import org.junit.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.FileEncodingApplicationListener;
import org.springframework.boot.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.core.env.ConfigurableEnvironment;

@ -19,7 +19,6 @@ package org.springframework.boot.context.env;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.boot.context.env.EnvironmentDelegateApplicationContextInitializer;
import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.context.ApplicationContextException;
import org.springframework.context.ApplicationContextInitializer;

@ -21,7 +21,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.env.EnvironmentDelegateApplicationListener;
import org.springframework.boot.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.context.ApplicationListener;

@ -16,9 +16,6 @@
package org.springframework.boot.json;
import org.springframework.boot.json.JacksonJsonParser;
import org.springframework.boot.json.JsonParser;
/**
* Tests for {@link JsonParser}.
*

@ -20,8 +20,6 @@ import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.springframework.boot.json.JsonParser;
import org.springframework.boot.json.SimpleJsonParser;
import static org.junit.Assert.assertEquals;

@ -16,9 +16,6 @@
package org.springframework.boot.json;
import org.springframework.boot.json.JsonParser;
import org.springframework.boot.json.YamlJsonParser;
/**
* Tests for {@link YamlJsonParser}.
*

@ -30,8 +30,6 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.event.ApplicationStartedEvent;
import org.springframework.boot.logging.LogLevel;
import org.springframework.boot.logging.LoggingApplicationListener;
import org.springframework.boot.logging.java.JavaLoggingSystem;
import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.boot.test.OutputCapture;

@ -20,7 +20,6 @@ import java.io.IOException;
import java.util.Properties;
import org.junit.Test;
import org.springframework.boot.yaml.ArrayDocumentMatcher;
import org.springframework.boot.yaml.YamlProcessor.MatchStatus;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.support.PropertiesLoaderUtils;

@ -22,7 +22,6 @@ import java.util.LinkedHashMap;
import java.util.Map;
import org.junit.Test;
import org.springframework.boot.yaml.YamlMapFactoryBean;
import org.springframework.boot.yaml.YamlProcessor.ResolutionMethod;
import org.springframework.core.io.AbstractResource;
import org.springframework.core.io.ByteArrayResource;

@ -21,7 +21,6 @@ import java.util.Properties;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.boot.yaml.YamlProcessor;
import org.springframework.boot.yaml.YamlProcessor.MatchCallback;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.Resource;

@ -24,7 +24,6 @@ import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.boot.yaml.YamlPropertiesFactoryBean;
import org.springframework.boot.yaml.YamlProcessor.DocumentMatcher;
import org.springframework.boot.yaml.YamlProcessor.MatchStatus;
import org.springframework.boot.yaml.YamlProcessor.ResolutionMethod;

Loading…
Cancel
Save