This repository has been archived by the owner on Jan 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ondrej Pontes
authored and
Jakub Cechacek
committed
Jun 17, 2016
1 parent
b59a1c6
commit 001410c
Showing
3 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
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,32 @@ | ||
<?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"> | ||
<parent> | ||
<artifactId>apiman-integration-tests</artifactId> | ||
<groupId>io.apiman.test</groupId> | ||
<version>1.1.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>apiman-it-validator</artifactId> | ||
|
||
<properties> | ||
<version.groovy>2.4.6</version.groovy> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.codehaus.groovy</groupId> | ||
<artifactId>groovy-all</artifactId> | ||
<version>${version.groovy}</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.codehaus.groovy</groupId> | ||
<artifactId>groovy-json</artifactId> | ||
<version>${version.groovy}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
62 changes: 62 additions & 0 deletions
62
apiman-it-validator/src/main/groovy/ConfigValidator.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,62 @@ | ||
import groovy.json.JsonSlurper | ||
|
||
/** | ||
* @author opontes | ||
*/ | ||
|
||
def assertValidMetadata = { json -> | ||
json?.Metadata?.apimanVersion == version | ||
} | ||
|
||
def assertValidVersion = { json -> | ||
json?.version == version | ||
} | ||
|
||
def assertValidPlugins = { json -> | ||
json?.plugins?.every { it?.version == version } | ||
} | ||
|
||
def assertValidRepository = { json -> | ||
json?.repository?.url == repository | ||
} | ||
|
||
def setUpCliBuilder() { | ||
def cli = new CliBuilder(usage: 'ConfigValidator -d <amg_dir> -r <repository_url>') | ||
cli.with { | ||
d(longOpt: 'amg_dir', 'AMG directory', args: 1, required: true) | ||
r(longOpt: 'repository_url', 'Maven repository url', args: 1, required: true) | ||
v(longOpt: 'version', 'Apiman version', args: 1, required: false) | ||
} | ||
return cli.parse(args) | ||
} | ||
|
||
def MAPPER = [ | ||
"/apiman/data/basic-settings.apiman.json" : [ | ||
assertValidMetadata | ||
], | ||
"/standalone/data/bootstrap/amg-config.json" : [ | ||
assertValidMetadata | ||
], | ||
"/apiman/bootstrap/apiman-default-config.json" : [ | ||
assertValidMetadata | ||
], | ||
"/standalone/configuration/amg-plugin-registry.json" : [ | ||
assertValidVersion, | ||
assertValidPlugins, | ||
assertValidRepository | ||
] | ||
] | ||
|
||
def messages = [] | ||
def o = setUpCliBuilder() | ||
if (!o) return | ||
def amg_home = o.d | ||
version = o.v | ||
repository = o.r | ||
|
||
MAPPER.each { path, asserts -> | ||
def json = new JsonSlurper().parse(new File(amg_home + path)) | ||
def isValid = asserts.every { validator -> validator(json) } | ||
if (!isValid) messages.add("Possible error is in file: ${path}") | ||
} | ||
(messages.empty) ? println("Files are OK.") : println(messages) |
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