mirror of
https://gitee.com/dcren/initializr.git
synced 2025-09-18 17:48:14 +08:00
Move initializr-service to a separate repository
This commit moves the configuration of the start.spring.io website to a dedicated github repository. See https://github.com/spring-io/start.spring.io Closes gh-656
This commit is contained in:
@@ -61,13 +61,9 @@ The project can be built from the root directory using the standard Maven comman
|
||||
|
||||
[indent=0]
|
||||
----
|
||||
$ ./mvnw clean install -Pfull
|
||||
$ ./mvnw clean install
|
||||
----
|
||||
|
||||
NOTE: The `full` profile includes the `initializr-service` and the documentation. Make
|
||||
sure to include that profile when you change code there. It is also recommended to enable
|
||||
that profile in your IDE so that refactoring is applied on the entire codebase.
|
||||
|
||||
If you want to run the smoke tests, you need Firefox installed and available in the path
|
||||
|
||||
[indent=0]
|
||||
|
78
README.adoc
78
README.adoc
@@ -3,6 +3,7 @@
|
||||
:boot-doc: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle
|
||||
:code: https://github.com/spring-io/initializr/blob/master
|
||||
:docs: http://docs.spring.io/initializr/docs/current-SNAPSHOT/reference
|
||||
:service: https://github.com/spring-io/start.spring.io
|
||||
|
||||
Spring Initializr provides an extensible API to generate quickstart projects. It also
|
||||
provides a configurable service (you can see our default instance at
|
||||
@@ -14,14 +15,13 @@ format to allow third-party clients to provide the necessary assistance.
|
||||
|
||||
Finally, Initializr offers a configuration structure to define all the aspects
|
||||
related to the project to generate: list of dependencies, supported java and boot
|
||||
versions, etc. Check
|
||||
the {code}/initializr-service/src/main/resources/application.yml[configuration of our
|
||||
instance] for an example. Such configuration is also described in details in the
|
||||
documentation.
|
||||
versions, etc. Check {service}[the companion project] that defines
|
||||
https://start.spring.io and, in particular, the
|
||||
{service}/blob/master/src/main/resources/application.yml[configuration of our instance]
|
||||
for an example. Such configuration is also described in details in the documentation.
|
||||
|
||||
NOTE: We use the continuous deployment technique to manage our instance; check the
|
||||
https://github.com/spring-io/initializr/milestones[milestones page] for an overview
|
||||
of changes
|
||||
NOTE: Check the https://github.com/spring-io/initializr/milestones[milestones page] for an
|
||||
overview of the changes.
|
||||
|
||||
== Installation and Getting Started
|
||||
The {docs}/htmlsingle/[reference documentation] is published in
|
||||
@@ -38,10 +38,6 @@ in many environments (including embedded in your own project)
|
||||
generation
|
||||
* `initializr-docs`: documentation
|
||||
|
||||
`initializr-service` is an additional module that represents the production instance
|
||||
that is available at link:https://start.spring.io[]. It is not enabled by default but
|
||||
you can enable the `full` profile in your IDE to easily run it locally.
|
||||
|
||||
== Supported interfaces
|
||||
|
||||
Spring Initializr can be used as follows:
|
||||
@@ -167,7 +163,7 @@ deploy the service.
|
||||
You first need to create or update your configuration to define the necessary
|
||||
attributes that your instance will use. Again, check the documentation for a
|
||||
{docs}/htmlsingle/#configuration-format[description of the configuration] and
|
||||
{code}/initializr-service/application.yml[review our own config] for a sample.
|
||||
{service}[review our own config] for a sample.
|
||||
|
||||
You can integrate the library in a traditional Java-based project or by writing the
|
||||
super-simple script below:
|
||||
@@ -218,69 +214,13 @@ If you want to run the smoke tests using Geb, you need to enable the
|
||||
$ ./mvnw verify -PsmokeTests
|
||||
----
|
||||
|
||||
If you want to build both the library and the service, you can enable the `full`
|
||||
profile:
|
||||
To generate the docs as well, you should enable the `full` profile:
|
||||
|
||||
[indent=0]
|
||||
----
|
||||
$ ./mvnw clean install -Pfull
|
||||
----
|
||||
|
||||
|
||||
[[run-app]]
|
||||
=== Running the app locally
|
||||
|
||||
Once you have <<building, built the library>>, you can easily start the app as any
|
||||
other Spring Boot app from the `initializr-service` directory:
|
||||
|
||||
[indent=0]
|
||||
----
|
||||
$ cd initializr-service
|
||||
$ ../mvnw spring-boot:run
|
||||
----
|
||||
|
||||
[[run-ide]]
|
||||
=== Running the app in an IDE
|
||||
|
||||
You should be able to import the projects into your IDE with no problems. Once there you
|
||||
can run the `initializr-service` from its main method, debug it, and it will reload if
|
||||
you make changes to other modules. (You may need to manually enable the "full" profile.)
|
||||
This is the recommended way to operate while you are developing the application,
|
||||
especially the UI.
|
||||
|
||||
|
||||
## Deploying to Cloud Foundry
|
||||
|
||||
If you are on a Mac and using http://brew.sh/[homebrew], install the Cloud Foundry
|
||||
CLI:
|
||||
|
||||
[indent=0]
|
||||
----
|
||||
$ brew install cloudfoundry-cli
|
||||
----
|
||||
|
||||
Alternatively, download a suitable binary for your platform from
|
||||
https://console.run.pivotal.io/tools[Pivotal Web Services].
|
||||
|
||||
You should ensure that the application name and URL (name and host values) are
|
||||
suitable for your environment before running `cf push`.
|
||||
|
||||
First, make sure that you have <<building, built the library>>, then make sure first
|
||||
that the jar has been created:
|
||||
|
||||
[indent=0]
|
||||
----
|
||||
$ cd initializr-service
|
||||
$ ../mvnw package
|
||||
----
|
||||
|
||||
Once the jar has been created, you can push the application:
|
||||
|
||||
[indent=0]
|
||||
----
|
||||
$ cf push your-initializr -p target/initializr-service.jar
|
||||
----
|
||||
|
||||
== License
|
||||
Spring Initializr is Open Source software released under the
|
||||
http://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0 license].
|
||||
|
@@ -67,7 +67,12 @@
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>docs</id>
|
||||
<id>full</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>full</name>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<maven.test.skip>false</maven.test.skip>
|
||||
<snippets.location>${project.build.directory}/snippets</snippets.location>
|
||||
|
@@ -5,10 +5,6 @@ The metadata provided through configuration are driving the options exposed by a
|
||||
particular instance and <<metadata-format.adoc#metadata-format,the project metadata
|
||||
format>>.
|
||||
|
||||
TIP: A good way to get started with the configuration is to look at the
|
||||
{sc-initializr-service}/resources/application.yml[configuration of the production
|
||||
instance] and check the end-result on https://start.spring.io
|
||||
|
||||
The configuration is split in several sections:
|
||||
|
||||
* An `env` section used to provide various global settings.
|
||||
|
@@ -16,7 +16,6 @@ Stéphane Nicoll; Dave Syer
|
||||
:github-wiki: https://github.com/{github-repo}/wiki
|
||||
:github-master-code: https://github.com/{github-repo}/tree/master
|
||||
:sc-initializr-generator: {github-code}/initializr-generator/src/main/java/io/spring/initializr
|
||||
:sc-initializr-service: {github-code}/initializr-service/src/main
|
||||
:spring-initializr-docs-version: current
|
||||
:spring-initializr-docs: http://docs.spring.io/initializr/docs/{spring-initializr-docs-version}/reference
|
||||
:spring-initializr-docs-current: http://docs.spring.io/initializr/docs/current/reference
|
||||
|
@@ -1,121 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>io.spring.initializr</groupId>
|
||||
<artifactId>initializr</artifactId>
|
||||
<version>0.7.0.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>initializr-service</artifactId>
|
||||
<name>Spring Initializr :: Service</name>
|
||||
|
||||
<properties>
|
||||
<main.basedir>${basedir}/..</main.basedir>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.spring.initializr</groupId>
|
||||
<artifactId>initializr-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.spring.initializr</groupId>
|
||||
<artifactId>initializr-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.cache</groupId>
|
||||
<artifactId>cache-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ehcache</groupId>
|
||||
<artifactId>ehcache</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.spring.initializr</groupId>
|
||||
<artifactId>initializr-generator</artifactId>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xmlunit</groupId>
|
||||
<artifactId>xmlunit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>initializr-service</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>pl.project13.maven</groupId>
|
||||
<artifactId>git-commit-id-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>revision</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<dotGitDirectory>${project.basedir}/../.git</dotGitDirectory>
|
||||
<dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
|
||||
<generateGitPropertiesFile>true</generateGitPropertiesFile>
|
||||
<generateGitPropertiesFilename>
|
||||
${project.build.outputDirectory}/git.properties
|
||||
</generateGitPropertiesFilename>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>repackage</id>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<excludeDevtools>true</excludeDevtools>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>build information</id>
|
||||
<goals>
|
||||
<goal>build-info</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<additionalProperties>
|
||||
<versions.spring-boot>${spring.boot.version}
|
||||
</versions.spring-boot>
|
||||
</additionalProperties>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service;
|
||||
|
||||
import io.spring.initializr.metadata.InitializrMetadataProvider;
|
||||
import io.spring.initializr.web.project.LegacyStsController;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.web.servlet.resource.ResourceUrlProvider;
|
||||
|
||||
/**
|
||||
* Initializr service application. Enables legacy STS support for older clients.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableCaching
|
||||
@EnableAsync
|
||||
public class InitializrService {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(InitializrService.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LegacyStsController legacyStsController(
|
||||
InitializrMetadataProvider metadataProvider,
|
||||
ResourceUrlProvider resourceUrlProvider) {
|
||||
return new LegacyStsController(metadataProvider, resourceUrlProvider);
|
||||
}
|
||||
|
||||
}
|
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import io.spring.initializr.generator.ProjectRequestPostProcessor;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.util.Version;
|
||||
|
||||
/**
|
||||
* Base {@link ProjectRequestPostProcessor} with reusable utilities.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class AbstractProjectRequestPostProcessor implements ProjectRequestPostProcessor {
|
||||
|
||||
/**
|
||||
* Determine if the {@link ProjectRequest request} defines the dependency with the
|
||||
* specified {@code dependencyId}.
|
||||
* @param request the request to handle
|
||||
* @param dependencyId the id of a dependency
|
||||
* @return {@code true} if the project defines that dependency
|
||||
*/
|
||||
protected boolean hasDependency(ProjectRequest request, String dependencyId) {
|
||||
return hasDependencies(request, dependencyId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the {@link ProjectRequest request} defines the dependencies with the
|
||||
* specified {@code dependenciesId}.
|
||||
* @param request the request to handle
|
||||
* @param dependenciesId the dependency ids
|
||||
* @return {@code true} if the project defines all dependencies
|
||||
*/
|
||||
protected boolean hasDependencies(ProjectRequest request, String... dependenciesId) {
|
||||
for (String id : dependenciesId) {
|
||||
if (getDependency(request, id) == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link Dependency} with the specified {@code id} or {@code null} if the
|
||||
* project does not define it.
|
||||
* @param request the request to handle
|
||||
* @param id the id of a dependency
|
||||
* @return the {@link Dependency} with that id or {@code null} if the project does not
|
||||
* define such dependency
|
||||
*/
|
||||
protected Dependency getDependency(ProjectRequest request, String id) {
|
||||
return request.getResolvedDependencies().stream()
|
||||
.filter((dependency) -> id.equals(dependency.getId())).findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify if the Spring Boot version of the {@link ProjectRequest request} is higher
|
||||
* or equal to the specified {@link Version}.
|
||||
* @param request the request to handle
|
||||
* @param version the minimum version
|
||||
* @return {@code true} if the requested version is equal or higher than the specified
|
||||
* {@code version}
|
||||
*/
|
||||
protected boolean isSpringBootVersionAtLeastAfter(ProjectRequest request,
|
||||
Version version) {
|
||||
Version requestVersion = Version.safeParse(request.getBootVersion());
|
||||
return version.compareTo(requestVersion) <= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify if the Spring Boot version of the {@link ProjectRequest request} is lower
|
||||
* than the specified {@link Version}.
|
||||
* @param request the request to handle
|
||||
* @param version the maximum version
|
||||
* @return {@code true} if the requested version is lower than the specified
|
||||
* {@code version}
|
||||
*/
|
||||
protected boolean isSpringBootVersionBefore(ProjectRequest request, Version version) {
|
||||
Version requestVersion = Version.safeParse(request.getBootVersion());
|
||||
return version.compareTo(requestVersion) > 0;
|
||||
}
|
||||
|
||||
}
|
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import io.spring.initializr.generator.ProjectRequestPostProcessor;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* A {@link ProjectRequestPostProcessor} that automatically adds "jackson-module-kotlin"
|
||||
* when Kotlin is used and a dependency has the "json" facet.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
@Component
|
||||
class JacksonKotlinRequestPostProcessor implements ProjectRequestPostProcessor {
|
||||
|
||||
static final Dependency JACKSON_KOTLIN = Dependency.withId("jackson-module-kotlin",
|
||||
"com.fasterxml.jackson.module", "jackson-module-kotlin");
|
||||
|
||||
@Override
|
||||
public void postProcessAfterResolution(ProjectRequest request,
|
||||
InitializrMetadata metadata) {
|
||||
if (request.getFacets().contains("json")
|
||||
&& "kotlin".equals(request.getLanguage())) {
|
||||
request.getResolvedDependencies().add(JACKSON_KOTLIN);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
import io.spring.initializr.util.Version;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Validate that the requested java version is compatible with the chosen Spring Boot
|
||||
* generation and adapt the request if necessary.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Component
|
||||
class JavaVersionRequestPostProcessor extends AbstractProjectRequestPostProcessor {
|
||||
|
||||
private static final Version VERSION_2_0_0_M1 = Version.parse("2.0.0.M1");
|
||||
|
||||
private static final Version VERSION_2_0_1 = Version.parse("2.0.1.RELEASE");
|
||||
|
||||
private static final Version VERSION_2_1_0_M1 = Version.parse("2.1.0.M1");
|
||||
|
||||
private static final List<String> UNSUPPORTED_LANGUAGES = Arrays.asList("groovy",
|
||||
"kotlin");
|
||||
|
||||
@Override
|
||||
public void postProcessAfterResolution(ProjectRequest request,
|
||||
InitializrMetadata metadata) {
|
||||
Integer javaGeneration = determineJavaGeneration(request.getJavaVersion());
|
||||
if (javaGeneration == null) {
|
||||
return;
|
||||
}
|
||||
// Not supported for Spring Boot 1.x
|
||||
if (isSpringBootVersionBefore(request, VERSION_2_0_0_M1)) {
|
||||
request.setJavaVersion("1.8");
|
||||
}
|
||||
// Not supported for Kotlin & Groovy
|
||||
if (UNSUPPORTED_LANGUAGES.contains(request.getLanguage())) {
|
||||
request.setJavaVersion("1.8");
|
||||
}
|
||||
// 10 support only as of 2.0.1
|
||||
if (javaGeneration == 10 && isSpringBootVersionBefore(request, VERSION_2_0_1)) {
|
||||
request.setJavaVersion("1.8");
|
||||
}
|
||||
// 11 support only as of 2.1.x
|
||||
if (javaGeneration == 11
|
||||
&& isSpringBootVersionBefore(request, VERSION_2_1_0_M1)) {
|
||||
request.setJavaVersion("1.8");
|
||||
}
|
||||
}
|
||||
|
||||
private Integer determineJavaGeneration(String javaVersion) {
|
||||
try {
|
||||
int generation = Integer.valueOf(javaVersion);
|
||||
return ((generation > 8 && generation <= 11) ? generation : null);
|
||||
}
|
||||
catch (NumberFormatException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import io.spring.initializr.generator.ProjectRequestPostProcessor;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
import io.spring.initializr.util.Version;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* A {@link ProjectRequestPostProcessor} that automatically adds "reactor-test" when
|
||||
* webflux is selected.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Component
|
||||
class ReactorTestRequestPostProcessor extends AbstractProjectRequestPostProcessor {
|
||||
|
||||
private static final Version VERSION_2_0_0_M2 = Version.parse("2.0.0.M2");
|
||||
|
||||
static final Dependency REACTOR_TEST = Dependency.withId("reactor-test",
|
||||
"io.projectreactor", "reactor-test", null, Dependency.SCOPE_TEST);
|
||||
|
||||
@Override
|
||||
public void postProcessAfterResolution(ProjectRequest request,
|
||||
InitializrMetadata metadata) {
|
||||
if (hasDependency(request, "webflux")
|
||||
&& isSpringBootVersionAtLeastAfter(request, VERSION_2_0_0_M2)) {
|
||||
request.getResolvedDependencies().add(REACTOR_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import io.spring.initializr.generator.ProjectRequestPostProcessor;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
import io.spring.initializr.util.Version;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* A {@link ProjectRequestPostProcessor} that automatically adds {@code spring-batch-test}
|
||||
* when Spring Batch is selected.
|
||||
*
|
||||
* @author Tim Riemer
|
||||
*/
|
||||
@Component
|
||||
class SpringBatchTestRequestPostProcessor extends AbstractProjectRequestPostProcessor {
|
||||
|
||||
private static final Version VERSION_1_3_0 = Version.parse("1.3.0.RELEASE");
|
||||
|
||||
static final Dependency SPRING_BATCH_TEST = Dependency.withId("spring-batch-test",
|
||||
"org.springframework.batch", "spring-batch-test", null,
|
||||
Dependency.SCOPE_TEST);
|
||||
|
||||
@Override
|
||||
public void postProcessAfterResolution(ProjectRequest request,
|
||||
InitializrMetadata metadata) {
|
||||
if (hasDependency(request, "batch")
|
||||
&& isSpringBootVersionAtLeastAfter(request, VERSION_1_3_0)) {
|
||||
request.getResolvedDependencies().add(SPRING_BATCH_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
import io.spring.initializr.util.Version;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* As of Spring Boot 2.0, Java8 is mandatory so this extension makes sure that the java
|
||||
* version is forced.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Component
|
||||
class SpringBoot2RequestPostProcessor extends AbstractProjectRequestPostProcessor {
|
||||
|
||||
private static final Version VERSION_2_0_0_M1 = Version.parse("2.0.0.M1");
|
||||
|
||||
private static final List<String> VALID_VERSIONS = Arrays.asList("1.8", "9", "10",
|
||||
"11");
|
||||
|
||||
@Override
|
||||
public void postProcessAfterResolution(ProjectRequest request,
|
||||
InitializrMetadata metadata) {
|
||||
if (!VALID_VERSIONS.contains(request.getJavaVersion())
|
||||
&& isSpringBootVersionAtLeastAfter(request, VERSION_2_0_0_M1)) {
|
||||
request.setJavaVersion("1.8");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
import io.spring.initializr.util.Version;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Determine the appropriate Spring Cloud function dependency according to the messaging
|
||||
* and/or platform dependencies requested.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Component
|
||||
class SpringCloudFunctionRequestPostProcessor
|
||||
extends AbstractProjectRequestPostProcessor {
|
||||
|
||||
static final Dependency SCS_ADAPTER = Dependency.withId("cloud-function-stream",
|
||||
"org.springframework.cloud", "spring-cloud-function-stream");
|
||||
|
||||
static final Dependency WEB_ADAPTER = Dependency.withId("cloud-function-web",
|
||||
"org.springframework.cloud", "spring-cloud-function-web");
|
||||
|
||||
static final Version VERSION_2_1_0_M1 = Version.parse("2.1.0.M1");
|
||||
|
||||
@Override
|
||||
public void postProcessAfterResolution(ProjectRequest request,
|
||||
InitializrMetadata metadata) {
|
||||
Dependency cloudFunction = getDependency(request, "cloud-function");
|
||||
if (cloudFunction != null) {
|
||||
List<Dependency> swap = new ArrayList<>();
|
||||
if ((hasDependency(request, "cloud-stream")
|
||||
|| hasDependency(request, "reactive-cloud-stream"))
|
||||
&& isSpringBootVersionBefore(request, VERSION_2_1_0_M1)) {
|
||||
swap.add(SCS_ADAPTER);
|
||||
}
|
||||
if (hasDependency(request, "web")) {
|
||||
swap.add(WEB_ADAPTER);
|
||||
}
|
||||
if (hasDependency(request, "webflux")
|
||||
&& isSpringBootVersionAtLeastAfter(request, VERSION_2_1_0_M1)) {
|
||||
swap.add(WEB_ADAPTER);
|
||||
}
|
||||
if (!swap.isEmpty()) {
|
||||
request.getResolvedDependencies().remove(cloudFunction);
|
||||
request.getResolvedDependencies().addAll(swap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Determine the appropriate Spring Cloud stream dependency to use based on the selected
|
||||
* integration technology.
|
||||
* <p>
|
||||
* Does not replace the integration technology jar by the relevant binder. If more than
|
||||
* one tech is selected, it is far more easier to remove the unnecessary binder jar than
|
||||
* to figure out the name of the tech jar to add to keep support for that technology.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Component
|
||||
class SpringCloudStreamRequestPostProcessor extends AbstractProjectRequestPostProcessor {
|
||||
|
||||
static final Dependency KAFKA_BINDER = Dependency.withId("cloud-stream-binder-kafka",
|
||||
"org.springframework.cloud", "spring-cloud-stream-binder-kafka");
|
||||
|
||||
static final Dependency KAFKA_STREAMS_BINDER = Dependency.withId(
|
||||
"cloud-stream-binder-kafka-streams", "org.springframework.cloud",
|
||||
"spring-cloud-stream-binder-kafka-streams");
|
||||
|
||||
static final Dependency RABBIT_BINDER = Dependency.withId(
|
||||
"cloud-stream-binder-rabbit", "org.springframework.cloud",
|
||||
"spring-cloud-stream-binder-rabbit");
|
||||
|
||||
static final Dependency SCS_TEST = Dependency.withId("cloud-stream-test",
|
||||
"org.springframework.cloud", "spring-cloud-stream-test-support", null,
|
||||
Dependency.SCOPE_TEST);
|
||||
|
||||
@Override
|
||||
public void postProcessAfterResolution(ProjectRequest request,
|
||||
InitializrMetadata metadata) {
|
||||
boolean hasSpringCloudStream = hasDependency(request, "cloud-stream");
|
||||
boolean hasReactiveSpringCloudStream = hasDependency(request,
|
||||
"reactive-cloud-stream");
|
||||
boolean hasSpringCloudBus = hasDependency(request, "cloud-bus");
|
||||
boolean hasSpringCloudTurbineStream = hasDependency(request,
|
||||
"cloud-turbine-stream");
|
||||
if (hasSpringCloudStream || hasReactiveSpringCloudStream || hasSpringCloudBus
|
||||
|| hasSpringCloudTurbineStream) {
|
||||
if (hasDependencies(request, "amqp")) {
|
||||
request.getResolvedDependencies().add(RABBIT_BINDER);
|
||||
}
|
||||
if (hasDependencies(request, "kafka")) {
|
||||
request.getResolvedDependencies().add(KAFKA_BINDER);
|
||||
}
|
||||
}
|
||||
// Spring Cloud Stream specific
|
||||
if (hasSpringCloudStream || hasReactiveSpringCloudStream) {
|
||||
if (hasDependencies(request, "kafka-streams")) {
|
||||
request.getResolvedDependencies().add(KAFKA_STREAMS_BINDER);
|
||||
}
|
||||
request.getResolvedDependencies().add(SCS_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import io.spring.initializr.generator.ProjectRequestPostProcessor;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
import io.spring.initializr.util.Version;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* A {@link ProjectRequestPostProcessor} that automatically adds
|
||||
* {@code spring-security-test} when Spring Security is selected.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Component
|
||||
class SpringSecurityTestRequestPostProcessor extends AbstractProjectRequestPostProcessor {
|
||||
|
||||
private static final Version VERSION_1_3_0 = Version.parse("1.3.0.RELEASE");
|
||||
|
||||
static final Dependency SPRING_SECURITY_TEST = Dependency.withId("security-test",
|
||||
"org.springframework.security", "spring-security-test", null,
|
||||
Dependency.SCOPE_TEST);
|
||||
|
||||
@Override
|
||||
public void postProcessAfterResolution(ProjectRequest request,
|
||||
InitializrMetadata metadata) {
|
||||
if (hasDependency(request, "security")
|
||||
&& isSpringBootVersionAtLeastAfter(request, VERSION_1_3_0)) {
|
||||
request.getResolvedDependencies().add(SPRING_SECURITY_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import io.spring.initializr.generator.ProjectRequestPostProcessor;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
import io.spring.initializr.util.Version;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* A {@link ProjectRequestPostProcessor} that provides explicit handling for the modules
|
||||
* introduced in Spring Session 2.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Component
|
||||
class SpringSessionRequestPostProcessor extends AbstractProjectRequestPostProcessor {
|
||||
|
||||
private static final Version VERSION_2_0_0_M3 = Version.parse("2.0.0.M3");
|
||||
|
||||
static final Dependency REDIS = Dependency.withId("session-data-redis",
|
||||
"org.springframework.session", "spring-session-data-redis");
|
||||
|
||||
static final Dependency JDBC = Dependency.withId("session-jdbc",
|
||||
"org.springframework.session", "spring-session-jdbc");
|
||||
|
||||
@Override
|
||||
public void postProcessAfterResolution(ProjectRequest request,
|
||||
InitializrMetadata metadata) {
|
||||
if (isSpringBootVersionAtLeastAfter(request, VERSION_2_0_0_M3)) {
|
||||
swapSpringSessionDependency(request);
|
||||
}
|
||||
}
|
||||
|
||||
private void swapSpringSessionDependency(ProjectRequest request) {
|
||||
Dependency session = getDependency(request, "session");
|
||||
if (session != null) {
|
||||
List<Dependency> swap = new ArrayList<>();
|
||||
if (hasDependency(request, "data-redis")
|
||||
|| hasDependency(request, "data-redis-reactive")) {
|
||||
swap.add(REDIS);
|
||||
}
|
||||
if (hasDependency(request, "jdbc")) {
|
||||
swap.add(JDBC);
|
||||
}
|
||||
if (!swap.isEmpty()) {
|
||||
request.getResolvedDependencies().remove(session);
|
||||
request.getResolvedDependencies().addAll(swap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.info;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.actuate.info.Info;
|
||||
import org.springframework.boot.actuate.info.InfoContributor;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* An {@link InfoContributor} that exposes the name of the app. Useful in a blue/green
|
||||
* deployment scenario as the name of the app provides a hint to that.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Component
|
||||
public class CloudFoundryInfoContributor implements InfoContributor {
|
||||
|
||||
private final Environment environment;
|
||||
|
||||
public CloudFoundryInfoContributor(Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contribute(Info.Builder builder) {
|
||||
String applicationName = this.environment.getProperty("vcap.application.name");
|
||||
if (StringUtils.hasText(applicationName)) {
|
||||
Map<String, String> details = new LinkedHashMap<>();
|
||||
details.put("name", applicationName);
|
||||
builder.withDetail("app", details);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link InitializrService} that force https.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = "initializr.env.force-ssl=true")
|
||||
@AutoConfigureCache
|
||||
public class InitializrServiceHttpsTests {
|
||||
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
||||
@LocalServerPort
|
||||
private int localPort;
|
||||
|
||||
@Test
|
||||
public void httpCallRedirectsToHttps() {
|
||||
RequestEntity<Void> request = RequestEntity.get(URI.create("/"))
|
||||
.accept(MediaType.TEXT_HTML).build();
|
||||
ResponseEntity<String> response = this.restTemplate.exchange(request,
|
||||
String.class);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.FOUND);
|
||||
assertThat(response.getHeaders().getLocation()).isEqualTo(
|
||||
URI.create(String.format("https://localhost:%s/", this.localPort)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void securedProxiedCallDoesNotRedirect() {
|
||||
RequestEntity<Void> request = RequestEntity.get(URI.create("/"))
|
||||
.header("X-Forwarded-Proto", "https").accept(MediaType.TEXT_HTML).build();
|
||||
ResponseEntity<String> response = this.restTemplate.exchange(request,
|
||||
String.class);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
import io.spring.initializr.metadata.InitializrMetadataBuilder;
|
||||
import io.spring.initializr.metadata.InitializrMetadataProvider;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for {@link InitializrService}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
@AutoConfigureCache
|
||||
public class InitializrServiceSmokeTests {
|
||||
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
||||
@Autowired
|
||||
private InitializrMetadataProvider metadataProvider;
|
||||
|
||||
@Test
|
||||
public void metadataCanBeSerialized() throws URISyntaxException, IOException {
|
||||
RequestEntity<Void> request = RequestEntity.get(new URI("/"))
|
||||
.accept(MediaType.parseMediaType("application/vnd.initializr.v2.1+json"))
|
||||
.build();
|
||||
ResponseEntity<String> response = this.restTemplate.exchange(request,
|
||||
String.class);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
new ObjectMapper().readTree(response.getBody());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void configurationCanBeSerialized() throws URISyntaxException {
|
||||
RequestEntity<Void> request = RequestEntity.get(new URI("/metadata/config"))
|
||||
.accept(MediaType.APPLICATION_JSON).build();
|
||||
ResponseEntity<String> response = this.restTemplate.exchange(request,
|
||||
String.class);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
InitializrMetadata actual = InitializrMetadataBuilder.create()
|
||||
.withInitializrMetadata(
|
||||
new ByteArrayResource(response.getBody().getBytes()))
|
||||
.build();
|
||||
assertThat(actual).isNotNull();
|
||||
InitializrMetadata expected = this.metadataProvider.get();
|
||||
assertThat(actual.getDependencies().getAll().size())
|
||||
.isEqualTo(expected.getDependencies().getAll().size());
|
||||
assertThat(actual.getConfiguration().getEnv().getBoms().size())
|
||||
.isEqualTo(expected.getConfiguration().getEnv().getBoms().size());
|
||||
}
|
||||
|
||||
}
|
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import io.spring.initializr.generator.ProjectGenerator;
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import io.spring.initializr.generator.ProjectRequestPostProcessor;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.metadata.InitializrMetadataProvider;
|
||||
import io.spring.initializr.test.generator.GradleBuildAssert;
|
||||
import io.spring.initializr.test.generator.PomAssert;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* Base test class for {@link ProjectRequestPostProcessor} implementations.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest
|
||||
public abstract class AbstractRequestPostProcessorTests {
|
||||
|
||||
@Autowired
|
||||
private ProjectGenerator projectGenerator;
|
||||
|
||||
@Autowired
|
||||
private InitializrMetadataProvider metadataProvider;
|
||||
|
||||
protected Dependency getDependency(String id) {
|
||||
return this.metadataProvider.get().getDependencies().get(id);
|
||||
}
|
||||
|
||||
protected PomAssert generateMavenPom(ProjectRequest request) {
|
||||
request.setType("maven-build");
|
||||
String content = new String(this.projectGenerator.generateMavenPom(request));
|
||||
return new PomAssert(content);
|
||||
}
|
||||
|
||||
protected GradleBuildAssert generateGradleBuild(ProjectRequest request) {
|
||||
request.setType("gradle-build");
|
||||
String content = new String(this.projectGenerator.generateGradleBuild(request));
|
||||
return new GradleBuildAssert(content);
|
||||
}
|
||||
|
||||
protected ProjectRequest createProjectRequest(String... styles) {
|
||||
ProjectRequest request = new ProjectRequest();
|
||||
request.initialize(this.metadataProvider.get());
|
||||
request.getStyle().addAll(Arrays.asList(styles));
|
||||
return request;
|
||||
}
|
||||
|
||||
}
|
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link JacksonKotlinRequestPostProcessor}.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class JacksonKotlinRequestPostProcessorTests
|
||||
extends AbstractRequestPostProcessorTests {
|
||||
|
||||
@Test
|
||||
public void jacksonModuleKotlinIsAdded() {
|
||||
ProjectRequest request = createProjectRequest("webflux");
|
||||
request.setBootVersion("2.0.0.M2");
|
||||
request.setLanguage("kotlin");
|
||||
generateMavenPom(request).hasSpringBootStarterDependency("webflux")
|
||||
.hasDependency(JacksonKotlinRequestPostProcessor.JACKSON_KOTLIN)
|
||||
.hasSpringBootStarterTest()
|
||||
.hasDependency(ReactorTestRequestPostProcessor.REACTOR_TEST)
|
||||
.hasDependency("org.jetbrains.kotlin", "kotlin-reflect")
|
||||
.hasDependency("org.jetbrains.kotlin", "kotlin-stdlib-jdk8")
|
||||
.hasDependenciesCount(6);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jacksonModuleKotlinIsNotAddedWithoutKotlin() {
|
||||
ProjectRequest request = createProjectRequest("webflux");
|
||||
request.setBootVersion("2.0.0.M2");
|
||||
generateMavenPom(request).hasSpringBootStarterDependency("webflux")
|
||||
.hasSpringBootStarterTest()
|
||||
.hasDependency(ReactorTestRequestPostProcessor.REACTOR_TEST)
|
||||
.hasDependenciesCount(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jacksonModuleKotlinIsNotAddedWithoutJsonFacet() {
|
||||
ProjectRequest request = createProjectRequest("actuator");
|
||||
request.setBootVersion("2.0.0.M2");
|
||||
request.setLanguage("kotlin");
|
||||
generateMavenPom(request).hasSpringBootStarterDependency("actuator")
|
||||
.hasSpringBootStarterTest()
|
||||
.hasDependency("org.jetbrains.kotlin", "kotlin-reflect")
|
||||
.hasDependency("org.jetbrains.kotlin", "kotlin-stdlib-jdk8")
|
||||
.hasDependenciesCount(4);
|
||||
}
|
||||
|
||||
}
|
@@ -1,194 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link JavaVersionRequestPostProcessor}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class JavaVersionRequestPostProcessorTests
|
||||
extends AbstractRequestPostProcessorTests {
|
||||
|
||||
@Test
|
||||
public void java9CannotBeUsedWithSpringBoot1Maven() {
|
||||
ProjectRequest request = createProjectRequest("web");
|
||||
request.setBootVersion("1.5.8.RELEASE");
|
||||
request.setJavaVersion("9");
|
||||
generateMavenPom(request).hasJavaVersion("1.8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java9CannotBeUsedWithSpringBoot1Gradle() {
|
||||
ProjectRequest request = createProjectRequest("data-jpa");
|
||||
request.setBootVersion("1.99.99.BUILD-SNAPSHOT");
|
||||
request.setJavaVersion("9");
|
||||
generateGradleBuild(request).hasJavaVersion("1.8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java9CannotBeUsedWithGroovyMaven() {
|
||||
ProjectRequest request = createProjectRequest("web");
|
||||
request.setBootVersion("2.0.1.RELEASE");
|
||||
request.setLanguage("groovy");
|
||||
request.setJavaVersion("9");
|
||||
generateMavenPom(request).hasJavaVersion("1.8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java9CannotBeUsedWithKotlinMaven() {
|
||||
ProjectRequest request = createProjectRequest("web");
|
||||
request.setBootVersion("2.0.1.RELEASE");
|
||||
request.setLanguage("kotlin");
|
||||
request.setJavaVersion("9");
|
||||
generateMavenPom(request).hasJavaVersion("1.8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java9CannotBeUsedWithGroovyGradle() {
|
||||
ProjectRequest request = createProjectRequest("data-jpa");
|
||||
request.setBootVersion("2.0.1.RELEASE");
|
||||
request.setLanguage("groovy");
|
||||
request.setJavaVersion("9");
|
||||
generateGradleBuild(request).hasJavaVersion("1.8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java9CannotBeUsedWithKotlinGradle() {
|
||||
ProjectRequest request = createProjectRequest("data-jpa");
|
||||
request.setBootVersion("2.0.1.RELEASE");
|
||||
request.setLanguage("kotlin");
|
||||
request.setJavaVersion("9");
|
||||
generateGradleBuild(request).hasJavaVersion("1.8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java9CanBeUsedWithSpringBoot2Maven() {
|
||||
ProjectRequest request = createProjectRequest("web");
|
||||
request.setBootVersion("2.0.1.RELEASE");
|
||||
request.setJavaVersion("9");
|
||||
generateMavenPom(request).hasJavaVersion("9");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java9CanBeUsedWithSpringBoot2Gradle() {
|
||||
ProjectRequest request = createProjectRequest("data-jpa");
|
||||
request.setBootVersion("2.0.0.M3");
|
||||
request.setJavaVersion("9");
|
||||
generateGradleBuild(request).hasJavaVersion("9");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java10CannotBeUsedWithSpringBoot1Maven() {
|
||||
ProjectRequest request = createProjectRequest("web");
|
||||
request.setBootVersion("1.5.8.RELEASE");
|
||||
request.setJavaVersion("10");
|
||||
generateMavenPom(request).hasJavaVersion("1.8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java10CannotBeUsedWithSpringBoot1Gradle() {
|
||||
ProjectRequest request = createProjectRequest("data-jpa");
|
||||
request.setBootVersion("1.99.99.BUILD-SNAPSHOT");
|
||||
request.setJavaVersion("10");
|
||||
generateGradleBuild(request).hasJavaVersion("1.8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java10CannotBeUsedWithSpringBoot200Maven() {
|
||||
ProjectRequest request = createProjectRequest("web");
|
||||
request.setBootVersion("2.0.0.RELEASE");
|
||||
request.setJavaVersion("10");
|
||||
generateMavenPom(request).hasJavaVersion("1.8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java10CannotBeUsedWithSpringBoot200Gradle() {
|
||||
ProjectRequest request = createProjectRequest("data-jpa");
|
||||
request.setBootVersion("2.0.0.RELEASE");
|
||||
request.setJavaVersion("10");
|
||||
generateGradleBuild(request).hasJavaVersion("1.8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java10CanBeUsedWithSpringBoot2Maven() {
|
||||
ProjectRequest request = createProjectRequest("web");
|
||||
request.setBootVersion("2.0.1.RELEASE");
|
||||
request.setJavaVersion("10");
|
||||
generateMavenPom(request).hasJavaVersion("10");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java10CanBeUsedWithSpringBoot2Gradle() {
|
||||
ProjectRequest request = createProjectRequest("data-jpa");
|
||||
request.setBootVersion("2.0.2.RELEASE");
|
||||
request.setJavaVersion("10");
|
||||
generateGradleBuild(request).hasJavaVersion("10");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java11CannotBeUsedWithSpringBoot1Maven() {
|
||||
ProjectRequest request = createProjectRequest("web");
|
||||
request.setBootVersion("1.5.8.RELEASE");
|
||||
request.setJavaVersion("11");
|
||||
generateMavenPom(request).hasJavaVersion("1.8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java11CannotBeUsedWithSpringBoot1Gradle() {
|
||||
ProjectRequest request = createProjectRequest("data-jpa");
|
||||
request.setBootVersion("1.99.99.BUILD-SNAPSHOT");
|
||||
request.setJavaVersion("11");
|
||||
generateGradleBuild(request).hasJavaVersion("1.8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java11CannotBeUsedWithSpringBoot20Maven() {
|
||||
ProjectRequest request = createProjectRequest("web");
|
||||
request.setBootVersion("2.0.5.RELEASE");
|
||||
request.setJavaVersion("11");
|
||||
generateMavenPom(request).hasJavaVersion("1.8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java11CannotBeUsedWithSpringBoot20Gradle() {
|
||||
ProjectRequest request = createProjectRequest("data-jpa");
|
||||
request.setBootVersion("2.0.5.RELEASE");
|
||||
request.setJavaVersion("11");
|
||||
generateGradleBuild(request).hasJavaVersion("1.8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java11CanBeUsedWithSpringBoot21Maven() {
|
||||
ProjectRequest request = createProjectRequest("web");
|
||||
request.setBootVersion("2.1.0.M1");
|
||||
request.setJavaVersion("11");
|
||||
generateMavenPom(request).hasJavaVersion("11");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java11CanBeUsedWithSpringBoot21Gradle() {
|
||||
ProjectRequest request = createProjectRequest("data-jpa");
|
||||
request.setBootVersion("2.1.1.RELEASE");
|
||||
request.setJavaVersion("11");
|
||||
generateGradleBuild(request).hasJavaVersion("11");
|
||||
}
|
||||
|
||||
}
|
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link ReactorTestRequestPostProcessor}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class ReactorTestRequestPostProcessorTests
|
||||
extends AbstractRequestPostProcessorTests {
|
||||
|
||||
@Test
|
||||
public void reactorTestIsAdded() {
|
||||
ProjectRequest request = createProjectRequest("webflux");
|
||||
request.setBootVersion("2.0.0.M2");
|
||||
Dependency reactorTest = Dependency.withId("reactor-test", "io.projectreactor",
|
||||
"reactor-test");
|
||||
reactorTest.setScope(Dependency.SCOPE_TEST);
|
||||
generateMavenPom(request).hasSpringBootStarterDependency("webflux")
|
||||
.hasSpringBootStarterTest().hasDependency(reactorTest)
|
||||
.hasDependenciesCount(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reactorTestIsNotAddedWithEarlierVersions() {
|
||||
ProjectRequest request = createProjectRequest("webflux");
|
||||
request.setBootVersion("2.0.0.M1");
|
||||
generateMavenPom(request).hasSpringBootStarterDependency("webflux")
|
||||
.hasSpringBootStarterTest().hasDependenciesCount(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reactorTestIsNotAddedWithoutWebFlux() {
|
||||
ProjectRequest request = createProjectRequest("web");
|
||||
request.setBootVersion("2.0.0.M2");
|
||||
generateMavenPom(request).hasSpringBootStarterDependency("web")
|
||||
.hasSpringBootStarterTest().hasDependenciesCount(2);
|
||||
}
|
||||
|
||||
}
|
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link SpringBatchTestRequestPostProcessor}.
|
||||
*
|
||||
* @author Tim Riemer
|
||||
*/
|
||||
public class SpringBatchTestRequestPostProcessorTests
|
||||
extends AbstractRequestPostProcessorTests {
|
||||
|
||||
@Test
|
||||
public void batchTestIsAddedWithBatch() {
|
||||
ProjectRequest request = createProjectRequest("batch");
|
||||
generateMavenPom(request).hasSpringBootStarterDependency("batch")
|
||||
.hasSpringBootStarterTest().hasDependency(springBatchTest())
|
||||
.hasDependenciesCount(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void batchTestIsNotAddedBefore13() {
|
||||
ProjectRequest request = createProjectRequest("batch");
|
||||
request.setBootVersion("1.2.7.RELEASE");
|
||||
generateMavenPom(request).hasSpringBootStarterDependency("batch")
|
||||
.hasSpringBootStarterTest().hasDependenciesCount(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void batchTestIsNotAddedWithoutSpringBatch() {
|
||||
ProjectRequest request = createProjectRequest("web");
|
||||
generateMavenPom(request).hasSpringBootStarterDependency("web")
|
||||
.hasSpringBootStarterTest().hasDependenciesCount(2);
|
||||
}
|
||||
|
||||
private static Dependency springBatchTest() {
|
||||
Dependency dependency = Dependency.withId("spring-batch-test",
|
||||
"org.springframework.batch", "spring-batch-test");
|
||||
dependency.setScope(Dependency.SCOPE_TEST);
|
||||
return dependency;
|
||||
}
|
||||
|
||||
}
|
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link SpringBoot2RequestPostProcessor}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class SpringBoot2RequestPostProcessorTests
|
||||
extends AbstractRequestPostProcessorTests {
|
||||
|
||||
@Test
|
||||
public void java8IsMandatoryMaven() {
|
||||
ProjectRequest request = createProjectRequest("web");
|
||||
request.setBootVersion("2.0.0.BUILD-SNAPSHOT");
|
||||
request.setJavaVersion("1.7");
|
||||
generateMavenPom(request).hasJavaVersion("1.8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java8IsMandatoryGradle() {
|
||||
ProjectRequest request = createProjectRequest("data-jpa");
|
||||
request.setBootVersion("2.0.0.M3");
|
||||
request.setJavaVersion("1.7");
|
||||
generateGradleBuild(request).hasJavaVersion("1.8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java9CanBeUsedMaven() {
|
||||
ProjectRequest request = createProjectRequest("web");
|
||||
request.setBootVersion("2.0.0.BUILD-SNAPSHOT");
|
||||
request.setJavaVersion("9");
|
||||
generateMavenPom(request).hasJavaVersion("9");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java9CanBeUsedGradle() {
|
||||
ProjectRequest request = createProjectRequest("data-jpa");
|
||||
request.setBootVersion("2.0.0.M3");
|
||||
request.setJavaVersion("9");
|
||||
generateGradleBuild(request).hasJavaVersion("9");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java10CanBeUsedMaven() {
|
||||
ProjectRequest request = createProjectRequest("web");
|
||||
request.setBootVersion("2.1.0.BUILD-SNAPSHOT");
|
||||
request.setJavaVersion("10");
|
||||
generateMavenPom(request).hasJavaVersion("10");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void java10CanBeUsedGradle() {
|
||||
ProjectRequest request = createProjectRequest("data-jpa");
|
||||
request.setBootVersion("2.0.2.RELEASE");
|
||||
request.setJavaVersion("10");
|
||||
generateGradleBuild(request).hasJavaVersion("10");
|
||||
}
|
||||
|
||||
}
|
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link SpringCloudFunctionRequestPostProcessor}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class SpringCloudFunctionRequestPostProcessorTests
|
||||
extends AbstractRequestPostProcessorTests {
|
||||
|
||||
@Test
|
||||
public void functionOnly() {
|
||||
ProjectRequest request = createProjectRequest("cloud-function");
|
||||
generateMavenPom(request).hasDependency(getDependency("cloud-function"))
|
||||
.hasSpringBootStarterTest().hasDependenciesCount(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springCloudStreamWithRabbit() {
|
||||
ProjectRequest request = createProjectRequest("cloud-stream", "amqp",
|
||||
"cloud-function");
|
||||
request.setBootVersion("2.0.6.RELEASE");
|
||||
generateMavenPom(request).hasDependency(getDependency("cloud-stream"))
|
||||
.hasDependency(getDependency("amqp"))
|
||||
.hasDependency(SpringCloudFunctionRequestPostProcessor.SCS_ADAPTER)
|
||||
.hasDependenciesCount(6);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reactiveSpringCloudStreamWithKafka() {
|
||||
ProjectRequest request = createProjectRequest("reactive-cloud-stream", "kafka",
|
||||
"cloud-function");
|
||||
request.setBootVersion("2.0.6.RELEASE");
|
||||
generateMavenPom(request).hasDependency(getDependency("reactive-cloud-stream"))
|
||||
.hasDependency(getDependency("kafka"))
|
||||
.hasDependency(SpringCloudFunctionRequestPostProcessor.SCS_ADAPTER)
|
||||
.hasDependenciesCount(6);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springCloudStreamWith21() {
|
||||
ProjectRequest request = createProjectRequest("cloud-stream", "cloud-function");
|
||||
request.setBootVersion("2.1.0.RC1");
|
||||
generateMavenPom(request).hasDependency(getDependency("cloud-stream"))
|
||||
.hasDependency(getDependency("cloud-function")).hasDependenciesCount(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reactiveSpringCloudStreamWith21() {
|
||||
ProjectRequest request = createProjectRequest("reactive-cloud-stream",
|
||||
"cloud-function");
|
||||
request.setBootVersion("2.1.0.RELEASE");
|
||||
generateMavenPom(request).hasDependency(getDependency("reactive-cloud-stream"))
|
||||
.hasDependency(getDependency("cloud-function")).hasDependenciesCount(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void web() {
|
||||
ProjectRequest request = createProjectRequest("web", "cloud-function");
|
||||
generateMavenPom(request).hasDependency(getDependency("web"))
|
||||
.hasDependency(SpringCloudFunctionRequestPostProcessor.WEB_ADAPTER)
|
||||
.hasDependenciesCount(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void webflux() {
|
||||
ProjectRequest request = createProjectRequest("webflux", "cloud-function");
|
||||
request.setBootVersion("2.1.0.BUILD-SNAPSHOT");
|
||||
generateMavenPom(request).hasDependency(getDependency("webflux"))
|
||||
.hasDependency(SpringCloudFunctionRequestPostProcessor.WEB_ADAPTER)
|
||||
.hasDependenciesCount(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void webfluxNotAvailableIn20() {
|
||||
ProjectRequest request = createProjectRequest("webflux", "cloud-function");
|
||||
request.setBootVersion("2.0.5.RELEASE");
|
||||
generateMavenPom(request).hasDependency(getDependency("webflux"))
|
||||
.hasDependency(getDependency("cloud-function")).hasDependenciesCount(4);
|
||||
}
|
||||
|
||||
}
|
@@ -1,199 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link SpringCloudStreamRequestPostProcessor}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class SpringCloudStreamRequestPostProcessorTests
|
||||
extends AbstractRequestPostProcessorTests {
|
||||
|
||||
@Test
|
||||
public void springCloudStreamWithRabbit() {
|
||||
ProjectRequest request = createProjectRequest("cloud-stream", "amqp");
|
||||
generateMavenPom(request).hasDependency(getDependency("cloud-stream"))
|
||||
.hasDependency(getDependency("amqp"))
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.RABBIT_BINDER)
|
||||
.hasSpringBootStarterTest()
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.SCS_TEST)
|
||||
.hasDependenciesCount(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springCloudStreamWithKafka() {
|
||||
ProjectRequest request = createProjectRequest("cloud-stream", "kafka");
|
||||
generateMavenPom(request).hasDependency(getDependency("cloud-stream"))
|
||||
.hasDependency(getDependency("kafka"))
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_BINDER)
|
||||
.hasSpringBootStarterTest()
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.SCS_TEST)
|
||||
.hasDependenciesCount(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springCloudStreamWithKafkaStreams() {
|
||||
ProjectRequest request = createProjectRequest("cloud-stream", "kafka-streams");
|
||||
request.setBootVersion("2.0.0.RELEASE");
|
||||
generateMavenPom(request).hasDependency(getDependency("cloud-stream"))
|
||||
.hasDependency(getDependency("kafka-streams"))
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_STREAMS_BINDER)
|
||||
.hasSpringBootStarterTest()
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.SCS_TEST)
|
||||
.hasDependenciesCount(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springCloudStreamWithAllBinders() {
|
||||
ProjectRequest request = createProjectRequest("cloud-stream", "amqp", "kafka",
|
||||
"kafka-streams");
|
||||
generateMavenPom(request).hasDependency(getDependency("cloud-stream"))
|
||||
.hasDependency(getDependency("amqp"))
|
||||
.hasDependency(getDependency("kafka"))
|
||||
.hasDependency(getDependency("kafka-streams"))
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.RABBIT_BINDER)
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_BINDER)
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_STREAMS_BINDER)
|
||||
.hasSpringBootStarterTest()
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.SCS_TEST)
|
||||
.hasDependenciesCount(9);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reactiveSpringCloudStreamWithRabbit() {
|
||||
ProjectRequest request = createProjectRequest("reactive-cloud-stream", "amqp");
|
||||
request.setBootVersion("2.0.0.RELEASE");
|
||||
generateMavenPom(request).hasDependency(getDependency("reactive-cloud-stream"))
|
||||
.hasDependency(getDependency("amqp"))
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.RABBIT_BINDER)
|
||||
.hasSpringBootStarterTest()
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.SCS_TEST)
|
||||
.hasDependenciesCount(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reactiveSpringCloudStreamWithKafka() {
|
||||
ProjectRequest request = createProjectRequest("reactive-cloud-stream", "kafka");
|
||||
request.setBootVersion("2.0.0.RELEASE");
|
||||
generateMavenPom(request).hasDependency(getDependency("reactive-cloud-stream"))
|
||||
.hasDependency(getDependency("kafka"))
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_BINDER)
|
||||
.hasSpringBootStarterTest()
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.SCS_TEST)
|
||||
.hasDependenciesCount(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reactiveSpringCloudStreamWithKafkaStreams() {
|
||||
ProjectRequest request = createProjectRequest("reactive-cloud-stream",
|
||||
"kafka-streams");
|
||||
request.setBootVersion("2.0.0.RELEASE");
|
||||
generateMavenPom(request).hasDependency(getDependency("reactive-cloud-stream"))
|
||||
.hasDependency(getDependency("kafka-streams"))
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_STREAMS_BINDER)
|
||||
.hasSpringBootStarterTest()
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.SCS_TEST)
|
||||
.hasDependenciesCount(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reactiveSpringCloudStreamWithAllBinders() {
|
||||
ProjectRequest request = createProjectRequest("reactive-cloud-stream", "amqp",
|
||||
"kafka", "kafka-streams");
|
||||
request.setBootVersion("2.0.0.RELEASE");
|
||||
generateMavenPom(request).hasDependency(getDependency("reactive-cloud-stream"))
|
||||
.hasDependency(getDependency("amqp"))
|
||||
.hasDependency(getDependency("kafka"))
|
||||
.hasDependency(getDependency("kafka-streams"))
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.RABBIT_BINDER)
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_BINDER)
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_STREAMS_BINDER)
|
||||
.hasSpringBootStarterTest()
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.SCS_TEST)
|
||||
.hasDependenciesCount(9);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springCloudBusWithRabbit() {
|
||||
ProjectRequest request = createProjectRequest("cloud-bus", "amqp");
|
||||
generateMavenPom(request).hasDependency(getDependency("cloud-bus"))
|
||||
.hasDependency(getDependency("amqp"))
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.RABBIT_BINDER)
|
||||
.hasSpringBootStarterTest().hasDependenciesCount(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springCloudBusWithKafka() {
|
||||
ProjectRequest request = createProjectRequest("cloud-bus", "amqp");
|
||||
generateMavenPom(request).hasDependency(getDependency("cloud-bus"))
|
||||
.hasDependency(getDependency("amqp"))
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.RABBIT_BINDER)
|
||||
.hasSpringBootStarterTest().hasDependenciesCount(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springCloudBusWithAllBinders() {
|
||||
ProjectRequest request = createProjectRequest("cloud-bus", "amqp", "kafka",
|
||||
"kafka-streams");
|
||||
generateMavenPom(request).hasDependency(getDependency("cloud-bus"))
|
||||
.hasDependency(getDependency("amqp"))
|
||||
.hasDependency(getDependency("kafka"))
|
||||
.hasDependency(getDependency("kafka-streams"))
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.RABBIT_BINDER)
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_BINDER)
|
||||
.hasSpringBootStarterTest().hasDependenciesCount(7);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springCloudTurbineStreamWithRabbit() {
|
||||
ProjectRequest request = createProjectRequest("cloud-turbine-stream", "amqp");
|
||||
request.setBootVersion("2.0.0.RELEASE");
|
||||
generateMavenPom(request).hasDependency(getDependency("cloud-turbine-stream"))
|
||||
.hasDependency(getDependency("amqp"))
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.RABBIT_BINDER)
|
||||
.hasSpringBootStarterTest().hasDependenciesCount(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springCloudTurbineStreamWithKafka() {
|
||||
ProjectRequest request = createProjectRequest("cloud-turbine-stream", "kafka");
|
||||
request.setBootVersion("2.0.0.RELEASE");
|
||||
generateMavenPom(request).hasDependency(getDependency("cloud-turbine-stream"))
|
||||
.hasDependency(getDependency("kafka"))
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_BINDER)
|
||||
.hasSpringBootStarterTest().hasDependenciesCount(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springCloudTurbineStreamWithAllBinders() {
|
||||
ProjectRequest request = createProjectRequest("cloud-turbine-stream", "amqp",
|
||||
"kafka", "kafka-streams");
|
||||
request.setBootVersion("2.0.0.RELEASE");
|
||||
generateMavenPom(request).hasDependency(getDependency("cloud-turbine-stream"))
|
||||
.hasDependency(getDependency("amqp"))
|
||||
.hasDependency(getDependency("kafka"))
|
||||
.hasDependency(getDependency("kafka-streams"))
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.RABBIT_BINDER)
|
||||
.hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_BINDER)
|
||||
.hasSpringBootStarterTest().hasDependenciesCount(7);
|
||||
}
|
||||
|
||||
}
|
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link SpringSecurityTestRequestPostProcessor}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class SpringSecurityTestRequestPostProcessorTests
|
||||
extends AbstractRequestPostProcessorTests {
|
||||
|
||||
@Test
|
||||
public void securityTestIsAddedWithSecurity() {
|
||||
ProjectRequest request = createProjectRequest("security");
|
||||
generateMavenPom(request).hasSpringBootStarterDependency("security")
|
||||
.hasSpringBootStarterTest().hasDependency(springSecurityTest())
|
||||
.hasDependenciesCount(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void securityTestIsNotAddedBefore13() {
|
||||
ProjectRequest request = createProjectRequest("security");
|
||||
request.setBootVersion("1.2.7.RELEASE");
|
||||
generateMavenPom(request).hasSpringBootStarterDependency("security")
|
||||
.hasSpringBootStarterTest().hasDependenciesCount(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void securityTestIsNotAddedWithoutSpringSecurity() {
|
||||
ProjectRequest request = createProjectRequest("web");
|
||||
generateMavenPom(request).hasSpringBootStarterDependency("web")
|
||||
.hasSpringBootStarterTest().hasDependenciesCount(2);
|
||||
}
|
||||
|
||||
private static Dependency springSecurityTest() {
|
||||
Dependency dependency = Dependency.withId("spring-security-test",
|
||||
"org.springframework.security", "spring-security-test");
|
||||
dependency.setScope(Dependency.SCOPE_TEST);
|
||||
return dependency;
|
||||
}
|
||||
|
||||
}
|
@@ -1,129 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.extension;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link SpringSessionRequestPostProcessor}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class SpringSessionRequestPostProcessorTests
|
||||
extends AbstractRequestPostProcessorTests {
|
||||
|
||||
@Test
|
||||
public void sessionWithSpringBoot15() {
|
||||
ProjectRequest request = createProjectRequest("session");
|
||||
request.setBootVersion("1.5.4.RELEASE");
|
||||
generateMavenPom(request)
|
||||
.hasDependency("org.springframework.session", "spring-session")
|
||||
.hasSpringBootStarterRootDependency().hasSpringBootStarterTest()
|
||||
.hasDependenciesCount(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sessionWithRedisAndSpringBoot15() {
|
||||
ProjectRequest request = createProjectRequest("session", "data-redis");
|
||||
request.setBootVersion("1.5.4.RELEASE");
|
||||
generateMavenPom(request)
|
||||
.hasDependency("org.springframework.session", "spring-session")
|
||||
.hasSpringBootStarterDependency("data-redis").hasSpringBootStarterTest()
|
||||
.hasDependenciesCount(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sessionWithJdbcAndSpringBoot15() {
|
||||
ProjectRequest request = createProjectRequest("session", "jdbc");
|
||||
request.setBootVersion("1.5.4.RELEASE");
|
||||
generateMavenPom(request)
|
||||
.hasDependency("org.springframework.session", "spring-session")
|
||||
.hasSpringBootStarterDependency("jdbc").hasSpringBootStarterTest()
|
||||
.hasDependenciesCount(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sessionWithSpringBoot20M2() {
|
||||
ProjectRequest request = createProjectRequest("session");
|
||||
request.setBootVersion("2.0.0.M2");
|
||||
generateMavenPom(request)
|
||||
.hasDependency("org.springframework.session", "spring-session")
|
||||
.hasSpringBootStarterRootDependency().hasSpringBootStarterTest()
|
||||
.hasDependenciesCount(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noSessionWithRedis() {
|
||||
ProjectRequest request = createProjectRequest("data-redis");
|
||||
request.setBootVersion("2.0.0.M3");
|
||||
generateMavenPom(request).hasSpringBootStarterDependency("data-redis")
|
||||
.hasSpringBootStarterTest().hasDependenciesCount(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sessionWithNoStore() {
|
||||
ProjectRequest request = createProjectRequest("session", "data-jpa");
|
||||
request.setBootVersion("2.0.0.M3");
|
||||
generateMavenPom(request)
|
||||
.hasDependency("org.springframework.session", "spring-session-core")
|
||||
.hasSpringBootStarterDependency("data-jpa").hasSpringBootStarterTest()
|
||||
.hasDependenciesCount(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sessionWithRedis() {
|
||||
ProjectRequest request = createProjectRequest("session", "data-redis");
|
||||
request.setBootVersion("2.0.0.M3");
|
||||
generateMavenPom(request).hasSpringBootStarterDependency("data-redis")
|
||||
.hasSpringBootStarterTest()
|
||||
.hasDependency(SpringSessionRequestPostProcessor.REDIS)
|
||||
.hasDependenciesCount(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sessionWithRedisReactive() {
|
||||
ProjectRequest request = createProjectRequest("session", "data-redis-reactive");
|
||||
request.setBootVersion("2.0.0.M7");
|
||||
generateMavenPom(request).hasSpringBootStarterDependency("data-redis-reactive")
|
||||
.hasSpringBootStarterTest()
|
||||
.hasDependency(SpringSessionRequestPostProcessor.REDIS)
|
||||
.hasDependenciesCount(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sessionWithJdbc() {
|
||||
ProjectRequest request = createProjectRequest("session", "jdbc");
|
||||
request.setBootVersion("2.0.0.M3");
|
||||
generateMavenPom(request).hasSpringBootStarterDependency("jdbc")
|
||||
.hasSpringBootStarterTest()
|
||||
.hasDependency(SpringSessionRequestPostProcessor.JDBC)
|
||||
.hasDependenciesCount(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sessionWithRedisAndJdbc() {
|
||||
ProjectRequest request = createProjectRequest("session", "data-redis", "jdbc");
|
||||
request.setBootVersion("2.0.0.M3");
|
||||
generateMavenPom(request).hasSpringBootStarterDependency("data-redis")
|
||||
.hasSpringBootStarterDependency("jdbc").hasSpringBootStarterTest()
|
||||
.hasDependency(SpringSessionRequestPostProcessor.REDIS)
|
||||
.hasDependency(SpringSessionRequestPostProcessor.JDBC)
|
||||
.hasDependenciesCount(5);
|
||||
}
|
||||
|
||||
}
|
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.service.info;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.actuate.info.Info;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.entry;
|
||||
|
||||
/**
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class CloudFoundryInfoContributorTests {
|
||||
|
||||
private final MockEnvironment environment = new MockEnvironment();
|
||||
|
||||
@Test
|
||||
public void noVcap() {
|
||||
Info info = getInfo(this.environment);
|
||||
assertThat(info.getDetails()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void applicationName() {
|
||||
this.environment.setProperty("vcap.application.name", "foo-bar");
|
||||
Info info = getInfo(this.environment);
|
||||
assertThat(info.getDetails()).containsOnlyKeys("app");
|
||||
Object appDetails = info.getDetails().get("app");
|
||||
assertThat(appDetails).isInstanceOf(Map.class);
|
||||
assertThat((Map<String, Object>) appDetails)
|
||||
.containsOnly(entry("name", "foo-bar"));
|
||||
}
|
||||
|
||||
private static Info getInfo(Environment env) {
|
||||
Info.Builder builder = new Info.Builder();
|
||||
new CloudFoundryInfoContributor(env).contribute(builder);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/base.xml" />
|
||||
<root level="warn">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
</root>
|
||||
</configuration>
|
@@ -124,7 +124,12 @@
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>docs</id>
|
||||
<id>full</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>full</name>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
Reference in New Issue
Block a user