Search in sources :

Example 1 with SchemaValidators

use of com.yahoo.config.model.application.provider.SchemaValidators in project vespa by vespa-engine.

the class VespaModelCreatorWithMockPkg method create.

public VespaModel create(boolean validate, DeployState deployState, ConfigModelRegistry configModelRegistry) {
    try {
        this.deployState = deployState;
        VespaModel model = new VespaModel(configModelRegistry, deployState);
        Version vespaVersion = new Version(6);
        if (validate) {
            SchemaValidators validators = new SchemaValidators(vespaVersion);
            try {
                if (appPkg.getHosts() != null) {
                    validators.hostsXmlValidator().validate(appPkg.getHosts());
                }
                if (appPkg.getDeployment().isPresent()) {
                    validators.deploymentXmlValidator().validate(appPkg.getDeployment().get());
                }
                validators.servicesXmlValidator().validate(appPkg.getServices());
            } catch (Exception e) {
                System.err.println(e.getClass());
                throw e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e);
            }
            // Validate, but without checking configSources or routing (routing
            // is constructed in a special way and cannot always be validated in
            // this step for unit tests)
            configChangeActions = Validation.validate(model, false, false, deployState);
        }
        return model;
    } catch (Exception e) {
        e.printStackTrace();
        throw e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e);
    }
}
Also used : Version(com.yahoo.component.Version) SchemaValidators(com.yahoo.config.model.application.provider.SchemaValidators) VespaModel(com.yahoo.vespa.model.VespaModel)

Example 2 with SchemaValidators

use of com.yahoo.config.model.application.provider.SchemaValidators in project vespa by vespa-engine.

the class TestDriver method validate.

private void validate(ApplicationPackage appPkg) throws IOException {
    if (!validate) {
        return;
    }
    SchemaValidators schemaValidators = new SchemaValidators(new Version(6), new BaseDeployLogger());
    if (appPkg.getHosts() != null) {
        schemaValidators.hostsXmlValidator().validate(appPkg.getHosts());
    }
    schemaValidators.servicesXmlValidator().validate(appPkg.getServices());
}
Also used : Version(com.yahoo.component.Version) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) SchemaValidators(com.yahoo.config.model.application.provider.SchemaValidators)

Aggregations

Version (com.yahoo.component.Version)2 SchemaValidators (com.yahoo.config.model.application.provider.SchemaValidators)2 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)1 VespaModel (com.yahoo.vespa.model.VespaModel)1