Example of integration / unit tests framework actions

Post here questions and problems related to oXygen frameworks/document types.
Johann
Posts: 198
Joined: Wed Jun 17, 2015 12:46 pm

Example of integration / unit tests framework actions

Post by Johann »

Hello everyone,


Is there a suggested way / example to perform integration / unit tests on actions or DocumentFilter implemented in a framework ?

The goal will be for example to have an input XML, call an action defined in the framework, check the output XML with the expected one.

The front end part is not necessary in that case.


Regards,

Johann
Radu
Posts: 8992
Joined: Fri Jul 09, 2004 5:18 pm

Re: Example of integration / unit tests framework actions

Post by Radu »

Hi Johann,

You can create high level JUnit tests using an Oxygen installation:

https://www.oxygenxml.com/doc/versions/ ... -sdk2.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
cristi_talau
Posts: 489
Joined: Thu Sep 04, 2014 4:22 pm

Re: Example of integration / unit tests framework actions

Post by cristi_talau »

Hello,

If you want to write unit tests for Web Author customizations you can use the instructions here: https://www.oxygenxml.com/doc/versions/ ... lugin.html .

Best,
Cristian
Johann
Posts: 198
Joined: Wed Jun 17, 2015 12:46 pm

Re: Example of integration / unit tests framework actions

Post by Johann »

Hello,

I cannot find the class ro.sync.exml.workspace.api.PluginWorkspaceTCBase described in https://www.oxygenxml.com/doc/versions/ ... -sdk2.html.

Has this class been renamed ? moved ?

Thanks,

Johann
Radu
Posts: 8992
Joined: Fri Jul 09, 2004 5:18 pm

Re: Example of integration / unit tests framework actions

Post by Radu »

Hi Johann,

It seems you are right, I added an internal issue to add it back. In the meantime you can use an older Oxygen kit for your tests.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Johann
Posts: 198
Joined: Wed Jun 17, 2015 12:46 pm

Re: Example of integration / unit tests framework actions

Post by Johann »

Hi Radu,

Can you tell me the last version of oxygen.jar this class is present ?

I tried 23 / 22 / 19 but I did not find it.

Is there any alternative in recent versions to perform unit tests on framework actions ?

Thanks,

Johann
Radu
Posts: 8992
Joined: Fri Jul 09, 2004 5:18 pm

Re: Example of integration / unit tests framework actions

Post by Radu »

Hi Johann,

I found it in Oxygen 21.1. At some point we mavenized our project and that is probably the version when the base class started to get excluded.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Johann
Posts: 198
Joined: Wed Jun 17, 2015 12:46 pm

Re: Example of integration / unit tests framework actions

Post by Johann »

Hi Radu,

I managed to write my first test class by getting the Oxygen Editor 21.1 oxygen.jar.

However, it fails when initializing PluginWorkspaceTCBase with this error:

Code: Select all

junit.framework.AssertionFailedError: Exception in constructor: testOpenFileAndBoldEXM_20417 (java.lang.NoClassDefFoundError: ro/sync/security/AbstractInteractiveChecker
	at ro.sync.exml.workspace.api.PluginWorkspaceTCBase.<init>(Unknown Source)
	at com._4dconcept.adam.author.framework.S1000D.TestFrameworkActions.<init>(TestFrameworkActions.java:12)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at junit.framework.TestSuite.createTest(TestSuite.java:59)
	at junit.framework.TestSuite.addTestMethod(TestSuite.java:296)
	at junit.framework.TestSuite.addTestsFromTestCase(TestSuite.java:139)
	at junit.framework.TestSuite.<init>(TestSuite.java:118)
	at org.junit.internal.runners.JUnit38ClassRunner.<init>(JUnit38ClassRunner.java:78)
	at org.junit.internal.builders.JUnit3Builder.runnerForClass(JUnit3Builder.java:11)
	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
	at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:37)
	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
	at org.junit.internal.requests.ClassRequest.createRunner(ClassRequest.java:28)
	at org.junit.internal.requests.MemoizingRequest.getRunner(MemoizingRequest.java:19)
	at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:36)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:50)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:64)
Caused by: java.lang.ClassNotFoundException: ro.sync.security.AbstractInteractiveChecker
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	... 27 more
)

	at junit.framework.Assert.fail(Assert.java:57)
	at junit.framework.TestCase.fail(TestCase.java:223)
	at junit.framework.TestSuite$1.runTest(TestSuite.java:96)
	at junit.framework.TestCase.runBare(TestCase.java:142)
	at junit.framework.TestResult$1.protect(TestResult.java:122)
	at junit.framework.TestResult.runProtected(TestResult.java:142)
	at junit.framework.TestResult.run(TestResult.java:125)
	at junit.framework.TestCase.run(TestCase.java:130)
	at junit.framework.TestSuite.runTest(TestSuite.java:241)
	at junit.framework.TestSuite.run(TestSuite.java:236)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:64)
Is there a missing jar to get ro/sync/security/AbstractInteractiveChecker class ?

Thanks,

Johann
Radu
Posts: 8992
Joined: Fri Jul 09, 2004 5:18 pm

Re: Example of integration / unit tests framework actions

Post by Radu »

Hi Johann,

You need an extra classpath reference to "lib/oxygen-sandbox.jar" I presume.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Johann
Posts: 198
Joined: Wed Jun 17, 2015 12:46 pm

Re: Example of integration / unit tests framework actions

Post by Johann »

No :(

Only ro.sync.security.SecurityChecker is present in oxygen-sandbox.jar

Johann
Radu
Posts: 8992
Joined: Fri Jul 09, 2004 5:18 pm

Re: Example of integration / unit tests framework actions

Post by Radu »

Hi Johann,

The "oxygen-sandbox.jar" from the Oxygen 21.1 installation "lib" folder has that class. Maybe you mixed Jars from different versions in the classpath.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Johann
Posts: 198
Joined: Wed Jun 17, 2015 12:46 pm

Re: Example of integration / unit tests framework actions

Post by Johann »

My bad, sorry...

Too many oxygen versions in parallel :(


Johann
Radu
Posts: 8992
Joined: Fri Jul 09, 2004 5:18 pm

Re: Example of integration / unit tests framework actions

Post by Radu »

Hi Johann,

Sorry about that, when we have a fix for this in a future Oxygen release I'll update this forum thread.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Johann
Posts: 198
Joined: Wed Jun 17, 2015 12:46 pm

Re: Example of integration / unit tests framework actions

Post by Johann »

Hello Radu,


Thank you!
Can you confirm that at the moment, this is the (only ?) way you recommend to test framework actions ?

Johann
Radu
Posts: 8992
Joined: Fri Jul 09, 2004 5:18 pm

Re: Example of integration / unit tests framework actions

Post by Radu »

Hi Johann,

This is the base JUnit class to start a Desktop Oxygen application and to invoke various actions from it.
As you are already using the Author component in your JUnit tests you could call our code which creates an AuthorComponentFactory and just work with it, I think you already have APIs to invoke actions defined at framework level.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Radu
Posts: 8992
Joined: Fri Jul 09, 2004 5:18 pm

Re: Example of integration / unit tests framework actions

Post by Radu »

Hi,

We released Oxygen 24.1 and it should include again the missing PluginWorkspaceTCBase base class.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply