Commit Graph

7306 Commits (a3bfc29e6e9115a6b4d866c76042d0bf19e853d3)
 

Author SHA1 Message Date
Phillip Webb a3bfc29e6e Fix warnings 9 years ago
Phillip Webb 609704a3bf Polish 9 years ago
Phillip Webb c68e5f12ff Formatting 9 years ago
Phillip Webb faba7a9514 Rename internal OutputCapture classes
Rename the internal versions of OutputCapture to prevent accidental
import.

See gh-5492
9 years ago
Phillip Webb f96cd144dc Remove internal EnvironmentTestUtils
Replace the internal EnvironmentTestUtils using in `spring-boot` tests
with Spring's TestPropertySourceUtils.

Fixes gh-5492
9 years ago
Stephane Nicoll aa171d1945 Merge pull request #5458 from jexp/contrib
* pr/5458:
  Polish contribution
  Add Neo4j support
9 years ago
Stephane Nicoll fd437797b6 Polish contribution
This commit polihes the original Neo4j contribution in several areas.

Rather than providing the packages to scan, this commit rearranges the
`EntityScan` and `EntityScanRegistrar` so that the logic can be shared
for other components. If no package is provided, scanning now defaults to
the "auto-configured" package(s) and a `@NodeEntityScan` annotation
allows to override that.

The configuration has also been updated to detect the driver based on the
`uri` property. If the embedded driver is available we use that by
default. If it is not available, we're trying to connect to a Neo4j
server running on localhost. It is possible to disable the embedded mode
or set the `uri` parameter explicitly to deviate from these defaults.

The sample no longer relies on the embedded driver for licensing reason:
rather it expects an instance running on localhost (like other
data-related samples) and gracefully ignore any connection error. A
README has been added in the sample to further explain the available
options;

Closes gh-5458
9 years ago
Michael Hunger 0658cc8aee Add Neo4j support
See gh-5458
9 years ago
Stephane Nicoll a413acee8b Merge branch '1.3.x' 9 years ago
Stephane Nicoll 422f3d12a3 Merge pull request #5489 from garyrussell/amqp-update13
* pr/5489:
  Upgrade Spring AMQP to 1.5.5.RELEASE
9 years ago
Gary Russell 67cffaebcc Upgrade Spring AMQP to 1.5.5.RELEASE
Closes gh-5489
9 years ago
Andy Wilkinson 13d4409f32 Merge branch '1.3.x' 9 years ago
Andy Wilkinson 86a9fc2f9a Upgrade to Undertow 1.3.19.Final
Closes gh-5264
9 years ago
Andy Wilkinson c42f859390 Ensure that ExplodedArchive lists its file in a consistent order
Closes gh-5422
9 years ago
Andy Wilkinson 209c2cf944 Polishing (again) 9 years ago
Andy Wilkinson 18234ebb26 Polishing 9 years ago
Andy Wilkinson 8a8a06381c Improve location diagnostics in ConfigFileApplicationListener
Closes gh-5486
9 years ago
Andy Wilkinson 1d3b84a5c8 Update Maven plugin's version as part of the release process
Closes gh-5261
9 years ago
Andy Wilkinson c0b74119e0 Use manifest from class’s jar when defining its package
Previously, when defining a package for a class, LaunchedURLClassLoader
would use the manifest from the first location that contained the
required package. If the package was split across multiple locations,
this could lead to the manifest from a jar other than the one that
contains the class being used.

This commit updates LaunchedURLClassLoader so that it will use the
manifest of the jar file that contains the class which triggered the
definition of the package.

Closes gh-5485
9 years ago
Andy Wilkinson 1d099035b1 Protect against a race condition when defining packages
LaunchedURLClassLoader preemptively defines the package for any
classes that it attempts to load so that the manifest from a nested
jar is correctly associated with the package. This can lead to a race
where the package is defined on two threads in parallel, resulting
in an IllegalArgumentException being thrown.

This problem was manifesting itself as a NoClassDefFoundError.
If the initialization of a class failed due to the above-described
IllegalArgumentException, subsequent attempts to use that class
would then fail with a NoClassDefFoundError.

This commit updates LaunchedURLClassLoader to catch the
IllegalArgumentException and then double-check that the package has
already been defined. This approach, including thrown an
AssertionError when the second check fails, is modelled on the
approach taken by URLClassLoader.

