forked from springfox/springfox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
205 additions
and
82 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
springfox-core/src/main/java/springfox/documentation/common/SpringVersion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* | ||
* Copyright 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 springfox.documentation.common; | ||
|
||
/** | ||
* Class providing a proxy for @{@link org.springframework.core.SpringVersion} | ||
* This enable mocking and testing of specific situations | ||
* @author dbaje | ||
*/ | ||
public class SpringVersion { | ||
/** | ||
* Return the full version string of the present Spring codebase, | ||
* or {@code null} if it cannot be determined. | ||
* @see Package#getImplementationVersion() | ||
*/ | ||
public Version getVersion() { | ||
return Version.parse(getVersionString()); | ||
} | ||
|
||
/** | ||
* Return the full version string of the present Spring codebase, | ||
* or {@code null} if it cannot be determined. | ||
* @see Package#getImplementationVersion() | ||
*/ | ||
private String getVersionString() { | ||
return org.springframework.core.SpringVersion.getVersion(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...ox-core/src/test/groovy/springfox/documentation/common/SpringVersionCapabilitySpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package springfox.documentation.common | ||
|
||
import spock.lang.Specification | ||
import spock.lang.Unroll | ||
|
||
import static springfox.documentation.common.SpringVersionCapability.* | ||
|
||
class SpringVersionCapabilitySpec extends Specification { | ||
|
||
def "Cannot instantitiate SpringVersionCompatibility"() { | ||
when: | ||
new SpringVersionCapability() | ||
|
||
then: | ||
thrown UnsupportedOperationException | ||
} | ||
|
||
@Unroll | ||
def "Version #springVersion should preservePath #expected"() { | ||
when: | ||
def result = !supportsXForwardPrefixHeader(Version.parse(springVersion)) | ||
|
||
then: | ||
result == expected | ||
|
||
where: | ||
springVersion | expected | ||
"3.10.20.RELEASE" | true | ||
"4.2.20.RELEASE" | true | ||
"4.3.14.RELEASE" | true | ||
"4.3.15.RELEASE" | false | ||
"4.4.16.RELEASE" | false | ||
"5.0.0.RELEASE" | true | ||
"5.0.5.RELEASE" | false | ||
"5.1.0.RELEASE" | false | ||
"5.1.5.RELEASE" | false | ||
"6.1.6.RELEASE" | false | ||
} | ||
|
||
@Unroll | ||
def "Version #springVersion should has extended PathVariable annotation #expected"() { | ||
when: | ||
def result = supportsExtendedPathVariableAnnotation(Version.parse(springVersion)) | ||
|
||
then: | ||
result == expected | ||
|
||
where: | ||
springVersion | expected | ||
"3.10.20.RELEASE" | false | ||
"4.2.20.RELEASE" | false | ||
"4.3.2.RELEASE" | false | ||
"4.3.3.RELEASE" | true | ||
"4.3.14.RELEASE" | true | ||
"4.3.15.RELEASE" | true | ||
"4.4.16.RELEASE" | true | ||
"5.0.0.RELEASE" | true | ||
"5.0.5.RELEASE" | true | ||
"5.1.0.RELEASE" | true | ||
"5.1.5.RELEASE" | true | ||
"6.1.6.RELEASE" | true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
...src/test/groovy/springfox/documentation/swagger/common/SpringVersionCapabilitySpec.groovy
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.