Skip to content

Conversation

@AtanasM98
Copy link

@AtanasM98 AtanasM98 commented Oct 20, 2022

Migrated project to MPS 2021.3 - had to manually change some try statements inside the project, and fix some missing dependencies.

Updated docx4j to 11.4.8. Changed JAXb Implementation to MOXy 11.4.8. Updated all samples to docx4j-samples 11.4.8.
Added docx4j-docx-anon library because it was needed to run some of the samples.

The biggest improvement is that all docx4j dependencies are from the original package - no need to change them with any native MPS libraries.

I haven't touched the org.xmlunit solutions so they don't work because of a missing dependency - Hamcrest.

Cleaned up all languages' and solutions' dependencies.

@eugenschindler
Copy link
Member

@enikao from a distance, changes look good to me. Do you want to review as well?

@jennek
Copy link
Contributor

jennek commented Oct 20, 2022 via email

@eugenschindler
Copy link
Member

I want to review. Monday 24 oct at the latest

Sent from my iPhone
On 20 Oct 2022, at 16:40, Eugen Schindler @.***> wrote:  @enikao from a distance, changes look good to me. Do you want to review as well? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

OK

@enikao
Copy link
Member

enikao commented Oct 20, 2022

I helped Atanas, so @jennek is probably better suited.
@AtanasM98 Maybe you can describe the key things you did in the PR?

@eugenschindler
Copy link
Member

I helped Atanas, so @jennek is probably better suited. @AtanasM98 Maybe you can describe the key things you did in the PR?

Thanks for the explanation. Clear. I'll leave it to you and Jennek to finish the PR. If you run into any issues like permissions our you need something done, you know where to find me :)

@AtanasM98
Copy link
Author

I've updated my first comment with more information on what I did.

@enikao enikao requested a review from jennek October 21, 2022 13:20
@jennek
Copy link
Contributor

jennek commented Oct 24, 2022

[S] org.xmlunit can't find dependency: Hamcrest
@AtanasM98 you noticed this already. Hamcrest is also in the dependencies of docx4j. Maybe pick it up there or just duplicate here.
NB in {MPS}\plugins\mbeddr.spawner\lib there is org.hamcrest.core_1.1.0.v20090501071000.jar

@jennek
Copy link
Contributor

jennek commented Oct 24, 2022

model org.xmlunit.tests.samples@tests does not have a TestInfo node
@AtanasM98 we have to decide whether to keep or drop the xmlunit related modules.
I would say: drop.

The original intention was to write XML level assertions for generated docx snippets. If that is no longer the intention, better remove the xmlunit related modules from the project.

@jennek
Copy link
Contributor

jennek commented Oct 24, 2022

when running the tests in com.dslfoundry.docx.samples.tests.unit, all three tests fail with the following stack trace.
@AtanasM98 would you be able to fix this in limited time?

