|
| 1 | +/* |
| 2 | + * Copyright 2012-2017 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package io.spring.initializr.service.extension; |
| 18 | + |
| 19 | +import io.spring.initializr.generator.ProjectRequest; |
| 20 | +import org.junit.Test; |
| 21 | + |
| 22 | +import static io.spring.initializr.service.extension.SpringSessionRequestPostProcessor.JDBC; |
| 23 | +import static io.spring.initializr.service.extension.SpringSessionRequestPostProcessor.REDIS; |
| 24 | + |
| 25 | +/** |
| 26 | + * Tests for {@link SpringSessionRequestPostProcessor}. |
| 27 | + * |
| 28 | + * @author Stephane Nicoll |
| 29 | + */ |
| 30 | +public class SpringSessionRequestPostProcessorTests |
| 31 | + extends AbstractRequestPostProcessorTests { |
| 32 | + |
| 33 | + @Test |
| 34 | + public void sessionWithSpringBoot15() { |
| 35 | + ProjectRequest request = createProjectRequest("session"); |
| 36 | + request.setBootVersion("1.5.4.RELEASE"); |
| 37 | + generateMavenPom(request) |
| 38 | + .hasDependency("org.springframework.session", "spring-session") |
| 39 | + .hasSpringBootStarterRootDependency() |
| 40 | + .hasSpringBootStarterTest() |
| 41 | + .hasDependenciesCount(3); |
| 42 | + } |
| 43 | + |
| 44 | + @Test |
| 45 | + public void sessionWithRedisAndSpringBoot15() { |
| 46 | + ProjectRequest request = createProjectRequest("session", "data-redis"); |
| 47 | + request.setBootVersion("1.5.4.RELEASE"); |
| 48 | + generateMavenPom(request) |
| 49 | + .hasDependency("org.springframework.session", "spring-session") |
| 50 | + .hasSpringBootStarterDependency("data-redis") |
| 51 | + .hasSpringBootStarterTest() |
| 52 | + .hasDependenciesCount(3); |
| 53 | + } |
| 54 | + |
| 55 | + @Test |
| 56 | + public void sessionWithJdbcAndSpringBoot15() { |
| 57 | + ProjectRequest request = createProjectRequest("session", "jdbc"); |
| 58 | + request.setBootVersion("1.5.4.RELEASE"); |
| 59 | + generateMavenPom(request) |
| 60 | + .hasDependency("org.springframework.session", "spring-session") |
| 61 | + .hasSpringBootStarterDependency("jdbc") |
| 62 | + .hasSpringBootStarterTest() |
| 63 | + .hasDependenciesCount(3); |
| 64 | + } |
| 65 | + |
| 66 | + @Test |
| 67 | + public void sessionWithSpringBoot20M2() { |
| 68 | + ProjectRequest request = createProjectRequest("session"); |
| 69 | + request.setBootVersion("2.0.0.M2"); |
| 70 | + generateMavenPom(request) |
| 71 | + .hasDependency("org.springframework.session", "spring-session") |
| 72 | + .hasSpringBootStarterRootDependency() |
| 73 | + .hasSpringBootStarterTest() |
| 74 | + .hasDependenciesCount(3); |
| 75 | + } |
| 76 | + |
| 77 | + @Test |
| 78 | + public void noSessionWithRedis() { |
| 79 | + ProjectRequest request = createProjectRequest("data-redis"); |
| 80 | + request.setBootVersion("2.0.0.M3"); |
| 81 | + generateMavenPom(request) |
| 82 | + .hasSpringBootStarterDependency("data-redis") |
| 83 | + .hasSpringBootStarterTest() |
| 84 | + .hasDependenciesCount(2); |
| 85 | + } |
| 86 | + |
| 87 | + @Test |
| 88 | + public void sessionWithNoStore() { |
| 89 | + ProjectRequest request = createProjectRequest("session", "data-jpa"); |
| 90 | + request.setBootVersion("2.0.0.M3"); |
| 91 | + generateMavenPom(request) |
| 92 | + .hasDependency("org.springframework.session", "spring-session-core") |
| 93 | + .hasSpringBootStarterDependency("data-jpa") |
| 94 | + .hasSpringBootStarterTest() |
| 95 | + .hasDependenciesCount(3); |
| 96 | + } |
| 97 | + |
| 98 | + @Test |
| 99 | + public void sessionWithRedis() { |
| 100 | + ProjectRequest request = createProjectRequest("session", "data-redis"); |
| 101 | + request.setBootVersion("2.0.0.M3"); |
| 102 | + generateMavenPom(request) |
| 103 | + .hasSpringBootStarterDependency("data-redis") |
| 104 | + .hasSpringBootStarterTest() |
| 105 | + .hasDependency(REDIS) |
| 106 | + .hasDependenciesCount(3); |
| 107 | + } |
| 108 | + |
| 109 | + @Test |
| 110 | + public void sessionWithRedisReactive() { |
| 111 | + ProjectRequest request = createProjectRequest("session", "data-redis-reactive"); |
| 112 | + request.setBootVersion("2.0.0.M3"); |
| 113 | + generateMavenPom(request) |
| 114 | + .hasSpringBootStarterDependency("data-redis-reactive") |
| 115 | + .hasSpringBootStarterTest() |
| 116 | + .hasDependency(REDIS) |
| 117 | + .hasDependenciesCount(3); |
| 118 | + } |
| 119 | + |
| 120 | + @Test |
| 121 | + public void sessionWithJdbc() { |
| 122 | + ProjectRequest request = createProjectRequest("session", "jdbc"); |
| 123 | + request.setBootVersion("2.0.0.M3"); |
| 124 | + generateMavenPom(request) |
| 125 | + .hasSpringBootStarterDependency("jdbc") |
| 126 | + .hasSpringBootStarterTest() |
| 127 | + .hasDependency(JDBC) |
| 128 | + .hasDependenciesCount(3); |
| 129 | + } |
| 130 | + |
| 131 | + @Test |
| 132 | + public void sessionWithRedisAndJdbc() { |
| 133 | + ProjectRequest request = createProjectRequest("session", "data-redis", "jdbc"); |
| 134 | + request.setBootVersion("2.0.0.M3"); |
| 135 | + generateMavenPom(request) |
| 136 | + .hasSpringBootStarterDependency("data-redis") |
| 137 | + .hasSpringBootStarterDependency("jdbc") |
| 138 | + .hasSpringBootStarterTest() |
| 139 | + .hasDependency(REDIS) |
| 140 | + .hasDependency(JDBC) |
| 141 | + .hasDependenciesCount(5); |
| 142 | + } |
| 143 | + |
| 144 | +} |
0 commit comments