Closes gh-5464
9 years ago
Stephane Nicoll 6be92675c2 Remove dependency version from child pom 9 years ago
Stephane Nicoll e8766f21a5 Fix typo 9 years ago
Stephane Nicoll 18d53d1c5b Info contributor documentation
This commit documents the new `InfoContributor` infrastructure.

Closes gh-2559
9 years ago
Andy Wilkinson 58ca9a1c5d Add a BuildInfo task for generating build.properties with Gradle
The commit adds a new BuildInfo task that can be used to generate
a build.properties file, intended for inclusion in the Actuator's
info endpoint.

A default instance of the task can be configure using the plugin's
DSL:

springBoot {
	buildInfo()
}

Additional properties can also be configured using the DSL:

springBoot {
	buildInfo {
		additionalProperties = [
			'foo': 'bar'
		]
	}
}

When configured via the DSL, the Java plugin's classes task is
configured to depend on the build info task. Alternatively, if more
control is required, the task can be declared and configured manually:

task buildInfo(type: org.springframework.boot.gradle.buildinfo.BuildInfo) {
	additionalProperties = [
		'foo': 'bar'
	]
}

classes {
	dependsOn buildInfo
}

See gh-2559
9 years ago
Phillip Webb 4167469781 Attempt to work around couchbase CI failures 9 years ago
Phillip Webb 88f3fa4f78 Document test improvements in 1.4
Closes gh-4901
9 years ago
Phillip Webb 247bdf9c84 Add a new spring-boot-sample-test application
Add a sample application that demonstrates recently added testing
features.

See gh-4901
9 years ago
Phillip Webb 81d5635571 Add @DataJpaTest annotation
Add @DataJpaTest and @AutoConfigureTestDatabase annotations to allow
testing of an application "slice" that only deals JPA.

See gh-4901
9 years ago
Phillip Webb bbc91cc03f Add @WebMvcTest annotation
Add @WebMvcTest and @AutoConfigureMockMvc annotations to allow testing
of an application "slice" that only deals with Spring MVC.

See gh-4901
9 years ago
Phillip Webb 0bd89017b6 Add @JsonTest annotation
Add @JsonTest and @AutoConfigureJsonTesters annotations to allow testing
of an application "slice" that only deals with JSON marshalling.

See gh-4901
9 years ago
Phillip Webb 56fd4e1f76 Add TypeExcludeFilters support
Provide a way for auto-configuration tests to easily filter scanned
components.

See gh-4901
9 years ago
Phillip Webb 46099c753b Add @PropertyMapping support
Add @PropertyMapping annotation which can be used to mark annotation
attributes that should contribute Environment properties.

Provides a quick way for tests to change auto-configuration behavior in
a structured way.

Fixes gh-4901
9 years ago
Phillip Webb e5f224118b Print AutoConfigureReport on test failures
Add a TestExecutionListener to print the auto-configuration report
when a test cannot load.

See gh-4901
9 years ago
Phillip Webb 6d934bb270 Add spring-boot-test-autoconfigure module
Add a new test module to deal with auto-configuration in tests.

See gh-4901
9 years ago
Phillip Webb fb70a56c79 Support override enable auto-configuration
Provide a way for full auto-configuration to be disabled
programmatically. Primarily added to allow special test annotations to
take over partial auto-configuration but still load
@SpringBootApplication classes.

See gh-4901
9 years ago
Phillip Webb 47f801d535 Make @ImportAutoConfiguration a meta-annotation
Update `@ImportAutoConfiguration` so that it can be used as a
meta-annotation. Also relocate it from the `test` package.

Fixes gh-5473
9 years ago
Phillip Webb ae1d352d34 Allow @Import to be used directly on test classes
Remove the need for a nested @Configuration class when writing a test
that need to @Import configuration.

Primarily added to allow @ImportAutoConfiguration to be used directly
on test classes.

Fixes gh-5473
9 years ago
Phillip Webb ab7b48de84 Provide TestRestTemplate for @WebIntegrationTests
Add a ContextCustomizerFactory to provide TestRestTemplate as a bean for
tests annotated with WebIntegrationTests. Additionally provide support
for automatically expanding URLs of the form `/example` to
`http://localhost:${local.server.port}/example`.

Fixes gh-5227
9 years ago
Phillip Webb cbea16ec01 Support HtmlUnit and Selenium localhost resolution
Provide variants of `WebClient` and `WebConnectionHtmlUnitDriver` that
automatically resolve relative URLs to "localhost:${local.server.port}".

