Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WFCORE-6812 Allow validating multiple XML files #6051

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

parsharma
Copy link
Contributor

@github-actions github-actions bot added the deps-ok Dependencies have been checked, and there are no significant changes label Jun 27, 2024
@wildfly-ci

This comment was marked as outdated.

@iweiss iweiss requested review from bstansberry and yersan July 2, 2024 07:37
Copy link
Collaborator

@yersan yersan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me, but what this PR does is create a new method to load multiple XML files as a single one.

The Jira description does not clarify too much, at least to me, about what is the final goal here. Is it to allow the validation of multiple XML files against a common XSD schema? Notice this class is used for subsystems, so I would understand the intention here is to concatenate multiple XML subsystem files into a single one, and if that's the intention, the final one will have multiple xmls namespaces, so, I don't get how this is expected to work.

@parsharma / @michpetrov Could you describe the Jira intention better and how this method would allow validating multiple XML files?

My only bet is that this is here to allow later to do the following:

SchemaValidator.validateXML(getSubsystemXml(List<String>), schemaPath, getResolvedProperties());

And, if that's the case, exposing a method that does this validation is the task to do here, otherwise this PR is to allow composing multiple XML files in a single one. And also, I cannot figure out what list of XML would be passed to this method, to do the above the resulting XML file should only have a single XML NS ... correct me if I am wrong, I think I need to refresh my XML knowledge.

@yersan yersan requested a review from michpetrov July 2, 2024 10:14
Copy link
Contributor

@michpetrov michpetrov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work unfortunately, if you concatenate multiple files it's no longer a valid XML and the parser will fail. Bear in mind that getSubsystemXml() is used in other methods, so we can't change its output.

I don't think you can get around processing the contents of each file separately.

@michpetrov
Copy link
Contributor

@yersan The goal is to validate multiple files against a single schema, yes.

I'm assuming the expected usage was to do

protected String getSubsystemXml() throws IOException {
    return getSubsystemXml(List.of("a.xml", "b.xml", "c.xml"));  // previously return readResource("a.xml");
}

which is kinda what I had in mind in terms of what's required to do in a given subsystem test. But putting it all into a single file doesn't work for the parser.

@yersan
Copy link
Collaborator

yersan commented Jul 11, 2024

thanks @michpetrov, then do you think we should close the Jira as won't do?

Otherwise, I would need a real use case since I don't know yet what kind of subsystem XML files we would need to compose and validate against a single xsd schema. I am also reluctant to add any piece of code if it is not going to be used yet, adding something for the future for someone who would need it doesn't look good, better let's add it when there is an immediate usage need.

@michpetrov
Copy link
Contributor

@yersan there are subsystems like datasources that use multiple files for testing - https://github.com/wildfly/wildfly/tree/main/connector/src/test/resources/org/jboss/as/connector/subsystems/datasources

currently only datasources-minimal.xml is being checked but datasources-full.xml is invalid. If we want to ensure everything is valid we would have to create a separate test class for each of the files, so I want a better way.

Copy link

There has been no activity on this PR for 45 days. It will be auto-closed after 90 days.

@github-actions github-actions bot added the Stale label Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deps-ok Dependencies have been checked, and there are no significant changes Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants