Formatting and cleanup
This commit is contained in:
@@ -29,7 +29,7 @@ import org.springframework.util.Assert;
|
||||
* <p>
|
||||
* If a different order is required or a new {@link Status} type will be used, the order
|
||||
* can be set by calling {@link #setStatusOrder(List)}.
|
||||
*
|
||||
*
|
||||
* @author Christian Dupuis
|
||||
* @since 1.1.0
|
||||
*/
|
||||
|
||||
@@ -42,7 +42,7 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests for {@link EndpointAutoConfiguration}.
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Phillip Webb
|
||||
* @author Greg Turnquist
|
||||
|
||||
@@ -21,11 +21,11 @@ import java.util.Map;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.actuate.health.DataSourceHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.boot.actuate.health.MongoHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.RabbitHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.RedisHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.DataSourceHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.SolrHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.VanillaHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
|
||||
@@ -41,7 +41,7 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests for {@link HealthIndicatorAutoConfiguration}.
|
||||
*
|
||||
*
|
||||
* @author Christian Dupuis
|
||||
*/
|
||||
public class HealthIndicatorAutoConfigurationTests {
|
||||
@@ -149,8 +149,8 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||
Map<String, HealthIndicator> beans = this.context
|
||||
.getBeansOfType(HealthIndicator.class);
|
||||
assertEquals(1, beans.size());
|
||||
assertEquals(DataSourceHealthIndicator.class, beans.values().iterator()
|
||||
.next().getClass());
|
||||
assertEquals(DataSourceHealthIndicator.class, beans.values().iterator().next()
|
||||
.getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -37,7 +37,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Tests for {@link SolrHealthIndicator}
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class SolrHealthIndicatorTests {
|
||||
|
||||
@@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests for {@link VanillaHealthIndicator}.
|
||||
*
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class VanillaHealthIndicatorTests {
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.data.solr.repository.SolrRepository;
|
||||
* If active auto configuration does the same as
|
||||
* {@link org.springframework.data.solr.repository.config.EnableSolrRepositories} would
|
||||
* do.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @since 1.1.0
|
||||
*/
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for FreeMarker.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Dave Syer
|
||||
* @since 1.1.0
|
||||
|
||||
@@ -47,7 +47,7 @@ import org.springframework.web.servlet.view.velocity.VelocityViewResolver;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Velocity.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
*/
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.junit.Test;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.data.alt.elasticsearch.CityElasticsearchDbRepository;
|
||||
import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.elasticsearch.city.City;
|
||||
import org.springframework.boot.autoconfigure.data.elasticsearch.city.CityRepository;
|
||||
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
|
||||
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.data.alt.mongo.CityMongoDbRepository;
|
||||
import org.springframework.boot.autoconfigure.data.alt.solr.CitySolrRepository;
|
||||
import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.jpa.city.City;
|
||||
import org.springframework.boot.autoconfigure.data.jpa.city.CityRepository;
|
||||
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration.JpaWebConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.jpa.city.City;
|
||||
import org.springframework.boot.autoconfigure.data.jpa.city.CityRepository;
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface CityRepository extends JpaRepository<City, Long> {
|
||||
|
||||
@Override
|
||||
Page<City> findAll(Pageable pageable);
|
||||
|
||||
Page<City> findByNameLikeAndCountryLikeAllIgnoringCase(String name, String country,
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
|
||||
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.data.alt.solr.CitySolrRepository;
|
||||
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
|
||||
import org.springframework.boot.autoconfigure.data.solr.SolrRepositoriesAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.solr.city.City;
|
||||
import org.springframework.boot.autoconfigure.data.solr.city.CityRepository;
|
||||
import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration;
|
||||
|
||||
@@ -26,8 +26,11 @@ import org.springframework.data.solr.core.mapping.SolrDocument;
|
||||
@SolrDocument(solrCoreName = "collection1")
|
||||
public class City {
|
||||
|
||||
private @Id String id;
|
||||
private @Indexed String name;
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
@Indexed
|
||||
private String name;
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
|
||||
@@ -16,11 +16,6 @@
|
||||
|
||||
package org.springframework.boot.autoconfigure.jdbc;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.sql.Connection;
|
||||
@@ -50,6 +45,11 @@ import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests for {@link DataSourceAutoConfiguration}.
|
||||
*
|
||||
@@ -70,7 +70,7 @@ public class DataSourceAutoConfigurationTests {
|
||||
@After
|
||||
public void restore() {
|
||||
EmbeddedDatabaseConnection.override = null;
|
||||
if (context!=null) {
|
||||
if (context != null) {
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
@@ -264,6 +264,7 @@ public class DataSourceAutoConfigurationTests {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
|
||||
return Mockito.mock(Logger.class);
|
||||
}
|
||||
|
||||
@@ -207,8 +207,7 @@ public class JmsAutoConfigurationTests {
|
||||
Class<?>... additionalClasses) {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.register(additionalClasses);
|
||||
context.register(ActiveMQAutoConfiguration.class,
|
||||
JmsAutoConfiguration.class);
|
||||
context.register(ActiveMQAutoConfiguration.class, JmsAutoConfiguration.class);
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.boot.autoconfigure.jms.activemq;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQProperties;
|
||||
import org.springframework.boot.test.EnvironmentTestUtils;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@ package org.springframework.boot.autoconfigure.jms.hornetq;
|
||||
import org.hornetq.core.config.Configuration;
|
||||
import org.hornetq.core.server.JournalType;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.autoconfigure.jms.hornetq.HornetQEmbeddedConfigurationFactory;
|
||||
import org.springframework.boot.autoconfigure.jms.hornetq.HornetQProperties;
|
||||
|
||||
import static org.hamcrest.Matchers.endsWith;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
@@ -33,7 +33,7 @@ import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link HibernateJpaAutoConfiguration}.
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
|
||||
@@ -106,7 +106,7 @@ public class RunCommand extends OptionParsingCommand {
|
||||
this.runner = new SpringApplicationRunner(configuration,
|
||||
sourceOptions.getSourcesArray(), sourceOptions.getArgsArray());
|
||||
this.runner.compileAndRun();
|
||||
|
||||
|
||||
return ExitStatus.OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,8 @@ public abstract class AstUtils {
|
||||
String... annotations) {
|
||||
for (AnnotationNode annotationNode : node.getAnnotations()) {
|
||||
for (String annotation : annotations) {
|
||||
if (PatternMatchUtils.simpleMatch(annotation, annotationNode.getClassNode().getName())) {
|
||||
if (PatternMatchUtils.simpleMatch(annotation, annotationNode
|
||||
.getClassNode().getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.springframework.boot.cli.compiler.grape.DependencyResolutionContext;
|
||||
* <p>
|
||||
* This class provides a fluent API for conditionally adding dependencies. For example:
|
||||
* {@code dependencies.ifMissing("com.corp.SomeClass").add(module)}.
|
||||
*
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
|
||||
@@ -265,7 +265,8 @@ public class GroovyCompiler {
|
||||
public void call(SourceUnit source, GeneratorContext context, ClassNode classNode)
|
||||
throws CompilationFailedException {
|
||||
|
||||
ImportCustomizer importCustomizer = new SmartImportCustomizer(source, context, classNode);
|
||||
ImportCustomizer importCustomizer = new SmartImportCustomizer(source,
|
||||
context, classNode);
|
||||
ClassNode mainClassNode = getMainClass(source.getAST().getClasses());
|
||||
|
||||
// Additional auto configuration
|
||||
|
||||
@@ -42,10 +42,8 @@ public class JUnitCompilerAutoConfiguration extends CompilerAutoConfiguration {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyImports(ImportCustomizer imports)
|
||||
throws CompilationFailedException {
|
||||
imports.addStarImports("org.junit")
|
||||
.addStaticStars("org.junit.Assert")
|
||||
public void applyImports(ImportCustomizer imports) throws CompilationFailedException {
|
||||
imports.addStarImports("org.junit").addStaticStars("org.junit.Assert")
|
||||
.addStaticStars("org.hamcrest.MatcherAssert")
|
||||
.addStaticStars("org.hamcrest.Matchers");
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ReactorCompilerAutoConfiguration extends CompilerAutoConfiguration
|
||||
public void applyImports(ImportCustomizer imports) {
|
||||
imports.addImports("reactor.core.Reactor", "reactor.core.spec.Reactors",
|
||||
"reactor.core.Observable", "reactor.event.Event",
|
||||
"reactor.function.Functions", "reactor.function.Predicates",
|
||||
"reactor.function.Functions", "reactor.function.Predicates",
|
||||
"reactor.function.Suppliers",
|
||||
"reactor.spring.context.annotation.Consumer",
|
||||
"reactor.spring.context.annotation.Selector",
|
||||
|
||||
@@ -45,8 +45,10 @@ public class SpringBootCompilerAutoConfiguration extends CompilerAutoConfigurati
|
||||
|
||||
@Override
|
||||
public void applyImports(ImportCustomizer imports) {
|
||||
imports.addImports("javax.annotation.PostConstruct",
|
||||
"javax.annotation.PreDestroy", "groovy.util.logging.Log",
|
||||
imports.addImports(
|
||||
"javax.annotation.PostConstruct",
|
||||
"javax.annotation.PreDestroy",
|
||||
"groovy.util.logging.Log",
|
||||
"org.springframework.stereotype.Controller",
|
||||
"org.springframework.stereotype.Service",
|
||||
"org.springframework.stereotype.Component",
|
||||
|
||||
@@ -50,8 +50,7 @@ public class SpringMvcCompilerAutoConfiguration extends CompilerAutoConfiguratio
|
||||
public void applyImports(ImportCustomizer imports) {
|
||||
imports.addStarImports("org.springframework.web.bind.annotation",
|
||||
"org.springframework.web.servlet.config.annotation",
|
||||
"org.springframework.web.servlet",
|
||||
"org.springframework.http",
|
||||
"org.springframework.web.servlet", "org.springframework.http",
|
||||
"org.springframework.web.servlet.handler", "org.springframework.http",
|
||||
"org.springframework.ui", "groovy.text");
|
||||
imports.addStaticImport(GroovyTemplate.class.getName(), "template");
|
||||
|
||||
@@ -23,7 +23,7 @@ package org.springframework.boot.cli.compiler.dependencies;
|
||||
* the relevant piece from the identifier. Alternatively the identifier may be in the form
|
||||
* {@code artifactId}, in which case coordinate resolution uses implementation-specific
|
||||
* metadata to resolve the groupId and version.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public interface ArtifactCoordinatesResolver {
|
||||
|
||||
@@ -48,7 +48,7 @@ import org.eclipse.aether.util.filter.DependencyFilterUtils;
|
||||
* A {@link GrapeEngine} implementation that uses <a
|
||||
* href="http://eclipse.org/aether">Aether</a>, the dependency resolution system used by
|
||||
* Maven.
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
|
||||
@@ -27,8 +27,7 @@ import org.springframework.boot.dependency.tools.ManagedDependencies;
|
||||
import org.springframework.boot.dependency.tools.PomDependencies;
|
||||
|
||||
/**
|
||||
* Factory to create Maven {@link Dependency} objects from Boot
|
||||
* {@link PomDependencies}.
|
||||
* Factory to create Maven {@link Dependency} objects from Boot {@link PomDependencies}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
|
||||
@@ -55,8 +55,8 @@ public abstract class GroovyTemplate {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private static Template getTemplate(TemplateEngine engine, String name) throws CompilationFailedException,
|
||||
ClassNotFoundException, IOException {
|
||||
private static Template getTemplate(TemplateEngine engine, String name)
|
||||
throws CompilationFailedException, ClassNotFoundException, IOException {
|
||||
|
||||
File file = new File("templates", name);
|
||||
if (file.exists()) {
|
||||
|
||||
@@ -39,7 +39,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Tests for {@link DependencyCustomizer}
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class DependencyCustomizerTests {
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.boot.dependency.tools.ManagedDependencies;
|
||||
|
||||
/**
|
||||
* Tests for using the Gradle plugin's support for custom version management
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class CustomVersionManagementTests {
|
||||
|
||||
@@ -22,21 +22,21 @@ import org.springframework.boot.dependency.tools.ManagedDependencies;
|
||||
|
||||
/**
|
||||
* Tests for using the Gradle plugin's support for installing artifacts
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class InstallTests {
|
||||
|
||||
private ProjectConnection project;
|
||||
|
||||
private static final String BOOT_VERSION = ManagedDependencies.get().find(
|
||||
"spring-boot").getVersion();
|
||||
private static final String BOOT_VERSION = ManagedDependencies.get()
|
||||
.find("spring-boot").getVersion();
|
||||
|
||||
@Test
|
||||
public void cleanInstall() throws Exception {
|
||||
project = new ProjectCreator().createProject("installer");
|
||||
project.newBuild().forTasks("install").withArguments(
|
||||
"-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
|
||||
project.newBuild().forTasks("install")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -44,8 +44,9 @@ public class InstallTests {
|
||||
project = new ProjectCreator().createProject("install-app");
|
||||
// "install" from the application plugin was renamed "installApp" in Gradle
|
||||
// 1.0
|
||||
project.newBuild().forTasks("installApp").withArguments(
|
||||
"-PbootVersion=" + BOOT_VERSION, "--stacktrace", "--info").run();
|
||||
project.newBuild().forTasks("installApp")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace", "--info")
|
||||
.run();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.boot.dependency.tools.ManagedDependencies;
|
||||
|
||||
/**
|
||||
* Tests for using the Gradle plugin's support for installing artifacts
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class MainClassTests {
|
||||
@@ -42,7 +42,8 @@ public class MainClassTests {
|
||||
|
||||
@Test
|
||||
public void buildFromRunTask() {
|
||||
project.newBuild().forTasks("build").withArguments("-PbootVersion=" + BOOT_VERSION, "--info").run();
|
||||
project.newBuild().forTasks("build")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION, "--info").run();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
package org.springframework.boot.gradle;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.gradle.tooling.ProjectConnection;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.dependency.tools.ManagedDependencies;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
/**
|
||||
* Tests for using the Gradle plugin's support for flat directory repos
|
||||
*
|
||||
|
||||
@@ -38,7 +38,7 @@ import static org.junit.Assert.fail;
|
||||
/**
|
||||
* Tests for the various starter projects to check that they don't pull in unwanted
|
||||
* transitive dependencies when used with Gradle
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
|
||||
package sample.actuator;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -34,6 +30,10 @@ import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Integration tests for endpoints configuration.
|
||||
*
|
||||
@@ -42,7 +42,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = SampleActuatorApplication.class)
|
||||
@WebAppConfiguration
|
||||
@IntegrationTest({"server.port=0", "management.context_path=/admin"})
|
||||
@IntegrationTest({ "server.port=0", "management.context_path=/admin" })
|
||||
@DirtiesContext
|
||||
public class ManagementPathSampleActuatorApplicationTests {
|
||||
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
|
||||
package sample.actuator;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -34,6 +30,10 @@ import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Integration tests for endpoints configuration.
|
||||
*
|
||||
@@ -42,7 +42,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = SampleActuatorApplication.class)
|
||||
@WebAppConfiguration
|
||||
@IntegrationTest({"server.port=0", "server.servletPath=/spring"})
|
||||
@IntegrationTest({ "server.port=0", "server.servletPath=/spring" })
|
||||
@DirtiesContext
|
||||
public class ServletPathSampleActuatorApplicationTests {
|
||||
|
||||
@@ -53,7 +53,8 @@ public class ServletPathSampleActuatorApplicationTests {
|
||||
public void testErrorPath() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = new TestRestTemplate("user", "password")
|
||||
.getForEntity("http://localhost:" + this.port + "/spring/error", Map.class);
|
||||
.getForEntity("http://localhost:" + this.port + "/spring/error",
|
||||
Map.class);
|
||||
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, entity.getStatusCode());
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> body = entity.getBody();
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
|
||||
package sample.actuator;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -33,6 +30,9 @@ import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
/**
|
||||
* Integration tests for unsecured service endpoints (even with Spring Security on
|
||||
* classpath).
|
||||
@@ -42,7 +42,8 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = SampleActuatorApplication.class)
|
||||
@WebAppConfiguration
|
||||
@IntegrationTest({ "server.port:0", "security.basic.enabled:false", "server.servletPath:/spring" })
|
||||
@IntegrationTest({ "server.port:0", "security.basic.enabled:false",
|
||||
"server.servletPath:/spring" })
|
||||
@DirtiesContext
|
||||
public class ServletPathUnsecureSampleActuatorApplicationTests {
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package sample.data.elasticsearch;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.net.ConnectException;
|
||||
|
||||
import org.junit.Rule;
|
||||
@@ -25,9 +23,11 @@ import org.junit.Test;
|
||||
import org.springframework.boot.test.OutputCapture;
|
||||
import org.springframework.core.NestedCheckedException;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests for {@link SampleElasticsearchApplication}.
|
||||
*
|
||||
*
|
||||
* @author Artur Konczak
|
||||
*/
|
||||
public class SampleElasticsearchApplicationTests {
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
|
||||
package sample.ui.secure;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -42,6 +38,10 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Basic integration tests for demo application.
|
||||
*
|
||||
@@ -65,8 +65,8 @@ public class SampleSecureApplicationTests {
|
||||
"http://localhost:" + this.port, HttpMethod.GET, new HttpEntity<Void>(
|
||||
headers), String.class);
|
||||
assertEquals(HttpStatus.FOUND, entity.getStatusCode());
|
||||
assertTrue("Wrong location:\n" + entity.getHeaders(),
|
||||
entity.getHeaders().getLocation().toString().endsWith(port + "/login"));
|
||||
assertTrue("Wrong location:\n" + entity.getHeaders(), entity.getHeaders()
|
||||
.getLocation().toString().endsWith(port + "/login"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -74,8 +74,8 @@ public class SampleSecureApplicationTests {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
|
||||
ResponseEntity<String> entity = new TestRestTemplate().exchange(
|
||||
"http://localhost:" + this.port + "/login", HttpMethod.GET, new HttpEntity<Void>(
|
||||
headers), String.class);
|
||||
"http://localhost:" + this.port + "/login", HttpMethod.GET,
|
||||
new HttpEntity<Void>(headers), String.class);
|
||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||
assertTrue("Wrong content:\n" + entity.getBody(),
|
||||
entity.getBody().contains("_csrf"));
|
||||
@@ -94,8 +94,8 @@ public class SampleSecureApplicationTests {
|
||||
new HttpEntity<MultiValueMap<String, String>>(form, headers),
|
||||
String.class);
|
||||
assertEquals(HttpStatus.FOUND, entity.getStatusCode());
|
||||
assertTrue("Wrong location:\n" + entity.getHeaders(),
|
||||
entity.getHeaders().getLocation().toString().endsWith(port + "/"));
|
||||
assertTrue("Wrong location:\n" + entity.getHeaders(), entity.getHeaders()
|
||||
.getLocation().toString().endsWith(port + "/"));
|
||||
assertNotNull("Missing cookie:\n" + entity.getHeaders(),
|
||||
entity.getHeaders().get("Set-Cookie"));
|
||||
}
|
||||
@@ -107,8 +107,8 @@ public class SampleSecureApplicationTests {
|
||||
assertEquals(HttpStatus.OK, page.getStatusCode());
|
||||
String cookie = page.getHeaders().getFirst("Set-Cookie");
|
||||
headers.set("Cookie", cookie);
|
||||
Matcher matcher = Pattern.compile("(?s).*name=\"_csrf\".*?value=\"([^\"]+).*").matcher(
|
||||
page.getBody());
|
||||
Matcher matcher = Pattern.compile("(?s).*name=\"_csrf\".*?value=\"([^\"]+).*")
|
||||
.matcher(page.getBody());
|
||||
assertTrue("No csrf token: " + page.getBody(), matcher.matches());
|
||||
headers.set("X-CSRF-TOKEN", matcher.group(1));
|
||||
return headers;
|
||||
|
||||
@@ -23,9 +23,9 @@ import java.util.Properties;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* {@link Dependencies} backed by an external properties file (of the form created
|
||||
* by the Spring IO platform). The property key should be the groupId and artifactId (in
|
||||
* the form {@literal groupId:artifactId}) and the value should be the version.
|
||||
* {@link Dependencies} backed by an external properties file (of the form created by the
|
||||
* Spring IO platform). The property key should be the groupId and artifactId (in the form
|
||||
* {@literal groupId:artifactId}) and the value should be the version.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 1.1.0
|
||||
@@ -33,8 +33,8 @@ import java.util.TreeMap;
|
||||
public class PropertiesFileDependencies extends AbstractDependencies {
|
||||
|
||||
/**
|
||||
* Create a new {@link PropertiesFileDependencies} instance from the specified
|
||||
* input stream.
|
||||
* Create a new {@link PropertiesFileDependencies} instance from the specified input
|
||||
* stream.
|
||||
* @param inputStream source input stream (will be closed when properties have been
|
||||
* loaded)
|
||||
* @throws IOException
|
||||
|
||||
@@ -110,7 +110,8 @@ class JarURLConnection extends java.net.JarURLConnection {
|
||||
this.connected = true;
|
||||
}
|
||||
|
||||
private void throwFileNotFound(Object entry, JarFile jarFile) throws FileNotFoundException {
|
||||
private void throwFileNotFound(Object entry, JarFile jarFile)
|
||||
throws FileNotFoundException {
|
||||
if (Boolean.TRUE.equals(useFastExceptions.get())) {
|
||||
throw FILE_NOT_FOUND_EXCEPTION;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Tests for {@link ExecutableArchiveLauncher}
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class ExecutableArchiveLauncherTests {
|
||||
@@ -74,16 +74,17 @@ public class ExecutableArchiveLauncherTests {
|
||||
|
||||
when(this.javaAgentDetector.isJavaAgentJar(javaAgent)).thenReturn(true);
|
||||
|
||||
doWithTccl(new URLClassLoader(new URL[] { javaAgent, one }), new Callable<Void>() {
|
||||
doWithTccl(new URLClassLoader(new URL[] { javaAgent, one }),
|
||||
new Callable<Void>() {
|
||||
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
ClassLoader classLoader = ExecutableArchiveLauncherTests.this.launcher
|
||||
.createClassLoader(new URL[0]);
|
||||
assertClassLoaderUrls(classLoader, new URL[] { one });
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
ClassLoader classLoader = ExecutableArchiveLauncherTests.this.launcher
|
||||
.createClassLoader(new URL[0]);
|
||||
assertClassLoaderUrls(classLoader, new URL[] { one });
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void assertClassLoaderUrls(ClassLoader classLoader, URL[] urls) {
|
||||
@@ -92,7 +93,7 @@ public class ExecutableArchiveLauncherTests {
|
||||
}
|
||||
|
||||
private static final class UnitTestExecutableArchiveLauncher extends
|
||||
ExecutableArchiveLauncher {
|
||||
ExecutableArchiveLauncher {
|
||||
|
||||
public UnitTestExecutableArchiveLauncher(JavaAgentDetector javaAgentDetector) {
|
||||
super(javaAgentDetector);
|
||||
|
||||
@@ -28,7 +28,7 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests for {@link InputArgumentsJavaAgentDetector}
|
||||
*
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class InputArgumentsJavaAgentDetectorTests {
|
||||
@@ -39,7 +39,7 @@ public class InputArgumentsJavaAgentDetectorTests {
|
||||
InputArgumentsJavaAgentDetector detector = new InputArgumentsJavaAgentDetector(
|
||||
Arrays.asList("-javaagent:my-agent.jar"));
|
||||
assertFalse(detector.isJavaAgentJar(new File("something-else.jar")
|
||||
.getCanonicalFile().toURI().toURL()));
|
||||
.getCanonicalFile().toURI().toURL()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -78,16 +78,15 @@ public class JarFileArchiveTests {
|
||||
@Test
|
||||
public void getUrl() throws Exception {
|
||||
URL url = this.archive.getUrl();
|
||||
assertThat(url.toString(), equalTo("jar:" + this.rootJarFileUrl
|
||||
+ "!/"));
|
||||
assertThat(url.toString(), equalTo("jar:" + this.rootJarFileUrl + "!/"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNestedArchive() throws Exception {
|
||||
Entry entry = getEntriesMap(this.archive).get("nested.jar");
|
||||
Archive nested = this.archive.getNestedArchive(entry);
|
||||
assertThat(nested.getUrl().toString(),
|
||||
equalTo("jar:" + this.rootJarFileUrl + "!/nested.jar!/"));
|
||||
assertThat(nested.getUrl().toString(), equalTo("jar:" + this.rootJarFileUrl
|
||||
+ "!/nested.jar!/"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -151,9 +151,9 @@ public class LoggingApplicationListener implements SmartApplicationListener {
|
||||
// Logback won't read backslashes so add a clean path for it to use
|
||||
if (!StringUtils.hasLength(System.getProperty("LOG_TEMP"))) {
|
||||
String path = System.getProperty("java.io.tmpdir");
|
||||
path = StringUtils.cleanPath(path);
|
||||
if(path.endsWith("/")) {
|
||||
path = path.substring(0,path.length()-1);
|
||||
path = StringUtils.cleanPath(path);
|
||||
if (path.endsWith("/")) {
|
||||
path = path.substring(0, path.length() - 1);
|
||||
}
|
||||
System.setProperty("LOG_TEMP", path);
|
||||
}
|
||||
|
||||
@@ -86,10 +86,11 @@ public class LoggingApplicationListenerTests {
|
||||
}
|
||||
|
||||
private String tmpDir() {
|
||||
String path = this.context.getEnvironment().resolvePlaceholders("${java.io.tmpdir}");
|
||||
String path = this.context.getEnvironment().resolvePlaceholders(
|
||||
"${java.io.tmpdir}");
|
||||
path = path.replace("\\", "/");
|
||||
if(path.endsWith("/")) {
|
||||
path = path.substring(0, path.length()-1);
|
||||
if (path.endsWith("/")) {
|
||||
path = path.substring(0, path.length() - 1);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user