Fixes gh-5472
9 years ago
Phillip Webb 24ab2bd891 Add utilities to help with JSON testing
Add Jackson, Gson and Basic String helper classes that allow AssertJ
assertions to be used to test JSON.

Fixes gh-5471
9 years ago
Phillip Webb 45c4f5f3f1 Add @MockBean support
Add a `@MockBean` annotation which can be used to setup and inject mocks
into an application context. The annotation can be used on test classes,
test fields, configuration classes or configuration fields. When used on
a field the annotation also acts as an injection point.

Fixes gh-5042
9 years ago
Phillip Webb 0829a1bde8 Drop superfluous annotations
Update internal tests to drop annotations that can now
be inferred.

Fixes gh-5470
9 years ago
Phillip Webb 7dffb702b5 Unify use of @BootStrapWith
Update @IntegrationTest to use @BootstrapWith rather than an explicitly
defined set of test execution listeners.

Also introduce a new @SpringApplicationTest annotation that is similar
to  @SpringApplicationConfiguration but a bootstrapper.

Fixes gh-5230
9 years ago
Phillip Webb 90950cfb1c Automatically find test configurations
Allow detection of `@SpringBootConfiguration` classes for both standard
spring tests and bootstrap (@IntegrationTest @WebIntegrationTest) based
tests.

Closes gh-5295
9 years ago
Phillip Webb 600a06af83 Auto-exclude test components from scanning
Add TestTypeExcludeFilter which will automatically attempt to exclude
test only configurations. All `@Configuration` annotated inner-classes
of tests are automatically excluded. The `@TestConfiguration` annotation
can be used to explicitly if a configuration needs explicit exclusion.

See gh-5295
See gh-4901
9 years ago
Phillip Webb 513dec718f Add TestExcludeFilter for component scanning
Add a new TypeFilter specifically for excluding candidate components.
The filter is applied to `@SpringBootApplication` and allows tests to
dynamically contribute exclude filters so that specific classes of
component can be excluded.

See gh-5295
See gh-4901
9 years ago
Phillip Webb 965dd33ec8 Introduce @SpringBootConfiguration annotation
Add a new @SpringBootConfiguration annotation that can be used to
indicate the primary application configuration. The new annotation is
primarily indented to allow test automatically code to find the main
configuration class.

See gh-5295
9 years ago
Phillip Webb 40c2e24a58 Fix SpringApplicationContextLoader customizers
Update SpringApplicationContextLoader to call ContextCustomizers in the
same way as other classes in `spring-test`.

Fixes gh-5294
9 years ago
Phillip Webb c28f552883 Migrate SpringJUnit4ClassRunner to SpringRunner
Replace all existing SpringJUnit4ClassRunner references with the new
SpringRunner alias.

Fixes gh-5292
9 years ago
Phillip Webb 2f815a907a Migrate existing tests from deprecated package
Update the existing tests to use the relocated `spring-boot-test`
classes. Restructuring was achieved using the following command:

find . -type f -name '*.java' -exec sed -i '' \
-e s/org.springframework.boot.test.ConfigFileApplicationContextInitializer/\
org.springframework.boot.test.context.ConfigFileApplicationContextInitializer/g \
-e s/org.springframework.boot.test.EnvironmentTestUtils/\
org.springframework.boot.test.util.EnvironmentTestUtils/g \
-e s/org.springframework.boot.test.IntegrationTest/\
org.springframework.boot.test.context.IntegrationTest/g \
-e s/org.springframework.boot.test.IntegrationTestPropertiesListener/\
org.springframework.boot.test.context.IntegrationTestPropertiesListener/g \
-e s/org.springframework.boot.test.OutputCapture/\
org.springframework.boot.test.rule.OutputCapture/g \
-e s/org.springframework.boot.test.SpringApplicationConfiguration/\
org.springframework.boot.test.context.SpringApplicationConfiguration/g \
-e s/org.springframework.boot.test.SpringApplicationContextLoader/\
org.springframework.boot.test.context.SpringApplicationContextLoader/g \
-e s/org.springframework.boot.test.SpringBootMockServletContext/\
org.springframework.boot.test.mock.web.SpringBootMockServletContext/g \
-e s/org.springframework.boot.test.TestRestTemplate/\
org.springframework.boot.test.web.client.TestRestTemplate/g \
-e s/org.springframework.boot.test.WebIntegrationTest/\
org.springframework.boot.test.context.web.WebIntegrationTest/g {} \;

See gh-5293
9 years ago