-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include a test collecting all *.camelk.yaml files in the repository a…
…nd validating it against the yaml schema #387
- Loading branch information
1 parent
d9468dd
commit f925cb4
Showing
4 changed files
with
45 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
37 changes: 37 additions & 0 deletions
37
...-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/RoutesValidationTest.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,37 @@ | ||
package org.apache.camel.k.loader.yaml | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory | ||
import com.github.fge.jackson.JsonLoader | ||
import com.github.fge.jsonschema.main.JsonSchemaFactory | ||
import spock.lang.Specification | ||
import spock.lang.Unroll | ||
|
||
import java.nio.file.Files | ||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
|
||
class RoutesValidationTest extends Specification { | ||
static def MAPPER = new ObjectMapper(new YAMLFactory()) | ||
static def SCHEMA_RES = JsonLoader.fromResource('/camel-yaml-dsl.json') | ||
static def SCHEMA = JsonSchemaFactory.byDefault().getJsonSchema(SCHEMA_RES) | ||
|
||
@Unroll | ||
def 'validate'(Path source) { | ||
given: | ||
def target = MAPPER.readTree(source.toFile()) | ||
when: | ||
def report = SCHEMA.validate(target) | ||
then: | ||
report.isSuccess() | ||
where: | ||
source << routes() | ||
} | ||
|
||
def routes() { | ||
def routes = getClass().getResource("/routes").toURI() | ||
def paths = Paths.get(routes) | ||
|
||
return Files.list(paths) | ||
} | ||
} |
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