(fix) tests

This commit is contained in:
Andreas Penski (init) 2020-04-29 13:55:12 +02:00
parent 7ca3ef90f3
commit 5b1d0cd467
12 changed files with 92 additions and 56 deletions

View file

@ -31,13 +31,13 @@ public interface ResolvingConfigurationStrategy {
SchemaFactory createSchemaFactory();
/**
* Creates a preconfigured {@link Processor Saxon Processor} for various tasks within the Validator. The validator
* Returns a preconfigured {@link Processor Saxon Processor} for various tasks within the Validator. The validator
* leverages the saxon s9api for internal processing e.g. xml reading and writing. So this is the main object to secure
* for reading, transforming and writing xml files.
*
* @return a preconfigured {@link Processor}
*/
Processor createProcessor();
Processor getProcessor();
/**
* Creates a specific implementation for resolving referenced objects in XML files. The URIResolver, it is used for

View file

@ -170,9 +170,9 @@ public class ConfigurationBuilder {
public Configuration build() {
final ResolvingConfigurationStrategy resolving = getResolvingConfigurationStrategy();
if (this.processor == null) {
this.processor = resolving.createProcessor();
this.processor = resolving.getProcessor();
}
final ContentRepository contentRepository = new ContentRepository(this.resolvingConfigurationStrategy, this.repository);
final ContentRepository contentRepository = new ContentRepository(resolving, this.repository);
final List<Scenario> list = initializeScenarios(contentRepository);
final Scenario fallbackScenario = initializeFallback(contentRepository);

View file

@ -117,7 +117,7 @@ public class ConfigurationLoader {
public Configuration build() {
final ResolvingConfigurationStrategy resolving = getResolvingConfigurationStrategy();
final Processor processor = resolving.createProcessor();
final Processor processor = resolving.getProcessor();
final ContentRepository contentRepository = new ContentRepository(resolving, getScenarioRepository());
final Scenarios def = loadScenarios(contentRepository.getScenarioSchema(), processor);

View file

@ -92,7 +92,7 @@ public class ContentRepository {
public ContentRepository(final ResolvingConfigurationStrategy strategy, final URI repository) {
this.repository = repository;
this.resolvingConfigurationStrategy = strategy;
this.processor = this.resolvingConfigurationStrategy.createProcessor();
this.processor = this.resolvingConfigurationStrategy.getProcessor();
this.resolver = this.resolvingConfigurationStrategy.createResolver(repository);
this.schemaFactory = this.resolvingConfigurationStrategy.createSchemaFactory();
}

View file

@ -58,8 +58,8 @@ public class ComputeAcceptanceAction implements CheckAction {
selector.setContextItem(results.getReport());
results.setAcceptStatus(selector.effectiveBooleanValue() ? AcceptRecommendation.ACCEPTABLE : AcceptRecommendation.REJECT);
} catch (final SaxonApiException e) {
final String msg = "Error evaluating accept recommendation: %s";
log.error(msg);
final String msg = String.format("Error evaluating accept recommendation: %s", selector.getUnderlyingXPathContext().toString());
log.error(msg, e);
results.addProcessingError(msg);
}
}

View file

@ -13,6 +13,8 @@ import lombok.extern.slf4j.Slf4j;
import de.kosit.validationtool.api.ResolvingConfigurationStrategy;
import net.sf.saxon.s9api.Processor;
/**
* @author Andreas Penski
*/
@ -27,6 +29,18 @@ public abstract class BaseResolvingStrategy implements ResolvingConfigurationStr
private static final String ORACLE_XERCES_CLASS = "com.sun.org.apache.xerces.internal.impl.Constants";
private Processor processor;
@Override
public Processor getProcessor() {
if (this.processor == null) {
this.processor = createProcessor();
}
return this.processor;
}
protected abstract Processor createProcessor();
public static void forceOpenJdkXmlImplementation() {
if (!isOpenJdkXmlImplementationAvailable()) {
throw new IllegalStateException("No OpenJDK version of XERCES found");

View file

@ -9,8 +9,6 @@ import javax.xml.validation.Validator;
import lombok.extern.slf4j.Slf4j;
import net.sf.saxon.s9api.Processor;
/**
*
*
@ -30,11 +28,6 @@ public class StrictLocalResolvingStrategy extends StrictRelativeResolvingStrateg
return schemaFactory;
}
@Override
public Processor createProcessor() {
return super.createProcessor();
}
@Override
public URIResolver createResolver(final URI repository) {
// intentionally return 'null', since all resolving is configured with the other objects

View file

@ -77,7 +77,7 @@ public class StrictRelativeResolvingStrategy extends BaseResolvingStrategy {
}
@Override
public Processor createProcessor() {
protected Processor createProcessor() {
final Processor processor = new Processor(false);
// verhindere global im Prinzip alle resolving strategien
final SecureUriResolver resolver = new SecureUriResolver();