WriteDocxFile() ERROR
org.docx4j.openpackaging.exceptions.Docx4JException: Couldn't get [Content_Types].xml from ZipFile
	at org.docx4j.openpackaging.io3.Load3.get(Load3.java:148)
	at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:561)
	at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:410)
	at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:287)
	at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:265)
	at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:168)
	at org.docx4j.Docx4J.load(Docx4J.java:255)
	at com.dslfoundry.docx.behavior.DocxDocument__BehaviorDescriptor.WriteDocxFile_id2QPHU78qPVk(DocxDocument__BehaviorDescriptor.java:130)
	at com.dslfoundry.docx.behavior.DocxDocument__BehaviorDescriptor.invokeSpecial0(DocxDocument__BehaviorDescriptor.java:246)
	at jetbrains.mps.core.aspects.behaviour.BaseBHDescriptor.invokeSpecial(BaseBHDescriptor.java:359)
	at jetbrains.mps.core.aspects.behaviour.BaseBHDescriptor.invokeNonVirtualCommon(BaseBHDescriptor.java:307)
	at jetbrains.mps.core.aspects.behaviour.BaseBHDescriptor.invokeNonVirtual(BaseBHDescriptor.java:283)
	at jetbrains.mps.core.aspects.behaviour.BaseBHDescriptor.invoke(BaseBHDescriptor.java:244)
	at jetbrains.mps.core.aspects.behaviour.SMethodImpl.invoke0(SMethodImpl.java:153)
	at jetbrains.mps.core.aspects.behaviour.SMethodImpl.invoke(SMethodImpl.java:128)
	at com.dslfoundry.docx.main.QueriesGenerated$1.visit(QueriesGenerated.java:42)
	at com.dslfoundry.docx.main.QueriesGenerated$1.visit(QueriesGenerated.java:40)
	at jetbrains.mps.internal.collections.runtime.IVisitor.invoke(IVisitor.java:12)
	at jetbrains.mps.internal.collections.runtime.IterableUtils.visitAll(IterableUtils.java:16)
	at jetbrains.mps.internal.collections.runtime.AbstractSequence.visitAll(AbstractSequence.java:80)
	at com.dslfoundry.docx.main.QueriesGenerated.mappingScript_CodeBlock_1(QueriesGenerated.java:40)
	at com.dslfoundry.docx.main.QueriesGenerated$SCB.invoke(QueriesGenerated.java:68)
	at jetbrains.mps.generator.impl.interpreted.TemplateMappingScriptInterpreted.apply(TemplateMappingScriptInterpreted.java:74)
	at jetbrains.mps.generator.template.DefaultQueryExecutionContext.executeScript(DefaultQueryExecutionContext.java:299)
	at jetbrains.mps.generator.impl.TemplateGenerator.executeScript(TemplateGenerator.java:289)
	at jetbrains.mps.generator.impl.GenerationSession.preProcessModel(GenerationSession.java:606)
	at jetbrains.mps.generator.impl.GenerationSession.executeMajorStepInternal(GenerationSession.java:442)
	at jetbrains.mps.generator.impl.GenerationSession.executeMajorStep(GenerationSession.java:421)
	at jetbrains.mps.generator.impl.GenerationSession.processGenPlanBranch(GenerationSession.java:282)
	at jetbrains.mps.generator.impl.GenerationSession.generateModel(GenerationSession.java:198)
	at jetbrains.mps.generator.impl.GenerationController.generateModel(GenerationController.java:136)
	at jetbrains.mps.generator.impl.GenerationController.generate(GenerationController.java:72)
	at jetbrains.mps.generator.GenerationFacade.process0(GenerationFacade.java:178)
	at jetbrains.mps.generator.GenerationFacade.process(GenerationFacade.java:161)
	at jetbrains.mps.lang.core.plugin.Generate_Facet$Target_generate$1$4.run(Generate_Facet.java:460)
	at jetbrains.mps.smodel.ActionDispatcher.dispatch(ActionDispatcher.java:88)
	at jetbrains.mps.smodel.WorkbenchModelAccess.lambda$runReadAction$0(WorkbenchModelAccess.java:88)
	at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:819)
	at jetbrains.mps.smodel.WorkbenchModelAccess.runReadAction(WorkbenchModelAccess.java:85)
	at jetbrains.mps.smodel.ModelAccessBase.runReadAction(ModelAccessBase.java:56)
	at jetbrains.mps.lang.core.plugin.Generate_Facet$Target_generate$1.execute(Generate_Facet.java:456)
	at jetbrains.mps.internal.make.runtime.script.Script$3.invoke(Script.java:311)
	at jetbrains.mps.internal.make.runtime.script.Script$3.invoke(Script.java:255)
	at jetbrains.mps.ide.make.WorkbenchMakeService$Controller.runJobWithMonitor(WorkbenchMakeService.java:322)
	at jetbrains.mps.internal.make.runtime.script.Script.executeTargets(Script.java:255)
	at jetbrains.mps.internal.make.runtime.script.Script.execute(Script.java:233)
	at jetbrains.mps.make.service.CoreMakeTask$1.invoke(CoreMakeTask.java:103)
	at jetbrains.mps.make.service.CoreMakeTask$1.invoke(CoreMakeTask.java:76)
	at jetbrains.mps.make.dependencies.MakeSequence.iterate(MakeSequence.java:56)
	at jetbrains.mps.make.service.CoreMakeTask.doRun(CoreMakeTask.java:76)
	at jetbrains.mps.ide.make.MakeTask$WorkbenchMakeTask.doRun(MakeTask.java:148)
	at jetbrains.mps.make.service.CoreMakeTask.run(CoreMakeTask.java:55)
	at jetbrains.mps.ide.make.MakeTask$2.run(MakeTask.java:68)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.docx4j.openpackaging.exceptions.InvalidFormatException: Bad [Content_Types].xml
	at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:854)
	at org.docx4j.openpackaging.io3.Load3.get(Load3.java:146)
	... 53 more
Caused by: java.lang.NullPointerException
	at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:821)
	... 54 more

@jennek
Copy link
Contributor

jennek commented Oct 24, 2022

when running tests in com.dslfoundry.docx.samples.tests.generator the test is green but no file is written to disk. The body of the one test method run is empty. @AtanasM98 is this supposed to be the case?

@AtanasM98
Copy link
Author

@jennek
I don't know what the XMLUnit related modules are for so I don't think I should be the one deciding about it. Dropping it would be the easiest solution.

What MPS version are you running this on? I had the same problem occur to me on previous MPS versions. If it's 2021.3 what plugins do you have installed on it? I ran the project on a fresh install today and I had no problems generating the com.dslfoundry.docx.samples model.

I haven't touched any code in the com.dslfoundry.docx.samples.tests module, it could've worked on previous versions, but there are some issues now.
Regarding the com.dslfoundry.docx.samples.tests.generator model - I don't think this is the correct way to test the generator. The reason no output exists is that the generator does not find the DocxDocument node inside the test node and it doesn't run the WriteDocxFile method on it. The empty method I could only guess is to be there to say if any exceptions where thrown during the building of the model.

Regarding the com.dslfoundry.docx.samples.tests.unit model - I ran the tests and I got --- Content is not Equal --- messages for the files, but when I open the expected and actual files the contents are the same. How did you create the expected docx files?
How does the IOUtils method check whether the contents of these files are indeed identical? I don't know how IOUtils works with docx files and if there are any specifics to programmatically compare them, because the contents may be the same but the actual surrounding infrastructure is different when saved from Word or generated by docx4j (this goes even further when you can generate docx files with different JAXb implementations, as you showed me there is a place where it states with implementation it used.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants